From: winapi on
Hello,

I noticed that when using the BTNS_DROPDOWN style, so when one clicks the
toolbar button a menu is displayed, "does not" behave like the standard
window menu. When using the standard menu, one clicks on the menu item, and
the menu displays "automatically" when the mouse moves(hovers) over
each/next menu item in the list,
"without" having to "re-click" on the menu.

When using the toolbar method this "automatic" selection display of the menu
does not happen, you have to "re-click" the button "each time" to get the
menu to display.

I found this article on MSDN. . . .
http://msdn.microsoft.com/en-us/library/bb775450(VS.85).aspx

In the section . . . . "Message Processing for Menu Hot-Tracking"
It mentions about a message hook for hot-tracking is this what I am looking
for to emulate the standard menu behavior? That being the automatic menu
display, "once the menu item is selected" when hovering(moving) the mouse
over the menu items with out having to
"re-click" the button.

If so? how would one go about implementing this? as it does not explain in
"much" detail.


Thanks.


From: Seetharam on
You can do the hot-tracking yourself by using WM_SETCAPTURE.
Set a flag to true once you click on a drop-down toolbar item and call
SetCapture(). As you move your mouse, you can detect if the current
mouse location is on another toolbar flyout item within the same
toolbar using TB_HITTEST.

-Seetharam



From: winapi on
"Seetharam" <smisro(a)gmail.com> wrote in message
news:926d2dc2-cd68-420a-8464-7edfcf8c25b2(a)x1g2000vbe.googlegroups.com...
> You can do the hot-tracking yourself by using WM_SETCAPTURE.
> Set a flag to true once you click on a drop-down toolbar item and call
> SetCapture(). As you move your mouse, you can detect if the current
> mouse location is on another toolbar flyout item within the same
> toolbar using TB_HITTEST.
>
> -Seetharam

<-------------------------------------------------->

Hi,

Thanks for the reply.

I am not sure how to implement your method with my existing code. The code
below is
currently what I am using, to handle the menu display when you click the
toolbar bottom.
This code is from the MSDN example. I have added the switch(lpnmTB->item)
to allow a different menu for each toolbar button if required. . . . . .

///////////////////////////////////////////////////////////////////////

BOOL DoNotify(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#define lpnm ((LPNMHDR)lParam)
#define lpnmTB ((LPNMTOOLBAR)lParam)

RECT rc;
TPMPARAMS tpm;
HMENU hMenuLoaded;
BOOL bRet = FALSE;

switch(lpnm->code)
{

case TBN_DROPDOWN:
SendMessage(lpnmTB->hdr.hwndFrom, TB_GETRECT,
(WPARAM)lpnmTB->iItem, (LPARAM)&rc);
MapWindowPoints(lpnmTB->hdr.hwndFrom, HWND_DESKTOP, (LPPOINT)&rc, 2);

tpm.cbSize = sizeof(TPMPARAMS);
tpm.rcExclude = rc;
hMenuLoaded = LoadMenu(0, (LPSTR)IDR_POPUP);
hMenuLoaded = GetSubMenu(hMenuLoaded, 0);

switch(lpnmTB->iItem)
{
case ID_TBUTTON_ONE:
TrackPopupMenuEx(hMenuLoaded, 0, rc.left, rc.bottom, g_hwndMain,
&tpm);
return 0;

case ID_TBUTTON_TWO:
TrackPopupMenuEx(hMenuLoaded, 0, rc.left, rc.bottom, g_hwndMain,
&tpm);
return 0;

case ID_TBUTTON_THREE:
TrackPopupMenuEx(hMenuLoaded, 0, rc.left, rc.bottom, g_hwndMain,
&tpm);
return 0;

}
return 0; // End lpnmTB->iItem.

return 0; // End TBN_DROPDOWN:

}

return 0; // End lpnm->code.
}




How would one implement your code into this function?



Thanks.



From: Seetharam on
Actually, its not so easy...
You would first need to install a hook on your menu (in
WM_INITMENUPOPUP, call SetWindowHookEx() and unhook in WM_MENUSELECT).
See http://www.codeproject.com/KB/menus/QuickODmenu.aspx for an
example on how to hook.

Once your menu is hooked, you can handle the WM_MOUSEMOVE message to
get your mouse coordinates. If you find that your mouse points on
another tooolbar button having a drop-down then you simply call
"TrackPopupMenuEx()" with right values. That will take care of
dismissing the earlier menu and show the new menu.

-Seetharam
From: winapi on

"Seetharam" <smisro(a)gmail.com> wrote in message
news:05e77c11-f568-423a-80e0-84d627d36aed(a)c7g2000vbc.googlegroups.com...
> Actually, its not so easy...
> You would first need to install a hook on your menu (in
> WM_INITMENUPOPUP, call SetWindowHookEx() and unhook in WM_MENUSELECT).
> See http://www.codeproject.com/KB/menus/QuickODmenu.aspx for an
> example on how to hook.
>
> Once your menu is hooked, you can handle the WM_MOUSEMOVE message to
> get your mouse coordinates. If you find that your mouse points on
> another tooolbar button having a drop-down then you simply call
> "TrackPopupMenuEx()" with right values. That will take care of
> dismissing the earlier menu and show the new menu.
>
> -Seetharam

Thanks for the info, I will look into it.


 | 
Pages: 1
Prev: Spy++ Source Code
Next: Findreplace Dialog