Title-less window: Restore/Maximize enablement wrong on Alt_Space menu (arwen)
- Posted by Pete Lomax <petelomax at blue?on?er.co.uk> Nov 01, 2007
- 559 views
Hi, I noticed a minor problem with a demo (arwen) program I wrote a while back. This program (see below) demonstrates hiding/displaying a window titlebar, and should work for normal (aka "restored") and maximised windows. When you press alt-space, you get the expected Restore/Move/Size/Minimise/Maximise/Close menu, and one of Restore/Maximise is always greyed out. The menu appears whether or not the title bar is visible, so far so good. Now, if the title bar is visible, and you alt-space Restore/Maximise, then press alt-space again, the enabled options have swapped as they should. However if you do this with the titlebar invisible, they are wrong/unchanged. Obviously in the "toggle" demo, I can "toggle" the title as a work-round, but if the title is permanently off, it could be a bit of a problem... I wonder if this is a bug which is fixed in later versions of Windows? The more I think about it, I doubt it can be caused by what I've done, since it is a keyboard event long after, which is failing to swap enabled states, but I still hope it is just some flag or event or other I am missing... I have tested this on both an old and the latest version of arwen.
-- -- title-less window demo -- include arwen.ew without warning constant Window1 = create(Window, "Press Escape to toggle", 0, 0, 100, 100, 400, 300, 0), w1txt = create(Label,"Press Escape to toggle",0,Window1,10,10,200,25,0), w1Hwnd=getHwnd(Window1) constant -- (to be incorporated into constants.ew) -- ShowWindowPos flags (needed after setWindowLong to remove cached effects) SWP_NOSIZE = #0001, SWP_NOMOVE = #0002, SWP_NOZORDER = #0004, SWP_NOREDRAW = #0008, SWP_NOACTIVATE = #0010, SWP_FRAMECHANGED = #0020, SWP_SHOWWINDOW = #0040, SWP_HIDEWINDOW = #0080, SWP_NOCOPYBITS = #0100, SWP_NOOWNERZORDER = #0200, SWP_NOSENDCHANGING = #0400, SWP_DRAWFRAME = SWP_FRAMECHANGED, SWP_NOREPOSITION = SWP_NOOWNERZORDER, SWP_DEFERERASE = #2000, SWP_ASYNCWINDOWPOS = #4000, SWP_UPDATECACHE = SWP_NOSIZE+SWP_NOMOVE+SWP_NOZORDER+SWP_FRAMECHANGED+SWP_NOCOPYBITS procedure toggleTitle() atom style style = c_func(xGetWindowLong,{w1Hwnd, GWL_STYLE }) style = xor_bits(style,WS_BORDER) void = c_func(xSetWindowLong,{w1Hwnd,GWL_STYLE,style}) void = c_func(xSetWindowPos,{w1Hwnd,0,0,0,0,0,SWP_UPDATECACHE}) end procedure -- uncomment this to start without a title: --toggleTitle() function w1Handler(integer id, integer msg, atom wParam, object lParam) if msg = WM_KEYDOWN and wParam = VK_ESCAPE then toggleTitle() end if return 0 end function setHandler(Window1, routine_id("w1Handler")) WinMain( Window1, SW_NORMAL ) --WinMain( Window1, SW_MAXIMIZE )
Regards, Pete