Click here to Skip to main content
15,566,266 members
Articles / Desktop Programming / MFC
Posted 14 Jul 2001


66 bookmarked


Rate me:
Please Sign up or sign in to vote.
4.96/5 (16 votes)
27 Oct 2001CPOL2 min read
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)

Written By
Technical Lead RoboTech srl
Italy Italy
Paolo began programming at the age of 9 with a glorious Olivetti M24 (i8086) and GW-BASIC, then he played a bit with Turbo C, Turbo Pascal and Assembly (using the MS-DOS Debug). Quick BASIC and Visual Basic shortly followed, until he learned C++ in College. He tought himself MFC and Windows programming, along with some DHTML and Javascript.

Always attracted by low-level programming and Assembly, he started to appreciate the joys of templates and STL while working for his Master Thesis. For seven months he was playing with airplanes and automatic control at the Unversity of Illinois at Urbana-Champaign, where he first met QNX and embedded systems.

In his job experience he learned Java to develop user interfaces and graphical editors, and re-discovered the Eclipse IDE that he had used in its early versions with the QNX SDK. He also deepened his knowledge of Linux and embedded systems, microcontrollers firmware and embedded voice recognition, while also practicing electronics design.

He graduated in Computer Engineering (Ingegneria informatica) at the University of Pisa, Italy, in December 2003. Currently working for an electronics and robotics company (

He lives in Pisa and in Follonica (GR), Italy.

Comments and Discussions

GeneralMy vote of 5 Pin
Cloudsy17-Jan-14 5:50
Cloudsy17-Jan-14 5:50 
QuestionHow can I use Resizable Lib with CMDIFrameWndEx Pin
Member 4499646-Nov-13 0:11
Member 4499646-Nov-13 0:11 
Questionis it some problem with this project? Pin
batsword10-Sep-10 23:43
batsword10-Sep-10 23:43 
Generalgreat, I need it Pin
Li Shu27-Oct-08 22:14
Li Shu27-Oct-08 22:14 
GeneralWorks with Ultimate tool and Grid Pin
mhorowit26-Sep-07 18:49
mhorowit26-Sep-07 18:49 
QuestionHow to avoid flickering Pin
chen.zd7-Jun-07 18:41
chen.zd7-Jun-07 18:41 
AnswerRe: How to avoid flickering Pin
Paolo Messina7-Jun-07 23:50
professionalPaolo Messina7-Jun-07 23:50 
GeneralRe: How to avoid flickering Pin
chen.zd8-Jun-07 7:03
chen.zd8-Jun-07 7:03 
GeneralGreat.It is just what I want.Thanks Pin
benben30-Jul-03 6:35
benben30-Jul-03 6:35 
GeneralCResizableForm do not resize itself Pin
Anonymous18-May-03 19:26
Anonymous18-May-03 19:26 
GeneralRe: CResizableForm do not resize itself Pin
Paolo Messina19-May-03 7:04
professionalPaolo Messina19-May-03 7:04 
GeneralProblems wiith windows media player activex Pin
Member 360790213-May-03 2:28
Member 360790213-May-03 2:28 
GeneralRe: Problems wiith windows media player activex Pin
Paolo Messina14-May-03 11:46
professionalPaolo Messina14-May-03 11:46 
GeneralRe: Problems wiith windows media player activex Pin
Member 360790215-May-03 6:31
Member 360790215-May-03 6:31 
GeneralRe: Problems wiith activex / Testing new version Pin
Paolo Messina15-May-03 10:35
professionalPaolo Messina15-May-03 10:35 
GeneralExcellent Pin
JohnJ14-Mar-03 1:10
JohnJ14-Mar-03 1:10 
GeneralActiveX control behaviour during resizing Pin
Alexander Silonosov31-Jan-03 5:36
Alexander Silonosov31-Jan-03 5:36 
GeneralRe: ActiveX control behaviour during resizing Pin
Paolo Messina31-Jan-03 13:32
professionalPaolo Messina31-Jan-03 13:32 
GeneralRe: ActiveX control behaviour during resizing Pin
Alexander Silonosov1-Feb-03 2:31
Alexander Silonosov1-Feb-03 2:31 
GeneralRe: ActiveX control behaviour during resizing Pin
Paolo Messina1-Feb-03 4:57
professionalPaolo Messina1-Feb-03 4:57 
GeneralCResizableMinMax and CResizableFormView Pin
Matt Philmon23-Aug-01 18:03
Matt Philmon23-Aug-01 18:03 
GeneralRe: CResizableMinMax and CResizableFormView Pin
Paolo Messina24-Aug-01 1:38
professionalPaolo Messina24-Aug-01 1:38 
Generalprobleme with VScroll Pin
bogdan26-Jul-01 0:07
bogdan26-Jul-01 0:07 
GeneralRe: probleme with VScroll Pin
Paolo Messina26-Jul-01 0:15
professionalPaolo Messina26-Jul-01 0:15 
GeneralRe: probleme with VScroll Pin
Member 5218751-Aug-03 7:45
Member 5218751-Aug-03 7:45 

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

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