Click here to Skip to main content
6,628,952 members and growing! (24,096 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » WTL » General     Intermediate

Saving and restoring window appearance in WTL

By Magomed Abdurakhmanov

Simple, but useful classes to save/restore window appearance
VC6Win2K, ATL, WTL, Dev
Posted:29 May 2001
Updated:27 Jun 2001
Views:63,930
Bookmarked:21 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
20 votes for this article.
Popularity: 5.83 Rating: 4.48 out of 5

1

2

3
1 vote, 14.3%
4
6 votes, 85.7%
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

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

About the Author

Magomed Abdurakhmanov


Member

Occupation: Web Developer
Location: Russian Federation Russian Federation

Other popular WTL articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 14 of 14 (Total in Forum: 14) (Refresh)FirstPrevNext
GeneralSmall adjustment to CreateEx when using splitter bars PinmemberJonathan Davies7:00 16 Mar '09  
GeneralRe: Small adjustment to CreateEx when using splitter bars PinmemberMagomed Abdurakhmanov0:50 17 Mar '09  
GeneralRe: Small adjustment to CreateEx when using splitter bars PinmemberJonathan Davies3:48 17 Mar '09  
GeneralThis is really good Pinmemberbeaverdown11:58 10 Mar '04  
GeneralAnother suggestion Pinsupporteryarp6:11 4 Jun '03  
GeneralHow about.. PinmemberTerry Denham13:22 30 May '01  
GeneralRe: How about.. PinmemberMagomed G. Abdurakhmanov23:32 30 May '01  
GeneralRe: How about.. PinmemberTerry Denham7:00 31 May '01  
GeneralRe: How about.. PinmemberJames Pullicino23:31 3 Jun '01  
GeneralSuggestions PinmemberMaximilian Hänel8:56 30 May '01  
GeneralRe: Suggestions PinmemberMagomed G. Abdurakhmanov23:38 30 May '01  
GeneralRe: Suggestions PinmemberPhilippe Mori5:08 31 May '01  
GeneralRe: Suggestions PinmemberMagomed Abdurakhmanov6:56 1 Jun '01  
GeneralRe: Suggestions PinmemberMaximilian Hänel13:16 2 Jun '01  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Jun 2001
Editor: Nishant Sivakumar
Copyright 2001 by Magomed Abdurakhmanov
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project