相關結構: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顯示窗口。