Announcement

Collapse
No announcement yet.

Coordinates of Graphic Window and sroll wheel

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

  • Coordinates of Graphic Window and sroll wheel

    Hi,

    I came across some phenomena of GRAPHIC WINDOW which I would like to discuss.

    (1) You can get the mouse coordinates easily without subclassing the GW: GetCursorPos(lpPoint)


    (2) When you work in a GW it is difficult to get the exact location of the GW client area.
    The GRAPHIC GET LOC statement only gives you the top left corner of the GW INCLUDING the
    window edge and the caption bar. It becomes obvious when the caption is used
    (in my case: 3 pixel edge and 29 pixel caption bar).
    Still, without the caption you are offset by one pixel!
    The width and height of GRAPHIC GET CLIENT are correct.

    The goal is to get the exact location of the client area of a GW, i.e. the area in which you can draw.
    The code below shows that x0, y0 are not good enough for that purpose.
    Using the Api call GetWindowRect() and a bit of calculation gives us the correct client coordinates x1 and y1.
    This also reveals that a GW without caption has a 1 pixels frame that can be corrected using x1 and y1.
    I had used this method already in the "Graphic Buttons for PB/CC 5.0" for getting the hover effect right.


    (3) On my two computers (PC and laptop, both Win XP) moving the scroll wheel crashes the program (without any leftovers, I hope).
    In my discussion with PB support they claimed that it could possibly be caused by my mouse driver(s).

    Does any one else also see that effect?

    With the code below you can test the situation with/without caption and checking if the mouse is within x0/y0 or x1/y1.
    I used the spaces in the print statement because I am too lazy to erased the old text exactly ...

    Regards,
    Gert Voland.

    Code:
    'test_coordinates.bas, Gert Voland, 11. Nov. 2008
    
    #COMPILE EXE
    #DIM ALL
    #BREAK ON
    #CONSOLE OFF
    
    #INCLUDE "Win32Api.inc"
    
    '----------------------------------------------------------------------------------------------
    
    FUNCTION PBMAIN
        LOCAL z$
        LOCAL hGW               AS LONG
        LOCAL x0, y0, x1, y1    AS LONG
        LOCAL deltax, deltay    AS SINGLE
        LOCAL x, y, w, h        AS SINGLE
        LOCAL xold, yold        AS SINGLE
        LOCAL lpPoint           AS POINTAPI                 ' Pointer type defined in Win32Api
        LOCAL GWRect            AS RECT                     ' Data structure defined in Win32Api
        LOCAL grstat            AS LONG
    
        x0 = 350
        y0 = 450
        w = 400
        h = 200
    
    ''    GRAPHIC WINDOW "", x0, y0, w, h TO hGW                  ' Without caption
        GRAPHIC WINDOW "test_coordinates", x0, y0, w, h TO hGW
    
        GRAPHIC ATTACH hGW, 0, REDRAW
    
        GRAPHIC SET POS (10, 10) : GRAPHIC PRINT "Test the coordinates.  Press ESC to quit"
        GRAPHIC SET POS (10, 30) : GRAPHIC PRINT "Move scroll wheel -> Crash?"
    
        DO                                                      ' Update the coordinates when GW is moved
            GRAPHIC GET LOC TO x0, y0                           ' Absolute pixels of the left top corner of the GW bounding rectangle
    
            GetWindowRect(hGW, GWRect)                          ' API call: absolute coordinates of the GW bounding rectangle
            deltax = (GWRect.nRight - GWRect.nLeft - w)/2       ' Half of: Width of the total GW - desired width (= edge of GW)
            deltay = GWRect.nBottom - GWRect.nTop - h - deltax  ' Height of the total GW - desired height - edge (= width of caption bar)
    
            x1 = GWRect.nLeft + deltax                          ' x of the GW client area, absolute pixels
            y1 = GWRect.nTop + deltay                           ' y of the GW client area, absolute pixels
    
            GetCursorPos(lpPoint)                               ' API call: absolute x/y coordinates
            x = lpPoint.x
            y = lpPoint.y
    
            IF x <> xold OR y <> yold THEN                      ' Update GW whenever the mouse is moved
                GRAPHIC SET POS (10, 60) : GRAPHIC PRINT "Position of GW: "; x0; y0; SPACE$(10); "Width and Height: ";w; h
                GRAPHIC SET POS (10, 80) : GRAPHIC PRINT "Absolute mouse coordinates: "; x ;y; SPACE$(10)
    
    '''            IF x >= x0 AND x <= x0 + w AND y >= y0 AND y <= y0 + h THEN     ' Using the GET LOC data: we are not in the client area of GW
                IF x >= x1 AND x <= x1 + w AND y >= y1 AND y <= y1 + h THEN     ' Using the API call: now inside the client area, independent of caption
                    GRAPHIC SET POS ( 10, 120) : GRAPHIC PRINT "Relative coordinates - GRAPHIC GET LOC : ";
                    GRAPHIC SET POS (220, 120) : GRAPHIC PRINT x - x0; y - y0; SPACE$(10)
                    GRAPHIC SET POS ( 10, 140) : GRAPHIC PRINT "Relative coordinates - Corrected: ";
                    GRAPHIC SET POS (220, 140) : GRAPHIC PRINT x - x1; y - y1; SPACE$(10)
                ELSE
                    GRAPHIC SET POS (10, 120) : GRAPHIC PRINT SPACE$(100)
                    GRAPHIC SET POS (10, 140) : GRAPHIC PRINT SPACE$(100)
                END IF
    
                xold = x
                yold = y
            END IF
    
            GRAPHIC INSTAT TO grstat
            IF ISTRUE grstat THEN
                GRAPHIC INKEY$ TO z$
                GRAPHIC SET POS (10, 180) : GRAPHIC PRINT "Pressed key: "; z$ ; SPACE$(10)
            END IF
    
            GRAPHIC REDRAW
    
        LOOP UNTIL z$ = $ESC
    
        GRAPHIC WINDOW END
    
    END FUNCTION
    
    '---end of file ------------------------------------------------------------------------------------
    Gert Voland

  • #2
    Originally posted by Gert Voland View Post
    (1) You can get the mouse coordinates easily without subclassing the GW: GetCursorPos(lpPoint)
    yes, but you have to subclass anyway to get the clicks, if you want them

    Originally posted by Gert Voland View Post
    (2) When you work in a GW it is difficult to get the exact location of the GW client area.
    yes, I noticed that icons in the corners do not quite work out. This is not a big problem for me yet as I am still at the "qualitative" stage!

    Originally posted by Gert Voland View Post
    ...moving the scroll wheel crashes the program (without any leftovers, I hope). In my discussion with PB support they claimed that it could possibly be caused by my mouse driver(s).

    Does any one else also see that effect?
    Sorry, but I don't have a mouse wheel or even a middle button - but I did wonder whether the Control Panel options for the mouse made any difference.

    Comment


    • #3
      GetSystemMetrics

      About issue #2:

      For this purpose there is also a Windows function :

      Code:
       
              FrameWidth    = GetSystemMetrics (%SM_CXDLGFRAME)
              CaptionHeight = GetSystemMetrics (%SM_CYCAPTION)

      Arie Verheul

      Comment


      • #4
        Chris:

        Did you overlook this?

        GRAPHIC WINDOW CLICK [hwin&] TO click&, x!, y!

        Comment


        • #5
          Originally posted by Emil Menzel View Post
          Chris:

          Did you overlook this?

          GRAPHIC WINDOW CLICK [hwin&] TO click&, x!, y!
          Yes, I forgot to mention it. But how do you get Left and Right clicks?

          Comment


          • #6
            Thanks for the hint.
            Code:
                    FrameWidth    = GetSystemMetrics (%SM_CXDLGFRAME)
                    CaptionHeight = GetSystemMetrics (%SM_CYCAPTION)
            Yes, that works well.
            But the Windows system doesn't seem to know when PB draws a GW without caption.
            If one wants to be very exact the method with GetWindowRect() also corrects that 1 pixel frame.

            Could someone - with a mouse wheel - please tell me if the wheel crashes a PB/CC 5.0 program as soon as a GW is present?
            The strange thing is, it happens on two completely different machines (Laptop with a Logitech mouse, updated driver
            and a desktop PC with standard MS mouse driver) - both with Win XP and German keyboard.
            Running it in debug mode give me not a PB ERR code but a message in the compiler window:

            116 bytes string literals, and 2008 bytes dgroup.
            Executable stack size: 1048576 bytes.

            Changing the #STACK setting does not help.

            Does anyone have a clue?
            Last edited by Gert Voland; 12 Nov 2008, 03:42 AM. Reason: Forgot to mention: German keyboard
            Gert Voland

            Comment


            • #7
              I'm not at my computer that has the mouse wheel. I'll give it a try tomorrow...

              Comment


              • #8
                >When you work in a GW it is difficult to get the exact location of the GW client area.

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

                Comment


                • #9
                  Michael,

                  GetClientRect() gives you basically the width and the height of a GW.
                  The origin is 0/0. SDK Help:
                  Because client coordinates are relative to the upper-left corner of a window's client area,
                  the coordinates of the upper-left corner are (0,0).
                  The PB statement GRAPHIC GET CLIENT TO ... does the same - without returning 0/0.

                  But where is that upper left corner of the client area of a GW in absolute screen coordinates?
                  You need it in order to locate your x/y in the GW because GetCursorPos(lpPoint) returns absolute screen coordinates.

                  My above example calculates that point for a GW with and without captions.
                  In that example we actually don't need the GRAPHIC GET LOC statement.
                  I used it to demonstrate the weakness of x0/y0 as compared to x1/y1.
                  Now the mouse cursor is detected exactly on every pixel of the client area.

                  Another method to get x1/y1 would be to use
                  (1) GRAPHIC GET LOC TO ... --> upper left corner including the frame and caption height,
                  i.e. the values of the coordinates are too small!

                  (2) GW with caption:
                  Add GetSystemMetrics (%SM_CXDLGFRAME) for x and GetSystemMetrics (%SM_CYCAPTION) for y,

                  (3) GW without caption:
                  Add 1 pixel for x and y for the one pixel frame.

                  Rgds,
                  Gert Voland.
                  Gert Voland

                  Comment


                  • #10
                    But where is that upper left corner of the client area of a GW in absolute screen coordinates
                    ClientToScreen()
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Michael,

                      Yes - OK - that works well - with and without caption.

                      Sometimes I wish we had a kind of Wiki - knowledge base to locate functions in this seemingly inexhaustible API pool.

                      Here is the corrected sample code:
                      Code:
                      'test_coordinates.bas, Gert Voland, 18. Nov. 2008
                      'API functions ClienttoScreen() and GetCursorPos() used to locate mouse cursor in GRAPHIC WINDOW
                      
                      #COMPILE EXE
                      #DIM ALL
                      #BREAK ON
                      #CONSOLE OFF
                      
                      #INCLUDE "Win32Api.inc"
                      
                      '----------------------------------------------------------------------------------------------
                      
                      FUNCTION PBMAIN
                          LOCAL z$
                          LOCAL hGW               AS LONG
                          LOCAL x0, y0, x1, y1    AS LONG
                          LOCAL x, y, w, h        AS SINGLE
                          LOCAL xold, yold        AS SINGLE
                          LOCAL lpPoint           AS POINTAPI                 ' Pointer type defined in Win32Api
                          LOCAL GWRect            AS RECT                     ' Data structure defined in Win32Api
                          LOCAL grstat            AS LONG
                      
                          x0 = 350
                          y0 = 450
                          w = 400
                          h = 200
                      
                          GRAPHIC WINDOW "", x0, y0, w, h TO hGW                  ' Without caption
                      ''    GRAPHIC WINDOW "test_coordinates", x0, y0, w, h TO hGW
                      
                          GRAPHIC ATTACH hGW, 0, REDRAW
                      
                          GRAPHIC SET POS (10, 10) : GRAPHIC PRINT "Test the coordinates.  Press ESC to quit"
                          GRAPHIC SET POS (10, 30) : GRAPHIC PRINT "Move scroll wheel -> Crash?"
                      
                          DO                                                      ' Update the coordinates when GW is moved
                              GRAPHIC GET LOC TO x0, y0                           ' Absolute pixels of the left top corner of the GW bounding rectangle
                      
                              IF x0 = 0 AND y0 = 0 THEN EXIT LOOP                 ' End the process when GW gets closed
                      
                              lpPoint.x = 0                                       ' Upper left corner of GW (client area) ...
                              lpPoint.y = 0
                              ClientToScreen(hGW, lpPoint)
                              x1 = lpPoint.x                                      ' ... converted to absolute screen coordinates
                              y1 = lpPoint.y
                      
                              GetCursorPos(lpPoint)                               ' API call: absolute x/y coordinates
                              x = lpPoint.x
                              y = lpPoint.y
                      
                              IF x <> xold OR y <> yold THEN                      ' Update GW whenever the mouse is moved
                                  GRAPHIC SET POS (10, 60) : GRAPHIC PRINT "Position of GW: "; x0; y0; SPACE$(10); "Width and Height: ";w; h
                                  GRAPHIC SET POS (10, 80) : GRAPHIC PRINT "Absolute mouse coordinates: "; x ;y; SPACE$(10)
                      
                                  ' Using the API call: now inside the client area, independent of caption
                                  IF x >= x1 AND x <= x1 + w AND y >= y1 AND y <= y1 + h THEN
                                      GRAPHIC SET POS ( 10, 120) : GRAPHIC PRINT "Relative coordinates - GRAPHIC GET LOC : ";
                                      GRAPHIC SET POS (220, 120) : GRAPHIC PRINT x - x0; y - y0; SPACE$(10)
                                      GRAPHIC SET POS ( 10, 140) : GRAPHIC PRINT "Relative coordinates - Corrected: ";
                                      GRAPHIC SET POS (220, 140) : GRAPHIC PRINT x - x1; y - y1; SPACE$(10)
                                  ELSE
                                      GRAPHIC SET POS (10, 120) : GRAPHIC PRINT SPACE$(100)
                                      GRAPHIC SET POS (10, 140) : GRAPHIC PRINT SPACE$(100)
                                  END IF
                      
                                  xold = x
                                  yold = y
                              END IF
                      
                              GRAPHIC INSTAT TO grstat
                              IF ISTRUE grstat THEN
                                  GRAPHIC INKEY$ TO z$
                                  GRAPHIC SET POS (10, 180) : GRAPHIC PRINT "Pressed key: "; z$ ; SPACE$(10)
                              END IF
                      
                              GRAPHIC REDRAW
                      
                          LOOP UNTIL z$ = $ESC
                      
                          GRAPHIC WINDOW END
                      
                      END FUNCTION
                      
                      '---end of file ------------------------------------------------------------------------------------
                      Gert Voland

                      Comment


                      • #12
                        a little knowledge is a dangerous thing!

                        Originally posted by Gert Voland View Post
                        Sometimes I wish we had a kind of Wiki - knowledge base to locate functions in this seemingly inexhaustible API pool.
                        MSDN, or a poor second - Win 32 Programmers reference?

                        Comment


                        • #13
                          Chris,

                          a little knowledge is a dangerous thing!
                          Yes, regarding my limited experience with the Win32 API I probably live quite dangerously!
                          On the other hand, I really appreciate the help/feedback from this forum.

                          Gert.
                          Gert Voland

                          Comment


                          • #14
                            Gert,

                            I tried the latest code along with SysInternals' ProcessExplorer.

                            Your program reports "The absolute mouse coordinates" no matter where the mouse is (desktop or other app). If the mouse pointer moves over your GW, its "Relative Coordinates" are reported. This holds true whether your GW is on top of other windows or if another is alongside...

                            If your GW does NOT have focus, it doesn't see any keystrokes; it only sees keystrokes if it has focus. (To see this, click on an empty part of your taskbar, or on another window that has been made smaller or moved left...)

                            The program does NOT terminate when the mouse pointer is at 0,0.

                            The program DOES terminate when your GW has focus and I press the ESC key, or if I move the mouse wheel (but does NOT terminate if I click the mouse wheel). Although your GW message implies that this is a CRASH, all I can tell is that the process terminates - I'd consider it a crash if it stayed in memory and stopped functioning, but it doesn't. As far as I can tell, it clears out cleanly, although (from a look at your code) unexpectedly.

                            -JohnM


                            Originally posted by Chris Holbrook View Post
                            MSDN, or a poor second - Win 32 Programmers reference?
                            Chris,

                            If you're not using them everyday, it can be quite a task just to phrase a search that returns useful results! I'm only spending about 10 hours a month programming, and whenever I try to answer my own question, I can get back so much material that half my time is just reading and filtering out what's NOT applicable.

                            So often, I will try things myself, read what I can, then come here, state the problem I'm working on, share experimental code, and ask for pointers to the right materials. Depending on who responds and what their particular knowledge is, I can get a wide variety of possible avenues to persue. (But usually this approach takes me a lot less time to filter...)

                            I've seen very few folks here who don't do some research and experimenting first, so a general pointer to MSDN and W32 Prog Ref really doesn't provide much help. I learn best when a knowledgeable person says "Read Topic X", and maybe gives a little more info about why that would be relevant, so to me a specific reference would be much more useful.

                            I think a wiki would be more navigable than MSDN or W32PR, serve as a source of practical info (from experience), and perhaps contain people's observations about using the feature. I would expect such content to fall somewhere in-between the MSDN technical stuff and code; in other words: guidance, "how to", "what not to do", etc.

                            -JohnM

                            Comment


                            • #15
                              John,

                              Thanks for taking a look.

                              - The function GetCursorPos() obviously returns the position irrespective of any window, focus etc.

                              - My aim was to detect the cursor over a structure in the GW. Anything drawn is usually done with the relative coordinates in that GW.
                              The values are thus displayed as long as the GW is attached - even when it is out of focus.
                              If one wants to detect the coordinates only in a GW with focus, the GetForegroundWindow() function helps. I put it in the attached updated sample.
                              It is peculiar but when the focus is switched to a PB-GW this function first returns a 0 and then
                              (when called again) the correct GW handle. PB support told me that it is not an unusual behavior ...

                              - I called it a "crash" because the scroll wheel had no influence in PB/CC 4.04 - which was not detecting any key/mouse events, though.
                              Since you confirmed the behavior, I will report it again to PB support.
                              To be more specific, the problem is:
                              When a GW has the focus, a movement (not click) of the mouse wheel "unexpectedly terminates" the program, no matter where the cursor is.

                              Regards,
                              Gert Voland.


                              PS: Is SysInternals' ProcessExplorer a program?


                              Code:
                              'test_coordinates.bas, Gert Voland, 22. Nov. 2008
                              'API functions ClientToScreen() and GetCursorPos() used to locate mouse cursor in GRAPHIC WINDOW
                              'Detection of focus added. The "Relative coordinates" are only displayed when mouse is over the GW in focus.
                              
                              #COMPILE EXE
                              #DIM ALL
                              #BREAK ON
                              #CONSOLE OFF
                              
                              #INCLUDE "Win32Api.inc"
                              
                              '----------------------------------------------------------------------------------------------
                              
                              FUNCTION PBMAIN
                                  LOCAL z$
                                  LOCAL hGW, hFg          AS LONG
                                  LOCAL x0, y0, x1, y1    AS LONG
                                  LOCAL x, y, w, h        AS SINGLE
                                  LOCAL xold, yold        AS SINGLE
                                  LOCAL lpPoint           AS POINTAPI                 ' Pointer type defined in Win32Api
                                  LOCAL GWRect            AS RECT                     ' Data structure defined in Win32Api
                                  LOCAL grstat            AS LONG
                              
                                  x0 = 350
                                  y0 = 450
                                  w = 400
                                  h = 200
                              
                                  GRAPHIC WINDOW "", x0, y0, w, h TO hGW                  ' Without caption
                              ''    GRAPHIC WINDOW "test_coordinates", x0, y0, w, h TO hGW
                              
                                  GRAPHIC ATTACH hGW, 0, REDRAW
                              
                                  GRAPHIC SET POS (10, 10) : GRAPHIC PRINT "Test the coordinates.  Press ESC to quit"
                                  GRAPHIC SET POS (10, 30) : GRAPHIC PRINT "Move scroll wheel -> Crash?"
                              
                                  DO                                                      ' Update the coordinates when GW is moved
                                      GRAPHIC GET LOC TO x0, y0                           ' Absolute pixels of the left top corner of the GW bounding rectangle
                              
                                      IF x0 = 0 AND y0 = 0 THEN EXIT LOOP                 ' End the process when GW gets closed externally
                              
                                      lpPoint.x = 0                                       ' Upper left corner of GW (client area) ...
                                      lpPoint.y = 0
                                      ClientToScreen(hGW, lpPoint)
                                      x1 = lpPoint.x                                      ' ... converted to absolute screen coordinates
                                      y1 = lpPoint.y
                              
                                      GetCursorPos(lpPoint)                               ' API call: absolute x/y coordinates
                                      x = lpPoint.x
                                      y = lpPoint.y
                              
                                      DO
                                          hFg = GetForegroundWindow()                             ' API call
                                      LOOP UNTIL hFg <> 0                                         ' When switching to a PB/CC GW the handle gets 0 before getting hGW
                              
                                      IF (x <> xold OR y <> yold) AND hFg = hGW THEN              ' Update GW whenever the mouse is moved AND GW is in focus!
                                          GRAPHIC SET POS (10, 60) : GRAPHIC PRINT "Position of GW: "; x0; y0; SPACE$(10); "Width and Height: ";w; h
                                          GRAPHIC SET POS (10, 80) : GRAPHIC PRINT "Absolute mouse coordinates: "; x ;y; SPACE$(10)
                              
                                          ' Using the API call: now inside the client area, independent of caption
                                          IF x >= x1 AND x <= x1 + w AND y >= y1 AND y <= y1 + h THEN
                                              GRAPHIC SET POS ( 10, 120) : GRAPHIC PRINT "Relative coordinates - GRAPHIC GET LOC : ";
                                              GRAPHIC SET POS (220, 120) : GRAPHIC PRINT x - x0; y - y0; SPACE$(10)
                                              GRAPHIC SET POS ( 10, 140) : GRAPHIC PRINT "Relative coordinates - Corrected: ";
                                              GRAPHIC SET POS (220, 140) : GRAPHIC PRINT x - x1; y - y1; SPACE$(10)
                                          ELSE
                                              GRAPHIC SET POS (10, 120) : GRAPHIC PRINT SPACE$(100)
                                              GRAPHIC SET POS (10, 140) : GRAPHIC PRINT SPACE$(100)
                                          END IF
                              
                                          xold = x
                                          yold = y
                                      END IF
                              
                                      GRAPHIC INSTAT TO grstat
                                      IF ISTRUE grstat THEN
                                          GRAPHIC INKEY$ TO z$
                                          GRAPHIC SET POS (10, 180) : GRAPHIC PRINT "Pressed key: "; z$ ; SPACE$(10)
                                      END IF
                              
                                      GRAPHIC REDRAW
                              
                                  LOOP UNTIL z$ = $ESC
                              
                                  GRAPHIC WINDOW END
                              
                              END FUNCTION
                              
                              '---end of file ------------------------------------------------------------------------------------
                              Gert Voland

                              Comment


                              • #16
                                SetWindowPos

                                Maybe the following can be interesting in relation to this subject:

                                I was never aware of it, but i accidentally found that the size of PBCC graphic window, al least in PBCC 4.04, can be changed with the Windows function SetWindowPos (see example code below). As the SetWindowPos function uses the outer dimensions of the window, this might be a way to create a graphic window with exact outer dimensions.

                                Arie Verheul



                                Code:
                                [FONT="Courier New"]#Compile Exe
                                #Dim All
                                #Console Off
                                
                                
                                Declare Function SetWindowPos Lib "USER32.DLL" Alias "SetWindowPos" (_
                                        ByVal hWnd As Dword, ByVal hWndInsertAfter As Dword, ByVal x As Long,_
                                        ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Dword) As Long
                                
                                Function PBMain () As Long
                                
                                    Local hWnd As Dword
                                    Local D As Long
                                    
                                    D = 400
                                
                                    Graphic Window "SetWindowPos",100,100,D,D To hWnd
                                    Graphic Attach hWnd,0
                                    Graphic Color %White,%Black
                                    Graphic Clear
                                    Graphic Box (50,50)-(350,350),20,%Yellow, &H400000
                                
                                    Sleep 2000
                                    
                                    For D = 400 To 300 Step -1
                                
                                        SetWindowPos hWnd, 0, 100,100,D,D,0
                                        Sleep 100
                                    Next
                                    
                                    
                                    For D = 300 To 450
                                        
                                        SetWindowPos hWnd, 0, 100,100,D,D,0
                                        Sleep 100
                                    Next
                                    
                                Sleep 5000
                                
                                End Function[/FONT]

                                Comment


                                • #17
                                  I'd be really careful about that, since the doc says GRAPHIC WINDOWs may not be resized.

                                  If you really want to create GW with exact outer dimension, use GetSystemMetrics() to calculate the size of the client associated with the desired outer dimensions before executing GRAPHIC WINDOW NEW.

                                  For that matter, I am pretty sure there is a WinApi function designed to do exactly this... you supply the client rect and the style and it returns the 'outer size'. Let me look...yup, this looks promising...
                                  AdjustWindowRect

                                  The AdjustWindowRect function calculates the required size of the window rectangle, based on the desired client-rectangle size. The window rectangle can then be passed to the CreateWindow function to create a window whose client area is the desired size.

                                  To specify an extended window style, use the AdjustWindowRectEx function.
                                  Oh, wait a minute, you can already go that way... you want to go the other way. Well, call this function and figure out the frame overhead... the left, right, top and bottom differences won't change as long as the style does not change.
                                  Last edited by Michael Mattias; 23 Nov 2008, 10:19 AM.
                                  Michael Mattias
                                  Tal Systems (retired)
                                  Port Washington WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    To be more specific, the problem is:
                                    When a GW has the focus, a movement (not click) of the mouse wheel "unexpectedly terminates" the program, no matter where the cursor is.

                                    Regards,
                                    Gert Voland.


                                    PS: Is SysInternals' ProcessExplorer a program?

                                    1. I'm going to test the mouse wheel movement on other programs just for the sake of bounding the problem, if possible.

                                    2. Here's the page for ProcessExplorer:
                                    http://technet.microsoft.com/en-us/s...53.aspx?ppud=4

                                    Or, for the overview of all the SysInternals tools:
                                    http://technet.microsoft.com/en-us/s...s/default.aspx

                                    SysInternals used to be independent, but was somehow folded into some aspect of Microsoft a few years ago. I'm sure the details are on their site.

                                    (The software author, Mark Russinovich, came into the spotlight a few years ago when his Rootkit Revealer showed that SONY Music's Digital Rights Management (DRM) system was installing hidden streams onto hard drives without the user's consent. His reports blew the lid off that abuse.)

                                    If I learn anything further about the mouse wheel, I'll report back here.

                                    Best regards,
                                    -John

                                    Added:
                                    Code posted in messages 15 and 16 both exit when mouse wheel is spun (not when it is only clicked).
                                    Last edited by John Montenigro; 23 Nov 2008, 10:44 AM. Reason: added note about test results

                                    Comment


                                    • #19
                                      AdjustWindowRect

                                      That 's a really useful one Michael, thanks,

                                      Arie Verheul

                                      Comment


                                      • #20
                                        Arie,

                                        I tried SetWindowPos() out and found that it only changes the position and/or appearance of the GW.
                                        The "canvas" - so to speak - for graphic operations has been set with GRAPHIC WINDOW - and stays set in its original coordinates.

                                        I.e. even if the GW has been reduced in size (or enlarged) one can draw on the full original size. GRAPHIC GET CLIENT always returns this original width and height.

                                        But SetWindowPos() can well be used to move a PB GW without caption.

                                        Gert.
                                        Gert Voland

                                        Comment

                                        Working...
                                        X