The Code Project View our sponsorsGet your new domain name now!Advertise on the CodeProject
Home >> The Windows Template Library >> Unedited Reader Contributions

Saving and restoring window appearance in WTL
By Magomed Abdurakhmanov

Simple, but useful classes to save/restore window appearance 
 Beginner
 VC6, Win95-98, NT4, W2K, ATL, WTL
 Posted 30 May 2001
 Updated 3 Jun 2001
Articles by this author
Send to a friend
Printer friendly version
[This is an unedited reader contribution] [Modify this article] [Delete this article]
Lounge New Articles Sign in Forums Contribute
Broken links? Email us!
9 users have rated this article. result:
4.33 out of 5.

Overview

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);
else
   wndMain.ShowWindow(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"))
  rs.ApplyTo(rbc);

5. Save window and rebar settings to registry by adding the following code to the OnDestroy method of the frame class:

CWindowSettings ws;
ws.GetFrom(*this);
ws.Save("Software\\WTLApps\\DemoApp", "MainFrame");

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

Also you can save/restore splitter position using CSplitterSettings class

[Top] Sign in to vote for this article:     PoorExcellent  
Hint: For improved responsiveness, use Internet Explorer 4 (or above) with Javascript enabled, choose 'Use DHTML' from the View dropdown and hit 'Set Options'.
 Keyword Filter
 View   Per page   Messages since
New threadMessages 1 to 9 of 9 (Total: 9)First Prev Next Last
Subject 
Author 
Date 
  How about..
Terry Denham 18:22 30 May 01 
  Re: How about..
Magomed G. Abdurakhmanov 4:32 31 May 01 
  Re: How about..
Terry Denham 12:00 31 May 01 
  Re: How about..
James Pullicino 4:31 4 Jun 01 
  Suggestions
Maximilian Hänel 13:56 30 May 01 
  Re: Suggestions
Magomed G. Abdurakhmanov 4:38 31 May 01 
  Re: Suggestions
Philippe Mori 10:08 31 May 01 
  Re: Suggestions
Magomed Abdurakhmanov 11:56 1 Jun 01 
  Re: Suggestions
Maximilian Hänel 18:16 2 Jun 01 
Last Visit: 12:00 Friday 1st January, 1999First Prev Next Last

Home >> The Windows Template Library >> Unedited Reader Contributions
last updated 3 Jun 2001
Article content copyright Magomed Abdurakhmanov, 2001
everything else © CodeProject, 1999-2001.
The Code Project View our sponsorsGet the power of C++ with the ease of VBAdvertise on the CodeProject