Announcement

Collapse
No announcement yet.

Use of DIALOG END

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

  • Use of DIALOG END

    Can any one tell me when the DIALOG END statement can be used without causing a GPF?

    Example.(Created using CONTROL ADD...under PBMAIN) text box receives input that requires the program to close.Processing by callback attached to DIALOG SHOW statement results in a GPF.

    Is it possible to fire the %WM_SYSCLOSE event and if so, does it do it cleanly ie: without causing a GPF.

    I have used Callbacks attached to CONTROL ADD BUTTON statements that just do a DIALOG END and they work.
    Problem is that the only other control is the System Close. I dont want to add a Close button if I can do without it.

  • #2
    You can certainly use DIALOG END inside the dialog callback, but it should not be used in response to certain messages, such as %WM_INITDIALOG, etc. The most common position is (as you note) in response to %WM_COMMAND messages.

    If you need to use END DIALOG in an "inappropriate" message handler, then the solution is to post the dialog a user-defined message and then use DIALOG END in response to the %WM_USER + 999& message.

    ie, in psuedo code:
    Code:
    CALLBACK FUNCTION MyDialogCallback
      IF CBMSG = lMessage& THEN ' lMessage& is the message you want to end the dialog from
        PostMessage CBHNDL, %WM_USER + 999&, 0, 0)
      ELSEIF CBMSG = %WM_USER + 999& THEN
        DIALOG END CBHNDL
      END IF
    END FUNCTION
    If you are still having problems, then may I suggest that you post your problematic code in compilable form so that we can duplicate the problem you are having.


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

    Comment


    • #3
      Lance..

      Your solution works great !. I guess I will have to be a bit more adventurous now I am getting a feel for the product.

      '===============================================================
      '
      ' SAMPLE PROG TO DEMONSTRATE ENDING PROG WITHOUT CAUSING GPF
      '
      '=================================================================
      #COMPILE EXE
      #REGISTER NONE
      #INCLUDE "WIN32API.INC"


      %TEST = 1
      %PM_END = %WM_USER + 999

      ' App equates
      '-------------------------------------------
      $AppTitle = "PROGRAM ENDING"

      ' Control ID's for updateable controls
      '-------------------------------------
      %ID = 100
      %ID_OPTION = 101

      ' Globals
      '-------------------------------------
      GLOBAL hDlg AS LONG

      CALLBACK FUNCTION TestIt

      ON ERROR RESUME NEXT

      LOCAL lsA AS STRING

      SELECT CASE CBMSG

      CASE %WM_COMMAND

      SELECT CASE CBCTL


      ' Options window
      CASE %ID_OPTION

      SELECT CASE CBCTLMSG

      CASE %EN_CHANGE ' sent when user changes contents of edit box
      ' AFTER change is displayed - @ each keystroke.

      CONTROL GET TEXT hDlg, %ID_OPTION TO lsA
      SELECT CASE LEN(lsA)
      CASE 1
      IF lsA = "E" THEN

      PostMessage CBHNDL, %PM_END, 0, 0

      ' causes a GPF
      '------------------
      ' DIALOG END CBHNDL, 0

      END IF

      END SELECT ' LEN(lsA)

      END SELECT ' CBCTLMSG

      END SELECT ' CBCTL

      CASE %PM_END

      DIALOG END CBHNDL, 0

      END SELECT ' CBMSG

      END FUNCTION


      regards

      Barney
      FUNCTION PBMAIN

      ON ERROR RESUME NEXT


      ' Create our primary GUI
      '-----------------------
      DIALOG NEW 0, $AppTitle, 0, 0,400, 300, %WS_CAPTION OR %WS_SYSMENU OR %WS_SYSMENU OR %DS_CENTER, %WS_EX_APPWINDOW TO hDlg
      CONTROL ADD TEXTBOX, hDlg, %ID_OPTION, "", 300, 260, 60, 14,%ES_UPPERCASE OR %WS_TABSTOP, %WS_EX_CLIENTEDGE

      DIALOG SHOW MODAL hDlg, CALL TestIt

      PBMAIN = 0

      END FUNCTION


      ------------------


      [This message has been edited by Barney Winton (edited March 01, 2000).]

      Comment

      Working...
      X