ReactOS 0.4.15-dev-6663-gd1e9fe1
settings_page.c File Reference
#include "input.h"
#include "layout_list.h"
#include "locale_list.h"
#include "input_list.h"
Include dependency graph for settings_page.c:

Go to the source code of this file.

Functions

static HICON CreateLayoutIcon (LANGID LangID)
 
static VOID InitDefaultLangComboBox (HWND hwndCombo)
 
static VOID SetControlsState (HWND hwndDlg)
 
static BOOL CALLBACK EnumResNameProc (HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
 
static HICON LoadIMEIcon (LPCTSTR pszImeFile)
 
static HTREEITEM FindLanguageInList (HWND hwndList, LPCTSTR pszLangName)
 
static VOID AddToInputListView (HWND hwndList, INPUT_LIST_NODE *pInputNode)
 
static VOID ExpandTreeItem (HWND hwndTree, HTREEITEM hItem)
 
static VOID UpdateInputListView (HWND hwndList)
 
static VOID OnInitSettingsPage (HWND hwndDlg)
 
static VOID OnDestroySettingsPage (HWND hwndDlg)
 
VOID OnCommandSettingsPage (HWND hwndDlg, WPARAM wParam)
 
static BOOL IsRebootNeeded (VOID)
 
BOOL EnableProcessPrivileges (LPCWSTR lpPrivilegeName, BOOL bEnable)
 
static INT_PTR OnNotifySettingsPage (HWND hwndDlg, LPARAM lParam)
 
INT_PTR CALLBACK SettingsPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static INT s_nAliveLeafCount = 0
 
static INT s_nRootCount = 0
 
static INT s_iKeyboardImage = -1
 
static INT s_iDotImage = -1
 
static BOOL s_bDefaultInputChanged = FALSE
 

Function Documentation

◆ AddToInputListView()

static VOID AddToInputListView ( HWND  hwndList,
INPUT_LIST_NODE pInputNode 
)
static

Definition at line 216 of file settings_page.c.

217{
220 HIMAGELIST hImageList = TreeView_GetImageList(hwndList, TVSIL_NORMAL);
221 WCHAR szKeyboard[64];
223 BOOL bBold = !!(pInputNode->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT);
224
225 hItem = FindLanguageInList(hwndList, pInputNode->pLocale->pszName);
226 if (hItem == NULL)
227 {
228 // Language icon
229 INT LangImageIndex = -1;
230 HICON hLangIcon = CreateLayoutIcon(LOWORD(pInputNode->pLocale->dwId));
231 if (hLangIcon)
232 {
233 LangImageIndex = ImageList_AddIcon(hImageList, hLangIcon);
234 DestroyIcon(hLangIcon);
235 }
236
237 // Language
238 ZeroMemory(&item, sizeof(item));
240 item.pszText = pInputNode->pLocale->pszName;
241 item.iImage = LangImageIndex;
242 item.iSelectedImage = LangImageIndex;
243 item.lParam = LOWORD(pInputNode->pLocale->dwId); // HIWORD(item.lParam) == 0
244 if (bBold)
245 {
246 item.state = item.stateMask = TVIS_BOLD;
247 }
248 insert.hParent = TVI_ROOT;
249 insert.hInsertAfter = TVI_LAST;
250 insert.item = item;
251 hItem = TreeView_InsertItem(hwndList, &insert);
252
253 // The type of input method (currently keyboard only)
254 LoadStringW(hApplet, IDS_KEYBOARD, szKeyboard, _countof(szKeyboard));
255 ZeroMemory(&item, sizeof(item));
257 item.pszText = szKeyboard;
258 item.iImage = s_iKeyboardImage;
259 item.iSelectedImage = s_iKeyboardImage;
260 item.lParam = 0; // HIWORD(item.lParam) == 0
261 insert.hParent = hItem;
262 insert.hInsertAfter = TVI_LAST;
263 insert.item = item;
264 hItem = TreeView_InsertItem(hwndList, &insert);
265 }
266 else
267 {
268 // Language
269 ZeroMemory(&item, sizeof(item));
270 item.mask = TVIF_STATE | TVIF_HANDLE;
271 item.hItem = hItem;
272 item.stateMask = TVIS_BOLD;
273 if (TreeView_GetItem(hwndList, &item) && bBold && !(item.state & TVIS_BOLD))
274 {
275 // Make the item bold
276 item.mask = TVIF_STATE | TVIF_HANDLE;
277 item.hItem = hItem;
278 item.state = item.stateMask = TVIS_BOLD;
279 TreeView_SetItem(hwndList, &item);
280 }
281
282 // The type of input method (currently keyboard only)
283 hItem = TreeView_GetChild(hwndList, hItem);
284 }
285
286 // Input method
287 if (hItem)
288 {
289 INT ImeImageIndex = s_iDotImage;
290 if (IS_IME_HKL(pInputNode->hkl) && pInputNode->pLayout->pszImeFile) // IME?
291 {
292 HICON hImeIcon = LoadIMEIcon(pInputNode->pLayout->pszImeFile);
293 if (hImeIcon)
294 {
295 ImeImageIndex = ImageList_AddIcon(hImageList, hImeIcon);
296 DestroyIcon(hImeIcon);
297 }
298 }
299
300 ZeroMemory(&item, sizeof(item));
302 item.pszText = pInputNode->pLayout->pszName;
303 item.iImage = ImeImageIndex;
304 item.iSelectedImage = ImeImageIndex;
305 item.lParam = (LPARAM)pInputNode; // HIWORD(item.lParam) != 0
306 if (bBold)
307 {
308 item.state = item.stateMask = TVIS_BOLD; // Make the item bold
309 }
310 insert.hParent = hItem;
311 insert.hInsertAfter = TVI_LAST;
312 insert.item = item;
313 hItem = TreeView_InsertItem(hwndList, &insert);
314 }
315}
#define NULL
Definition: types.h:112
HINSTANCE hApplet
Definition: access.c:17
#define IDS_KEYBOARD
Definition: resource.h:47
unsigned int BOOL
Definition: ntddk_ex.h:94
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:30
#define IS_IME_HKL(hKL)
Definition: kbswitch.c:32
static HICON
Definition: imagelist.c:84
static ATOM item
Definition: dde.c:856
#define LOWORD(l)
Definition: pedump.c:82
#define TVI_LAST
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3466
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define TVIS_BOLD
Definition: commctrl.h:3283
#define TreeView_GetImageList(hwnd, iImage)
Definition: commctrl.h:3441
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TV_INSERTSTRUCT
Definition: commctrl.h:3377
#define TVI_ROOT
Definition: commctrl.h:3368
#define TV_ITEM
Definition: commctrl.h:3300
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
#define TVIF_STATE
Definition: commctrl.h:3269
static HICON LoadIMEIcon(LPCTSTR pszImeFile)
static INT s_iDotImage
Definition: settings_page.c:17
static INT s_iKeyboardImage
Definition: settings_page.c:16
static HICON CreateLayoutIcon(LANGID LangID)
Definition: settings_page.c:21
static HTREEITEM FindLanguageInList(HWND hwndList, LPCTSTR pszLangName)
#define _countof(array)
Definition: sndvol32.h:68
LAYOUT_LIST_NODE * pLayout
Definition: input_list.h:37
LOCALE_LIST_NODE * pLocale
Definition: input_list.h:36
HTREEITEM hItem
Definition: treelist.h:37
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1700
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
static int insert
Definition: xmllint.c:138
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UpdateInputListView().

◆ CreateLayoutIcon()

static HICON CreateLayoutIcon ( LANGID  LangID)
static

Definition at line 21 of file settings_page.c.

22{
23 WCHAR szBuf[4];
24 HDC hdcScreen, hdc;
25 HBITMAP hbmColor, hbmMono, hBmpOld;
26 HFONT hFont, hFontOld;
27 LOGFONTW lf;
28 RECT rect;
33
34 /* Getting "EN", "FR", etc. from English, French, ... */
37 szBuf,
38 ARRAYSIZE(szBuf)) == 0)
39 {
40 szBuf[0] = szBuf[1] = L'?';
41 }
42 szBuf[2] = UNICODE_NULL; /* Truncate the identifier to two characters: "ENG" --> "EN" etc. */
43
44 /* Create hdc, hbmColor and hbmMono */
45 hdcScreen = GetDC(NULL);
46 hdc = CreateCompatibleDC(hdcScreen);
47 hbmColor = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
48 ReleaseDC(NULL, hdcScreen);
49 hbmMono = CreateBitmap(cxIcon, cyIcon, 1, 1, NULL);
50
51 /* Checking NULL */
52 if (!hdc || !hbmColor || !hbmMono)
53 {
54 if (hbmMono)
55 DeleteObject(hbmMono);
56 if (hbmColor)
57 DeleteObject(hbmColor);
58 if (hdc)
60 return NULL;
61 }
62
63 /* Create a font */
64 hFont = NULL;
65 if (SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
66 {
67 /* Override the current size with something manageable */
68 lf.lfHeight = -11;
69 lf.lfWidth = 0;
71 }
72 if (!hFont)
74
75 SetRect(&rect, 0, 0, cxIcon, cyIcon);
76
77 /* Draw hbmColor */
78 hBmpOld = SelectObject(hdc, hbmColor);
80 FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
81 hFontOld = SelectObject(hdc, hFont);
85 SelectObject(hdc, hFontOld);
86
87 /* Fill hbmMono with black */
88 SelectObject(hdc, hbmMono);
89 PatBlt(hdc, 0, 0, cxIcon, cyIcon, BLACKNESS);
90 SelectObject(hdc, hBmpOld);
91
92 /* Create an icon from hbmColor and hbmMono */
95 IconInfo.hbmColor = hbmColor;
96 IconInfo.hbmMask = hbmMono;
98
99 /* Clean up */
101 DeleteObject(hbmMono);
102 DeleteObject(hbmColor);
103 DeleteDC(hdc);
104
105 return hIcon;
106}
HFONT hFont
Definition: main.c:53
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
pKey DeleteObject()
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2417
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HICON hIcon
Definition: msconfig.c:44
#define UNICODE_NULL
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define L(x)
Definition: ntvdm.h:50
& rect
Definition: startmenu.cpp:1413
LONG lfHeight
Definition: dimm.idl:59
LONG lfWidth
Definition: dimm.idl:60
DWORD yHotspot
Definition: winuser.h:3115
BOOL fIcon
Definition: winuser.h:3113
DWORD xHotspot
Definition: winuser.h:3114
HBITMAP hbmColor
Definition: winuser.h:3117
HBITMAP hbmMask
Definition: winuser.h:3116
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
#define BLACKNESS
Definition: wingdi.h:323
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI DeleteDC(_In_ HDC)
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2550
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_HIGHLIGHT
Definition: winuser.h:920
#define DT_SINGLELINE
Definition: winuser.h:540
#define SM_CYSMICON
Definition: winuser.h:1007
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1370
#define SM_CXSMICON
Definition: winuser.h:1006
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:921
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define DT_VCENTER
Definition: winuser.h:543
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by AddToInputListView().

