Click here to Skip to main content
Click here to Skip to main content


, 27 Oct 2001 CPOL
Rate this:
Please Sign up or sign in to vote.
A CFormView derived class to implement resizable form views with MFC


This class handles resizable Form views and it's based on my ResizableLib class library (see article).

The user will have the ability to resize the Form, with consequent rearrangement of child windows. If the Form window gets smaller than its minimum size, it becomes scrollable like standard CFormView.

Conversion of a previously existant Form should be very simple, as well as creation of a new resizable dialog.

The Sample Applications

This is a view of the SDI application:

A SDI application with resizable Form View

This is a view of the MDI application:

A MDI application with resizable Form View

You may see how to do this in the next section.

Usage - Step by Step

Add the ResizableLib to your project's workspace, as explained in the relative article.

Create a standard Form view or take one you have already made which you want to be resizable.

Include 'ResizableFormView.h' in the associated header file.

Search and replace all CFormView occurrences with CResizableFormView in both your .cpp and .h files, just as if your dialog class was derived from CResizableFormView instead of CFormView. I think there's no way to let the Class Wizard do this for you. Let me know if I'm wrong, please.

Your header file should appear like this:

#include <span class="code-string">"ResizableFormView.h"</span>

class CMyFormView : public CResizableFormView
protected: // create from serialization only

// ( other stuff )
// ...

In your OnInitialUpdate override, add an anchor for each control you want the size and/or position to be changed when the user resizes the Form.

void CMyFormView::OnInitialUpdate()
    // must add controls to the layout
    // before OnInitialUpdate base implementation

    // complete initialization

    // these two lines are optional

You are ready to rebuild your project and you will have a resizable Form view just as you wanted.

For further details, see the next section.

Class Reference

This class inherits only from CResizableLayout and obviously from CFormView. It just needs basic resizing capabilities.


CResizableFormView(UINT nIDTemplate)
CResizableFormView(LPCTSTR lpszTemplateName)
These are needed to reproduce the construction scheme of a CFormView derived class. This is the reason why replacing one class with the other will work.


Implemented in the various base classes, see ResizableLib article.


Even this class is eventually integrated with ResizableLib. Many thanks to John Simmons for his first attempt to make resizable Form views and for pointing out the scrolling problem. To solve it I had to add more functionalities to CResizableLayout, that could be useful for other purposes.

The CVS tree is now on Source Forge.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Paolo Messina
Software Developer RoboTech srl
Italy Italy
Paolo began programming at the age of 9 with a glorious 8086 and GW-BASIC, then he played a bit with C, ASM and Pascal. He tought himself MFC and Windows programming, to exploit his studies of C++. Always attracted by low-level programming and Assembly, he's beginning to appreciate the joys of templates and STL. At work he changed his mind about Java, discovered Eclipse IDE, and now think it's cool.
He lives in Follonica, Italy.
He has been abroad in the U.S. to work on his final thesis before graduating. For seven months he was playing with airplanes and automatic control at the Unversity of Illinois at Urbana-Champaign.
He graduated in Computer Science Engineering at the University of Pisa, Italy, in December 2003.
Currently working for an edutainment robotics company (
Follow on   Google+

Comments and Discussions

GeneralMy vote of 5 PinmemberCloudsy17-Jan-14 4:50 
QuestionHow can I use Resizable Lib with CMDIFrameWndEx PinmemberMember 4499645-Nov-13 23:11 
Questionis it some problem with this project? Pinmemberbatsword10-Sep-10 22:43 
Generalgreat, I need it PinmemberLi Shu27-Oct-08 21:14 
GeneralWorks with Ultimate tool and Grid Pinmembermhorowit26-Sep-07 17:49 
QuestionHow to avoid flickering Pinmemberchen_zd7-Jun-07 17:41 
AnswerRe: How to avoid flickering PinmemberPaolo Messina7-Jun-07 22:50 
GeneralRe: How to avoid flickering Pinmemberchen_zd8-Jun-07 6:03 
GeneralGreat.It is just what I want.Thanks Pinmemberbenben30-Jul-03 5:35 
GeneralCResizableForm do not resize itself PinsussAnonymous18-May-03 18:26 
GeneralRe: CResizableForm do not resize itself PinmemberPaolo Messina19-May-03 6:04 
GeneralProblems wiith windows media player activex PinsussPedro Miranda13-May-03 1:28 
GeneralRe: Problems wiith windows media player activex PinmemberPaolo Messina14-May-03 10:46 
GeneralRe: Problems wiith windows media player activex PinsussPedro Miranda15-May-03 5:31 
GeneralRe: Problems wiith activex / Testing new version PinmemberPaolo Messina15-May-03 9:35 
Pedro Miranda wrote:
My question is if there is no problem in calling AddAnchor after CResizableFormView::OnInitialUpdate and specially if I need to call CResizableFormView::ArrangeLayout() again after it.
Well, there is a short and a long version of the story. Let's begin with the short one: you need to call AddAnchor after calling the base implementation of OnInitialUpdate(). That's precisely because DDX is initialized during that call.
Now the long version. Unfortunately OnInitialUpdate() is not the best place to do one-shot initialization tasks, because it could be called more than once by the framework. We would need something like OnInitDialog, that unfortunately is not available for FormViews. The good news is that I'm working on a workaround that enables OnInitDialog and will hopefully solve this and some other problems in the next version of the library.
Experimental code is on CVS at SourceForge, along with new versions of the demo applications. I have no time now to release anything, but I would be grateful to anyone interested in some testing.
The easiest way to obtain the code is downloading the CVS Nightly Tarball or using some CVS client, such as WinCvs.
Why spend 2 minutes doing it by hand when you can spend all night plus most of the following day writing a system to do it for you? - (Chris Maunder)

GeneralExcellent PinmemberJohnJ14-Mar-03 0:10 
GeneralActiveX control behaviour during resizing Pinmembershilon31-Jan-03 4:36 
GeneralRe: ActiveX control behaviour during resizing PinmemberPaolo Messina31-Jan-03 12:32 
GeneralRe: ActiveX control behaviour during resizing Pinmembershilon1-Feb-03 1:31 
GeneralRe: ActiveX control behaviour during resizing PinmemberPaolo Messina1-Feb-03 3:57 
GeneralCResizableMinMax and CResizableFormView PinmemberMatt Philmon23-Aug-01 17:03 
GeneralRe: CResizableMinMax and CResizableFormView PinmemberPaolo Messina24-Aug-01 0:38 
Generalprobleme with VScroll Pinmemberbogdan25-Jul-01 23:07 
GeneralRe: probleme with VScroll PinmemberPaolo Messina25-Jul-01 23:15 
GeneralRe: probleme with VScroll Pinsusshaibiao1-Aug-03 6:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 27 Oct 2001
Article Copyright 2001 by Paolo Messina
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid