News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Are menus windows?

Started by jj2007, November 23, 2011, 09:17:22 PM

Previous topic - Next topic

jj2007

I found an interesting code here claiming that it is possible to subclass menus by hooking their creating in the main window's WM_CREATE handler.
The hook works, technically speaking, but the menu windows handle does not show up :(

invoke GetCurrentThreadId ; shorter than GetWindowThreadProcessId, hWnd, 0
invoke SetWindowsHookEx, WH_CALLWNDPROC, CbMenu, 0, eax


Any ideas? The attachment has a useMB switch on top - set to 0 if you want to stick with QEditor. There is a cdt_MB.exe in the attachment showing what the deb 4 macro does. Sample output:
ResHook eax             140248117

CREATE
hMenu           197592281
wMenu           65562

posc
[ebx.WINDOWPOS.lx]      400
[ebx.WINDOWPOS.cy]      350
Class   $edi            ToolbarWindow32

No luck
ecx             4786962
hMainWindow     0
wMenu           65562
hMenu           197592281
Class   $edi            MSCTFIME UI

No luck
ecx             4983554
hMainWindow     0
wMenu           65562
hMenu           197592281
Class   $edi            CicMarshalWndClass

No luck
ecx             4131644
hMainWindow     0
wMenu           65562
hMenu           197592281

posc
[ebx.WINDOWPOS.lx]      400
[ebx.WINDOWPOS.cy]      350

dedndave

the only possibility that pops into mind is that the menu's window handle may not be the same as the menu handle  :P
the OS treats window handles differently than menu handles
the caption bar seems to be the same way

if you enumerate windows using the menu handle, you may not get it

dedndave

have you looked at the source code for xxControls ?

jj2007

Quote from: dedndave on November 24, 2011, 12:19:50 AM
the only possibility that pops into mind is that the menu's window handle may not be the same as the menu handle  :P

indeed. hMenu is the menu handle, wMenu is the menu's window handle obtained with FindWindow.