MaxGUI Window Centering & Multiple Monitors

BlitzMax Forums/BlitzMax Programming/MaxGUI Window Centering & Multiple Monitors

N(Posted 2006) [#1]
Is there any way to specify a monitor to center a window gadget on? Currently the created window is centered between both monitors, so it crosses over and it doesn't look good (at all).

Global frmMakePak:TGadget = CreateWindow( "MakePak", (GadgetWidth(Desktop())-512)/2, (GadgetHeight(Desktop())-200)/2, 512, 256, Null, WINDOW_TITLEBAR )


Basically, that's what I have thus far. If anyone has any ideas I'd greatly appreciate if you posted them.


skidracer(Posted 2006) [#2]
the problem is win32maxgui.mod/win32gui/win32desktop.cpp which uses the GetSystemMetrics call to initialize the deskop gadgets size but I think should be using the following constants:

SM_CXSCREEN, SM_CYSCREEN

I suggest you do your own call to GetSystemMetrics and let me know if you can get the correct results using the above. I'm guessing if your primary monitor has a non 0,0 origin (is this possible?) it won't be quite that straight forward.


N(Posted 2006) [#3]
I'm not sure if it's possible, I'd doubt it though, since Windows probably repositions all monitors relative to the primary monitor (which would always be at 0,0 presumably).

Anyhow, changing it to SM_C{XY}SCREEN did the trick. Thanks, skid.


TeaVirus(Posted 2006) [#4]
Noel - If you use ClientWidth(Desktop()) and ClientHeight(Desktop()) you will get the primary monitor dinensions. At least it works for me on my dual monitor setup.


N(Posted 2006) [#5]
Thanks, TeaVirus :)