2 * Copyright (C) 1997 Cygnus Solutions.
4 * Author: Michael Graff
22 * 1) Create the dialog with all the windows we will need
23 * later. This is done by calling vardlg_build() from
26 * 2) Run the dialog from within gic_prompter(). If the return
27 * value of the dialog is -1 or IDCANCEL, return an error.
28 * Otherwise, return success.
30 * 3) From within the dialog initialization code, call
31 * vardlg_config(), which will:
33 * a) Set all the label strings in all the entry labels and
36 * b) Set the maximum input lengths on the entry fields.
38 * c) Calculate the size of the text used within the banner.
40 * d) Calculate the longest string of text used as a label.
42 * e) Resize each label and each entry within the dialog
45 * f) Place the OK and perhaps the Cancel buttons at the bottom
48 * 4) When the OK button is clicked, copy all the values from the
49 * input fields and store them in the pointers we are given.
50 * Also, set the actual lengths to what we collected from the
51 * entries. Finally, call EndDialog(IDOK) to end the dialog.
55 * Yes, a global. It is a PITA to not use them in windows.
61 * initialize the dialog
64 gic_dialog_init(HWND hwnd, HWND hwndFocus, LPARAM lParam)
66 vardlg_config(hwnd, gd->width, gd->banner, gd->num_prompts,
67 gd->prompts, (WORD)(gd->id));
73 * process dialog "commands"
76 gic_dialog_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify)
83 * We are only interested in button clicks, and then only of
84 * type IDOK or IDCANCEL.
86 if (codeNotify != BN_CLICKED)
88 if (cid != IDOK && cid != IDCANCEL)
92 * If we are canceled, wipe all the fields and return IDCANCEL.
94 if (cid == IDCANCEL) {
95 EndDialog(hwnd, IDCANCEL);
103 for (n = 0 ; n < gd->num_prompts ; n++) {
104 Edit_GetText(GetDlgItem(hwnd, id), gd->prompts[n].reply->data,
105 gd->prompts[n].reply->length);
106 gd->prompts[n].reply->length = (unsigned)strlen(gd->prompts[n].reply->data);
110 EndDialog(hwnd, IDOK);
114 * The dialog callback.
116 static INT_PTR CALLBACK
117 gic_dialog(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
120 HANDLE_MSG(hwnd, WM_INITDIALOG, gic_dialog_init);
122 HANDLE_MSG(hwnd, WM_COMMAND, gic_dialog_command);
130 * All the disgusting code to use the get_init_creds() functions in a
133 krb5_error_code KRB5_CALLCONV
134 gic_prompter(krb5_context ctx, void *data, const char *name,
135 const char *banner, int num_prompts, krb5_prompt prompts[])
143 gd->num_prompts = num_prompts;
144 gd->prompts = prompts;
148 dlg = vardlg_build((WORD)(gd->width), name, gd->banner,
149 (WORD)num_prompts, prompts, (WORD)(gd->id));
151 rc = DialogBoxIndirect(gd->hinstance, (LPDLGTEMPLATE)dlg, gd->hwnd, gic_dialog);