CWindow::ResizeClient() Function for CWnd (or derived classes)

With this Function you can resize the window to the specified client area size of your CWnd or derived classes like the CWindow::ResizeClient() function.

Example

You have a dialog based application and the client rect of the dialog depends on the size of a bitmap.

Source Code

BOOL CYourWndOrDialog::ResizeClient (int nWidth, 
                                     int nHeight, 
                                     BOOL bRedraw)
{
 RECT rcWnd;
 GetClientRect (&rcWnd);

 if(nWidth != -1)
  rcWnd.right = nWidth;
 
 if(nHeight != -1)
  rcWnd.bottom = nHeight;

 if(!::AdjustWindowRectEx(&rcWnd, 
                          GetStyle(), 
                          (!(GetStyle() & WS_CHILD) 
 && GetMenu() != NULL)), GetExStyle()))
  return FALSE;

 UINT uFlags = SWP_NOZORDER | SWP_NOMOVE;

 if(!bRedraw)
  uFlags |= SWP_NOREDRAW;

 return SetWindowPos(NULL, 
                     0, 0, 
                     rcWnd.right - rcWnd.left, 
                     rcWnd.bottom - rcWnd.top, 
                     uFlags);
} // CYourWndOrDialog::ResizeClient		
    


Comments

  • about scroll bar

    Posted by Legacy on 12/12/2001 12:00am

    Originally posted by: vivi

    When I resizing the foreview ,the scroll bar doesn't appear.
    How to show the scrool bar when need?

    I dynamic create edit to this view ,but when there aer a lot of edit ,the view 's size must to be enlarge .But i don't konw how to adjust the scroll bar accommodate the view .

    thank u very much for you help .

    Reply
  • But what about a SDI App?

    Posted by Legacy on 11/30/2001 12:00am

    Originally posted by: me

    see page title ;)

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • CentreCorp is a fully integrated and diversified property management and real estate service company, specializing in the "shopping center" segment, and is one of the premier retail service providers in North America. Company executives travel a great deal, carrying a number of traveling laptops with critical current business data, and no easy way to back up to the network outside the office. Read this case study to learn how CentreCorp implemented a suite of business continuity services that included …

Most Popular Programming Stories

More for Developers

RSS Feeds