Resizing MDI child windows

This is a discussion on Resizing MDI child windows within the Windows Programming forums, part of the Platform Specific Boards category; In an MDI MFC app, I load up bitmaps to display in child windows. I want to resize the child ...

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Resizing MDI child windows

    In an MDI MFC app, I load up bitmaps to display in child windows. I want to resize the child windows so that the bitmaps fit nicely in. The bitmaps are loaded from their files in CDocument::Serialize(). I was wondering, when is the best time to resize the child windows to fit the bitmaps?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    The best time to resize the window is before drawing the bitmap on the screen. Determine its size, resize the MDI child window, and then draw it.

    Kuphryn

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    But that means I have to resize each time I draw the bitmap. That will slow my program down.

    I ended up putting the code in the WM_INITIALUPDATE message handler. Works fine now.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    This might help....

    Code:
    //Rect is filled with bitmaps dimension, 
    //use GetObject() if the bitmaps width and height are not known
    
    //get the styles from the window
    lStyle=GetWindowLong(hWnd, GWL_STYLE);
    lExStyle=GetWindowLong(hWnd, GWL_EXSTYLE);
    
    //send in the required client area and styles
    AdjustWindowRectEx(&Rect, lStyle, bHasMenu, lExStyle);
    
    //returned is the required window size so set the window to this size and bring to the front
    SetWindowPos(hWnd, HWND_TOP, 0,0,Rect.right- Rect.left, Rect.bottom- Rect.top, SWP_NOMOVE);
    "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

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Cheers, that's how I was doing it. It doesn't work 100% though, because the window that the bitmap is drawn to is actually a child window of the MDI ChildFrame, and thus the dimensions are a few pixels different. What I might do though is use GetWindowRect() on each window to calculate the exact dimensions required.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting text into MDI program
    By Rutabega in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2005, 10:25 AM
  2. Scale MDI child to parent
    By bludstayne in forum C# Programming
    Replies: 0
    Last Post: 07-10-2004, 02:26 PM
  3. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  4. Question about MDI child windows?
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 07-21-2002, 08:30 PM
  5. child windows
    By face_master in forum Windows Programming
    Replies: 14
    Last Post: 03-01-2002, 06:08 AM

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