Graphic Window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Cliff Nichols
    Member
    • Aug 2006
    • 3753

    Graphic Window

    What am I doing wrong? The Graphic window appears to close but is still a running process when I check processes.
    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "Win32Api.inc"
    
    FUNCTION PBMAIN () AS LONG
         LOCAL hWin AS LONG
         GRAPHIC WINDOW "Plot Points", 10, 10, 800, 800 TO hWin
         GRAPHIC ATTACH hWin, 0
         GRAPHIC CLEAR %WHITE
         GRAPHIC REDRAW
         DIALOG SHOW MODAL hWin
    END FUNCTION
    Do I need to add a callback to get the window to close for real?
    Also since this is my 1st real trial with Graphic Window, will I be able to use all I try in Graphic Window to just Graphic?

    Thanx in advance
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "
  • Michael Mattias
    Member
    • Aug 1998
    • 43447

    #2
    >DIALOG SHOW MODAL hWin

    Um, that should be failing on invalid handle. DIALOG SHOW is only valid with a handle to a dialog created with DIALOG NEW.

    Since you are already experienced with PB/WIN, you might want to work with CONTROL ADD GRAPHIC instead of GRAPHIC WINDOW. I think you can get clicks by using style SS_NOTIFY on the control.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment

    • Manuel Valdes
      Member
      • Mar 2009
      • 856

      #3
      Cliff:

      As far as I know, the GRAPHIC WINDOW is a different creature than a Dialog.

      Regards,


      Code:
       
      #COMPILE EXE
      #DIM ALL
      '#INCLUDE "C:\PBWin90\WinAPI\WIN32API.INC"
      FUNCTION PBMAIN () AS LONG
       LOCAL hWin,hVin AS LONG
       hvin=1
       GRAPHIC WINDOW "Plot Points", 10, 10, 800, 800 TO hWin
       GRAPHIC ATTACH hWin, 0,REDRAW
       GRAPHIC CLEAR %WHITE
       GRAPHIC BOX(100,100)-(700,700),0,%BLACK
      ' 
      '
       GRAPHIC REDRAW
       'dialog show modal hWin
       DO
        GRAPHIC GET DC TO hvin      'detect if the close button was pressed,
        IF hvin=0 THEN EXIT LOOP    'and exit the loop if it was, thus avoiding the process to keep running.
       LOOP
       GRAPHIC WINDOW END
      END FUNCTION
      Last edited by Manuel Valdes; 30 Jul 2009, 07:24 PM.

      Comment

      • Jules Marchildon
        Member
        • Feb 1999
        • 2125

        #4
        Sample code from help file,....

        Code:
        FUNCTION PBMAIN () AS LONG
          ' Create and show a Graphic window on screen
          LOCAL hWin AS DWORD
          GRAPHIC WINDOW "Box", 300, 300, 130, 130 TO hWin
          GRAPHIC ATTACH hWin, 0
          GRAPHIC BOX (10, 10) - (120, 120), 0, %BLUE
          SLEEP 5000  ' show it for 5 seconds, then end
        END FUNCTION

        Comment

        • Rodney Hicks
          • Apr 2007
          • 5254

          #5
          Since you are already experienced with PB/WIN, you might want to work with CONTROL ADD GRAPHIC instead of GRAPHIC WINDOW. I think you can get clicks by using style SS_NOTIFY on the control.
          There is also, if you are using the GRAPHIC WINDOW, the GRAPHIC WINDOW CLICK [hWin] TO click&, x!, y!
          Rod
          In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

          Comment

          • Gary Beene
            Member
            • May 2008
            • 20026

            #6
            Did you try the Graphic Window End statement to see if that helped?


            GRAPHIC WINDOW END can be used to close and destroy the selected graphic window at any time. Otherwise, the window is automatically destroyed when the program ends.
            Also, when I run your code, the program ends and the process list does not show the window to still be in work.
            Last edited by Gary Beene; 30 Jul 2009, 09:21 PM.

            Comment

            • Michael Mattias
              Member
              • Aug 1998
              • 43447

              #7
              The thing is, using the GRAPHIC WINDOW requires procedural-style code.... "asking" rather than "waiting to be told" about user actions.

              I have gotten so used to the latter it's really hard to shift gears to the former.

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

              Comment

              • Guy Dombrowski
                Member
                • Mar 2005
                • 648

                #8
                >But Real Programmers should be able to do both equally well ???
                Old QB45 Programmer

                Comment

                • Guy Dombrowski
                  Member
                  • Mar 2005
                  • 648

                  #9
                  I know, I am only an old Engineer
                  Old QB45 Programmer

                  Comment

                  • Michael Mattias
                    Member
                    • Aug 1998
                    • 43447

                    #10
                    That gear-shifter is only one thing which does not work quite as quickly as it used to.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment

                    Working...
                    X