◆ EnableProcessPrivileges()

BOOL EnableProcessPrivileges ( LPCWSTR  lpPrivilegeName,
BOOL  bEnable 
)

Definition at line 567 of file settings_page.c.

568{
569 HANDLE hToken;
570 LUID luid;
571 TOKEN_PRIVILEGES tokenPrivileges;
572 BOOL Ret;
573
576 &hToken);
577 if (!Ret)
578 return Ret; // failure
579
580 Ret = LookupPrivilegeValueW(NULL, lpPrivilegeName, &luid);
581 if (Ret)
582 {
583 tokenPrivileges.PrivilegeCount = 1;
584 tokenPrivileges.Privileges[0].Luid = luid;
585 tokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
586
587 Ret = AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0, 0, 0);
588 }
589
590 CloseHandle(hToken);
591 return Ret;
592}
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
_In_ BOOL bEnable
Definition: winddi.h:3426
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by OnNotifySettingsPage().

◆ EnumResNameProc()

static BOOL CALLBACK EnumResNameProc ( HMODULE  hModule,
LPCWSTR  lpszType,
LPWSTR  lpszName,
LONG_PTR  lParam 
)
static

Definition at line 159 of file settings_page.c.

160{
161 HICON* phIconSm = (HICON*)lParam;
162 if (*phIconSm)
163 return FALSE;
164
165 *phIconSm = (HICON)LoadImageW(hModule, lpszName, IMAGE_ICON,
168 0);
169 return TRUE;
170}
LPARAM lParam
Definition: combotst.c:139
HMODULE hModule
Definition: animate.c:44
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2172

