Solved

Save and restore the views within an application

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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