Thread: How to get child's x, y coords?

  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,981
    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,868
    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,981
    >> 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, 06:51 PM
  3. mouse click coords and moving a rect
    By techrolla in forum Windows Programming
    Replies: 1
    Last Post: 03-07-2004, 09:49 PM
  4. Direct Input and Mouse Coords
    By Khelder in forum Game Programming
    Replies: 5
    Last Post: 12-30-2003, 02:29 PM
  5. collision detect - compare player's coords to...?
    By MadHatter in forum Game Programming
    Replies: 3
    Last Post: 12-12-2002, 02:26 AM