相关结构:WINDOWPLACEMENT
原型:typedef struct tagWINDOWPLACEMENT {
UINT length;
UINT flags;
UINT showCmd;
POINT ptMinPosition;
POINT ptMaxPosition;
RECT rcNormalPosition;
#ifdef _MAC
RECT rcDevice;
#endif
} WINDOWPLACEMENT;
typedef WINDOWPLACEMENT *PWINDOWPLACEMENT, *LPWINDOWPLACEMENT;
MSDN描述:The WINDOWPLACEMENT structure contains information about the placement of a window on the screen. 这个结构记录了窗口在显示器上的位置信息。
元素详情请查阅MSDN。
相关函数:BOOL CWindow::GetWindowPlacement(WINDOWPLACEMENT *);
MSDN描述:Retrieves the show state and positions. 检索窗口的显示状态和位置。
相关函数:BOOL CWindow::SetWindowPlacement(WINDOWPLACEMENT *);
MSDN描述:Sets the show state and positions. 设置窗口的显示状态和位置。
相关函数:LONG WINAPI RegOpenKeyEx( __in HKEY , __in_opt LPCTSTR , __reserved DWORD , __in REGSAM , __out PHKEY );
MSDN描述:Opens the specified registry key. Note that key names are not case sensitive. 打开指定注册表项。名称大小写不敏感。
相关函数:LONG WINAPI RegCreateKeyEx( __in HKEY, __in LPCTSTR , __reserved DWORD , __in_opt LPTSTR , __in DWORD , __in REGSAM , __in_opt LPSECURITY_ATTRIBUTES , __out PHKEY , __out_opt LPDWORD );
MSDN描述:Creates the specified registry key. If the key already exists, the function opens it. Note that key names are not case sensitive.创建指定注册表项。如果该注册表项已存在,则打开。名称大小写不敏感。
相关函数:LONG WINAPI RegSetValueEx( __in HKEY , __in_opt LPCTSTR , __reserved DWORD , __in DWORD , __in_opt const BYTE* , __in DWORD );
MSDN描述:Sets the data and type of a specified value under a registry key.在注册表项下设置键的类型和值。
相关函数:LONG WINAPI RegQueryValueEx( __in HKEY , __in_opt LPCTSTR , __reserved LPDWORD , __out_opt LPDWORD , __out_opt LPBYTE , __inout_opt LPDWORD );
MSDN描述:Retrieves the type and data for the specified value name associated with an open registry key. 通过指定注册表项键名获得其键类型和值。
函数参数详情请查阅MSDN。
本文思路是改写程序关闭函数OnClose(),在内添加读取窗口位置、将窗口位置写入注册表的代码;在程序InitInstance()方法中,在主窗口显示之前读取注册表中的窗口位置数据,将改变窗口位置,然后DoModel显示窗口。