원본 : http://www.sarangnamu.net/basic/basic_v ··· ory%3D33
To implement a drop-down button
Once your CToolBarCtrl object has been created, set the TBSTYLE_EX_DRAWDDARROWS style, using the following code:
Set the TBSTYLE_DROPDOWN style for any new (InsertButton or AddButtons) or existing (SetButtonInfo) buttons that will be drop-down buttons. The following example demonstrates modifying an existing button in a CToolBarCtrl object:
Add a WM_NOTIFY handler to the parent class of the toolbar object.
In the new handler, check for the TBN_DROPDOWN notification, using the following code:
If the TBN_DROPDOWN notification has been sent, display the appropriate popup menu. The following code demonstrates one method:
CMenu menu;
VERIFY(menu.LoadMenu(IDR_MENU1));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->TrackPopupMenu(TPM_RIGHTALIGN |
TPM_RIGHTBUTTON, x, y, this);
To implement a drop-down button
Once your CToolBarCtrl object has been created, set the TBSTYLE_EX_DRAWDDARROWS style, using the following code:
m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
Set the TBSTYLE_DROPDOWN style for any new (InsertButton or AddButtons) or existing (SetButtonInfo) buttons that will be drop-down buttons. The following example demonstrates modifying an existing button in a CToolBarCtrl object:
TBBUTTONINFO tbi;
tbi.dwMask= TBIF_STYLE;
tbi.cbSize= sizeof(TBBUTTONINFO);
m_wndToolBar.GetToolBarCtrl().GetButtonInfo(ID_EDIT_CUT, &tbi);
tbi.fsStyle |= TBSTYLE_DROPDOWN;
m_wndToolBar.GetToolBarCtrl().SetButtonInfo(ID_EDIT_CUT, &tbi);
tbi.dwMask= TBIF_STYLE;
tbi.cbSize= sizeof(TBBUTTONINFO);
m_wndToolBar.GetToolBarCtrl().GetButtonInfo(ID_EDIT_CUT, &tbi);
tbi.fsStyle |= TBSTYLE_DROPDOWN;
m_wndToolBar.GetToolBarCtrl().SetButtonInfo(ID_EDIT_CUT, &tbi);
Add a WM_NOTIFY handler to the parent class of the toolbar object.
In the new handler, check for the TBN_DROPDOWN notification, using the following code:
#define lpnm ((LPNMHDR)lParam)
#define lpnmTB ((LPNMTOOLBAR)lParam)
switch(lpnm->code)
{
case TBN_DROPDOWN:
//drop down button was hit
//handle appropriately
. . .
return FALSE; //indicates the TBN_DROPDOWN
//notification was handled.
}
#define lpnmTB ((LPNMTOOLBAR)lParam)
switch(lpnm->code)
{
case TBN_DROPDOWN:
//drop down button was hit
//handle appropriately
. . .
return FALSE; //indicates the TBN_DROPDOWN
//notification was handled.
}
If the TBN_DROPDOWN notification has been sent, display the appropriate popup menu. The following code demonstrates one method:
CMenu menu;
VERIFY(menu.LoadMenu(IDR_MENU1));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->TrackPopupMenu(TPM_RIGHTALIGN |
TPM_RIGHTBUTTON, x, y, this);
"MFC" 카테고리의 다른 글
- MSFlexGrid Example For VS2005 (0)2007/04/03
- Using a System icon (SHGetFileInfo) (시스템 아... (0)2007/04/03
- Using Drop-Down Buttons in a Toolbar Control (... (0)2007/04/03
- CGdiObject Class (0)2007/04/03
- CMetaFileDC Class (0)2007/04/03

수안이의 컴퓨터 연구실



Leave your greetings.