Click here to Skip to main content
15,173,646 members
Articles / Desktop Programming / WTL
Posted 29 May 2001


24 bookmarked

Saving and restoring window appearance in WTL

Rate me:
Please Sign up or sign in to vote.
4.71/5 (9 votes)
27 Jun 2001
Simple, but useful classes to save/restore window appearance


Now you can use simple classes CWindowSettings, CReBarSettings, CSplitterSettings with your WTL projects to quickly save/restore window appearance (size, position). Settings are saved in registry. Additional properties saved for ReBar Control including bands sequence and position. So your window will appear next time when opened as user customized him.

How to use these classes in your WTL App

  1. Add two files RegSettings.h and RegSettings.cpp to your project.
  2. Add the header file RegSettings.h to the Frame or Window source code that will be using the classes.
  3. Load window settings from registry by adding the following code to the method that shows the window (the global Run function for a main frame):

    CWindowSettings ws;
    if(ws.Load("Software\\WTLApps\\DemoApp", "MainFrame"))
       ws.ApplyTo(wndMain, nCmdShow);
  4. Load rebar settings from registry by adding the following code to the OnCreate method of the frame class:

    CReBarSettings rs;
    CReBarCtrl rbc = m_hWndToolBar;
    if(rs.Load("Software\\WTLApps\\DemoApp", "ReBar"))
  5. Save window and rebar settings to registry by adding the following code to the OnDestroy method of the frame class:

    CWindowSettings ws;
    ws.Save("Software\\WTLApps\\DemoApp", "MainFrame");
    CReBarSettings rs;
    CReBarCtrl rbc = m_hWndToolBar;
    rs.Save("Software\\WTLApps\\DemoApp", "ReBar");

    Also you can save/restore splitter position using CSplitterSettings class


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


About the Author

Magomed Abdurakhmanov
Web Developer
Russian Federation Russian Federation
No Biography provided

Comments and Discussions

GeneralSmall adjustment to CreateEx when using splitter bars Pin
Jonathan Davies16-Mar-09 7:00
MemberJonathan Davies16-Mar-09 7:00 
GeneralRe: Small adjustment to CreateEx when using splitter bars Pin
Magomed Abdurakhmanov17-Mar-09 0:50
MemberMagomed Abdurakhmanov17-Mar-09 0:50 
GeneralRe: Small adjustment to CreateEx when using splitter bars Pin
Jonathan Davies17-Mar-09 3:48
MemberJonathan Davies17-Mar-09 3:48 
GeneralThis is really good Pin
beaverdown10-Mar-04 11:58
Memberbeaverdown10-Mar-04 11:58 
GeneralAnother suggestion Pin
yarp4-Jun-03 6:11
Memberyarp4-Jun-03 6:11 
QuestionHow about.. Pin
30-May-01 13:22
suss30-May-01 13:22 
AnswerRe: How about.. Pin
Magomed Abdurakhmanov30-May-01 23:32
MemberMagomed Abdurakhmanov30-May-01 23:32 
GeneralRe: How about.. Pin
31-May-01 7:00
suss31-May-01 7:00 
GeneralRe: How about.. Pin
[James Pullicino]3-Jun-01 23:31
Member[James Pullicino]3-Jun-01 23:31 
GeneralSuggestions Pin
Maximilian Hänel30-May-01 8:56
MemberMaximilian Hänel30-May-01 8:56 
GeneralRe: Suggestions Pin
Magomed Abdurakhmanov30-May-01 23:38
MemberMagomed Abdurakhmanov30-May-01 23:38 
Thanks a lot. I will correct these problems.Blush | :O

Magomed G. Abdurakhmanov
GeneralRe: Suggestions Pin
Philippe Mori31-May-01 5:08
MemberPhilippe Mori31-May-01 5:08 
GeneralRe: Suggestions Pin
Magomed Abdurakhmanov1-Jun-01 6:56
MemberMagomed Abdurakhmanov1-Jun-01 6:56 
GeneralRe: Suggestions Pin
Maximilian Hänel2-Jun-01 13:16
MemberMaximilian Hänel2-Jun-01 13:16 

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.