1. Newbie: Win32Lib: open maximized?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET>
Aug 26, 1999
-
Last edited Aug 27, 1999
Hello all,
Another newbie question, if you all don't mind:
How can I make a windows program start out MAXIMIZED using Win32Lib?
I tried putting WS_MAXIMIZE in the style parameter for "create window",
but it didn't do anything; I tried using the "get system metrics" function
described in a Win32 Tutorial by Ad Rienks & Wolfgang Fritz, but that just
gives a "big" window, not a truly maximized one.
Any suggestions?
Dan Moyer
2. 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
3. Re: Newbie: Win32Lib: open maximized?
On Fri, 27 Aug 1999, Cuny, David wrote:
>
> WinMain( TheWindow, SW_SHOWMAXIMIZED )
>
> Do people want this added to Win32Lib?
>
> -- David Cuny
>
Is there a way to do it so that WS_MAXIMIZE and WS_MINIMIZE styles are
used when calling 'create'? This seems to me to be the intended use of
these style types. As it is, they appear to be ignored. I've looked over
the code but it's still a bit beyond me how you might make it work this
way. Would it require too much of a rewrite? The method you described
is probably the easiest way to accomplish the desired behavior...
-- Brian
4. Re: Newbie: Win32Lib: open maximized?
Brian K. Broker wondered:
> Is there a way to do it so that WS_MAXIMIZE
> and WS_MINIMIZE styles are used when calling
> 'create'?
Yes, but I prefer the method I outlined. If I define the flags:
Normal
Maximize
Minimize
Modal
then there are no Win32 specific flags, and the code's portable. I can also
get rid of openModal() and minimizeWindow(). \
I'm tempted to rename the routine to "showWindow()" and add the flags:
Hidden
Close
but there are too many problems with knowing when to trigger onOpen vs.
onResize. I could get around that by setting a state flag, but I suspect it
would disrupt too much existing code, and it doesn't feel that clean of a
solution.
-- David Cuny
5. Re: Newbie: Win32Lib: open maximized?
On Fri, 27 Aug 1999 11:13:08 -0700, Cuny, David <David.Cuny at DSS.CA.GOV>
wrote:
>Dan Moyer wondered:
>
>> How can I make a windows program start out
>> MAXIMIZED using Win32Lib?
>
>You can't without hacking Win32Lib
><<snip>>
>Do people want this added to Win32Lib?
>
>-- David Cuny
David,
Ok, looks like by some "time warp" you have "already" updated Win32Lib on
August 28th to handle min/max, so I'll just download it here on the 27th &
try it out. :) Thanks.
Dan