mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 09:46:21 +00:00
[CHARMAP]
* Implement LoadSettings() and SaveSettings(). Patch by Edijs Kolesnikovics with some minor changes by me. See issue #6925 for more details. svn path=/trunk/; revision=56382
This commit is contained in:
parent
ca75cf2a0d
commit
88e4b7735f
4 changed files with 156 additions and 8 deletions
|
@ -6,13 +6,14 @@ list(APPEND SOURCE
|
||||||
charmap.c
|
charmap.c
|
||||||
lrgcell.c
|
lrgcell.c
|
||||||
map.c
|
map.c
|
||||||
|
settings.c
|
||||||
charmap.rc)
|
charmap.rc)
|
||||||
|
|
||||||
add_executable(charmap ${SOURCE})
|
add_executable(charmap ${SOURCE})
|
||||||
|
|
||||||
set_module_type(charmap win32gui UNICODE)
|
set_module_type(charmap win32gui UNICODE)
|
||||||
|
|
||||||
add_importlibs(charmap msvcrt user32 gdi32 comctl32 kernel32)
|
add_importlibs(charmap advapi32 user32 gdi32 comctl32 msvcrt kernel32)
|
||||||
|
|
||||||
add_pch(charmap precomp.h)
|
add_pch(charmap precomp.h)
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,11 @@
|
||||||
|
|
||||||
#define ID_ABOUT 0x1
|
#define ID_ABOUT 0x1
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
BOOL IsAdvancedView;
|
|
||||||
} SETTINGS;
|
|
||||||
|
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
HWND hCharmapDlg;
|
|
||||||
HWND hAdvancedDlg;
|
HWND hAdvancedDlg;
|
||||||
HWND hStatusWnd;
|
HWND hStatusWnd;
|
||||||
HICON hSmIcon;
|
HICON hSmIcon;
|
||||||
HICON hBgIcon;
|
HICON hBgIcon;
|
||||||
SETTINGS Settings;
|
|
||||||
|
|
||||||
/* Font-enumeration callback */
|
/* Font-enumeration callback */
|
||||||
static
|
static
|
||||||
|
@ -103,7 +97,7 @@ FillFontStyleComboList(HWND hwndCombo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
extern
|
||||||
VOID
|
VOID
|
||||||
ChangeMapFont(HWND hDlg)
|
ChangeMapFont(HWND hDlg)
|
||||||
{
|
{
|
||||||
|
@ -464,6 +458,7 @@ PanelWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
|
SaveSettings();
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -534,6 +529,7 @@ InitInstance(HINSTANCE hInst)
|
||||||
|
|
||||||
if (hWnd != NULL)
|
if (hWnd != NULL)
|
||||||
{
|
{
|
||||||
|
LoadSettings();
|
||||||
ShowWindow(hWnd, SW_SHOW);
|
ShowWindow(hWnd, SW_SHOW);
|
||||||
UpdateWindow(hWnd);
|
UpdateWindow(hWnd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
@ -51,6 +53,12 @@ typedef struct {
|
||||||
WCHAR ch;
|
WCHAR ch;
|
||||||
} MAPNOTIFY, *LPMAPNOTIFY;
|
} MAPNOTIFY, *LPMAPNOTIFY;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BOOL IsAdvancedView;
|
||||||
|
} SETTINGS;
|
||||||
|
|
||||||
|
SETTINGS Settings;
|
||||||
|
HWND hCharmapDlg;
|
||||||
|
|
||||||
LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
@ -59,4 +67,11 @@ VOID ShowAboutDlg(HWND hWndParent);
|
||||||
BOOL RegisterMapClasses(HINSTANCE hInstance);
|
BOOL RegisterMapClasses(HINSTANCE hInstance);
|
||||||
VOID UnregisterMapClasses(HINSTANCE hInstance);
|
VOID UnregisterMapClasses(HINSTANCE hInstance);
|
||||||
|
|
||||||
|
/* charmap.c */
|
||||||
|
extern VOID ChangeMapFont(HWND hDlg);
|
||||||
|
|
||||||
|
/* settings.c */
|
||||||
|
extern void LoadSettings(void);
|
||||||
|
extern void SaveSettings(void);
|
||||||
|
|
||||||
#endif /* __CHARMAP_PRECOMP_H */
|
#endif /* __CHARMAP_PRECOMP_H */
|
||||||
|
|
136
reactos/base/applications/charmap/settings.c
Normal file
136
reactos/base/applications/charmap/settings.c
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Character Map
|
||||||
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* FILE: base/applications/charmap/settings.c
|
||||||
|
* PURPOSE: save/load settings
|
||||||
|
* COPYRIGHT: Copyright 2012 Edijs Kolesnikovics <terminedijs@yahoo.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <precomp.h>
|
||||||
|
|
||||||
|
|
||||||
|
const TCHAR g_szGeneralRegKey[] = _T("Software\\Microsoft\\CharMap");
|
||||||
|
HWND hWnd;
|
||||||
|
|
||||||
|
LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
|
||||||
|
{
|
||||||
|
LONG lResult;
|
||||||
|
HKEY hSubKey = NULL;
|
||||||
|
DWORD cbData, dwType;
|
||||||
|
|
||||||
|
if (lpSubKey)
|
||||||
|
{
|
||||||
|
lResult = RegOpenKey(hKey, lpSubKey, &hSubKey);
|
||||||
|
if (lResult != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
hKey = hSubKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
cbData = (dwBufferLen - 1) * sizeof(*pszBuffer);
|
||||||
|
lResult = RegQueryValueEx(hKey, lpValueName, NULL, &dwType, (LPBYTE) pszBuffer, &cbData);
|
||||||
|
if (lResult != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
if (dwType != REG_SZ)
|
||||||
|
{
|
||||||
|
lResult = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
pszBuffer[cbData / sizeof(*pszBuffer)] = _T('\0');
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (lResult != ERROR_SUCCESS)
|
||||||
|
pszBuffer[0] = _T('\0');
|
||||||
|
if (hSubKey)
|
||||||
|
RegCloseKey(hSubKey);
|
||||||
|
return lResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void LoadSettings(void)
|
||||||
|
{
|
||||||
|
HKEY hKey = NULL;
|
||||||
|
int iItemIndex = -1;
|
||||||
|
|
||||||
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, g_szGeneralRegKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
TCHAR szBuffer[MAX_PATH];
|
||||||
|
DWORD dwAdvanChecked;
|
||||||
|
unsigned long type = REG_DWORD, size = 1024;
|
||||||
|
|
||||||
|
/* Restore last selected font */
|
||||||
|
if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("Font"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
//Get combobox handle
|
||||||
|
hWnd = GetDlgItem(hCharmapDlg, IDC_FONTCOMBO);
|
||||||
|
|
||||||
|
//Search for match and return index if match found
|
||||||
|
iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
|
||||||
|
if(iItemIndex != CB_ERR)
|
||||||
|
{
|
||||||
|
ComboBox_SetCurSel(hWnd, iItemIndex);
|
||||||
|
ChangeMapFont(hCharmapDlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Restore last selected character set */
|
||||||
|
if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("CodePage"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
//Get combobox handle
|
||||||
|
hWnd = GetDlgItem(hCharmapDlg, IDC_COMBO_CHARSET);
|
||||||
|
|
||||||
|
iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
|
||||||
|
if(iItemIndex != CB_ERR)
|
||||||
|
{
|
||||||
|
ComboBox_SetCurSel(hWnd, iItemIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegQueryValueEx(hKey, _T("Advanced"), NULL, &type, (LPBYTE)&dwAdvanChecked, &size);
|
||||||
|
if(dwAdvanChecked == TRUE)
|
||||||
|
SendDlgItemMessage(hCharmapDlg, IDC_CHECK_ADVANCED, BM_CLICK, (dwAdvanChecked ? MF_CHECKED : MF_UNCHECKED), 0);
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Default font seems to be Arial */
|
||||||
|
hWnd = GetDlgItem(hCharmapDlg, IDC_FONTCOMBO);
|
||||||
|
|
||||||
|
iItemIndex = ComboBox_FindStringExact(hWnd, -1, _T("Arial"));
|
||||||
|
if(iItemIndex != CB_ERR)
|
||||||
|
{
|
||||||
|
ComboBox_SetCurSel(hWnd, iItemIndex);
|
||||||
|
ChangeMapFont(hCharmapDlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SaveSettings(void)
|
||||||
|
{
|
||||||
|
HKEY hKey = NULL;
|
||||||
|
|
||||||
|
if (RegCreateKey(HKEY_CURRENT_USER, g_szGeneralRegKey, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, g_szGeneralRegKey, 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
TCHAR szBuffer[MAX_PATH];
|
||||||
|
|
||||||
|
hWnd = GetDlgItem(hCharmapDlg, IDC_FONTCOMBO);
|
||||||
|
ComboBox_GetText(hWnd, szBuffer, MAX_PATH);
|
||||||
|
|
||||||
|
if(szBuffer != NULL && *szBuffer != '\0')
|
||||||
|
RegSetValueEx(hKey, _T("Font"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) MAX_PATH);
|
||||||
|
|
||||||
|
hWnd = GetDlgItem(hCharmapDlg, IDC_COMBO_CHARSET);
|
||||||
|
ComboBox_GetText(hWnd, szBuffer, MAX_PATH);
|
||||||
|
|
||||||
|
if(szBuffer != NULL && *szBuffer != '\0')
|
||||||
|
RegSetValueEx(hKey, _T("CodePage"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) MAX_PATH);
|
||||||
|
|
||||||
|
RegSetValueEx(hKey, _T("Advanced"), 0, REG_DWORD, (LPBYTE)&Settings.IsAdvancedView, (DWORD) sizeof(DWORD));
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue