Announcement

Collapse
No announcement yet.

Error 496 again

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

  • Error 496 again

    Can anyone explain why you can close this graphic window with an 'Esc' OK,
    But if you close it with the upper right 'X' you get the error 496 :
    Destination file write error. (the program is still running)
    You can stop it in Task Manager, then do it all over again!
    TIA , Lynn again.

    Code:
    #COMPILE EXE
    #BREAK ON
    #DIM ALL
    #CONSOLE OFF
    GLOBAL i AS STRING
    GLOBAL hWin AS DWORD
    FUNCTION PBMAIN () AS LONG
        GRAPHIC WINDOW "Testing", 0 , 0, 1015, 725 TO hWin
        GRAPHIC ATTACH hWin, 0
        DO
            IF hWin = 0 THEN EXIT FUNCTION
            GRAPHIC INKEY$ TO i
        LOOP UNTIL i = $ESC
    END Function

  • #2
    Go to that previouse post by GUY, the one below this one, and check out his second post. You'll see Function GrProc, try adding a new case line : CASE %WM_DESTROY
    Postquitmessage 0



    I notice that the CODEPTR for it is in his PBMAIN Function, about the 9th line down, starting with GrStaticProc =..................

    Thats not my style of programming, so I really don't know, but I've always used case wm-destroy and Postquitmessage 0 to be able to click on the X button in the corner.

    Comment


    • #3
      You should use GRAPHIC GET CLIENT TO x&, y& and if x& and y& are zero then the user closed the Window.
      Sincerely,

      Steve Rossell
      PowerBASIC Staff

      Comment


      • #4
        Error 496

        Lynn,

        A simple way to do it is to add the GRAPHIC GET DC TO Command in your loop

        See your corrected code

        Code:
        #COMPILE EXE
        #BREAK ON
        #DIM ALL
        #CONSOLE OFF
        GLOBAL i AS STRING
        GLOBAL hWin AS DWORD
        FUNCTION PBMAIN () AS LONG
            GRAPHIC WINDOW "Testing", 0 , 0, 1015, 725 TO hWin
            GRAPHIC ATTACH hWin, 0
            DO
                GRAPHIC GET DC TO hwin: IF hwin=0 THEN END 
                IF hWin = 0 THEN EXIT FUNCTION
                GRAPHIC INKEY$ TO i
            LOOP UNTIL i = $ESC
        END FUNCTION
        Old QB45 Programmer

        Comment


        • #5
          Thanks again guys, Steve Rossell, your code fixed it:
          'GRAPHIC GET CLIENT TO x&, y& and if x& and y& are zero then the user closed the Window'
          Thanks again! Lynn

          Comment

          Working...
          X