ReactOS 0.4.16-dev-91-g764881a
add_dialog.c File Reference
#include "input.h"
#include "locale_list.h"
#include "layout_list.h"
#include "input_list.h"
Include dependency graph for add_dialog.c:

Go to the source code of this file.

Functions

static DWORD GetDefaultLayoutForLocale (DWORD dwLocaleId)
 
static VOID OnInitAddDialog (HWND hwndDlg)
 
static VOID OnCommandAddDialog (HWND hwndDlg, WPARAM wParam)
 
INT_PTR CALLBACK AddDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ AddDialogProc()

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

Definition at line 177 of file add_dialog.c.

178{
179 switch (uMsg)
180 {
181 case WM_INITDIALOG:
182 OnInitAddDialog(hwndDlg);
183 return TRUE;
184
185 case WM_COMMAND:
186 OnCommandAddDialog(hwndDlg, wParam);
187 break;
188
189 case WM_DESTROY:
190 break;
191 }
192
193 return FALSE;
194}
static VOID OnCommandAddDialog(HWND hwndDlg, WPARAM wParam)
Definition: add_dialog.c:108
static VOID OnInitAddDialog(HWND hwndDlg)
Definition: add_dialog.c:62
WPARAM wParam
Definition: combotst.c:138
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_DESTROY
Definition: winuser.h:1612

Referenced by OnCommandSettingsPage().

◆ GetDefaultLayoutForLocale()

static DWORD GetDefaultLayoutForLocale ( DWORD  dwLocaleId)
static

Definition at line 15 of file add_dialog.c.

16{
17 DWORD dwResult = 0;
18 HINF hIntlInf;
19
20 hIntlInf = SetupOpenInfFileW(L"intl.inf", NULL, INF_STYLE_WIN4, NULL);
21 if (hIntlInf != INVALID_HANDLE_VALUE)
22 {
23 WCHAR szLangID[MAX_STR_LEN];
24 INFCONTEXT InfContext;
25
26 StringCchPrintfW(szLangID, ARRAYSIZE(szLangID), L"%08X", dwLocaleId);
27
28 if (SetupFindFirstLineW(hIntlInf, L"Locales", szLangID, &InfContext))
29 {
30 if (SetupGetFieldCount(&InfContext) >= 5)
31 {
32 WCHAR szField[MAX_STR_LEN];
33
34 if (SetupGetStringFieldW(&InfContext, 5, szField, ARRAYSIZE(szField), NULL))
35 {
36 if (wcslen(szField) == 13) // like 0409:00000409 (13 chars)
37 {
38 WCHAR *pszSeparator = L":";
39 WCHAR *pszToken;
40
41 pszToken = wcstok(szField, pszSeparator);
42 if (pszToken != NULL)
43 pszToken = wcstok(NULL, pszSeparator);
44
45 if (pszToken != NULL)
46 {
47 dwResult = DWORDfromString(pszToken);
48 }
49 }
50 }
51 }
52 }
53
54 SetupCloseInfFile(hIntlInf);
55 }
56
57 return dwResult;
58}
#define MAX_STR_LEN
Definition: defines.h:43
#define NULL
Definition: types.h:112
static DWORD DWORDfromString(const WCHAR *pszString)
Definition: input.h:80
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define INF_STYLE_WIN4
Definition: infsupp.h:41
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:186
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:56
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:93
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCommandAddDialog(), and OnInitAddDialog().

◆ OnCommandAddDialog()

static VOID OnCommandAddDialog ( HWND  hwndDlg,
WPARAM  wParam 
)
static

Definition at line 108 of file add_dialog.c.

