Re: win32lib main window
- Posted by ghaberek (admin) Dec 08, 2014
- 1128 views
This works for me...
include Win32Lib.ew constant Main = create( Window, "Min/Max Testing", 0, Default, Default, 640, 480, 0 ), MinButton = create( PushButton, "Minimize", Main, 0, 0, 90, 30, 0 ), MaxButton = create( PushButton, "Maximize", Main, 0, 0, 90, 30, 0 ), $ procedure Main_OnResize( integer self, integer event, sequence params ) -- params[1] is the 'style' of the size event. -- See Win32Lib documentation for w32HResize. if params[1] = SIZE_RESTORED then -- Next action should be SW_MAXIMIZE. setText( MaxButton, "Maximize" ) elsif params[1] = SIZE_MAXIMIZED then -- Next action should be SW_RESTORE. setText( MaxButton, "Restore" ) end if -- Center the buttons. setRect( MinButton, {0.5,-45}, {0.5,-35}, 90, 30, w32True ) setRect( MaxButton, {0.5,-45}, {0.5, 5}, 90, 30, w32True ) end procedure setHandler( Main, w32HResize, routine_id("Main_OnResize") ) procedure MinButton_OnClick( integer self, integer event, sequence params ) -- Just minimize the window. showWindow( Main, SW_MINIMIZE ) end procedure setHandler( MinButton, w32HClick, routine_id("MinButton_OnClick") ) procedure MaxButton_OnClick( integer self, integer event, sequence params ) sequence text = getText( MaxButton ) -- Update the window state, based on the current button text. The event -- handler for w32HResize the window will update the text accordingly. if equal( text, "Maximize" ) then showWindow( Main, SW_MAXIMIZE ) elsif equal( text, "Restore" ) then showWindow( Main, SW_RESTORE ) end if end procedure setHandler( MaxButton, w32HClick, routine_id("MaxButton_OnClick") ) WinMain( Main, Normal )
-Greg