Referenced by LoadIMEIcon().

◆ ExpandTreeItem()

static VOID ExpandTreeItem ( HWND  hwndTree,
HTREEITEM  hItem 
)
static

Definition at line 317 of file settings_page.c.

318{
319 TreeView_Expand(hwndTree, hItem, TVE_EXPAND);
320 hItem = TreeView_GetChild(hwndTree, hItem);
321 while (hItem)
322 {
323 ExpandTreeItem(hwndTree, hItem);
325 }
326}
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3420
#define TVE_EXPAND
Definition: commctrl.h:3423
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3467
static VOID ExpandTreeItem(HWND hwndTree, HTREEITEM hItem)

Referenced by ExpandTreeItem(), and UpdateInputListView().

◆ FindLanguageInList()

static HTREEITEM FindLanguageInList ( HWND  hwndList,
LPCTSTR  pszLangName 
)
static

Definition at line 191 of file settings_page.c.

192{
194 TCHAR szText[128];
196
197 hItem = TreeView_GetRoot(hwndList);
198 while (hItem)
199 {
200 szText[0] = 0;
201 item.mask = TVIF_TEXT | TVIF_HANDLE;
202 item.pszText = szText;
203 item.cchTextMax = _countof(szText);
204 item.hItem = hItem;
205 TreeView_GetItem(hwndList, &item);
206 if (_wcsicmp(szText, pszLangName) == 0)
207 return hItem;
208
210 }
211
212 return NULL;
213}
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3475
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
char TCHAR
Definition: xmlstorage.h:189

