Click here to Skip to main content
6,634,665 members and growing! (16,220 online)
Email Password   helpLost your password?
Desktop Development » Document / View » General     Intermediate License: The Code Project Open License (CPOL)

ResizableFormView

By Paolo Messina

A CFormView derived class to implement resizable form views with MFC
VC6, Windows, MFC, Dev
Posted:14 Jul 2001
Updated:27 Oct 2001
Views:120,920
Bookmarked:48 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
16 votes for this article.
Popularity: 5.73 Rating: 4.76 out of 5

1

2

3
1 vote, 12.5%
4
7 votes, 87.5%
5

CResizableFormView

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 "ResizableFormView.h"

class CMyFormView : public CResizableFormView
{
protected: // create from serialization only
    CMyFormView();
    DECLARE_DYNCREATE(CMyFormView)


// ( 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
    AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_GROUP1, TOP_LEFT, BOTTOM_LEFT);

    // complete initialization
    CResizableFormView::OnInitialUpdate();

    // these two lines are optional
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();
}

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::CResizableFormView

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.

CResizable???::???

Implemented in the various base classes, see ResizableLib article.

Conclusion

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.

License

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

About the Author

Paolo Messina


Member
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 (www.robotechsrl.com).
Occupation: Software Developer
Company: RoboTech srl
Location: Italy Italy

Other popular Document / View articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 23 of 23 (Total in Forum: 23) (Refresh)FirstPrevNext
Generalgreat, I need it PinmemberLi Shu22:14 27 Oct '08  
GeneralWorks with Ultimate tool and Grid Pinmembermhorowit18:49 26 Sep '07  
QuestionHow to avoid flickering Pinmemberchen_zd18:41 7 Jun '07  
AnswerRe: How to avoid flickering PinmemberPaolo Messina23:50 7 Jun '07  
GeneralRe: How to avoid flickering Pinmemberchen_zd7:03 8 Jun '07  
GeneralGreat.It is just what I want.Thanks Pinmemberbenben6:35 30 Jul '03  
GeneralCResizableForm do not resize itself PinsussAnonymous19:26 18 May '03  
GeneralRe: CResizableForm do not resize itself PinmemberPaolo Messina7:04 19 May '03  
GeneralProblems wiith windows media player activex PinsussPedro Miranda2:28 13 May '03  
GeneralRe: Problems wiith windows media player activex PinmemberPaolo Messina11:46 14 May '03  
GeneralRe: Problems wiith windows media player activex PinsussPedro Miranda6:31 15 May '03  
GeneralRe: Problems wiith activex / Testing new version PinmemberPaolo Messina10:35 15 May '03  
GeneralExcellent PinmemberJohnJ1:10 14 Mar '03  
GeneralActiveX control behaviour during resizing Pinmembershilon5:36 31 Jan '03  
GeneralRe: ActiveX control behaviour during resizing PinmemberPaolo Messina13:32 31 Jan '03  
GeneralRe: ActiveX control behaviour during resizing Pinmembershilon2:31 1 Feb '03  
GeneralRe: ActiveX control behaviour during resizing PinmemberPaolo Messina4:57 1 Feb '03  
GeneralCResizableMinMax and CResizableFormView PinmemberMatt Philmon18:03 23 Aug '01  
GeneralRe: CResizableMinMax and CResizableFormView PinmemberPaolo Messina1:38 24 Aug '01  
Generalprobleme with VScroll Pinmemberbogdan0:07 26 Jul '01  
GeneralRe: probleme with VScroll PinmemberPaolo Messina0:15 26 Jul '01  
GeneralRe: probleme with VScroll Pinsusshaibiao7:45 1 Aug '03  
GeneralJust what I needed :) PinmemberMatt Newman9:01 16 Jul '01  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Oct 2001
Editor: Sean Ewington
Copyright 2001 by Paolo Messina
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project