Announcement

Collapse
No announcement yet.

found big bug in version 9.00 graphics

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

  • found big bug in version 9.00 graphics

    when i create a graphic window then have some kinda loop afterwards running, as long as the program flow is directed to the end of the code the program exits correctly. but if i click on the close button or click on the top left icon then close the graphic window goes away and the taskbar entry goes away like its supposed to but if i hit control alt delete and launch task manager and look at running processes the executable still is running in memory. but like i said if the code runs to the end then this doesnt happen, it only doesnt work when i click on close button.

    the code snippet below shows problem. as long as you hit the escape key and exit the do loop the program exits correctly. but if you click on the close button at top right of window it doesnt clear itself from memory


    i hope they fix that soon. thats a big bug....


    code snipet:

    FUNCTION PBMAIN () AS LONG
    GLOBAL system AS system_type
    LOCAL temp AS STRING
    system.id_textbox=100

    GRAPHIC WINDOW "Box", 50, 50, 300, 300 TO system.hWin
    GRAPHIC ATTACH system.hWin, 0
    GRAPHIC BOX (10, 10) - (200, 200), 0, %BLUE
    DO
    GRAPHIC INKEY$ TO temp
    SELECT CASE temp
    CASE CHR$(27)
    EXIT DO
    CASE " " TO "~"
    GRAPHIC PRINT temp;
    CASE CHR$(13)
    GRAPHIC PRINT
    END SELECT
    LOOP
    GRAPHIC WINDOW END

    END FUNCTION

  • #2
    Hello Kevin,

    Your example doesn't compile BTW. Presumably you could give your main dialog a callback function and kill the graphic window in the WM_CLOSE handler?

    Comment


    • #3
      Closing a WINDOW does not automatically close the PROGRAM. After you close the graphic window your loop is still running. That's not a bug, that's just the way things work. Investigate the use of GRAPHIC WAITKEY$ rather than INKEY$ and implement a check for the graphic window being closed if you want that condition to terminate the program.

      99.9% of the things reported as "bugs" here turn out to be errors on the part of the programmer. That makes most of us hesitant to use the word until it has been thoroughly confirmed.
      - LJ

      Comment


      • #4
        This is not a big bug. In fact, it's not even a tiny bug! {smile} This is the way a Graphic Window works. The actual problem is that your code is not written correctly to perform the functionality you seem to want.

        Closing a Graphic Window does not terminate a program. Closing a Graphic Window simply closes the Graphic Window. Nothing more.

        To terminate a PowerBASIC program, you must exit the PBMain() function. As currently written, your code does not perform in that way. To do what you want, you must detect that the Graphic Window has closed, and then cause the flow of execution to exit PBMain().


        Best regards,

        Bob Zale
        PowerBASIC Inc.

        Comment


        • #5
          A direct call to kernel32's ExitProcess will get the job done if exiting PBMAIN at a particular stage is tricky
          -

          Comment


          • #6
            You always have to take care of things that you normally do elsewhere OR simply disable and do not use the CLOSE system box.

            And, always be careful when you say big bug. There may be bugs missed, but a big bug is very rare with the length of the beta cycle (started way before 8.05 came out) and the size and level of the beta group.

            Anyone saying BIG bug is sure to be shown the errors of their way
            Barry

            Comment


            • #7
              If I find what I think is an error or a typo, I send it directly to Support - there are too many sharp axes here to stick my neck out!

              Iain Johnstone
              “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

              Comment


              • #8
                >>Closing a Graphic Window does not terminate a program. Closing a Graphic Window simply closes the Graphic Window. Nothing more.

                In PBCC, prior to version 5, it was possible to terminate a program and close any attached graphics windows, and the console, all in one shot, simply by clicking the X on the top right corner of the console window, or by clicking on the top-left & picking the "close" option. I like that! Now, in PBCC 5, I get instead the message -- "Windows cannot terminate this program". I would not call that a "new, improved feature", because that's what PBDOS does, and I don't like it. I wouldn't call it a "bug" either. But I would call it a personal annoyance, for which it would be nice to have a quick and easy fix, to spare the programmer and the user from unnecessary work and/or readings of that "error" message?

                Comment


                • #9
                  >... it would be nice to have a quick and easy fix

                  Now what did your mother and father teach you about 'quick and easy' fixes?

                  It's only thru honest hard work you will become successful!
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    >If I find what I think is an error or a typo, I send it directly to Support

                    Of course you do, because it's a bug, and all bugs should be reported to PB support.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Slightly Disappointed...

                      Gee after reading the first post about the bug and the quick followups I was rather disappointed to find someone did'nt alter the supplied example code and post a modified version to perform as it should have been written..... Maybe someone is still working on it....

                      Just a thought...
                      LEARNING EXPERIENCE: What you get when you didn't get what you THOUGHT you wanted!

                      Comment


                      • #12
                        supplied example code and post a modified version to perform as it should have been written..... Maybe someone is still working on it....
                        Code:
                        FUNCTION PBMAIN () AS LONG 
                            ......
                           GRAPHIC WINDOW caption$, x&, y&, nWidth&, nHeight& TO hWin???
                        InsertHere: 
                            hMenu        = GetSystemMenu (hWin???, %FALSE) 
                            RemoveMenu  hmenu, %SC_CLOSE, %MF_BYCOMMAND
                        EndInsert: 
                        
                           ....
                        MCM
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          This thread has got me to thinking. In my PB/Win programs I usually include a small print-to-console function to use for debugging purposes. If this console is invoked, closing it will close the entire application. Why?

                          This behavior is the same in PB/Win 9 as it was in 8.
                          - LJ

                          Comment


                          • #14
                            That is Windows behavior.

                            Bob Zale
                            PowerBASIC Inc.

                            Comment


                            • #15
                              "This is Windows behavior" is totally accurate but a tad brusque.

                              When you add a console, by default your program will process event notifications from that console; one of those events is "Click on the system menu's 'close' button"; the default action unsurprisingly is, "end."

                              If you don't want to remove the 'X' option from the console's system menu as shown above, you can set up to intercept that notification and 'do something' at that time, either prevent it entirely or ask the user for confirmation. See the SetConsoleCtrlHandler() WinAPI function for details. (Or search here for it; there must be an example somewhere here).

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

                              Comment


                              • #16
                                Or for a debugging display, use something like...

                                Use Listview control as a console. September 13 2003.

                                I like this because the listview control retains all the text sent to it and you can scroll back to see what happened before everything scrolled off the visible area.
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  Thanks for the responses Bob and Michael. Don't get me wrong - I'm not complaining. Being able to use the console to close the application is a GOOD THING and is often just what is needed when debugging an infinite loop problem (easier than going to Task Manager).

                                  I'll keep your Listview solution in mind should I need it MCM, but using a console is considerably simpler and is adequate for most situations.
                                  - LJ

                                  Comment


                                  • #18
                                    Originally posted by Wayne Suite View Post
                                    Gee after reading the first post about the bug and the quick followups I was rather disappointed to find someone did'nt alter the supplied example code and post a modified version to perform as it should have been written..... Maybe someone is still working on it....
                                    I wanted to run this past support before I posted ...
                                    Code:
                                    FUNCTION PBMAIN () AS LONG
                                    
                                    LOCAL hWin AS DWORD
                                    LOCAL Temp AS STRING
                                    
                                    GRAPHIC WINDOW "Box", 50, 50, 300, 300 TO hWin
                                    GRAPHIC ATTACH hWin, 0
                                    GRAPHIC BOX (10, 10) - (200, 200), 0, %BLUE
                                    DO
                                      GRAPHICWAITKEY$ TO Temp
                                      SELECT CASE Temp
                                      CASE ""
                                        EXIT DO
                                      CASE CHR$(27)
                                        EXIT DO
                                      CASE " " TO "~"
                                        GRAPHIC PRINT Temp;
                                      CASE CHR$(13)
                                        GRAPHIC PRINT
                                      END SELECT
                                    LOOP
                                    GRAPHIC WINDOW END
                                    
                                    END FUNCTION
                                    
                                    
                                    FUNCTION GRAPHICWAITKEY () AS STRING
                                    
                                    LOCAL hDC AS DWORD
                                    LOCAL Temp AS STRING
                                    
                                    DO
                                      SLEEP 1
                                      GRAPHIC GET DC TO hDC
                                      IF hDC = 0 THEN
                                        Temp = ""
                                        EXIT DO
                                      END IF
                                      GRAPHIC INKEY$ TO Temp
                                    LOOP WHILE Temp = ""
                                    FUNCTION = Temp
                                    
                                    END FUNCTION
                                    The more adventurous may want to try inserting a space in GRAPHICWAITKEY$ to revert to the inbuilt function.
                                    - LJ

                                    Comment


                                    • #19
                                      The more adventurous may want to try inserting a space in GRAPHICWAITKEY$ to revert to the inbuilt function.
                                      Well, I went ahead and did just that.
                                      And after that, I compiled and ran the program, pressed 'ESC', after fooling around with various keys including a 'Ctrl'+key combination.
                                      When I went to run the program again, I got a Error 496. "Destination file write error."
                                      The window had closed(disappeared) but the process was still running.

                                      The reason I tried this was because when I tried to use 'GRAPHIC WAITKEY$' with a GRAPHIC CONTROL, this was the same thing that happened.

                                      The only two lines added to a PBForms generated test program were:
                                      Code:
                                      GRAPHIC ATTACH CB.HNDL, %IDC_GRAPHIC1
                                      GRAPHIC WAITKEY$
                                      I tried using 'GRAPHIC KILL' but the process was still running, although the 'application' was not.
                                      Removing the GRAPHIC WAITKEY$ resulted in the program behaving normally.
                                      Is there some way that I have missed, ignored, or don't understand that will result in normal shut down behavior or should I report this to support?
                                      Rod
                                      I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                                      Comment


                                      • #20
                                        Hi Rodney,
                                        If I want to make sure that an application goes away properly when a graphics window is terminated, I have used this code successfully.

                                        Code:
                                        #include "win32api.inc"
                                        function pbmain etc
                                        
                                        While iswindow(gwnd)
                                                sleep
                                        wend
                                        
                                        end function
                                        As soon as the graphics window is destroyed, iswindow returns false and the applcation exits gracefully.

                                        If you would like to see it in action refer to my 'Betelgeuse' or 'life' examples in the source code forum.

                                        I hope that helps.
                                        Gary Barnes
                                        The Control Key

                                        If you are not part of the solution
                                        then you are either a gas, solid, plasma or some other form of matter.

                                        Comment

                                        Working...
                                        X