Solved

Save and restore the views within an application

Posted on 2002-05-10
2
179 Views
Last Modified: 2013-11-20
I have an application with several documents and each document is associated to several different views. During the execution, user always arranges the views in a specific way in the main frame. How could I save this configuration when it is closed and restores it when it is started, so as to minimized the user´s.

I´d appreciate your help, thanks.
0
Comment
Question by:mauling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
mblat earned 100 total points
ID: 7002544
Store type and location of the views in registry.

Look at calls:

SetRegistryKey
WriteProfileInt
WriteProfileString
ReadProfileInt
ReadProfileString


etc....

Then when app. is coming up read it and here you go....


Hope it helps...
0
 
LVL 37

Expert Comment

by:zzynx
ID: 7005985
Hi mauling,

I store in the registry (or ini file) per view
the name, Z-order, Left, Top, width, height, maximized (or not), the zooming factor (maybe you don't need that), position of vertical en horizontal scrollbars.

I store this info in the key HKEY_CURRENT_USER\Software\<My company name>\doc:<the doc name>

And indeed I use the functions like mblat mentioned.

Don't forget to delete the corresponding settings if a document is deleted.
Don't forget to 'rename' the key (=delete and add a new one) when the document is renamed. (doc:Doc1 to doc:Doc1Renamed)

I use a class for it: (read map as doc)

class CMapSettings
{
public:
  CMapSettings(); // default constructor
  ~CMapSettings(); // default destructor

  void SetName(LPCTSTR strName)  { m_strName = strName; }
  void SetZOrder(int iZOrder)    { m_iZOrder = iZOrder; }
  void SetLeft(int iLeft)        { m_iLeft = iLeft; }
  void SetTop(int iTop)          { m_iTop = iTop; }
  void SetWidth(int iWidth)      { m_iWidth = iWidth; }
  void SetHeight(int iHeight)    { m_iHeight = iHeight; }
  void SetMaximized(int iMax)    { m_iMaximized = iMax; }
  void SetZoom(int iZoom)        { m_iZoom = iZoom; }
  void SetScrollPosX(int iPos)   { m_iScrollPosX = iPos; }
  void SetScrollPosY(int iPos)   { m_iScrollPosY = iPos; }

  int  GetLeft(void) { return m_iLeft; }
  int  GetTop(void) { return m_iTop; }
  int  GetWidth(void) { return m_iWidth; }
  int  GetHeight(void) { return m_iHeight; }
  int  GetZOrder(void) { return m_iZOrder; }

  void WriteMapSettings(BOOL bForce=FALSE);
  void ReadMapSettings(void);
  void ApplyMapSettings(void);
  void DeleteMapSettings(void);
  void RenameMapSettings(LPCTSTR strOldName, LPCTSTR strNewName);

protected:
// data members
  CString m_strName;
  int m_iZOrder;
  int m_iLeft;
  int m_iTop;
  int m_iWidth;
  int m_iHeight;
  int m_iMaximized; // 1=TRUE, 0=FALSE
  int m_iZoom; // Zoom factor
  int m_iScrollPosX;
  int m_iScrollPosY;
};

Success.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question