Referenced by AddToInputListView().

◆ InitDefaultLangComboBox()

static VOID InitDefaultLangComboBox ( HWND  hwndCombo)
static

Definition at line 108 of file settings_page.c.

109{
110 WCHAR szText[256];
111 INPUT_LIST_NODE *pNode;
112 INT iIndex, nCount, iDefault = (INT)SendMessageW(hwndCombo, CB_GETCURSEL, 0, 0);
113
114 SendMessageW(hwndCombo, CB_RESETCONTENT, 0, 0);
115
116 for (pNode = InputList_GetFirst(); pNode != NULL; pNode = pNode->pNext)
117 {
119 continue;
120
121 StringCchPrintfW(szText, _countof(szText), L"%s - %s",
122 pNode->pLocale->pszName, pNode->pLayout->pszName);
123 iIndex = (INT)SendMessageW(hwndCombo, CB_ADDSTRING, 0, (LPARAM)szText);
124 SendMessageW(hwndCombo, CB_SETITEMDATA, iIndex, (LPARAM)pNode);
125
127 iDefault = iIndex;
128 }
129
130 nCount = (INT)SendMessageW(hwndCombo, CB_GETCOUNT, 0, 0);
131 if (iDefault >= nCount)
132 SendMessageW(hwndCombo, CB_SETCURSEL, nCount - 1, 0);
133 else
134 SendMessageW(hwndCombo, CB_SETCURSEL, iDefault, 0);
135}
INPUT_LIST_NODE * InputList_GetFirst(VOID)
Definition: input_list.c:780
#define INPUT_LIST_NODE_FLAG_DELETED
Definition: input_list.h:24
#define INT
Definition: polytest.cpp:20
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:44
#define CB_SETITEMDATA
Definition: winuser.h:1956
#define CB_SETCURSEL
Definition: winuser.h:1951
#define CB_RESETCONTENT
Definition: winuser.h:1949
#define CB_GETCOUNT
Definition: winuser.h:1932
#define CB_ADDSTRING
Definition: winuser.h:1926
#define CB_GETCURSEL
Definition: winuser.h:1933
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by SetControlsState().

