Window priority above other apps.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hutch
    New Member
    • Mar 2007
    • 74

    Window priority above other apps.

    How do i get my access 2003 Windows to always appear above all other applications running?
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by Hutch
    How do i get my access 2003 Windows to always appear above all other applications running?
    Hi. I have moved your thread to the access forum

    Comment

    • Hutch
      New Member
      • Mar 2007
      • 74

      #3
      Do you have any idea on this subject?

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by Hutch
        How do i get my access 2003 Windows to always appear above all other applications running?
        I should have the answer for you shortly. It involves an API call and the Handle to the Main Access Window. Please be patient.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by Hutch
          How do i get my access 2003 Windows to always appear above all other applications running?
          As previously promised, the following code will make the 'Main Access Window' always appear above all other running applications. First the API Declaration:
          Code:
          Declare Function 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) As Long
          NOTE: Use extreme caution whenever using API Calls and always backup your Database prior to experimenting. The slightest Syntax or other Error could cause a General Protection Fault. This code has been tested on Access 2003 and does, in fact, work:
          Now the code:
          Code:
          Private Sub Form_Open(Cancel As Integer)
            Dim wFlags As Long, lngX As Long
          
            wFlags = &H2 Or &H1 Or &H40 Or &H10
            lngX = SetWindowPos(Application.hWndAccessApp, -1, 0, 0, 0, 0, wFlags)
          End Sub

          Comment

          • Hutch
            New Member
            • Mar 2007
            • 74

            #6
            I get an error message after opening the form saying "Compile error: Expected variable or procedure, not module" it then opens VBA and highlites "SetWindowP os" in the private sub on the form. Any ideas?

            Comment

            • Hutch
              New Member
              • Mar 2007
              • 74

              #7
              Take that back I got it to work, However the only draw back on this is when an error message appears behind the window you cant get to it.

              Comment

              • ADezii
                Recognized Expert Expert
                • Apr 2006
                • 8834

                #8
                Originally posted by Hutch
                Take that back I got it to work, However the only draw back on this is when an error message appears behind the window you cant get to it.
                That is a considerable Trade Off.

                Comment

                • Hutch
                  New Member
                  • Mar 2007
                  • 74

                  #9
                  Originally posted by ADezii
                  That is a considerable Trade Off.
                  So check it out i am using this code in a command click button now. Sometimes i want it to remain above other apps other times i don't so far i have this

                  Private Sub Pri_Click_Click ()
                  If Me.Pri_Click = True Then
                  Dim wFlags As Long, lngX As Long
                  wFlags = &H2 Or &H1 Or &H40 Or &H10
                  lngX = SetWindowPos(Ap plication.hWndA ccessApp, -1, 0, 0, 0, 0, wFlags)
                  If Me.Pri_Click = False Then GoTo Ext_Pri
                  End If
                  Ext_Pri:
                  End Sub

                  Do you happen to know the code to take the Window Priority away?
                  Any help would be amazing, thanks in advance.

                  Comment

                  • ADezii
                    Recognized Expert Expert
                    • Apr 2006
                    • 8834

                    #10
                    Originally posted by Hutch
                    So check it out i am using this code in a command click button now. Sometimes i want it to remain above other apps other times i don't so far i have this

                    Private Sub Pri_Click_Click ()
                    If Me.Pri_Click = True Then
                    Dim wFlags As Long, lngX As Long
                    wFlags = &H2 Or &H1 Or &H40 Or &H10
                    lngX = SetWindowPos(Ap plication.hWndA ccessApp, -1, 0, 0, 0, 0, wFlags)
                    If Me.Pri_Click = False Then GoTo Ext_Pri
                    End If
                    Ext_Pri:
                    End Sub

                    Do you happen to know the code to take the Window Priority away?
                    Any help would be amazing, thanks in advance.
                    Try the following code segment to turn OFF the TopMost Attribute:
                    [CODE=vb]Dim wFlags As Long, lngX As Long
                    wFlags = &H10 Or &H40
                    lngX = SetWindowPos(Ap plication.hWndA ccessApp, -2, 0, 0, 0, 0, wFlags)[/CODE]

                    Comment

                    • Hutch
                      New Member
                      • Mar 2007
                      • 74

                      #11
                      That code take the window minimizes it and move it into the tope left corner of my screen.

                      Comment

                      • Hutch
                        New Member
                        • Mar 2007
                        • 74

                        #12
                        Dim wFlags As Long, lngX As Long
                        wFlags = &H10 Or &H40
                        lngX = SetWindowPos(Ap plication.hWndA ccessApp, -2, 0, 0, 0, 0, wFlags)

                        I figured out that the H10 and H40 was the cause of the screen movement, I changed them to 2 and 1 like in the previouse code but kept the -2. this works great.

                        Comment

                        • ADezii
                          Recognized Expert Expert
                          • Apr 2006
                          • 8834

                          #13
                          Originally posted by Hutch
                          Dim wFlags As Long, lngX As Long
                          wFlags = &H10 Or &H40
                          lngX = SetWindowPos(Ap plication.hWndA ccessApp, -2, 0, 0, 0, 0, wFlags)

                          I figured out that the H10 and H40 was the cause of the screen movement, I changed them to 2 and 1 like in the previouse code but kept the -2. this works great.
                          Glad you figured it out.

                          Comment

                          Working...