Solved

Save and restore the views within an application

Posted on 2002-05-10
2
175 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now