No announcement yet.

DDT dialogs - to end, or not to end?

  • Filter
  • Time
  • Show
Clear All
new posts

  • DDT dialogs - to end, or not to end?

    Does anyone know how to prevent a modal DDT dialog from closing, once DIALOG END
    has been used (or if/when the DDT dialog is closed from the system menu)?

    I have tried trapping it in WM_CLOSE and that gives me the option of showing
    a messagebox to the user, "Exit? - Yes or No", but then I'm stuck, because
    the dialog closes no matter what I do. Shouldn't it be enough to return zero
    and exit the function to cancel the process?

    Am I stupid or isn't it possible to do this with DDT dialogs? I have searched
    all messages here and looked at all samples, with no luck. Somehow it should
    be possible to do it though.. I think.

  • #2
    If the user clicks the "X" button to close the dialog (or uses the system-menu's CLOSE option), then intercept %WM_SYSCOMMAND and trap the %SC_CLOSE parameter. Returning %TRUE (non-zero) the the function in the callback will prevent it from closing.

    If your code executes an explicit DIALOG END then you will have to add code to make that execute "conditionally". In other words, that will be a function of *your* program code, rather than the responsibility of the DDT engine.

    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    mailto:[email protected]


    • #3
      Thank you, Lance. You have solved my problem (I'll add this to the little
      PB/DLL game I've posted in the source code section.)

      So in other words, one has to write a special end procedure before
      DIALOG END is used. I can live with that, and the following seems to
      take care of closing from the system menu:

              IF MessageBox(hDlg, "Exit program?", "Title", _
                            %MB_YESNO OR %MB_ICONQUESTION) = %IDNO THEN
                FUNCTION = 1 : EXIT FUNCTION
              END IF
            END IF