Trouble centering a panel in a window

BlitzMax Forums/MaxGUI Module/Trouble centering a panel in a window

1goto1(Posted 2009) [#1]
This ends up centered by width but is off by height. What am I doing wrong?... I can't spot it.




_JIM(Posted 2009) [#2]
The width and height of the window includes the titlebar and borders and menubar and so on, but the position of the panel is relative to the usable area of the window, which is just beneath the menu bar.

That's why your panel is off a bit.

Don't know if there's a cross-platform clean solution to find the usable area of the window. I usually just subtract some hardcoded values from the window sizes and go with that.


jsp(Posted 2009) [#3]
Use ClientWidth() and ClientHeight() instead! And better no hardcoded values:)




_JIM(Posted 2009) [#4]
Oooooh, so that's what ClientWidth() and ClientHeight() are for. Thanks jsp! Now I feel really dumb for not figuring that out. :)


SebHoll(Posted 2009) [#5]
Or use the WINDOW_CLIENTCOORDS flag with your CreateWindow() call, in which case the window will be created such that the window's client area dimensions are the supplied width and height (W and H).


1goto1(Posted 2009) [#6]
Very helpful. All is good :)
Thanks!


jsp(Posted 2009) [#7]
If you you didn't use ClientWidth() and ClientHeight() before, than you may not know that it can be used not only for windows but all other gadgets as well (container gadgets obviously, GroupPanel, BorderPanel and such). For the Desktop() it retrieves the primary screen size when there is more than one screen/monitor.