27 typedef struct _CHOICE_DIALOG_CONTEXT
32 ULONG NumberOfChoices;
36 PBOOLEAN SelectedOption;
37 PWSTR SavedChoicesSettingName;
56 _In_ HWND ParentWindowHandle,
59 _In_opt_ PWSTR *Choices,
60 _In_opt_ ULONG NumberOfChoices,
61 _In_opt_ PWSTR Option,
64 _Inout_opt_ PBOOLEAN SelectedOption,
65 _In_opt_ PWSTR SavedChoicesSettingName
70 context.Title = Title;
71 context.Message = Message;
72 context.Choices = Choices;
73 context.NumberOfChoices = NumberOfChoices;
74 context.Option = Option;
75 context.Flags = Flags;
76 context.SelectedChoice = SelectedChoice;
77 context.SelectedOption = SelectedOption;
78 context.SavedChoicesSettingName = SavedChoicesSettingName;
80 return DialogBoxParam(
112 SetWindowText(hwndDlg, context->Title);
113 SetWindowText(GetDlgItem(hwndDlg,
IDC_MESSAGE), context->Message);
131 context->SavedChoicesSettingName = NULL;
135 comboBoxHandle = GetDlgItem(hwndDlg,
IDC_CHOICE);
136 ShowWindow(GetDlgItem(hwndDlg,
IDC_CHOICE), SW_SHOW);
140 context->ComboBoxHandle = comboBoxHandle;
142 checkBoxHandle = GetDlgItem(hwndDlg,
IDC_OPTION);
151 ULONG_PTR indexOfDelim;
157 while (i < savedChoices->Length / 2)
162 if (indexOfDelim == -1)
163 indexOfDelim = savedChoices->
Length / 2;
165 savedChoice =
PhSubstring(savedChoices, i, indexOfDelim - i);
167 if (savedChoice->
Length != 0)
172 ComboBox_InsertString(comboBoxHandle, -1, unescaped->
Buffer);
178 i = indexOfDelim + 2;
185 for (i = 0; i < context->NumberOfChoices; i++)
187 ComboBox_AddString(comboBoxHandle, context->Choices[i]);
190 context->SavedChoicesSettingName = NULL;
195 if (*context->SelectedChoice)
196 SetWindowText(comboBoxHandle, (*context->SelectedChoice)->Buffer);
198 Edit_SetSel(comboBoxHandle, 0, -1);
205 comboBoxHandle, (*context->SelectedChoice)->Buffer,
FALSE) == CB_ERR)
209 SetWindowText(comboBoxHandle, (*context->SelectedChoice)->Buffer);
213 ComboBox_SetCurSel(comboBoxHandle, 0);
218 ComboBox_SetEditSel(comboBoxHandle, 0, -1);
223 SetWindowText(checkBoxHandle, context->Option);
225 if (context->SelectedOption)
226 Button_SetCheck(checkBoxHandle, *context->SelectedOption ? BST_CHECKED : BST_UNCHECKED);
232 ShowWindow(checkBoxHandle, SW_HIDE);
233 GetWindowRect(checkBoxHandle, &checkBoxRect);
234 MapWindowPoints(NULL, hwndDlg, (POINT *)&checkBoxRect, 2);
235 GetWindowRect(GetDlgItem(hwndDlg, IDOK), &rect);
236 MapWindowPoints(NULL, hwndDlg, (POINT *)&rect, 2);
237 diff = rect.top - checkBoxRect.top;
242 SetWindowPos(GetDlgItem(hwndDlg, IDOK), NULL, rect.left, rect.top,
243 rect.right - rect.left, rect.bottom - rect.top,
244 SWP_NOACTIVATE | SWP_NOZORDER);
247 GetWindowRect(GetDlgItem(hwndDlg, IDCANCEL), &rect);
248 MapWindowPoints(NULL, hwndDlg, (POINT *)&rect, 2);
251 SetWindowPos(GetDlgItem(hwndDlg, IDCANCEL), NULL, rect.left, rect.top,
252 rect.right - rect.left, rect.bottom - rect.top,
253 SWP_NOACTIVATE | SWP_NOZORDER);
256 GetWindowRect(hwndDlg, &rect);
258 SetWindowPos(hwndDlg, NULL, rect.left, rect.top,
259 rect.right - rect.left, rect.bottom - rect.top,
260 SWP_NOACTIVATE | SWP_NOZORDER);
263 SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)comboBoxHandle,
TRUE);
273 switch (LOWORD(wParam))
276 EndDialog(hwndDlg, IDCANCEL);
286 *context->SelectedChoice = selectedChoice;
292 *context->SelectedChoice = selectedChoice;
295 if (context->Option && context->SelectedOption)
296 *context->SelectedOption = Button_GetCheck(GetDlgItem(hwndDlg,
IDC_OPTION)) == BST_CHECKED;
298 if (context->SavedChoicesSettingName)
310 if (selectedChoice->
Length != 0)
318 for (i = 1; i < choicesToSave; i++)
349 EndDialog(hwndDlg, IDOK);