◆ IsRebootNeeded()

static BOOL IsRebootNeeded ( VOID  )
static

Definition at line 549 of file settings_page.c.

550{
551 INPUT_LIST_NODE *pNode;
552
554 return TRUE;
555
556 for (pNode = InputList_GetFirst(); pNode != NULL; pNode = pNode->pNext)
557 {
558 if (IS_IME_HKL(pNode->hkl)) /* IME? */
559 {
560 return TRUE;
561 }
562 }
563
564 return FALSE;
565}
static BOOL s_bDefaultInputChanged
Definition: settings_page.c:18

Referenced by OnNotifySettingsPage().

◆ LoadIMEIcon()

static HICON LoadIMEIcon ( LPCTSTR  pszImeFile)
static

Definition at line 172 of file settings_page.c.

173{
174 WCHAR szSysDir[MAX_PATH], szPath[MAX_PATH];
175 HINSTANCE hImeInst;
177
178 GetSystemDirectoryW(szSysDir, _countof(szSysDir));
179 StringCchPrintfW(szPath, _countof(szPath), L"%s\\%s", szSysDir, pszImeFile);
180
182 if (hImeInst == NULL)
183 return NULL;
184
186 FreeLibrary(hImeInst);
187
188 return hIconSm;
189}
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
Definition: res.c:358
LPCWSTR szPath
Definition: env.c:37
HICON hIconSm
Definition: msconfig.c:44
#define RT_GROUP_ICON
Definition: pedump.c:375
static BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
#define DONT_RESOLVE_DLL_REFERENCES
Definition: winbase.h:341

Referenced by AddToInputListView().

◆ OnCommandSettingsPage()

VOID OnCommandSettingsPage ( HWND  hwndDlg,
WPARAM  wParam 
)

Definition at line 425 of file settings_page.c.

