Re: Newbie: Win32Lib: open maximized?
Dan Moyer wondered:
> How can I make a windows program start out
> MAXIMIZED using Win32Lib?
You can't without hacking Win32Lib. The problem is in openWindow and
showWindow are hardcoded to use SW_SHOWNORMAL. You need to use
SW_SHOWMAXIMIZED in order to open the window maximized.
The best approach is probably to change openWindow to accept an additional
style parameter. WinMain would also need to be updated:
-- START OF CODE --
global procedure openWindow( integer id, atom style )
atom hWnd
-- get the handle
hWnd = window_handle[ id ]
-- set the text and background colors
setTextColor( id, getSysColor( COLOR_WINDOWTEXT ) )
setBackColor( id, getSysColor( COLOR_WINDOW ) )
-- action?
if onOpen[ id ] != -1 then
call_proc( onOpen[ id ], {} )
end if
-- need to show menubar?
if window_menu[ id ] then
ok = c_func( xDrawMenuBar, {hWnd} )
end if
-- START OF CHANGES
-- if no style, use normal
if style < 1 then
style = SW_SHOWNORMAL
end if
-- display the window
ok = c_func( xShowWindow, { hWnd, style } )
-- END OF CHANGES
-- update the window
c_proc( xUpdateWindow, { hWnd } )
-- set focus
c_proc( xSetFocus, {hWnd} )
end procedure
global procedure WinMain( integer id, atom style )
-- main routine
atom hWnd
atom msg
-- allocate a message buffer
msg = allocate_struct(SIZEOF_MESSAGE)
-- create the default window
defaultWindow = id
-- START OF CHANGES
openWindow( id, style )
-- END OF CHANGES
-- message loop
while c_func( xGetMessage, { msg, NULL, 0, 0 } ) do
c_proc( xTranslateMessage, { msg } )
c_proc( xDispatchMessage, { msg } )
end while
-- release all resources
releaseAllResources()
end procedure
-- END OF CODE --
All existing calls to openWindow in WIN32LIB.EW also have to be changed to:
openWindow( TheWindow, Default )
When you call WinMain, you now need to pass the style. If you don't care,
you can use:
WinMain( TheWindow, Default )
If you want a maximized window, you can use:
WinMain( TheWindow, SW_SHOWMAXIMIZED )
Do people want this added to Win32Lib?
-- David Cuny
|
Not Categorized, Please Help
|
|