On Aug 24, 2006, at 10:59 PM, Steven Hedgepeth wrote:
1. Is this the best way to position a window when it is shown?
=================================================
Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As
Integer) As Integer
'Returns screen width in pixels
intScreenWidth = GetSystemMetrics(0)
'Returns screen height in pixes
intScreenHeight = GetSystemMetrics(1)
Main.Left = (intScreenWidth - Main.Width)/2
Main.Top = (intScreenHeight - Main.Height)/2
=================================================
The above code is not cross-platform compatible. While there are
good reason to use OS-specific declares like this, in this particular
case it is not necessary. You can use the Screen class to get info
like Width, Height, Depth and more; and for all of the monitors
connected to the computer (see ScreenCount function).
Your code rewritten with the Screen class would be:
Main.Left = (Screen(0).Width - Main.Width) / 2
Main.Top = (Screen(0).Height - Main.Height) / 2
Another option is to use the AvailableWidth and other functions to
position windows outside of the areas occupied by: TaskBar, MenuBar
and the Dock in OS X.
2. Where is the best place to put window positioning code? I tried
placing it the window's open event or is there a better place for it?
Window.Open event is fine... and will position the Window before it
is displayed on the screen. Of course you can change the Window
properties at any time, such as making the Window smaller when the
user chooses to hide certain UI elements.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>