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
Solved

Save and restore the views within an application

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 66
Host to IP 7 80
either24  challenge 19 101
My project did see openJDK that I installed. What could be the problem 7 152
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.

828 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