mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
save window position
svn path=/trunk/; revision=32049
This commit is contained in:
parent
ee02b70f0e
commit
8994a89463
4 changed files with 48 additions and 8 deletions
|
@ -369,6 +369,7 @@ static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
|||
|
||||
case WM_DESTROY:
|
||||
SetWindowLongPtr(Globals.hEdit, GWLP_WNDPROC, (LONG_PTR)Globals.EditProc);
|
||||
SaveSettings();
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
|
@ -547,6 +548,10 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh
|
|||
MSG msg;
|
||||
HACCEL hAccel;
|
||||
WNDCLASSEX wndclass;
|
||||
HMONITOR monitor;
|
||||
MONITORINFO info;
|
||||
INT x, y;
|
||||
|
||||
static const TCHAR className[] = _T("NPClass");
|
||||
static const TCHAR winName[] = _T("Notepad");
|
||||
|
||||
|
@ -574,9 +579,22 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh
|
|||
|
||||
/* Setup windows */
|
||||
|
||||
monitor = MonitorFromRect( &Globals.main_rect, MONITOR_DEFAULTTOPRIMARY );
|
||||
info.cbSize = sizeof(info);
|
||||
GetMonitorInfoW( monitor, &info );
|
||||
|
||||
x = Globals.main_rect.left;
|
||||
y = Globals.main_rect.top;
|
||||
if (Globals.main_rect.left >= info.rcWork.right ||
|
||||
Globals.main_rect.top >= info.rcWork.bottom ||
|
||||
Globals.main_rect.right < info.rcWork.left ||
|
||||
Globals.main_rect.bottom < info.rcWork.top)
|
||||
x = y = CW_USEDEFAULT;
|
||||
|
||||
Globals.hMainWnd =
|
||||
CreateWindow(className, winName, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
|
||||
x, y, Globals.main_rect.right - Globals.main_rect.left,
|
||||
Globals.main_rect.bottom - Globals.main_rect.top,
|
||||
NULL, NULL, Globals.hInstance, NULL);
|
||||
if (!Globals.hMainWnd)
|
||||
{
|
||||
|
@ -606,6 +624,5 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh
|
|||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
SaveSettings();
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef struct
|
|||
|
||||
FINDREPLACE find;
|
||||
WNDPROC EditProc;
|
||||
RECT main_rect;
|
||||
} NOTEPAD_GLOBALS;
|
||||
|
||||
extern NOTEPAD_GLOBALS Globals;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<module name="notepad" type="win32gui" installbase="system32" installname="notepad.exe" unicode="yes">
|
||||
<include base="notepad">.</include>
|
||||
<define name="_WIN32_IE">0x0501</define>
|
||||
<define name="_WIN32_WINNT">0x501</define>
|
||||
<library>kernel32</library>
|
||||
<library>user32</library>
|
||||
<library>gdi32</library>
|
||||
|
|
|
@ -107,6 +107,14 @@ void LoadSettings(void)
|
|||
HKEY hKey = NULL;
|
||||
HFONT hFont;
|
||||
DWORD dwPointSize = 0;
|
||||
INT base_length, dx, dy;
|
||||
|
||||
base_length = (GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN))?
|
||||
GetSystemMetrics(SM_CYSCREEN) : GetSystemMetrics(SM_CXSCREEN);
|
||||
|
||||
dx = base_length * .95;
|
||||
dy = dx * 3 / 4;
|
||||
SetRect( &Globals.main_rect, 0, 0, dx, dy );
|
||||
|
||||
if (RegOpenKey(HKEY_CURRENT_USER, s_szRegistryKey, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -126,6 +134,14 @@ void LoadSettings(void)
|
|||
QueryBool(hKey, _T("fWrap"), &Globals.bWrapLongLines);
|
||||
QueryBool(hKey, _T("fStatusBar"), &Globals.bShowStatusBar);
|
||||
|
||||
QueryByte(hKey, _T("iWindowPosX"), (LPBYTE)&Globals.main_rect.left);
|
||||
QueryByte(hKey, _T("iWindowPosX"), (LPBYTE)&Globals.main_rect.top);
|
||||
QueryByte(hKey, _T("iWindowPosDX"), (LPBYTE)&dx);
|
||||
QueryByte(hKey, _T("iWindowPosDY"), (LPBYTE)&dy);
|
||||
|
||||
Globals.main_rect.right = Globals.main_rect.left + dx;
|
||||
Globals.main_rect.bottom = Globals.main_rect.top + dy;
|
||||
|
||||
Globals.bShowStatusBar = !Globals.bShowStatusBar; /* invert value becuase DIALOG_ViewStatusBar will be called to show it*/
|
||||
|
||||
if (dwPointSize != 0)
|
||||
|
@ -158,6 +174,8 @@ void SaveSettings(void)
|
|||
HKEY hKey;
|
||||
DWORD dwDisposition;
|
||||
|
||||
GetWindowRect(Globals.hMainWnd, &Globals.main_rect);
|
||||
|
||||
if (RegCreateKeyEx(HKEY_CURRENT_USER, s_szRegistryKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition)
|
||||
== ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -176,7 +194,10 @@ void SaveSettings(void)
|
|||
SaveDword(hKey, _T("iPointSize"), PointSizeFromHeight(Globals.lfFont.lfHeight));
|
||||
SaveDword(hKey, _T("fWrap"), Globals.bWrapLongLines ? 1 : 0);
|
||||
SaveDword(hKey, _T("fStatusBar"), Globals.bShowStatusBar ? 1 : 0);
|
||||
|
||||
SaveDword(hKey, _T("iWindowPosX"), Globals.main_rect.left);
|
||||
SaveDword(hKey, _T("iWindowPosY"), Globals.main_rect.top);
|
||||
SaveDword(hKey, _T("iWindowPosDX"), Globals.main_rect.right - Globals.main_rect.left);
|
||||
SaveDword(hKey, _T("iWindowPosDY"), Globals.main_rect.bottom - Globals.main_rect.top);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue