Announcement

Collapse
No announcement yet.

Pixels/Dialog Units???

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

  • Pixels/Dialog Units???

    I have a dialog with a graphic of evenly spaced dots. When the cursor is over that region I want the cursor to "snap to" the dots.
    I'm having trouble converting the values from GetCursorPos to the coordinates of the graphic in my dialog. Can someone offer (or a reference to) a snippet of code to make this conversion.

    Also how would recommend doing the "snap to"? Based on a wm_mousemove event or setup a timer?

    Thanks
    Brent Boshart

    ------------------
    Brent Boshart

  • #2
    Use GetWindowRect to get the Screen Coordinates for your Image
    (the control it is in of course).

    Both GetWindowRect and GetCursorPos use Screen Coordinates which are in
    Pixels and not dialog units. Simply avoid the use of Dialog units
    altogether. Once you know where your Image (the static control its in)
    is located in screen coordinates, you are all set.

    Now if you use a border around the Image, you may need to use
    GetClientRect to get the actual size of the client area. Now
    remember that GetClientRect returns coordinates in based on the
    Parent Dialog and not screen coordinates. Use GetClientRect to
    simply get the true height and width of the image control, then
    subtract that from the screen coordinates returned from getWindowRect
    to find the offset (because of the border) to the beginning of the Image.


    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment

    Working...
    X