426{
427 switch (LOWORD(wParam))
428 {
429 case IDC_ADD_BUTTON:
430 {
433 hwndDlg,
435 {
437 SetControlsState(hwndDlg);
438 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
439 }
440 }
441 break;
442
444 {
445 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
446 if (hwndList)
447 {
450 item.hItem = hItem;
451
452 if (hItem && TreeView_GetItem(hwndList, &item))
453 {
454 if (item.lParam == 0) // Branch? (currently branch is keyboard only)
455 {
456 // Get root of branch
457 item.hItem = TreeView_GetParent(hwndList, hItem);
458 TreeView_GetItem(hwndList, &item);
459 }
460
461 if (HIWORD(item.lParam)) // Leaf?
462 {
465 }
466 else // Root?
467 {
470 }
471
472 UpdateInputListView(hwndList);
473 SetControlsState(hwndDlg);
474 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
475 }
476 }
477 }
478 break;
479
480 case IDC_PROP_BUTTON:
481 {
482 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
483 if (hwndList)
484 {
487 item.hItem = hItem;
488
489 if (hItem && TreeView_GetItem(hwndList, &item) && HIWORD(item.lParam))
490 {
493 hwndDlg,
495 item.lParam) == IDOK)
496 {
497 UpdateInputListView(hwndList);
498 SetControlsState(hwndDlg);
499 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
500 }
501 }
502 }
503 }
504 break;
505
506 case IDC_KEY_SET_BTN:
507 {
510 hwndDlg,
512 }
513 break;
514
515 case IDC_LANGUAGE_BAR:
516 {
517 // FIXME
518 break;
519 }
520
522 {
523 if (HIWORD(wParam) == CBN_SELENDOK)
524 {
525 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
526 HWND hwndCombo = GetDlgItem(hwndDlg, IDC_DEFAULT_LANGUAGE);
527 INT iSelected = (INT)SendMessageW(hwndCombo, CB_GETCURSEL, 0, 0);
528 if (iSelected != CB_ERR)
529 {
530 LPARAM lParam = SendMessageW(hwndCombo, CB_GETITEMDATA, iSelected, 0);
531 if (lParam)
532 {
534 if (!(pNode->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT))
535 {
538 UpdateInputListView(hwndList);
539 SetControlsState(hwndDlg);
540 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
541 }
542 }
543 }
544 }
545 }
546 }
547}
INT_PTR CALLBACK AddDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: add_dialog.c:177
WPARAM wParam
Definition: combotst.c:138
INT_PTR CALLBACK KeySettingsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define IDC_REMOVE_BUTTON
Definition: resource.h:24
#define IDD_ADD
Definition: resource.h:17
#define IDC_KEY_SET_BTN
Definition: resource.h:26
#define IDC_KEYLAYOUT_LIST
Definition: resource.h:21
#define IDC_PROP_BUTTON
Definition: resource.h:25
#define IDC_LANGUAGE_BAR
Definition: resource.h:42
#define IDD_INPUT_LANG_PROP
Definition: resource.h:15
#define IDC_ADD_BUTTON
Definition: resource.h:23
#define IDD_KEYSETTINGS
Definition: resource.h:18
#define IDC_DEFAULT_LANGUAGE
Definition: resource.h:22
INT_PTR CALLBACK EditDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit_dialog.c:14
VOID InputList_SetDefault(INPUT_LIST_NODE *pNode)
Definition: input_list.c:527
BOOL InputList_RemoveByLang(LANGID wLangId)
Definition: input_list.c:616
BOOL InputList_Remove(INPUT_LIST_NODE *pNode)
Definition: input_list.c:576
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
static VOID UpdateInputListView(HWND hwndList)
static VOID SetControlsState(HWND hwndDlg)
#define HIWORD(l)
Definition: typedefs.h:247
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4389
#define CB_ERR
Definition: winuser.h:2425
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
#define CB_GETITEMDATA
Definition: winuser.h:1940
HWND WINAPI GetParent(_In_ HWND)
#define CBN_SELENDOK
Definition: winuser.h:1971
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by SettingsPageProc().

◆ OnDestroySettingsPage()

static VOID OnDestroySettingsPage ( HWND  hwndDlg)
static

Definition at line 416 of file settings_page.c.

417{
421}
VOID InputList_Destroy(VOID)
Definition: input_list.c:197
VOID LayoutList_Destroy(VOID)
Definition: layout_list.c:67
VOID LocaleList_Destroy(VOID)
Definition: locale_list.c:60

Referenced by SettingsPageProc().

◆ OnInitSettingsPage()

static VOID OnInitSettingsPage ( HWND  hwndDlg)
static

Definition at line 389 of file settings_page.c.

390{
391 HWND hwndInputList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
392 HIMAGELIST hLayoutImageList, hOldImageList;
393
397
399
402 ILC_COLOR8 | ILC_MASK, 0, 0);
403 if (hLayoutImageList != NULL)
404 {
405 hOldImageList = TreeView_SetImageList(hwndInputList, hLayoutImageList, TVSIL_NORMAL);
406 ImageList_Destroy(hOldImageList);
407 }
408
409 UpdateInputListView(hwndInputList);
410
411 SetControlsState(hwndDlg);
412}
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
VOID InputList_Create(VOID)
Definition: input_list.c:639
VOID LayoutList_Create(VOID)
Definition: layout_list.c:171
LOCALE_LIST_NODE * LocaleList_Create(VOID)
Definition: locale_list.c:84
#define ILC_COLOR8
Definition: commctrl.h:355
#define ILC_MASK
Definition: commctrl.h:351
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by SettingsPageProc().

◆ OnNotifySettingsPage()

static INT_PTR OnNotifySettingsPage ( HWND  hwndDlg,
LPARAM  lParam 
)
static

Definition at line 595 of file settings_page.c.

596{
598
599 switch (header->code)
600 {
601 case TVN_SELCHANGED:
602 {
603 SetControlsState(hwndDlg);
604 break;
605 }
606
608 {
609 // FIXME: Prevent collapse (COMCTL32 is buggy)
610 // https://bugs.winehq.org/show_bug.cgi?id=53727
611 NM_TREEVIEW* pTreeView = (NM_TREEVIEW*)lParam;
612 if ((pTreeView->action & TVE_TOGGLE) == TVE_COLLAPSE)
613 {
615 return TRUE;
616 }
617 break;
618 }
619
620 case PSN_APPLY:
621 {
622 BOOL bRebootNeeded = IsRebootNeeded();
623
624 /* Write Input Methods list to registry */
625 if (InputList_Process() && bRebootNeeded)
626 {
627 /* Needs reboot */
628 WCHAR szNeedsReboot[128], szLanguage[64];
629 LoadStringW(hApplet, IDS_REBOOT_NOW, szNeedsReboot, _countof(szNeedsReboot));
630 LoadStringW(hApplet, IDS_LANGUAGE, szLanguage, _countof(szLanguage));
631
632 if (MessageBoxW(hwndDlg, szNeedsReboot, szLanguage,
634 {
637 }
638 }
639 break;
640 }
641 }
642
643 return 0;
644}
#define IDS_LANGUAGE
Definition: resource.h:52
#define IDS_REBOOT_NOW
Definition: resource.h:62
BOOL InputList_Process(VOID)
Definition: input_list.c:382
#define PSN_APPLY
Definition: prsht.h:117
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define NM_TREEVIEW
Definition: commctrl.h:3624
#define TVE_TOGGLE
Definition: commctrl.h:3424
#define TVE_COLLAPSE
Definition: commctrl.h:3422
#define TVN_ITEMEXPANDING
Definition: commctrl.h:3738
BOOL EnableProcessPrivileges(LPCWSTR lpPrivilegeName, BOOL bEnable)
static BOOL IsRebootNeeded(VOID)
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:384
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define EWX_REBOOT
Definition: winuser.h:633
struct tagNMHDR * LPNMHDR
#define EWX_FORCE
Definition: winuser.h:630
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define DWLP_MSGRESULT
Definition: winuser.h:864
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define IDYES
Definition: winuser.h:829
#define SetWindowLongPtrW
Definition: winuser.h:5336
#define MB_YESNOCANCEL
Definition: winuser.h:812

Referenced by SettingsPageProc().

◆ SetControlsState()

static VOID SetControlsState ( HWND  hwndDlg)
static

Definition at line 138 of file settings_page.c.

139{
140 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
141 HWND hwndCombo = GetDlgItem(hwndDlg, IDC_DEFAULT_LANGUAGE);
142 BOOL bIsLeaf, bCanRemove, bCanProp;
143 HTREEITEM hSelected = TreeView_GetSelection(hwndList);
145 item.hItem = hSelected;
146
147 bIsLeaf = (hSelected && TreeView_GetItem(hwndList, &item) && HIWORD(item.lParam));
148
149 bCanRemove = (bIsLeaf && (s_nAliveLeafCount > 1)) || (s_nRootCount > 1);
150 bCanProp = bIsLeaf;
151
152 EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_BUTTON), bCanRemove);
153 EnableWindow(GetDlgItem(hwndDlg, IDC_PROP_BUTTON), bCanProp);
154
155 InitDefaultLangComboBox(hwndCombo);
156}
static VOID InitDefaultLangComboBox(HWND hwndCombo)
static INT s_nAliveLeafCount
Definition: settings_page.c:14
static INT s_nRootCount
Definition: settings_page.c:15

Referenced by OnCommandSettingsPage(), OnInitSettingsPage(), and OnNotifySettingsPage().

◆ SettingsPageProc()

INT_PTR CALLBACK SettingsPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 647 of file settings_page.c.

648{
649 switch (uMsg)
650 {
651 case WM_INITDIALOG:
652 OnInitSettingsPage(hwndDlg);
653 return TRUE;
654
655 case WM_DESTROY:
656 OnDestroySettingsPage(hwndDlg);
657 break;
658
659 case WM_COMMAND:
661 break;
662
663 case WM_NOTIFY:
664 return OnNotifySettingsPage(hwndDlg, lParam);
665 }
666
667 return FALSE;
668}
#define WM_NOTIFY
Definition: richedit.h:61
static INT_PTR OnNotifySettingsPage(HWND hwndDlg, LPARAM lParam)
static VOID OnInitSettingsPage(HWND hwndDlg)
static VOID OnDestroySettingsPage(HWND hwndDlg)
VOID OnCommandSettingsPage(HWND hwndDlg, WPARAM wParam)
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_INITDIALOG
Definition: winuser.h:1729
#define WM_DESTROY
Definition: winuser.h:1599

Referenced by SystemApplet().

◆ UpdateInputListView()

static VOID UpdateInputListView ( HWND  hwndList)
static

Definition at line 329 of file settings_page.c.

330{
331 INPUT_LIST_NODE *pNode;
332 HIMAGELIST hImageList = TreeView_GetImageList(hwndList, TVSIL_NORMAL);
334 HICON hKeyboardIcon, hDotIcon;
335
336 ImageList_RemoveAll(hImageList);
337 TreeView_DeleteAllItems(hwndList);
338
339 // Add keyboard icon
340 s_iKeyboardImage = -1;
343 0);
344 if (hKeyboardIcon)
345 {
346 s_iKeyboardImage = ImageList_AddIcon(hImageList, hKeyboardIcon);
347 DestroyIcon(hKeyboardIcon);
348 }
349
350 // Add dot icon
351 s_iDotImage = -1;
354 0);
355 if (hDotIcon)
356 {
357 s_iDotImage = ImageList_AddIcon(hImageList, hDotIcon);
358 DestroyIcon(hDotIcon);
359 }
360
362
364
365 // Add items to the list
366 for (pNode = InputList_GetFirst(); pNode; pNode = pNode->pNext)
367 {
369 continue;
370
371 AddToInputListView(hwndList, pNode);
372 }
373
374 // Expand all (with counting s_nRootCount)
375 s_nRootCount = 0;
376 hItem = TreeView_GetRoot(hwndList);
377 while (hItem)
378 {
379 ++s_nRootCount;
380 ExpandTreeItem(hwndList, hItem);
382 }
383
384 // Redraw
385 InvalidateRect(hwndList, NULL, TRUE);
386}
#define IDI_DOT
Definition: resource.h:10
#define IDI_KEYBOARD
Definition: resource.h:9
INT InputList_GetAliveCount(VOID)
Definition: input_list.c:763
VOID InputList_Sort(VOID)
Definition: input_list.c:704
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
#define ImageList_RemoveAll(himl)
Definition: commctrl.h:556
static VOID AddToInputListView(HWND hwndList, INPUT_LIST_NODE *pInputNode)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by OnCommandSettingsPage(), and OnInitSettingsPage().

Variable Documentation

◆ s_bDefaultInputChanged

BOOL s_bDefaultInputChanged = FALSE
static

Definition at line 18 of file settings_page.c.

Referenced by IsRebootNeeded(), and OnCommandSettingsPage().

◆ s_iDotImage

INT s_iDotImage = -1
static

Definition at line 17 of file settings_page.c.

Referenced by AddToInputListView(), and UpdateInputListView().

◆ s_iKeyboardImage

INT s_iKeyboardImage = -1
static

Definition at line 16 of file settings_page.c.

Referenced by AddToInputListView(), and UpdateInputListView().

◆ s_nAliveLeafCount

INT s_nAliveLeafCount = 0
static

Definition at line 14 of file settings_page.c.

Referenced by SetControlsState(), and UpdateInputListView().

◆ s_nRootCount

INT s_nRootCount = 0
static

Definition at line 15 of file settings_page.c.

Referenced by SetControlsState(), and UpdateInputListView().