Home All Groups Group Topic Archive Search About

Win Forms Positioning

Author
2 Jul 2005 3:14 AM
Shane Story
I need to position a normal form at a certain position above another
form....mainly I would like it to have
a left of 0 (far left) and its top to start just below my toolbar.

Other than using GetSystemMetrics API to determine height of menu and win
caption, I have no idea how to do this.

Any ideas?  Or is that the only way?

thanks,

Shane

Author
2 Jul 2005 10:28 AM
Ken Tucker [MVP]
Hi,

            You can use the setwindowpos function.  Use the hwnd_topmost
flag to make window a topmost window.

    Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal
hwnd As Integer, _
        ByVal hWndInsertAfter As Integer, ByVal x As IntPtr, ByVal y As
Integer, _
        ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
As Integer

    Const HWND_TOPMOST As Integer = -1
    Const SWP_NOMOVE As Integer = &H2
    Const SWP_NOSIZE As Integer= &H1

    SetWindowPos(Me.Handle.ToInt32, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE +
SWP_NOSIZE)


Ken
------------------------
"Shane Story" <nospam@nothanks.com> wrote in message
news:ujdpzQrfFHA.1044@tk2msftngp13.phx.gbl...
I need to position a normal form at a certain position above another
form....mainly I would like it to have
a left of 0 (far left) and its top to start just below my toolbar.

Other than using GetSystemMetrics API to determine height of menu and win
caption, I have no idea how to do this.

Any ideas?  Or is that the only way?

thanks,

Shane