Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
I'm trying to determine if a window's menu bar has been clicked on (so I can avoid SendKeying at an inappropriate time). I thought using the GetMenuBarInfo API function should be able to help me but I cannot get the function to work.
Code I've been using:
OBJID_CLIENT = -4 OBJID_MENU = -3 OBJID_SYSMENU = -1 w_title = "~Notepad" hwnd = dllhwnd(w_title) terminate(!hwnd, "bah", "window not found") ; set up the MENUBARINFO structure (do I need this?) structsize = 4 + 4*4 + 4 + 4 + 4 + 4 menubarinfo = binaryalloc(structsize) binaryeodset(menubarinfo, structsize) binarypoke4(menubarinfo, 0, structsize) ; call the API menu0 = dllcall("user32.dll", long:"GetMenu", long:hwnd) ; handle to main menu ismenu = dllcall("user32.dll", long:"IsMenu", long:menu0) ; this returns 1 (success) success = DllCall("user32.dll", long:"GetMenuBarInfo", long:menu0, long:OBJID_MENU, long:0, lpbinary:menubarinfo) ; but haven't made this succeed yet no matter what the OBJID ; look at fBarFocused member of MENUBARINFO structure here...Would be really grateful if anyone had any ideas.
However, the function still does not work with this change ( the error number returned from DllLastError() just changes) so there is something else wrong.
With this in mind I changed the structsize to 24 and added these lines:
RECT = binaryalloc(16) pRect = IntControl(42, RECT, 0, 0, 0) binarypoke4(menubarinfo, 4, pRECT)but no joy.
The last two members of the MENUBARINFO structure are declared as bit fields. Change the structure size from 36 to 32 bytes and it should work.
Article ID: W16458
File Created: 2005:02:18:12:20:50
Last Updated: 2005:02:18:12:20:50