child window resizing problem

This is a discussion on child window resizing problem within the Windows Programming forums, part of the Platform Specific Boards category; How can I get hwndChild1's height to auto-resize to the current window dimensions? Code: ... RECT rect; int height; switch(message) ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Location
    pacific northwest
    Posts
    37

    child window resizing problem

    How can I get hwndChild1's height to auto-resize to the current window dimensions?

    Code:
        ...
    
        RECT rect;
        int height;
    
        switch(message) {
    
            case WM_CREATE:
    
                GetClientRect(hwnd, &rect);
                height = rect.bottom;
    
                hwndChild1 = CreateWindowEx(
                    WS_EX_STATICEDGE,
                    "STATIC",
                    "",
                    WS_VISIBLE | WS_TABSTOP | WS_CHILD,
                    0, 0, 200, height,
                    hwnd,
                    NULL,
                    hInst,
                    NULL);
    
                break;
    
            case WM_SIZE:
    
                / * i am assuming i need a SendMessage? */
                break;
    
        ...
    "No, I am not wise, but I am a lover of wisdom." --Pythagoras

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    WM_SIZE
    fwSizeType = wParam; // resizing flag
    nWidth = LOWORD(lParam); // width of client area
    nHeight = HIWORD(lParam); // height of client area
    You recieve this info and recalculate the child window size based on the proportions you decided earlier...

    Then use

    Code:
    BOOL SetWindowPos(
      HWND hWnd,             // handle to window
      HWND hWndInsertAfter,  // placement-order handle
      int X,                 // horizontal position
      int Y,                 // vertical position
      int cx,                // width
      int cy,                // height
      UINT uFlags            // window-positioning flags
    );
    To resize that child window......

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You can also use MoveWindow
    eg.
    Code:
    MoveWindow(hwndChild1, NewLeft, NewTop, NewWidth, NewHeight,TRUE);
    where NewLeft, NewTop, NewWidth and NewHeight are the new values for position/dimensions of your child window. The final param is TRUE if you want the control to be redrawn (so usually TRUE) or FALSE if you don't.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a child window in a parent window
    By vopo in forum Windows Programming
    Replies: 8
    Last Post: 10-06-2007, 05:15 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 09:23 AM
  3. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  4. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

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