Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetWindowRect(),GetClientRect() question

GetWindowRect(),GetClientRect() question

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    econy
    wrote on last edited by
    #1

    Hi, I am confused with screen/window/client coordinate in windows programming. As I understand, 3 coordinates are like the following: screen top left point: spoint(Xs,Ys); window top left point: wpoint(Xw,Yw); client top left point: cpoint(Xc,Yc); so the related position for 3 points are:

    spoint -----------
    | wpoint----------
    | |
    | cpoint ----------
    |
    |

    GetWindowRect(&rect) gets wpoint; ScreenToClient(&rect) gets which point? if it gets cpoint,then cpoint (x,y) based on wpoint, or spoint? And in a dialog template:

    CONTROL "",IDC_STATIC_TST,"Static",SS_BLACKFRAME,80,83,118,35
    80,83,118,35 based on client top left point?

    L 1 Reply Last reply
    0
    • E econy

      Hi, I am confused with screen/window/client coordinate in windows programming. As I understand, 3 coordinates are like the following: screen top left point: spoint(Xs,Ys); window top left point: wpoint(Xw,Yw); client top left point: cpoint(Xc,Yc); so the related position for 3 points are:

      spoint -----------
      | wpoint----------
      | |
      | cpoint ----------
      |
      |

      GetWindowRect(&rect) gets wpoint; ScreenToClient(&rect) gets which point? if it gets cpoint,then cpoint (x,y) based on wpoint, or spoint? And in a dialog template:

      CONTROL "",IDC_STATIC_TST,"Static",SS_BLACKFRAME,80,83,118,35
      80,83,118,35 based on client top left point?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi, It's all relative, my dear Watson.

      econy wrote:

      ScreenToClient(&rect) gets which point?

      ScreenToClient will convert a screet RECT (your 'spoint') coordinates to be relative to client RECT (your 'cpoint'). In your example the top and left will be negative coordinates relative to the client top/left. Window Coordinate System[^] Best Wishes, -David Delaune

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups