How to get child's x, y coords?

This is a discussion on How to get child's x, y coords? within the Windows Programming forums, part of the Platform Specific Boards category; Hey! I can get the child window's length and height with GetClientRect(), but the x and y coordinates are 0. ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102

    How to get child's x, y coords?

    Hey!

    I can get the child window's length and height with GetClientRect(), but the x and y coordinates are 0.

    GetWindowRect() gets the coordinates relative to the whole screen.

    How to get these coordinates relative to child's parent?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,673
    You do some math on the GetWindowRect() coords of the parent and the child. Draw it out on paper - that's what I do.

    gg

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Don't have an IDE here....

    Can you get the screen coods ( GetWindowRect() ) of the client object/window

    Then convert to client coods (ScreenToClient() ) using the parents HWND?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,673
    >> Then convert to client coods [with] ScreenToClient()
    Oh yeah - that's probably the best way.

    gg

  5. #5
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Thanks, ScreenToClient() method worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heightfield Texture Coords
    By psychopath in forum Game Programming
    Replies: 1
    Last Post: 10-03-2005, 09:55 AM
  2. Using fork() to create two childs
    By Yasir_Malik in forum C Programming
    Replies: 2
    Last Post: 03-05-2005, 05:51 PM
  3. mouse click coords and moving a rect
    By techrolla in forum Windows Programming
    Replies: 1
    Last Post: 03-07-2004, 08:49 PM
  4. Direct Input and Mouse Coords
    By Khelder in forum Game Programming
    Replies: 5
    Last Post: 12-30-2003, 01:29 PM
  5. collision detect - compare player's coords to...?
    By MadHatter in forum Game Programming
    Replies: 3
    Last Post: 12-12-2002, 01:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21