Author: cwittich Date: Wed Jan 30 12:25:54 2008 New Revision: 32049
URL: http://svn.reactos.org/svn/reactos?rev=32049&view=rev Log: save window position
Modified: trunk/reactos/base/applications/notepad/main.c trunk/reactos/base/applications/notepad/main.h trunk/reactos/base/applications/notepad/notepad.rbuild trunk/reactos/base/applications/notepad/settings.c
Modified: trunk/reactos/base/applications/notepad/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/notepad/m... ============================================================================== --- trunk/reactos/base/applications/notepad/main.c (original) +++ trunk/reactos/base/applications/notepad/main.c Wed Jan 30 12:25:54 2008 @@ -355,8 +355,8 @@
case WM_CLOSE: if (DoCloseFile()) { - if (Globals.hFont) - DeleteObject(Globals.hFont); + if (Globals.hFont) + DeleteObject(Globals.hFont); DestroyWindow(hWnd); } break; @@ -369,6 +369,7 @@
case WM_DESTROY: SetWindowLongPtr(Globals.hEdit, GWLP_WNDPROC, (LONG_PTR)Globals.EditProc); + SaveSettings(); PostQuitMessage(0); break;
@@ -544,9 +545,13 @@ */ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show) { - MSG msg; - HACCEL hAccel; - WNDCLASSEX wndclass; + 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 @@
/* 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 @@ DispatchMessage(&msg); } } - SaveSettings(); return (int) msg.wParam; }
Modified: trunk/reactos/base/applications/notepad/main.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/notepad/m... ============================================================================== --- trunk/reactos/base/applications/notepad/main.h (original) +++ trunk/reactos/base/applications/notepad/main.h Wed Jan 30 12:25:54 2008 @@ -68,6 +68,7 @@
FINDREPLACE find; WNDPROC EditProc; + RECT main_rect; } NOTEPAD_GLOBALS;
extern NOTEPAD_GLOBALS Globals;
Modified: trunk/reactos/base/applications/notepad/notepad.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/notepad/n... ============================================================================== --- trunk/reactos/base/applications/notepad/notepad.rbuild (original) +++ trunk/reactos/base/applications/notepad/notepad.rbuild Wed Jan 30 12:25:54 2008 @@ -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>
Modified: trunk/reactos/base/applications/notepad/settings.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/notepad/s... ============================================================================== --- trunk/reactos/base/applications/notepad/settings.c (original) +++ trunk/reactos/base/applications/notepad/settings.c Wed Jan 30 12:25:54 2008 @@ -107,6 +107,14 @@ 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 @@ 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) @@ -157,6 +173,8 @@ { 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 @@ 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); }