Click here to Skip to main content
Click here to Skip to main content
Go to top

Control Positioner -- Repostion your child windows without code change

, 24 Jun 2003
Rate this:
Please Sign up or sign in to vote.
This is a small class for control repositioning. It can create an INI file, which logs all aspects of your control.

Sample Image - Control_Positioner.gif

Introduction

Control Positioner (Control Poser) - This is a small class for control repositioning. It can create an INI file, which logs all aspects of your controls (child windows). e.g.:

  1. Enable
  2. Visibility
  3. Default value (checked or text title)
  4. Size and screen position

So when you want to change them, you just update this INI file instead of recompiling your code. Sometimes it helps to create a highly flexible user interface, especially useful when the customer doesn't know what they want or your requirement manager has a really changing personality Smile | :)

How to use it:

  1. Include header CtrlPositioner.h in your Dialog/Main window code.
  2. In OnInitDialog add:
    CCtrlPositioner poser;
     poser.SetDlg(this); 
    //Add the control you wish to control
     poser.AddCtrl(IDC_STATIC); 
     poser.AddCtrl(IDC_CHECK1);
     poser.AddCtrl(IDC_EDIT1);
     poser.AddCtrl(IDC_BUTTON1); 
     //poser.SavePosData(); //This creates an ini file for you first time,
                           //so latter you can just change the file.
                          //This line should be commented 
                         //out after you got the file
    poser.ReadPosData(); //Read Position from ini file
    //Organize control regarding your ini definition.
    poser.PositionControls(); 

Notes:

  1. INI file is called CtrlPos.ini, this can be changed easily in CtrlPositioner.cpp.
  2. This class should also work with other parent windows besides CDialog, although I never tested it Frown | :-(
  3. Currently parent window's title is used as section name in INI file, it's not good as there could be more windows with the same caption on it. I would like to improve this if you can give me any suggestions?

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

Ziming
Software Developer (Senior) www.wonga.com
Ireland Ireland
I have over 13 Years IT industry experience as Principle/Senior Programmer. I am experienced in .NET/J2EE system design and detailed implementation. I master UML modelling and OO design methodology with a strong C#/C++/Java coding background. I have been in working/managing a distributed project using Agile/Waterfall approach. My business knowledge includes Telecommunication, Financial Investment/Trading, and Banking.

Comments and Discussions

 
Questionideas? PinmemberJohn A. Johnson25-Jun-03 4:46 
AnswerRe: ideas? PinmemberZiming25-Jun-03 4:55 
GeneralRe: ideas? PinmemberTW25-Jun-03 5:50 
GeneralRe: ideas? PinmemberZiming25-Jun-03 6:00 
GeneralRe: ideas? PinmemberTW26-Jun-03 0:36 
GeneralRe: ideas? PinmemberJohn A. Johnson25-Jun-03 7:45 
GeneralRe: ideas? PinmemberZiming25-Jun-03 21:59 

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
Web04 | 2.8.140922.1 | Last Updated 25 Jun 2003
Article Copyright 2003 by Ziming
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid