From: <kr_...@us...> - 2004-05-07 14:24:05
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10560/src/cbits/Win32 Modified Files: ConfigKey.c Frame.c Internals.h Util.c Log Message: Persist the frame state between sessions Index: ConfigKey.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ConfigKey.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ConfigKey.c 23 Jul 2003 16:25:21 -0000 1.2 --- ConfigKey.c 7 May 2004 14:23:47 -0000 1.3 *************** *** 7,11 **** FrameData *pFrameData; HKEY hSoftwareKey, hAppKey, hKey; ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 7,11 ---- FrameData *pFrameData; HKEY hSoftwareKey, hAppKey, hKey; ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 19,26 **** *s = '\\'; } ! s++; } ! if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_READ, &hSoftwareKey) != ERROR_SUCCESS) return NULL; --- 19,26 ---- *s = '\\'; } ! s++; } ! if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_READ, &hSoftwareKey) != ERROR_SUCCESS) return NULL; *************** *** 39,43 **** RegCloseKey(hAppKey); } ! RegCloseKey(hSoftwareKey); --- 39,43 ---- RegCloseKey(hAppKey); } ! RegCloseKey(hSoftwareKey); *************** *** 50,54 **** DWORD dwType, dwLength; char *szValue, *szValueName; ! hKey = openKey(szName, &szValueName); if (!hKey) --- 50,54 ---- DWORD dwType, dwLength; char *szValue, *szValueName; ! hKey = openKey(szName, &szValueName); if (!hKey) *************** *** 62,78 **** if (dwType != REG_SZ && dwType != REG_EXPAND_SZ) ! { RegCloseKey(hKey); return strdup(defvalue); } ! szValue = malloc(dwLength); if (RegQueryValueEx(hKey, szValueName, NULL, &dwType, szValue, &dwLength) != ERROR_SUCCESS) ! { RegCloseKey(hKey); free(szValue); return strdup(defvalue); } ! RegCloseKey(hKey); return szValue; --- 62,78 ---- if (dwType != REG_SZ && dwType != REG_EXPAND_SZ) ! { RegCloseKey(hKey); return strdup(defvalue); } ! szValue = malloc(dwLength); if (RegQueryValueEx(hKey, szValueName, NULL, &dwType, szValue, &dwLength) != ERROR_SUCCESS) ! { RegCloseKey(hKey); free(szValue); return strdup(defvalue); } ! RegCloseKey(hKey); return szValue; *************** *** 98,102 **** DWORD dwType, dwLength, dwValue; char *szValueName; ! hKey = openKey(szName, &szValueName); if (!hKey) --- 98,102 ---- DWORD dwType, dwLength, dwValue; char *szValueName; ! hKey = openKey(szName, &szValueName); if (!hKey) *************** *** 115,119 **** return defvalue; } ! RegCloseKey(hKey); return dwValue; --- 115,119 ---- return defvalue; } ! RegCloseKey(hKey); return dwValue; *************** *** 140,144 **** char *szValueName; char buffer[64]; ! hKey = openKey(szName, &szValueName); if (!hKey) --- 140,144 ---- char *szValueName; char buffer[64]; ! hKey = openKey(szName, &szValueName); if (!hKey) *************** *** 153,161 **** if (dwType != REG_SZ && dwType != REG_EXPAND_SZ) ! { RegCloseKey(hKey); return defvalue; } ! RegCloseKey(hKey); return atof(buffer); --- 153,161 ---- if (dwType != REG_SZ && dwType != REG_EXPAND_SZ) ! { RegCloseKey(hKey); return defvalue; } ! RegCloseKey(hKey); return atof(buffer); *************** *** 183,187 **** DWORD dwType, dwLength, dwValue; char *szValueName; ! hKey = openKey(szName, &szValueName); if (!hKey) --- 183,187 ---- DWORD dwType, dwLength, dwValue; char *szValueName; ! hKey = openKey(szName, &szValueName); if (!hKey) *************** *** 200,204 **** return defvalue; } ! RegCloseKey(hKey); return (dwValue != 0); --- 200,204 ---- return defvalue; } ! RegCloseKey(hKey); return (dwValue != 0); Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Frame.c 7 May 2004 13:41:09 -0000 1.24 --- Frame.c 7 May 2004 14:23:48 -0000 1.25 *************** *** 6,9 **** --- 6,10 ---- #include "MenuHandlesMap.h" #include "Canvas.h" + #include "ConfigKey.h" #include "Internals.h" #include "Handlers_stub.h" *************** *** 22,25 **** --- 23,60 ---- } + void SaveWindowState(HWND hWnd) + { + char *keyName; + WINDOWPLACEMENT wp; + wp.length = sizeof(wp); + + if (GetWindowPlacement(hWnd, &wp)) + { + if (IsIconic(hWnd)) + // never restore to Iconic state + wp.showCmd = SW_SHOW; + + if ((wp.flags & WPF_RESTORETOMAXIMIZED) != 0) + // if maximized and maybe iconic restore maximized state + wp.showCmd = SW_SHOWMAXIMIZED; + + // and write it to the registry + keyName = strdup("HToolkit.FrameState"); + osSetConfigIntKey(keyName, wp.showCmd); + free(keyName); + } + } + + void RestoreWindowState(HWND hWnd, int nShow) + { + char *keyName; + + keyName = strdup("HToolkit.FrameState"); + nShow = osGetConfigIntKey(keyName, nShow); + free(keyName); + + ShowWindow(hWnd, nShow); + } + LRESULT CALLBACK HFrameSharedFunction(int DocumentInterface, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { *************** *** 33,36 **** --- 68,72 ---- { case WM_CLOSE: + SaveWindowState(hWnd); // save the current window placement to be restored the next time handleProcessDismiss(); return 0; Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Internals.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Internals.h 7 May 2004 12:45:42 -0000 1.20 --- Internals.h 7 May 2004 14:23:48 -0000 1.21 *************** *** 72,74 **** --- 72,77 ---- void DrawCheckListBoxItem(LPDRAWITEMSTRUCT lpDIS); + void SaveWindowState(HWND hWnd); + void RestoreWindowState(HWND hWnd, int nShow); + #endif Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Util.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Util.c 25 Nov 2003 14:12:22 -0000 1.29 --- Util.c 7 May 2004 14:23:48 -0000 1.30 *************** *** 118,122 **** wc.lpszClassName = "HMDIWINDOW"; RegisterClass(&wc); ! // CompoundControl class wc.style = CS_DBLCLKS; --- 118,122 ---- wc.lpszClassName = "HMDIWINDOW"; RegisterClass(&wc); ! // CompoundControl class wc.style = CS_DBLCLKS; *************** *** 131,135 **** wc.lpszClassName = "HCOMPOUND"; RegisterClass(&wc); ! // GroupBox class GetClassInfo(ghModule, "BUTTON", &wc); --- 131,135 ---- wc.lpszClassName = "HCOMPOUND"; RegisterClass(&wc); ! // GroupBox class GetClassInfo(ghModule, "BUTTON", &wc); *************** *** 147,151 **** wc.lpszClassName = "HCHECKLISTBOX"; RegisterClass(&wc); ! // DockBar class wc.style = CS_DBLCLKS; --- 147,151 ---- wc.lpszClassName = "HCHECKLISTBOX"; RegisterClass(&wc); ! // DockBar class wc.style = CS_DBLCLKS; *************** *** 160,164 **** wc.lpszClassName = "HDOCKBAR"; RegisterClass(&wc); ! // ToolBar class (subclass of the standard ToolBar class) GetClassInfo(ghModule, TOOLBARCLASSNAME, &wc); --- 160,164 ---- wc.lpszClassName = "HDOCKBAR"; RegisterClass(&wc); ! // ToolBar class (subclass of the standard ToolBar class) GetClassInfo(ghModule, TOOLBARCLASSNAME, &wc); *************** *** 168,172 **** wc.lpszClassName = "HTOOLBAR"; RegisterClass(&wc); ! // Notebook class (subclass of the standard TabCtrl class) GetClassInfo(ghModule, WC_TABCONTROL, &wc); --- 168,172 ---- wc.lpszClassName = "HTOOLBAR"; RegisterClass(&wc); ! // Notebook class (subclass of the standard TabCtrl class) GetClassInfo(ghModule, WC_TABCONTROL, &wc); *************** *** 176,180 **** wc.lpszClassName = "HNOTEBOOK"; RegisterClass(&wc); ! // NotebookPage class wc.style = CS_DBLCLKS; --- 176,180 ---- wc.lpszClassName = "HNOTEBOOK"; RegisterClass(&wc); ! // NotebookPage class wc.style = CS_DBLCLKS; *************** *** 194,198 **** InitCommonControlsEx(&icc); } ! if (ghWndFrame == NULL) { --- 194,198 ---- InitCommonControlsEx(&icc); } ! if (ghWndFrame == NULL) { *************** *** 223,227 **** ); } ! { // Store appVersion for future usage FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 223,227 ---- ); } ! { // Store appVersion for future usage FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 229,233 **** } ! ShowWindow(ghWndFrame,SW_NORMAL); UpdateWindow(ghWndFrame); } --- 229,233 ---- } ! RestoreWindowState(ghWndFrame, SW_NORMAL); UpdateWindow(ghWndFrame); } *************** *** 259,263 **** MSG msg; FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! while (GetMessage(&msg, NULL, 0, 0) != 0) { --- 259,263 ---- MSG msg; FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! while (GetMessage(&msg, NULL, 0, 0) != 0) { |