Announcement

Collapse
No announcement yet.

Dialog Show Modal

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

  • John Tate
    replied
    I use your scenario all the time. When a dialog is called from the main dialog, the main dialog does not receive any messages at all. I use DDT all the time. Here is the way I use it. The first sample code is what I normally use. the second is another way to close the main dialog, then call it again when the second dialog is ended.
    Code:
    #PBFORMS CREATED V1.50
    '------------------------------------------------------------------------------
    ' The first line in this file is a PB/Forms metastatement.
    ' It should ALWAYS be the first line of the file. Other
    ' PB/Forms metastatements are placed at the beginning and
    ' end of "Named Blocks" of code that should be edited
    ' with PBForms only. Do not manually edit or delete these
    ' metastatements or PB/Forms will not be able to reread
    ' the file correctly.  See the PB/Forms documentation for
    ' more information.
    ' Named blocks begin like this:    #PBFORMS BEGIN ...
    ' Named blocks end like this:      #PBFORMS END ...
    ' Other PB/Forms metastatements such as:
    '     #PBFORMS DECLARATIONS
    ' are used by PB/Forms to insert additional code.
    ' Feel free to make changes anywhere else in the file.
    '------------------------------------------------------------------------------
    
    #COMPILE EXE
    #DIM ALL
    
    '------------------------------------------------------------------------------
    '   ** Includes **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Constants **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS
    %IDD_DIALOG1 =  101
    %IDC_BUTTON1 = 1001
    %IDCANCEL    =    2
    %IDD_DIALOG2 =  102
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Declarations **
    '------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG2Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
       ' ShowDIALOG2 %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_BUTTON1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            MSGBOX "here"
                            showdialog2(CBHNDL)
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG2Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW  hParent, "Dialog1", 70, 70, 320, 222, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "call next dialog", 85, 135, 55, _
            15
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "exit", 165, 135, 50, 15
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG2->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW  hParent, "Dialog2", 70, 70, 305, 190, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "exit", 115, 115, 50, 15
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG2Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG2
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    this destroys the main dialog when calling dialog2

    Code:
    #PBFORMS CREATED V1.50
    '------------------------------------------------------------------------------
    ' The first line in this file is a PB/Forms metastatement.
    ' It should ALWAYS be the first line of the file. Other
    ' PB/Forms metastatements are placed at the beginning and
    ' end of "Named Blocks" of code that should be edited
    ' with PBForms only. Do not manually edit or delete these
    ' metastatements or PB/Forms will not be able to reread
    ' the file correctly.  See the PB/Forms documentation for
    ' more information.
    ' Named blocks begin like this:    #PBFORMS BEGIN ...
    ' Named blocks end like this:      #PBFORMS END ...
    ' Other PB/Forms metastatements such as:
    '     #PBFORMS DECLARATIONS
    ' are used by PB/Forms to insert additional code.
    ' Feel free to make changes anywhere else in the file.
    '------------------------------------------------------------------------------
    
    #COMPILE EXE
    #DIM ALL
    
    '------------------------------------------------------------------------------
    '   ** Includes **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Constants **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS
    %IDD_DIALOG1 =  101
    %IDC_BUTTON1 = 1001
    %IDCANCEL    =    2
    %IDD_DIALOG2 =  102
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------
    GLOBAL gHdlg1 AS DWORD
    GLOBAL gHdlg2 AS DWORD
    '------------------------------------------------------------------------------
    '   ** Declarations **
    '------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG2Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
       ' ShowDIALOG2 %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_BUTTON1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0  'close the main dialog
                            showdialog2(0)  'becomes child of desktop
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG2Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                            showdialog1 (0)  'now open the main dialog again as child of desktop
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW  hParent, "Dialog1", 70, 70, 320, 222, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "call next dialog", 85, 135, 55, _
            15
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "exit", 165, 135, 50, 15
    #PBFORMS END DIALOG
    gHdlg1 = hDlg
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG2->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW  hParent, "Dialog2", 70, 70, 305, 190, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "exit", 115, 115, 50, 15
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG2Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG2
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------

    I hope this helps.

    John Tate

    Leave a comment:


  • mark pruitt
    replied
    Thanks Chris; I'll take a longer look at it when I have the time. In regards to the way PBForms creates the dialogs as top level, maybe that could be a changed feature in PBForms 2.0 (are you listening, Bob? )!

    Leave a comment:


  • Chris Holbrook
    replied
    OK Mark, now I understand. PBForms will cretae dialogs for you but they are all top level unless you use a menu (maybe some other ways?). you have to massage the PBForms code to do your bidding.

    Typically you would create the second child dialog in the callback for the first and so on, passing to each dialog creation function the CBHNDL (ie dialog handle) from the callback:

    Code:
    #PBFORMS CREATED V1.51
    #COMPILE EXE
    #DIM ALL
    
    #PBFORMS BEGIN INCLUDES 
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    
    #PBFORMS BEGIN CONSTANTS 
    %IDD_DIALOG1 = 101
    %IDD_DIALOG2 = 102
    %IDD_DIALOG3 = 103
    %IDC_BUTTON2 = 105
    %IDC_BUTTON3 = 106
    #PBFORMS END CONSTANTS
    
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG2Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG3Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG3(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
    
    END FUNCTION
    
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_BUTTON3
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                              ShowDialog2(CBHNDL)
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    
    CALLBACK FUNCTION ShowDIALOG2Proc()
    
       SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_BUTTON2
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                              ShowDialog3(CBHNDL)
                        END IF
    
            END SELECT
        END SELECT
    END FUNCTION
    
    CALLBACK FUNCTION ShowDIALOG3Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                SELECT CASE AS LONG CBCTL
                END SELECT
            END SELECT
    END FUNCTION
    
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "Parent Dialog", 5, 49, 93, 32, %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 hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_BUTTON3, "start dialog 2", 5, 5, 55, 20
    #PBFORMS END DIALOG
    
    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
    FUNCTION = lRslt
    END FUNCTION
    '---------------------------------------------------------------------
    FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG2->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "Dialog2", 45, 78, 102, 42, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
            %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
            %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT OR %WS_EX_CONTEXTHELP OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_BUTTON2, "start dialog 3", 10, 10, 65, 20
    #PBFORMS END DIALOG
    
    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG2Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG2
    #PBFORMS END CLEANUP
    
    FUNCTION = lRslt
    END FUNCTION
    
    FUNCTION ShowDIALOG3(BYVAL hParent AS DWORD) AS LONG
    LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG3->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "Dialog3", 231, 171, 77, 42, %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 hDlg
    #PBFORMS END DIALOG
    
    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG3Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG3
    #PBFORMS END CLEANUP
    
    FUNCTION = lRslt
    END FUNCTION

    Leave a comment:


  • mark pruitt
    replied
    Thanks Chris. I haven't changed any of the DIALOG NEW statements, possibly a setting changed in the styles for dialogs?

    I went back and looked, and under PBMain each dialog is listed with %HWND_Desktop at the end.

    I'll apply your suggestion and post some code with a link to this thread. Thanks again.

    Leave a comment:


  • Chris Holbrook
    replied
    Mark,

    If you need the parent's handle, getparent is simpler than FindWindow.

    My guess: If your parent window handle is always zero, the implication is that you created them under the desktop (%HWND_DESTOP defined zero in Win32API.inc), so something is wrong with the your DIALOG NEW statement, the first parameter is the parent window handle and in your case this is being evaluated to zero. It should be the handle of the parent dialog, as in Pierre's example.

    Why not post your code in a compilable form, there are some demon debuggers on this forum but they need something to work on.
    Last edited by Chris Holbrook; 12 Jan 2008, 05:13 PM. Reason: speling

    Leave a comment:


  • mark pruitt
    replied
    Pierre, I tried to use the example you gave. Maybe it's my lack of programming the last few years, but I couldn't make it work with code from PBForms without a lot of cut and paste. I did find a way to do it though. The help file said that if hParent were missing or were 0, the parent dialog could still receive focus. I put msgbox commands at the end of every dialog, and found hParent was always 0, so this is a section I added to every dialog's code except my main dialog.

    FUNCTION ShowDIALOG_FirstChildDialog(BYVAL hParent AS DWORD) AS LONG
    LOCAL lRslt AS LONG

    'make sure Parent dialog is disabled
    LOCAL wHandle AS DWORD
    wHandle = FindWindow ("", "Caption in Parent Dialog Goes Here")
    hParent = wHandle

    After changing the value of hParent to the value of the handle for the main dialog, you can't focus on the main dialog again until you close the child.

    If there is a better way to do this in PB Forms and someone can post, please do. Thanks again for your help.

    Leave a comment:


  • mark pruitt
    replied
    Doh! Thanks guys. It's amazing how much you forget when you haven't programmed in a while.

    Leave a comment:


  • Pierre Bellisle
    replied
    Mark,
    Use CBHNDL as parent dialog handle when creating child dialog...

    Code:
    #COMPILE EXE '#Win 8.04#
    #DIM ALL
    #INCLUDE "Win32Api.inc" '#2005-01-27#
     
    %Button1  = 101
    '______________________________________________________________________________
     
    CALLBACK FUNCTION ChildProc
    END FUNCTION
    '______________________________________________________________________________
     
    CALLBACK FUNCTION DlgProc
     LOCAL hChild AS DWORD
     
     SELECT CASE CBMSG
     
       CASE %WM_COMMAND
         SELECT CASE LOWRD(CBWPARAM)
           CASE %Button1
             IF CBCTLMSG = %BN_CLICKED THEN
               DIALOG NEW CBHNDL, "Child", , , 100, 50, %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU, 0 TO hChild
               DIALOG SHOW MODAL hChild CALL ChildProc
             END IF
         END SELECT
     
      END SELECT
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PBMAIN()
     LOCAL hDlg AS DWORD
     
     DIALOG NEW %HWND_DESKTOP, "Main dialog", , , 200, 100, %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU, 0 TO hDlg
     SetClassLong hDlg, %GCL_HICON, LoadIcon(BYVAL %NULL, BYVAL %IDI_INFORMATION) 'Set a nice dialog icon
     
     CONTROL ADD BUTTON,  hDlg, %Button1,  "Child dialog", 5, 5, 50, 15
     
     DIALOG SHOW MODAL hDlg CALL DlgProc
     
    END FUNCTION
    '______________________________________________________________________________
    Last edited by Pierre Bellisle; 10 Jan 2008, 11:11 PM.

    Leave a comment:


  • Fred Buffington
    replied
    What I did some years ago and still use it (although there are no doubt better ways) is define a global variable, in this case just a long. When an option is
    chosen, the variable is set and after it returns it is reset to 0. Before an option
    is chosen, it checks the variable and if set it exits the callback before trying to access the option.

    example
    Code:
    CASE %EMPLOYEE_MAINTENANCE
       if anotheroptionisrunning& then exit function
       anotheroptionisrunning&=1
       Employee_Maint company_id$
       anotheroptionisrunning&=0

    Leave a comment:


  • mark pruitt
    started a topic Dialog Show Modal

    Dialog Show Modal

    Maybe I'm missing something obvious, but I thought the above would focus on the dialog I had opened until I closed it.

    Here is what I want to do; I've got a main dialog with command buttons, which launch other dialogs depending on the choices. When another dialog is opened, I don't want a user to be able to do anything on the main dialog until this one is closed.

    Excuse the ignorance guys. It's been a few years since I've done any programming; necessity once again demands I design my own tools!
Working...
X