Re: F10 and File menu
- Posted by Derek Parnell <ddparnell at bigpond.com> May 29, 2003
- 412 views
On Wed, 28 May 2003 23:12:51 +0100, Pete Lomax <petelomax at blueyonder.co.uk> wrote: > > > When I press F10, it selects the File menu and messes up the focus > (which also happens when there is no menu, btw). Does anyone have any > idea why & what can be done to stop it? > Example code: > include win32lib.ew > constant > win=create(Window,"Test",0,Default,Default,Default,Default,0), > men=create(Menu, "&File", win, 0,0,0,0,0) > > WinMain(win,Normal) > Believe it or not, but this is normal Windows functionality. The F10 key is supposed to invoke the menu bar, according to Microsoft. However, here is some code to add to win32lib (I've done it here and will release this weekend) to get around this behaviour. Find the routine called 'isHotKey' and add these lines just above that routine... ------------ integer vSkipF10 vSkipF10 = False global function skipF10(integer pNewValue) integer lOldValue lOldValue = vSkipF10 vSkipF10 = pNewValue return lOldValue end function ------------- Then in the isHotKey routine, find the lines ... if event = WM_SYSKEYDOWN and key = VK_F10 then VOID = sendMessage(id, WM_KEYDOWN, key, lParam) return {kReturnNow} end if and change them to ... if event = WM_SYSKEYDOWN and key = VK_F10 then if not vSkipF10 then VOID = sendMessage(id, WM_KEYDOWN, key, lParam) end if return {kReturnNow} end if Now in your program, add the line ... VOID = skipF10(True) just before the WinMain call. -- cheers, Derek Parnell