|
-
January 14th, 2002, 06:35 AM
#1
Adding a drop down button control on toolbar
I have to add a button in one of the toolbar of my application which has a drop down arrow associated with it e.g
same as it is in the case of "New" button of standard toolbar in the Microsoft Outlook which has options like Mail Message,fax Message,Appointments etc associated with it.This control also has an icon assocaited with it.
This Control should have two options 1)send to Pocket PC and 2)Send to Palm
-
January 14th, 2002, 07:21 AM
#2
Re: Adding a drop down button control on toolbar
Read MSDN!!!!
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 orAddButtons) 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);
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.
}
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);
Rating isn't important...But gurus respect it and keep high
-
April 11th, 2003, 08:28 AM
#3
Dear igbus,
I have managed to add two drop-arrow control in the toolbar. It is working fine. One main MFC Toolbar and second to a dialog toolbar. Now the toolbar that belongs to MFC main view area is working fine. But the toolbar of dialog is not working fine. Is there some limitation about drop arrow toolbar not being functional properly with dialogs.
For example, I add print icon to a dialog with droparrow control and the items that are included in the drop arrow are Toolbar and Status bar, that are working properly (Same as toolbar and status bar present in VIEW menu item in standard MFC App Wizard Application). Upon pressing the Toolbar & Status bar menu items of drop-arrow icon of main MFC Toolbar main area, the state of menu items toggles (check/uncheck) and operation related to menu item executes. But If I add the same drop-arrow icon control to a dialog that contains print icon with drop-arrow menu control. Then a different behavior was observed. Upon pressing drop-arrow menu item in the Toolbar, the target operation performs (i.e. Toolbar hide/visible) but the menu item in the dialog drop-arrow won't check/uncheck. Am I missing something? Check/uncheck is performing through update_UI_method.
Waiting for your reply,
Best Regards,
Shozi
Anyone who has never made a mistake has never tried anything new.
-
April 11th, 2003, 09:05 AM
#4
I don't think that UPDATE_UI works for dialogs. You should do it explicitly by yourself
-
April 12th, 2003, 04:41 AM
#5
Well, UPDATE_UI method is working for main toobar drop-arrow, but not for dailog. If I need to explicity set check and uncheck then. But you know the menu item I was setting explicitly is the outer one .. but the inner one (dialog one) is the same-unchecked.
Any Comments on that ?
shozi
Originally posted by igbrus
I don't think that UPDATE_UI works for dialogs. You should do it explicitly by yourself
Anyone who has never made a mistake has never tried anything new.
-
April 14th, 2003, 11:43 AM
#6
I don't understand you. Could you show your code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|