Announcement

Collapse
No announcement yet.

How to know that the user leave a dialog or enter a dialog

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

  • How to know that the user leave a dialog or enter a dialog

    Is there any way to find out in a DALOG CALLBACK
    1 that the user has activated another dialog?
    2 that users have made the current dialog active?
    Code:
     SKAPA_DIALOGEN:
    DIALOG NEW PIXELS, 0, "", KOM.DIALOGPOSITION_X, KOM.DIALOGPOSITION_Y, BREDD(BILD_BREDD), HOJD(BILD_HOJD), _
    %WS_CAPTION _
    OR %WS_SYSMENU _
    OR %WS_MAXIMIZEBOX _
    OR %WS_MINIMIZEBOX _
    OR %WS_OVERLAPPED _
    OR %WS_THICKFRAME _
    OR %WS_CLIPSIBLINGS _
    TO HD
    .
    .
    .
    .
    DIALOG SHOW MODAL HD CALL DIALOG_BEHANDLING
    .
    .
    CALLBACK FUNCTION DIALOG_BEHANDLING
    '===================================
    '
    ' Here I want to know that the user has activated another dialog
    ' or that users have made this dialog active?
    END FUNCTION
    Fim W.
    Fim Wästberg

  • #2
    Check out this thread, look for EnumWindows in a post by Pierre Bellisle, for starters.
    https://forum.powerbasic.com/forum/u...ow-alternative
    Rod
    I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

    Comment


    • #3
      Fim,

      Do you mean which window has FOCUS? (Yours or not yours?)
      Dale

      Comment


      • #4
        Dale,
        I want to get "a signal" when the user change
        focus
        Fim Wästberg

        Comment


        • #5
          %wm_activate ?

          Comment


          • #6
            Link to MSDN page for message Stuart mentioned.

            https://docs.microsoft.com/en-us/win...ev/wm-activate
            Dale

            Comment


            • #7
              Or as per PBForms template..
              Code:
                  Case %WM_NCActivate
                    Static hWndSaveFocus As Dword
                    If IsFalse CB.wParam Then
                      hWndSaveFocus = GetFocus()
                    ElseIf hWndSaveFocus Then
                      SetFocus(hWndSaveFocus)
                      hWndSaveFocus = 0
                    End If
              Rgds, Dave

              Comment


              • #8
                Actually %WM_NCACTIVATE: https://docs.microsoft.com/en-us/win.../wm-ncactivate
                Simple demo:
                '
                Code:
                #COMPILE EXE
                #DIM ALL
                '#INCLUDE ONCE "WIN32API.INC"
                %IDC_BUTTON1 =1001
                GLOBAL hDlg1,hDlg2 AS DWORD
                FUNCTION PBMAIN () AS LONG
                    DIALOG NEW 0, "Dialog1-Active", 200, 100, 200, 100, %WS_POPUP OR _
                        %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
                        %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
                        %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
                        %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg1
                    CONTROL ADD BUTTON, hDlg1, %IDC_BUTTON1, "Dialog2", 105, 25, 75, 20
                
                    DIALOG NEW 0, "Dialog2-Active", 500, 100, 200, 100, %WS_POPUP OR _
                        %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
                        %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
                        %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
                        %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg2
                
                    DIALOG SHOW MODAL hDlg1 CALL Dlg1Proc
                END FUNCTION
                
                CALLBACK FUNCTION dlg1Proc()
                     SELECT CASE AS LONG CB.MSG
                        CASE %WM_NCACTIVATE
                            IF CB.WPARAM THEN
                                DIALOG SET TEXT CB.HNDL, "Dialog 1: Active"
                             ELSE
                                DIALOG SET TEXT CB.HNDL, "Dialog 1: InActive"
                             END IF
                        CASE %WM_COMMAND
                            SELECT CASE AS LONG CB.CTL
                                CASE %IDC_BUTTON1
                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                        DIALOG SHOW MODAL hdlg2 CALL dlg2proc
                                    END IF
                             END SELECT
                    END SELECT
                END FUNCTION
                CALLBACK FUNCTION dlg2Proc()
                    SELECT CASE AS LONG CB.MSG
                        CASE %WM_NCACTIVATE
                            IF CB.WPARAM THEN
                                DIALOG SET TEXT CB.HNDL, "Dialog 2: Active"
                             ELSE
                                DIALOG SET TEXT CB.HNDL, "Dialog 2: InActive"
                             END IF
                    END SELECT
                END FUNCTION
                
                '

                Comment


                • #9
                  Originally posted by Fim Wästberg View Post
                  Is there any way to find out in a DALOG CALLBACK
                  1 that the user has activated another dialog?
                  2 that users have made the current dialog active?
                  Note, code above is more general than case 1
                  It's not just the user "activating another dialog". It happens any time the current dialog loses focus by:
                  user activating another dialog
                  user switching to another application
                  user clicking on the desktop/taskbar
                  another application taking focus
                  ...

                  Comment


                  • #10
                    Stuart,
                    Brilliant, it solves my problem. Many thanks.
                    /Fim W.
                    Fim Wästberg

                    Comment

                    Working...
                    X