Results 1 to 2 of 2

Thread: Keeping Program on Top

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962

    Keeping Program on Top

    I am making a game where I have one form as a background form. I wish to keep that form on top of all other forms, except other forms my game brings up. So, I have frmStartup (background/main options) which needs to be on top, then any msgboxs or my frmNewGame needs to be above that.

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Call like

    OnTop (Me.hwnd), True

    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)
    
    Public Sub OnTop(Handle As Long, Pos As Long)
        Dim wFlags As Long, PosFlag As Long
        Const Swp_Nosize = &H1
        Const SWP_Nomove = &H2
        Const Swp_NoActivate = &H10
        Const Swp_ShowWindow = &H40
        Const Hwnd_TopMost = -1
        Const Hwnd_NoTopMost = -2
        wFlags = SWP_Nomove Or Swp_Nosize Or Swp_ShowWindow
        Select Case Pos
             Case True
                PosFlag = Hwnd_TopMost
             Case False
                PosFlag = Hwnd_NoTopMost
             End Select
        SetWindowPos Handle, PosFlag, 0, 0, 0, 0, wFlags
    End Sub
    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width