Announcement

Collapse
No announcement yet.

How do I do EXIT?

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

  • How do I do EXIT?

    What is the command to end a program?

    Sorry but I am new to PB/Win

    I have looked at the tutorials, but still am stuck on this.

    I have a CASE %IDM_FILE_EXIT
    and I know I need something in there to make the program end
    when this action is activated.

    Thanks,

    Brian
    Brian Heibert
    [email protected]
    http://www.heibertsoftware.com
    http://www.winvocalassist.com
    http://www.heibert.net

  • #2
    Exiting A Program

    Hi Brian;

    I know I'm missing something here, but typically a program is exited be clicking on the X inside the red box in the upper right corner of the GUI.

    The code below works, but it has to be called from within a callback function.

    Code:
                    CASE %IDC_EXIT
                        IF CBCTLMSG = %BN_CLICKED THEN
                            CLOSE
                            DIALOG END CBHNDL, 0
                        END IF

    Comment


    • #3
      Given the nature of the question, i am guessing you come from a DOS (or the like)
      programming environment.

      Windows programming is not like DOS programming.

      In DOS basic, a simple EXIT command is enough to end a program.

      In windows, closing a program depends on a number of things.

      If your program doesnt use any Windows (Dialogs), a simple "EXIT FUNCTION"
      in the "PBMAIN" or "WINMAIN", is enough to close your application, unless
      you created threads... etc. As i said, there is a number of things on wich it depends.

      If you use Dialogs in your application, thats another story, you first need to
      close the dialogs properly, as Walter stated.

      By the way i would guess that the %IDM_FILE_EXIT is simply a user ID that the
      programmer used in his code to trigger the "Close dialog" command (that walter stated),
      and execute any code required to close app.

      Comment


      • #4
        Originally posted by Brian Heibert View Post
        What is the command to end a program?
        Put a "DIALOG END CbHndl" any place in the CallBack Function you want to Exit your program.

        Sorry but I am new to PB/Win
        Nothing to be sorry about Brian. This is the best place to be when starting oiut with PBWin.

        I have looked at the tutorials, but still am stuck on this.
        While in your program editor, place the cursor on any Keyword and the Help File will load, explaining the keyword.

        Being new to PBWin you will want to take a look at the PBWin Shortcuts below. It should be helpful to get started.


        I have a CASE %IDM_FILE_EXIT
        and I know I need something in there to make the program end
        when this action is activated.
        Put" DIALOG END CbHndl" right underneath it and you're in business.

        ==========================================
        "Many wealthy people are little more than
        janitors of their possessions."
        Frank Lloyd Wright (1868-1959)
        ==========================================
        It's a pretty day. I hope you enjoy it.

        Gösta

        JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
        LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

        Comment


        • #5
          Thanks Gösta,
          Your code worked great!

          Brian
          Brian Heibert
          [email protected]
          http://www.heibertsoftware.com
          http://www.winvocalassist.com
          http://www.heibert.net

          Comment


          • #6
            The bottom line answer is, "your program ends when the Entry Point function (Winmain or PBMain) ends."

            i.e., reach the end of WinMain/PbMain by any program logic and your program ends.

            Above 'works' for you because your program probably (code not shown) looks like this....
            Code:
            FUNCTION PBMAIN () AS LONG
            
             ....
            ...
                DIALOG SHOW MODAL hDlg, CALL DlgProc
            
            END FUNCTION
            ... and DIALOG SHOW MODAL returns when 'hDlg' executes DIALOG END.

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

            Comment


            • #7
              if the X button is being displayed on the dialog line you can use this

              the mymsgbox functioin was created by
              Mr. Charles Dietz and he has the program on his website now!
              Thanks Charles

              http://www.cgdsoftware.com

              i am a beginner with gui programming
              if this is the wrong way to do it, PLEASE SOMEBODY CORRECT ME!

              you can replace the mymsgbox with msgbox if you want too,
              but i suggest finding and using an alternative so that the messages stays inside your programs dialog

              inside the callback
              Code:
              ' somewhere declare response as a long
               CASE %WM_SYSCOMMAND
                        IF (CBWPARAM = %SC_CLOSE) THEN
                            response=BigTimeExit()
                            IF response=1& THEN EXIT FUNCTION 'forgot why i put this line here, i believe if DIALOG END is removed in the bigtimeexit function i had use of it
                            FUNCTION=1  'forgot why this line is here you can probably remove it if you leave DIALOG END inside the bigtimeexit function
                        END IF
              placed outside the callback and above the callback
              Code:
              'next line at near the top of the program where your other declares are located
              DECLARE FUNCTION Bigtimeexit() AS LONG  
              
              
              'place this code anywhere
              
              FUNCTION BigTimeExit AS LONG
                  LOCAL res&
                  res&=myMSGBOX ("Are you sure that you want to quit?", %MB_YESNO OR %MB_ICONERROR OR %MB_DEFBUTTON2 OR %MB_TASKMODAL ,"Exit my program name") '0,0,-25,-25)
              
                   IF res&=%IDYES THEN
                      res&=myMSGBOX ("Entries will be lost"+$CRLF+"Are double sure you want to quit?",_
                         %MB_YESNO OR %MB_DEFBUTTON2 OR %MB_TASKMODAL,"Exit my program name")',0,-25,-25)
                      IF res&=%IDYES THEN  FUNCTION=1&:DIALOG END hDlg
                      END IF
              
                  FUNCTION=0&
              END FUNCTION
              Last edited by Paul Purvis; 26 Feb 2008, 01:56 PM.
              p purvis

              Comment

              Working...
              X