Thread: Getting the position of a child window

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273

    Getting the position of a child window

    Hi,
    I'm trying to process the WM_SIZE message in my main window's WindowProc so that a child window (used for displaying images) has a scrollbar window underneath it (not actually "in" the child window). I've tried using GetWindowRect and setting the scrollbars window's Top value to the resulting RECT's top, but as the coordinates are relative to the screen this doesn't work properly. I was thinking of perhaps using MapWindowPoints in some way. Any ideas?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You could try the GetWindowRect and GetClientRect
    then use ClientToScreen or ScreenToClient to convert to one set of cood.

    Or look at ScrollDC or ScrollWindow.

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    I figured it out!

    Using the following code:-

    GetWindowRect(hView, &rcView);
    MapWindowPoints(HWND_DESKTOP, hwnd, (LPPOINT)&rcView, 2);

    Gives me the child window's (hView) position relative to its parent (hwnd).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  3. Posting a message to a child window
    By axr0284 in forum Windows Programming
    Replies: 6
    Last Post: 01-27-2005, 09:35 AM
  4. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM