Click here to Skip to main content
15,885,244 members
Articles / Desktop Programming / WTL

Saving and restoring window appearance in WTL

Rate me:
Please Sign up or sign in to vote.
4.71/5 (9 votes)
27 Jun 2001 99K   1.4K   24  
Simple, but useful classes to save/restore window appearance
// RegSettings.h
//
// Copyright (c) 2001 Magomed Abdurakhmanov
// maq@hotbox.ru, http://mickels.iwt.ru/en
//
//
//
// No warranties are given. Use at your own risk.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_REGSETTINGS_H__91E69C67_8104_4819_969A_B5E71A9993D5__INCLUDED_)
#define AFX_REGSETTINGS_H__91E69C67_8104_4819_969A_B5E71A9993D5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <AtlMisc.h>
#include <AtlCtrls.h>

class CWindowSettings
{
public:
	WINDOWPLACEMENT m_WindowPlacement;

	CWindowSettings();
	void GetFrom(CWindow& Wnd);
	void ApplyTo(CWindow& Wnd, int nCmdShow = SW_SHOWNORMAL)const;

	bool Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER);
	bool Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER)const;
};

class CReBarSettings
{
public:
	struct BandInfo
	{
		DWORD ID;
		DWORD cx;
		bool BreakLine;
	}* m_pBands;

	DWORD m_cbBandCount;

	CReBarSettings();
	~CReBarSettings();

	void GetFrom(CReBarCtrl& ReBar);
	void ApplyTo(CReBarCtrl& ReBar)const;

	bool Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER);
	bool Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER)const;
};

class CSplitterSettings
{
public:
	DWORD m_dwPos;

	template <class T> void GetFrom(const T& Splitter)
	{
		m_dwPos = Splitter.GetSplitterPos();
	}

	template <class T> void ApplyTo(T& Splitter)const
	{
		Splitter.SetSplitterPos(m_dwPos);
	}

	bool Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER);
	bool Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER)const;
};

#endif // !defined(AFX_REGSETTINGS_H__91E69C67_8104_4819_969A_B5E71A9993D5__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions