Announcement

Collapse
No announcement yet.

Signal no longer top most

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Signal no longer top most

    Is there a message that gets sent to the form when it is no longer the topmost window? My Google-Fu is weak. I have a dialog in my program that I want to stay on top until it is acknowledged.
    Real programmers use a magnetized needle and a steady hand

  • #2
    Howdy, Bud!

    WM_KillFocus might be helpful. But I do not know of a message that specifically addresses the loss of topmost status.

    Comment


    • #3
      Use SetWindowPos() with the HWND_NOTOPMOST option

      :Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        I have a dialog in my program that I want to stay on top until it is acknowledged.
        Code:
        #Compile Exe
        #Dim All
        #Include "WIN32API.INC"
        '------------------
         
        CallBack Function DlgProc()
          Select Case As Long CbMsg
            Case %WM_InitDialog
              SetWindowPos Cb.Hndl, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE
         
            Case %WM_NCActivate
              Static hWndSaveFocus As Dword
              If IsFalse CB.wParam Then
                WinBeep 800,200
              Else
                WinBeep 1800,200
              End If
         
            Case %WM_Command
              Select Case As Long CbCtl
                Case %IdOk
                  If CbCtlMsg = %BN_Clicked Then
                    DIALOG END Cb.Hndl
                  End If
              End Select
          End Select
        End Function
        '------------------/DlgProc
         
        Function PBMain()
         Local hDlg As Dword
          Dialog New 0, "Test", 800, 500, 200, 120, %WS_Caption Or %WS_SysMenu, To hDlg
            Control Add Button,  hDlg, %IDOK,  "Fine", 75, 60, 50, 15
          Dialog Show Modal hDlg, Call DlgProc
        End Function
        '------------------/PbMain
        Rgds, Dave

        Comment


        • #5
          Is there a message that gets sent to the form when it is no longer the topmost window?
          Are you trying to make it non-topmost after you have all the info you need from it? Or are you trying to keep it on top until it is dismissed by the user?

          Looks like I am answering the first question and Mssrs. Biggs and Beene are answering the latter.

          Making the dialog style WS_SYSMODAL will also do the latter, but as they say, it's your application but it's not your computer, so use this style with care!
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Don't know how useful it is in this case, but there is message that MS describes: "The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in the Z order is about to change as a result of a call to the SetWindowPos function or another window-management function."

            Comment


            • #7
              Originally posted by Bud Durland View Post
              I have a dialog in my program that I want to stay on top until it is acknowledged.
              Do you want the dialog to keep focus (i.e. sysmodal) or just be "topmost" while other windows or applications can still have focus/be used?

              If just topmost, for your application of for other running applications as well?

              What should happen to the dialog once it is acknowledged? (closed, minimized, still there, but able to be coverd by another window?)




              Comment


              • #8
                The program in question is used on the factory floor, on a PC that is nearly in Kiosk mode, with touch screens. Sometimes stray screen touches will take focus away from the dialog, or start some other program (chrome, etc.). Once acknowledged, the form closes and the program proceeds. But if not acknowledged, some things get jammed up. The program is done with Paul Squire's FireFly, and though the form is loaded/displayed in what it calls "Modal" mode, I suspect it is application modal, not system. I guess I should have looked into the source code FF generates to see. I was hoping to be able to check for an incoming message to the form, to the effect "you're not on top any more".

                @MM -- I get the risks of WS_SYSMODAL, but in this case it's an acceptable one.
                Real programmers use a magnetized needle and a steady hand

                Comment


                • #9
                  Just add this code to your FireFly source callback (assumes equiv Cb.wParam and Cb.Hndle)
                  Code:
                      Case %WM_NCActivate
                        If IsFalse wParam Then
                          SetWindowPos hWndForm, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE
                        End If
                  WM_NCActivate is received when the dialog is about to lose focus..
                  Last edited by Dave Biggs; 8 Oct 2021, 08:22 PM. Reason: Removed redundant code
                  Rgds, Dave

                  Comment


                  • #10
                    Originally posted by Dave Biggs View Post
                    Just add this code to your FireFly source callback (assumes equiv Cb.wParam and Cb.Hndle)
                    Code:
                    Case %WM_NCActivate
                    If IsFalse wParam Then
                    SetWindowPos hWndForm, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE
                    End If
                    WM_NCActivate is received when the dialog is about to lose focus..
                    Yep, better solution that SYSMODAL in this situation
                    Keeps the dialog on top, but allows interaction with other windows.

                    For standard PBWIn DDT:
                    Code:
                    ...
                    CASE %WM_NCACTIVATE
                        IF ISFALSE CB.WPARAM THEN
                            SetWindowPos CB.HNDL, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE
                        END IF
                    ...

                    Comment


                    • #11
                      WM_NCActivate is received when the dialog is about to lose focus..
                      Just what i needed. Thanks
                      Real programmers use a magnetized needle and a steady hand

                      Comment

                      Working...
                      X