Form always on Top

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do i keep a form always on top, like the TopMost Property of a form does, which is not included in the compact framework?
 
Can you make the form modal?

Dante said:
How do i keep a form always on top, like the TopMost Property of a form
does, which is not included in the compact framework?
 
Hi

You have to PInvoke... E.g. stick the following in your form load...

SetWindowPos(GetFocus(), -1, Me.Left, Me.Top, 0, 0, &H1 Or &H2 Or &H40)

....after you stick these somwhere where the form can see them:

<System.Runtime.InteropServices.DllImport("coredll.dll")> _
Public Shared Function GetFocus() As IntPtr
End Function

<System.Runtime.InteropServices.DllImport("coredll.dll")> _
Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal
hWndInsertAfter As Int32, ByVal X As Int32, ByVal Y As Int32, ByVal cx As
Int32, ByVal cy As Int32, ByVal uFlags As Int32) As Boolean
End Function

Cheers
Daniel


Dante said:
How do i keep a form always on top, like the TopMost Property of a form
does, which is not included in the compact framework?
 
Back
Top