Visual C++ 7.1Visual Studio 6Visual C++ 7.0Windows 2003Windows 2000Visual C++ 6.0Windows XPMFCIntermediateDevVisual StudioWindowsC++
Control Positioner -- Repostion your child windows without code change





3.00/5 (7 votes)
Jun 25, 2003

78223

1897
This is a small class for control repositioning. It can create an INI file, which logs all aspects of your control.
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.:
- Enable
- Visibility
- Default value (checked or text title)
- 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:
- Include header CtrlPositioner.h in your Dialog/Main window code.
- 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:
- INI file is called CtrlPos.ini, this can be changed easily in CtrlPositioner.cpp.
- This class should also work with other parent windows besides
CDialog
, although I never tested it :-( - 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?