Solved

Save and restore the views within an application

Posted on 2002-05-10
2
174 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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

12 Experts available now in Live!

Get 1:1 Help Now