Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set focus

Status
Not open for further replies.

mettodog

Vendor
Jul 11, 2000
94
US
how do i set focus on the currently active form? so that it stays "on top" while another form loads behind it?
 
Looks like you want code for "Always on top".

Here it is:


Put this into a .bas module:
Code:
Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal _
    hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx _
    As Long, ByVal cy As Long, ByVal wFlags As Long)
    Global Const HWND_TOPMOST = -1
    Global Const HWND_NOTOPMOST = -2
    Global AOTValue As Boolean

Put this into your form:
Code:
Dim i As Integer
    i = SetWindowPos(Me.hWnd, HWND_TOPMOST, _
    Me.Left \ Screen.TwipsPerPixelX, Me.Top \ Screen.TwipsPerPixelY, _
    Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, 0)

To take it off the top, replace HWND_TOPMOST with HWND_NOTOPMOST.

Hope this helps.

--Michael P. Gerety
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top