Announcement

Collapse
No announcement yet.

Windows cannot end this program

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

  • Windows cannot end this program

    With the new PBCC5 if I click on X to end the program (console) it works fine on my windows XP home edition computer. But with my windows XP pro computer it shows a box:

    "Windows cannot end this program. It may need more time to complete an operation.

    To return to Windows and check the status of the program, click Cancel."

    It shows 2 boxes - EndNow - Cancel

    Any help or fix? TIA Lynn

  • #2
    You need to post code and/or send to [email protected] to get explicit help.

    It sounds like you may have an endless loop in the program
    Rick Angell

    Comment


    • #3
      Windows cannot end this program

      All my old programs compiled under PBCC4.04 work ok. If re-run under PBCC5.0 I get the same results (can't end console with the Upper 'X').
      Same results if run in the IDE or from windows.
      A small example:

      Code:
      #COMPILE EXE
      #DIM ALL
         GLOBAL test,n1(),a AS STRING
         GLOBAL x,z,zz,Flagg,row,col,block,BlockNum() AS LONG
      FUNCTION PBMAIN () AS LONG
         DIM n1(1 TO 81) AS STRING
         DIM BlockNum(1 TO 81) AS LONG
         Flagg = 0     ' Print to printer      0 = Screen
         IF Flagg THEN
              XPRINT ATTACH DEFAULT
              XPRINT WIDTH 2
              XPRINT FONT "New Courier",7,0
         END IF
          FOR z = 1 TO 81
              BlockNum(z) = CEIL(z/3 MOD z) MOD 3.1
              IF z > 27 THEN BlockNum(z) = BlockNum(z) + 3
              IF z > 54 THEN BlockNum(z) = BlockNum(z) + 4
          NEXT z
         CLS
         IF Flagg THEN XPRINT "  z            row         col         block" ELSE _
              PRINT "  z            row         col         block"
         IF Flagg THEN XPRINT "------------------------------------------------" ELSE _
              PRINT "------------------------------------------------"
          FOR z = 1 TO 81
                  IF z = 28 OR z = 55 THEN IF Flagg THEN XPRINT " " ELSE PRINT " "
                  row = CEIL(z / 9)
                  col = CEIL(z MOD 9.1)
                  IF z = 55 AND Flagg = 0 THEN
                      WAITKEY$
                      CLS
                      PRINT "  z            row         col         block"
                      PRINT "------------------------------------------------"
                  END IF
                  block = CEIL(z/3 MOD z) MOD 3.1
                  IF row >3 THEN block = block + 3
                  IF row >6 THEN block = block + 4
                  IF Flagg AND z < 10 THEN XPRINT "  ";
                  IF Flagg THEN XPRINT _
                      STR$(z)+"              "+ STR$(row)+"          "+STR$(col)+"             "+STR$(BlockNum(z)) ELSE _
                      PRINT z,row,col,BlockNum(z)
          NEXT z
          zz = CEIL(46 MOD 9.1)
          IF Flagg THEN XPRINT zz ELSE PRINT zz
          IF Flagg THEN PRINT "Hit any key to continue . . ."
         WAITKEY$
         IF Flagg THEN XPRINT CLOSE
      END FUNCTION
      TIA Lynn

      Comment


      • #4
        The differences between v4 & v5 are for PowerBasic to explain, but if you add a message loop to your application and deal with WM_CLOSE properly, the problem will go away.

        See also this thread: http://www.powerbasic.com/support/pbforums/showthread.php?t=38496

        Comment


        • #5
          Lynn,
          try adding this line to the start of your code:
          Code:
          #BREAK ON
          Paul.

          Comment


          • #6
            or even add a consolectrlhadndler as below from thread http://www.powerbasic.com/support/pb...ighlight=close:


            ... I should have said that it is untested with V5 of PBCC, which I am too tight to buy.

            Code:
            #COMPILE EXE
            #DIM ALL
            #INCLUDE "win32api.inc"
               GLOBAL test,n1(),a AS STRING
               GLOBAL x,z,zz,Flagg,row,col,block,BlockNum() AS LONG
            
            FUNCTION ConsoleHandler(BYVAL dwEvent AS DWORD) AS LONG
              BEEP
              'Alt + F4 not trapped here, Ctrl-C not working either
              SELECT CASE dwEvent
                CASE %CTRL_BREAK_EVENT
                  PRINT "Ctrl-Break pressed"
                CASE %CTRL_CLOSE_EVENT
                  PRINT "[x] Close clicked"
                CASE %CTRL_LOGOFF_EVENT
                  PRINT "User logging off or restarting"
                CASE %CTRL_SHUTDOWN_EVENT
                  PRINT "System shutting down"
              END SELECT
              SLEEP 1000
            END FUNCTION
            
            FUNCTION PBMAIN () AS LONG
               DIM n1(1 TO 81) AS STRING
               DIM BlockNum(1 TO 81) AS LONG
              SetConsoleCtrlHandler CODEPTR(ConsoleHandler), 1
               Flagg = 0     ' Print to printer      0 = Screen
               IF Flagg THEN
                    XPRINT ATTACH DEFAULT
                    XPRINT WIDTH 2
                    XPRINT FONT "New Courier",7,0
               END IF
                FOR z = 1 TO 81
                    BlockNum(z) = CEIL(z/3 MOD z) MOD 3.1
                    IF z > 27 THEN BlockNum(z) = BlockNum(z) + 3
                    IF z > 54 THEN BlockNum(z) = BlockNum(z) + 4
                NEXT z
               CLS
               IF Flagg THEN XPRINT "  z            row         col         block" ELSE _
                    PRINT "  z            row         col         block"
               IF Flagg THEN XPRINT "------------------------------------------------" ELSE _
                    PRINT "------------------------------------------------"
                FOR z = 1 TO 81
                        IF z = 28 OR z = 55 THEN IF Flagg THEN XPRINT " " ELSE PRINT " "
                        row = CEIL(z / 9)
                        col = CEIL(z MOD 9.1)
                        IF z = 55 AND Flagg = 0 THEN
                            WAITKEY$
                            CLS
                            PRINT "  z            row         col         block"
                            PRINT "------------------------------------------------"
                        END IF
                        block = CEIL(z/3 MOD z) MOD 3.1
                        IF row >3 THEN block = block + 3
                        IF row >6 THEN block = block + 4
                        IF Flagg AND z < 10 THEN XPRINT "  ";
                        IF Flagg THEN XPRINT _
                            STR$(z)+"              "+ STR$(row)+"          "+STR$(col)+"             "+STR$(BlockNum(z)) ELSE _
                            PRINT z,row,col,BlockNum(z)
                NEXT z
                zz = CEIL(46 MOD 9.1)
                IF Flagg THEN XPRINT zz ELSE PRINT zz
                IF Flagg THEN PRINT "Hit any key to continue . . ."
               WAITKEY$
               SetConsoleCtrlHandler CODEPTR(ConsoleHandler), 0
               IF Flagg THEN XPRINT CLOSE
            END FUNCTION
            Last edited by Chris Holbrook; 4 Oct 2008, 07:07 AM.

            Comment


            • #7
              Ending console program

              Chris,

              I tested your code with PBCC5 and it does work but I had to add END after the SLEEP 1000 instruction in order to shut down the program.
              You can hear the Beep sound coming from the Windows Error but it is the only drawback.
              Lynn, why not starting to work with a Graphical Console like the demo I posted here a few days ago ?
              It is a bit more work but the result is well worth it.
              Old QB45 Programmer

              Comment


              • #8
                Beep

                Just noticed that the beep came from your code Chris.
                Removed it and everything works like a charm.
                Old QB45 Programmer

                Comment


                • #9
                  Originally posted by Guy Dombrowski View Post
                  ... everything works like a charm.
                  how rare is that!

                  Comment


                  • #10
                    Windows cannot end this program

                    You guys (& gals) are great! Thanks to all for the help!
                    Paul, your #BREAK ON fixed it, The program even closes faster!

                    Guy, I am going to start working with the Graphical Console & may need a little help along the way.

                    Thanks again, problem solved! Lynn (male)!

                    Comment

                    Working...
                    X