Auto repositioning/resizing of child controls (using C++ templates) Kentucky

Instead of having to derive from a whole new hierarchy

Local Companies

Global Software
859-264-9215
501 Darby Creek RD
Lexington, KY
Business Technology Solutions
859-977-3829
1450 N Broadway
Lexington, KY
Onsite Solutions Corp
859-255-0545
271 W Short St
Lexington, KY
National Innovative Software Solutions LLC
502-495-0548
2108 Plantside DR
Louisville, KY
Information Systems Solutions Inc
502-245-7003
12730 Townepark Way
Louisville, KY
Epicor Software
502-339-7748
8700 Westport RD
Louisville, KY
Api
859-233-2006
167 W Main St
Lexington, KY
Dynamic Accounting Solutions
859-858-3598
2375 Glass Mill RD
Lexington, KY
Halo Group, Inc.
502-657-6468
9900 Corporate Campus Drive
Louisville, KY
Epicor Software Corporation
502-412-7666
9100 Shelbyville RD
Louisville, KY

provided by: 
Originally published at Internet.com


Yet, another method to reposition/resize child windows within their parent framework. Although the subject received a lot of attention, including this web site, I invite you to look at the following method as it presents certain advantages over the others I already know.

First of all this is not a library. There is no associated DLL or LIB to link to. Secondly, it is not a class hierarchy. You don't have to derive your classes from classes exposing this functionality. Often, you already have a hierarchy of classes designed for a certain behavior. This behavior does not include repositioning/resizing of child controls, but you want to add it. Since the MFC doesn't let you use multiple inheritance when it comes to windows, you might wonder what is the solution. Well, the solution is templates. GEOMETRY is actually a collection of templates designed to make your windows to resize gracefully.

The interface to GEOMETRY is a single class template CGeometryWnd. You can use this class template with all your window classes including dialogs, forms, property sheets/property pages and splitter windows. Being a template library, GEOMETRY is contained in a single file Geometry.h. All you have to do is to include this file, to use CGeometryWnd and possibly a series of macros, in relation with your classes.

For example to make a dialog resizeable you need to: 1. make your dialog in resource editor resizeable (replace the dialog frame with a resizeable border) 2. specify the rules to apply to child controls (either in the resource editor or in the source code) 3. include in dialog's source code Geometry.h 4. use the template CGeometryWnd over your dialog's class

Ex: #include Geometry.h USE_GEOMETRY_TEMPLATES; ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { DECLARE_GEOMETRY_RTSUPPORT() public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA virtual BOOL OnInitDialog(); //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) // No message handlers //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() BOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); AddConstraint(IDOK,CConstraint("X")); return TRUE; } // App command to run the dialog void CTestPSGeoApp::OnAppAbout() { CGeometryWnd aboutDlg; aboutDlg.DoModal(); } The constraints added to child windows, control their behavior in case the parent resizes. The constraints can be added at design time (aka in resource editor, see note) or at runtime using the DECLARE_GEOMETRY_RTSUPPORT() macro and AddConstraint()function. The constraint object has two important constructors: CConstraint(LPCSTR lpOptions) and CConstraint(float x,float y=0,float cx=0,float cy=0) In the first case you can specify the repositioning/resizing of the control by using a control string (see table for details). Basically the string format is:

Option1[value]+Option2[value]+Â…

Where Optionx (see table below) controls the position/size of the control and [value] ([] are not optional) is an optional parameter specifying the amount (between 0 and 1 as a float number) with which the control will repossition/resize from the total amount of the parent resize value.

Option Meaning Comment

X

Reposition on x axis

Control will move on the x axis

Y

Reposition on y axis

Control will move on the y axis

CX

Resize on x axis

Control will resize its width

CY

Resize on y axis

Control will resize its height

x

Stay on x axis center

Equivalent with X[0.5]

y

Stay on y axis center

Equivalent with Y[0.5]

cx

Equivalent with CX[0.5]

cy

Equivalent with CY[0.5]

MX

Maintain aspect on x axis

Preserves the X/CXParent ratio

MY

Maintain aspect on y axis

Preserves the Y/CYParent ratio

MCX

Maintain aspect on the width

Preserves the CX/CXParent ratio

MCY

Maintain aspect on the height

Preserves the CY/CYParent ratio

Note:

To add the constraints at design time directly in resource editor you' ll gonna surround the controls sharing the same constraint options with invisible group boxes having the caption in the form " $Geometry:Option1[value]+Option2[value]+Â…" w/o the quotes. Please note the $Geometry in front of the options string, this is not optional. Be careful with the capital/minor letters as they have different significance. Using this form of constraints specification you don't need DECLARE_GEOMETRY_RTSUPPORT() and AddConstraint() as previously displayed.