109{
110 switch (LOWORD(wParam))
111 {
112 case IDOK:
113 {
114 HWND hwndLocaleCombo = GetDlgItem(hwndDlg, IDC_INPUT_LANG_COMBO);
115 HWND hwndLayoutCombo = GetDlgItem(hwndDlg, IDC_KEYBOARD_LO_COMBO);
116 LOCALE_LIST_NODE *pCurrentLocale;
117 LAYOUT_LIST_NODE *pCurrentLayout;
118
119 pCurrentLocale = (LOCALE_LIST_NODE*)ComboBox_GetItemData(hwndLocaleCombo,
120 ComboBox_GetCurSel(hwndLocaleCombo));
121 pCurrentLayout = (LAYOUT_LIST_NODE*)ComboBox_GetItemData(hwndLayoutCombo,
122 ComboBox_GetCurSel(hwndLayoutCombo));
123
124 InputList_Add(pCurrentLocale, pCurrentLayout);
125
126 EndDialog(hwndDlg, LOWORD(wParam));
127 }
128 break;
129
130 case IDCANCEL:
131 {
132 EndDialog(hwndDlg, LOWORD(wParam));
133 }
134 break;
135
137 {
139 {
140 HWND hwndLocaleCombo = GetDlgItem(hwndDlg, IDC_INPUT_LANG_COMBO);
141 HWND hwndLayoutCombo = GetDlgItem(hwndDlg, IDC_KEYBOARD_LO_COMBO);
142 LOCALE_LIST_NODE *pCurrentLocale;
143
144 pCurrentLocale = (LOCALE_LIST_NODE*)ComboBox_GetItemData(hwndLocaleCombo,
145 ComboBox_GetCurSel(hwndLocaleCombo));
146 if (pCurrentLocale != NULL)
147 {
148 DWORD dwLayoutId;
149 INT iIndex;
150 INT iCount;
151
152 dwLayoutId = GetDefaultLayoutForLocale(pCurrentLocale->dwId);
153
154 iCount = ComboBox_GetCount(hwndLayoutCombo);
155
156 for (iIndex = 0; iIndex < iCount; iIndex++)
157 {
158 LAYOUT_LIST_NODE *pCurrentLayout;
159
160 pCurrentLayout = (LAYOUT_LIST_NODE*)ComboBox_GetItemData(hwndLayoutCombo, iIndex);
161
162 if (pCurrentLayout != NULL && pCurrentLayout->dwKLID == dwLayoutId)
163 {
164 ComboBox_SetCurSel(hwndLayoutCombo, iIndex);
165 break;
166 }
167 }
168 }
169 }
170 }
171 break;
172 }
173}
static DWORD GetDefaultLayoutForLocale(DWORD dwLocaleId)
Definition: add_dialog.c:15
#define IDC_KEYBOARD_LO_COMBO
Definition: resource.h:32
#define IDC_INPUT_LANG_COMBO
Definition: resource.h:31
BOOL InputList_Add(LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout)
Definition: input_list.c:502
#define LOWORD(l)
Definition: pedump.c:82
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:66
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:54
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:48
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:49
#define IDCANCEL
Definition: winuser.h:834
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
#define CBN_SELCHANGE
Definition: winuser.h:1982
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by AddDialogProc().

◆ OnInitAddDialog()

static VOID OnInitAddDialog ( HWND  hwndDlg)
static

Definition at line 62 of file add_dialog.c.

63{
64 HWND hwndLocaleCombo = GetDlgItem(hwndDlg, IDC_INPUT_LANG_COMBO);
65 HWND hwndLayoutCombo = GetDlgItem(hwndDlg, IDC_KEYBOARD_LO_COMBO);
66 LOCALE_LIST_NODE *pCurrentLocale;
67 LAYOUT_LIST_NODE *pCurrentLayout;
68 DWORD dwDefaultLocaleId;
69 DWORD dwDefaultLayoutId;
70 INT iItemIndex;
71
72 dwDefaultLocaleId = GetSystemDefaultLCID();
73
74 for (pCurrentLocale = LocaleList_GetFirst();
75 pCurrentLocale != NULL;
76 pCurrentLocale = pCurrentLocale->pNext)
77 {
78 iItemIndex = ComboBox_AddString(hwndLocaleCombo, pCurrentLocale->pszName);
79 ComboBox_SetItemData(hwndLocaleCombo, iItemIndex, pCurrentLocale);
80
81 if (pCurrentLocale->dwId == dwDefaultLocaleId)
82 {
83 ComboBox_SetCurSel(hwndLocaleCombo, iItemIndex);
84 }
85 }
86
87 dwDefaultLayoutId = GetDefaultLayoutForLocale(dwDefaultLocaleId);
88
89 for (pCurrentLayout = LayoutList_GetFirst();
90 pCurrentLayout != NULL;
91 pCurrentLayout = pCurrentLayout->pNext)
92 {
93 iItemIndex = ComboBox_AddString(hwndLayoutCombo, pCurrentLayout->pszName);
94 ComboBox_SetItemData(hwndLayoutCombo, iItemIndex, pCurrentLayout);
95
96 if (pCurrentLayout->dwKLID == dwDefaultLayoutId)
97 {
98 ComboBox_SetCurSel(hwndLayoutCombo, iItemIndex);
99 }
100 }
101
102 if (dwDefaultLayoutId == 0)
103 ComboBox_SetCurSel(hwndLayoutCombo, 0);
104}
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
LAYOUT_LIST_NODE * LayoutList_GetFirst(VOID)
Definition: layout_list.c:249
LOCALE_LIST_NODE * LocaleList_GetFirst(VOID)
Definition: locale_list.c:146
struct _LAYOUT_LIST_NODE * pNext
Definition: layout_list.h:14
struct _LOCALE_LIST_NODE * pNext
Definition: locale_list.h:12
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:41
#define ComboBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:69

Referenced by AddDialogProc().