Announcement

Collapse
No announcement yet.

Destroy a dialog between DIALOG NEW and DIALOG SHOW?

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

  • Destroy a dialog between DIALOG NEW and DIALOG SHOW?

    I've got a function currently structured like so:
    Code:
    FUNCTION MakeDialog( )
    
    DIALOG NEW ...
    CONTROL ADD ...
    ...
    
    IF MakeComboBox( hDlg, %COMBOBOXID, etc.) THEN ???
    
    DIALOG SHOW MODAL ...
    
    FUNCTION = lResult
    
    END FUNCTION
    The MakeCombobox function might fail (ie. no data for the control) and if it does, I'd like to destroy the dialog and exit. Unless I'm mistaken, my only choices here are to either restructure the MakeComboBox function to return a string (or array) and not populate the control directly (so I can call it before DIALOG NEW), or to DIALOG POST a fail message. Is this correct?
    Bernard Ertl
    InterPlan Systems

  • #2
    Originally posted by Bern Ertl View Post
    I've got a function currently structured like so:
    Code:
    FUNCTION MakeDialog( )
    
    DIALOG NEW ...
    CONTROL ADD ...
    ...
    
    IF MakeComboBox( hDlg, %COMBOBOXID, etc.) THEN ???
    
    DIALOG SHOW MODAL ...
    
    FUNCTION = lResult
    
    END FUNCTION
    The MakeCombobox function might fail (ie. no data for the control) and if it does, I'd like to destroy the dialog and exit. Unless I'm mistaken, my only choices here are to either restructure the MakeComboBox function to return a string (or array) and not populate the control directly (so I can call it before DIALOG NEW), or to DIALOG POST a fail message. Is this correct?
    Edited a previous comment that was not comprehensive...
    Obviously, if you're expecting data from a user, you wouldn't be needing this test, so I'm concluding that you're checking to see if the program has any data available from another source. I think I'd check the data source before beginning with DIALOG NEW...
    Last edited by John Montenigro; 4 Feb 2009, 01:20 PM.

    Comment


    • #3
      Code:
      IF (no data) THEN 
          DIALOG SET USER hDlg, 1, %TRUE 
      END IF 
      
      DIALOG  SHOW someway .....
      ...
      CALLBACK FUNCTION ...
          CASE %WM_INITDIALOG   ' dialog has not been displayed yet. 
               DIALOG GET USER CBHNDL, 1 TO bAbort 
               IF ISTRUE bAbort then 
                    DIALOG END CBHNDL value 
               ELSE
                    ' regular processing 
                 ........
      ???

      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Do not execute a DIALOG END statement in a WM_INITDIALOG message handler, instead use DIALOG POST to post a custom message. See the DIALOG END statement in the help file for an explanation and work around.

        But this would show your dialog, if you do not want the dialog to display based on some value, then check this value before you execute a dialog show or even better before you execute a dialog new.
        Sincerely,

        Steve Rossell
        PowerBASIC Staff

        Comment


        • #5
          Originally posted by John Montenigro View Post
          I think I'd check the data source before beginning with DIALOG NEW...
          Yeah, that's what I've ended up doing. I had to restructure the MakeComboBox function.
          Bernard Ertl
          InterPlan Systems

          Comment


          • #6
            >Do not execute a DIALOG END statement in a WM_INITDIALOG message handler,

            See, I'm really NOT a DDT guy. The SDK-style equivalent for modal dialogs (EndDialog) is perfectly acceptable during WM_INITDIALOG.

            A dialog box procedure can call EndDialog at any time, even during the processing of the WM_INITDIALOG message. If your application calls the function while WM_INITDIALOG is being processed, the dialog box is destroyed before it is shown and before the input focus is set.
            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Originally posted by Bern Ertl View Post
              Yeah, that's what I've ended up doing. I had to restructure the MakeComboBox function.
              I think it'll help you live a longer, happier life! :laugh:

              Comment

              Working...
              X