Using the second constructor you will specify the values between 0 and 1 that will be multiplied with the total resize amount of

Author: Eugen Paval

Read article at Internet.com site

Featured Local Company

Epicor Software

502-339-7748
8700 Westport RD
Louisville, KY

Related Articles
- Learning PHP: Installing and Configuring Kentucky
Before you can begin programming with PHP, you must first install and configure it on your system. In this second article of the Learning PHP series, Liz Fulghum teaches you how.
- Creating an App using JScript .NET and Windows Forms Kentucky
- Language Essentials for Experienced Programmers Kentucky
- Programming Microsoft .NET : Web Forms Kentucky
- So You Want to Resize Your Window, Huh? Kentucky
Regional Articles
- Auto repositioning/resizing of child controls (using C++ templates) Ashland KY
- Auto repositioning/resizing of child controls (using C++ templates) Bardstown KY
- Auto repositioning/resizing of child controls (using C++ templates) Bowling Green KY
- Auto repositioning/resizing of child controls (using C++ templates) Campbellsville KY
- Auto repositioning/resizing of child controls (using C++ templates) Corbin KY
- Auto repositioning/resizing of child controls (using C++ templates) Covington KY
- Auto repositioning/resizing of child controls (using C++ templates) Crestwood KY
- Auto repositioning/resizing of child controls (using C++ templates) Cynthiana KY
- Auto repositioning/resizing of child controls (using C++ templates) Elizabethtown KY
- Auto repositioning/resizing of child controls (using C++ templates) Erlanger KY
- Auto repositioning/resizing of child controls (using C++ templates) Florence KY
- Auto repositioning/resizing of child controls (using C++ templates) Fort Campbell KY
- Auto repositioning/resizing of child controls (using C++ templates) Fort Thomas KY
- Auto repositioning/resizing of child controls (using C++ templates) Frankfort KY
- Auto repositioning/resizing of child controls (using C++ templates) Ft Mitchell KY
- Auto repositioning/resizing of child controls (using C++ templates) Georgetown KY
- Auto repositioning/resizing of child controls (using C++ templates) Glasgow KY
- Auto repositioning/resizing of child controls (using C++ templates) Harrodsburg KY
- Auto repositioning/resizing of child controls (using C++ templates) Hazard KY
- Auto repositioning/resizing of child controls (using C++ templates) Henderson KY
- Auto repositioning/resizing of child controls (using C++ templates) Hopkinsville KY
- Auto repositioning/resizing of child controls (using C++ templates) Latonia KY
- Auto repositioning/resizing of child controls (using C++ templates) Leitchfield KY
- Auto repositioning/resizing of child controls (using C++ templates) Lexington KY
- Auto repositioning/resizing of child controls (using C++ templates) London KY
- Auto repositioning/resizing of child controls (using C++ templates) Louisville KY
- Auto repositioning/resizing of child controls (using C++ templates) Madisonville KY
- Auto repositioning/resizing of child controls (using C++ templates) Mayfield KY
- Auto repositioning/resizing of child controls (using C++ templates) Morehead KY
- Auto repositioning/resizing of child controls (using C++ templates) Mount Sterling KY
- Auto repositioning/resizing of child controls (using C++ templates) Murray KY
- Auto repositioning/resizing of child controls (using C++ templates) Newport KY
- Auto repositioning/resizing of child controls (using C++ templates) Nicholasville KY
- Auto repositioning/resizing of child controls (using C++ templates) Owensboro KY
- Auto repositioning/resizing of child controls (using C++ templates) Paducah KY
- Auto repositioning/resizing of child controls (using C++ templates) Pikeville KY
- Auto repositioning/resizing of child controls (using C++ templates) Radcliff KY
- Auto repositioning/resizing of child controls (using C++ templates) Richmond KY
- Auto repositioning/resizing of child controls (using C++ templates) Scottsville KY
- Auto repositioning/resizing of child controls (using C++ templates) Shepherdsville KY
- Auto repositioning/resizing of child controls (using C++ templates) Somerset KY
- Auto repositioning/resizing of child controls (using C++ templates) Versailles KY
- Auto repositioning/resizing of child controls (using C++ templates) Winchester KY
Related Articles
- Learning PHP: Installing and Configuring Kentucky
Before you can begin programming with PHP, you must first install and configure it on your system. In this second article of the Learning PHP series, Liz Fulghum teaches you how.
- Creating an App using JScript .NET and Windows Forms Kentucky
- Language Essentials for Experienced Programmers Kentucky
- Programming Microsoft .NET : Web Forms Kentucky
- So You Want to Resize Your Window, Huh? Kentucky

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML