Click here to Skip to main content
15,850,921 members
Articles / Desktop Programming / MFC

Control Positioner -- Repostion your child windows without code change

Rate me:
Please Sign up or sign in to vote.
3.00/5 (7 votes)
24 Jun 2003 77.5K   1.9K   28   7
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


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

How to use it:

  1. Include header CtrlPositioner.h in your Dialog/Main window code.
  2. In OnInitDialog add:
    CCtrlPositioner poser;
    //Add the control you wish to control
     //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.


  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 :-(
  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?


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

Written By
Software Developer (Senior)
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? Pin
andyj11525-Jun-03 5:46
andyj11525-Jun-03 5:46 
AnswerRe: ideas? Pin
Ziming25-Jun-03 5:55
Ziming25-Jun-03 5:55 
GeneralRe: ideas? Pin
TW25-Jun-03 6:50
TW25-Jun-03 6:50 
Consider ::CreateDialog, ::CreateDialogIndirect etc dialog creation API. If you design a dynamic dialog manipulation framework with Model/View/Controller pattern, use of XML becomes obvious.

Of course, if your intention is only simple INI with control position, the suggestion means nothing to you. Smile | :)
GeneralRe: ideas? Pin
Ziming25-Jun-03 7:00
Ziming25-Jun-03 7:00 
GeneralRe: ideas? Pin
TW26-Jun-03 1:36
TW26-Jun-03 1:36 
GeneralRe: ideas? Pin
andyj11525-Jun-03 8:45
andyj11525-Jun-03 8:45 
GeneralRe: ideas? Pin
Ziming25-Jun-03 22:59
Ziming25-Jun-03 22:59 

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.