]>
Commit | Line | Data |
---|---|---|
23c9e63c DD |
1 | /* |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by DJ Delorie <dj@cygnus.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | /* The purpose of this file is to provide common functionality for | |
17 | all the dialogs in the program. */ | |
18 | ||
b24c88b3 RC |
19 | #if 0 |
20 | static const char *cvsid = | |
21 | "\n%%% $Id$\n"; | |
22 | #endif | |
8507f105 | 23 | |
23c9e63c DD |
24 | #include "win32.h" |
25 | #include <stdio.h> | |
26 | #include <stdlib.h> | |
27 | #include "dialog.h" | |
28 | #include "msg.h" | |
89b1a15b | 29 | #include "log.h" |
85b43844 | 30 | #include "mount.h" |
23c9e63c DD |
31 | |
32 | char * | |
33 | eget (HWND h, int id, char *var) | |
34 | { | |
35 | char tmp[4000]; | |
85b43844 | 36 | if (var && var != get_root_dir ()) |
23c9e63c DD |
37 | { |
38 | free (var); | |
85b43844 | 39 | var = NULL; |
23c9e63c | 40 | } |
42bf5b92 | 41 | if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0) |
23c9e63c | 42 | { |
85b43844 | 43 | var = (char *) malloc (strlen (tmp) + 1); |
23c9e63c DD |
44 | strcpy (var, tmp); |
45 | } | |
46 | return var; | |
47 | } | |
48 | ||
49 | int | |
50 | eget (HWND h, int id) | |
51 | { | |
52 | BOOL s; | |
53 | int r = GetDlgItemInt (h, id, &s, TRUE); | |
54 | return r; | |
55 | } | |
56 | ||
57 | void | |
85b43844 | 58 | eset (HWND h, int id, const char *val) |
23c9e63c DD |
59 | { |
60 | SetDlgItemText (h, id, val); | |
61 | } | |
62 | ||
63 | void | |
64 | eset (HWND h, int id, int val) | |
65 | { | |
b24c88b3 | 66 | SetDlgItemInt (h, id, (UINT) val, TRUE); |
23c9e63c DD |
67 | } |
68 | ||
69 | int | |
70 | rbget (HWND h, int *ids) | |
71 | { | |
72 | int i; | |
b24c88b3 | 73 | for (i = 0; ids[i]; i++) |
23c9e63c DD |
74 | if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED) |
75 | return ids[i]; | |
76 | return 0; | |
77 | } | |
78 | ||
79 | void | |
80 | rbset (HWND h, int *ids, int id) | |
81 | { | |
82 | int i; | |
b24c88b3 RC |
83 | for (i = 0; ids[i]; i++) |
84 | CheckDlgButton (h, ids[i], id == ids[i] ? BST_CHECKED : BST_UNCHECKED); | |
23c9e63c DD |
85 | } |
86 | ||
87 | void | |
b24c88b3 | 88 | fatal (const char *msg) |
23c9e63c | 89 | { |
1fd6d0a2 | 90 | DWORD e = GetLastError (); |
23c9e63c DD |
91 | char *buf; |
92 | FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, | |
b24c88b3 | 93 | 0, e, 0, (CHAR *) & buf, 0, 0); |
23c9e63c | 94 | MessageBox (0, buf, msg, 0); |
89b1a15b | 95 | exit_setup (1); |
23c9e63c | 96 | } |