Click here to Skip to main content
12,502,578 members (59,382 online)
Click here to Skip to main content
Add your own
alternative version

Stats

49.3K views
844 downloads
13 bookmarked
Posted

Sizing Framework

, 15 Oct 2001
Rate this:
Please Sign up or sign in to vote.
Port of the window sizing framework from Paul DiLascia
<!-- Download Links --> <!-- Article image -->

Sample Image - sizingframework.jpg

<!-- Main HTML starts here -->

Introduction

The WTL possibilities to build sizeable graphical user interface exists but was not fitting my needs so I decided to port the excellent framework from Paul DiLascia 'Windows UI: Our WinMgr Sample Makes Custom Window Sizing Simple' published in the July 2001 issue of MSDN Magazine. To understand all the principle of the framework, please read the original article.

The port was almost straightforward. I just added the gripper to the dialog.

Usage

To use the framework you need first to add those files to your project:
  • WinMgr.h
  • WinMgr.cpp
  • WinRect.cpp
  • SizeableDlg.h
Your dialog needs then to inherit from the class CDialogSizeable like this:
class CTestDlg :
    public CDialogSizeable<CTestDlg>,
    public CDialogImpl<CTestDlg>
In the OnInitDialog() event handler, add as first line the following:
LRESULT CTestDlg::OnInitDialog( HWND hwnd, LPARAM  lParam)
{
    BOOL bRet = CDialogSizeable<CTestDlg>::OnInitDialog( hwnd, lParam );
    ...
}
Add the following macro to your main message map:
BEGIN_MSG_MAP_EX(CTestDlg)
    ...
    MESSAGE_HANDLER_EX(WM_WINMGR, OnWinMgr)
    ...
END_MSG_MAP()
And the the method to your dialog class (get more information on the original article):
///////////////////
// Handle WM_WINMGR: return min size for OK/Cancel buttons
//
LRESULT CTestDlg::OnWinMgr(UINT uMsg, WPARAM wp, LPARAM lp)
{
    ATLASSERT(lp);
    NMWINMGR& nmw = *(NMWINMGR*)lp;

    if ( nmw.code == NMWINMGR::GET_SIZEINFO )
    {
        if ( wp==IDOK || wp==IDCANCEL )
        {
            nmw.sizeinfo.szMin = m_szMinButton;
            return TRUE;
        }
    }
    return 0;
}
Build the Window map in the cpp file of your dialog class, i.e.:
BEGIN_WINDOW_MAP(TestDlgMap)
BEGINROWS(WRCT_REST,0,RCMARGINS(8,8))
 BEGINCOLS(WRCT_REST,0,0)
  BEGINROWS(WRCT_REST,4,RCMARGINS(-4,-4))
   RCTOFIT(IDC_STATIC1)
   RCSPACE(-4)
    BEGINROWS(WRCT_TOFIT,IDC_GROUP1,RCMARGINS(-8,-8))
     RCSPACE(-10)
    RCTOFIT(IDC_RADIO1)
    RCTOFIT(IDC_RADIO2)
    ENDGROUP()
  ENDGROUP()
  RCPERCENT(IDC_EDIT1,50)
 ENDGROUP()
 RCSPACE(-4)
 RCTOFIT(IDC_STATIC2)
 RCTOFIT(IDC_SLIDER1)
 BEGINCOLS(WRCT_TOFIT,0,0)
  RCREST(-1)
  BEGINROWS(WRCT_TOFIT,0,0)
    RCTOFIT(IDOK)
    RCSPACE(-2)
    RCTOFIT(IDCANCEL)
  ENDGROUP()
 ENDGROUP()
ENDGROUP()
END_WINDOW_MAP()
Add finally the following to the constructor of your dialog:
CTestDlg::CTestDlg( ) :
    CDialogSizeable<CTestDlg>( TestDlgMap )
{
    ...
Now enjoy your sizing dialog.

Faced Problems

None (at the moment ;-).

History

Version 1.00 October 8, 2001
. Submitted the article to Codeproject web site.
. Added the article on Tech Head web site.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Laurent Kempé
Architect
France France

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent is awarded by Microsoft since Avril 2002: Most Valuable Professional (MVP).


You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionCSizeableDlg class with child dialog s Pin
fkhanoom20-Apr-10 11:09
memberfkhanoom20-Apr-10 11:09 
QuestionCSizerBar? Pin
Anatoly Ivasyuk16-Oct-01 4:26
memberAnatoly Ivasyuk16-Oct-01 4:26 
AnswerRe: CSizerBar? Pin
Laurent Kempé16-Oct-01 6:21
memberLaurent Kempé16-Oct-01 6:21 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 16 Oct 2001
Article Copyright 2001 by Laurent Kempé
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid