]>
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 | ||
8507f105 DD |
19 | static char *cvsid = "\n%%% $Id$\n"; |
20 | ||
23c9e63c DD |
21 | #include "win32.h" |
22 | #include <stdio.h> | |
23 | #include <stdlib.h> | |
24 | #include "dialog.h" | |
25 | #include "msg.h" | |
89b1a15b | 26 | #include "log.h" |
85b43844 | 27 | #include "mount.h" |
23c9e63c DD |
28 | |
29 | char * | |
30 | eget (HWND h, int id, char *var) | |
31 | { | |
32 | char tmp[4000]; | |
85b43844 | 33 | if (var && var != get_root_dir ()) |
23c9e63c DD |
34 | { |
35 | free (var); | |
85b43844 | 36 | var = NULL; |
23c9e63c | 37 | } |
42bf5b92 | 38 | if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0) |
23c9e63c | 39 | { |
85b43844 | 40 | var = (char *) malloc (strlen (tmp) + 1); |
23c9e63c DD |
41 | strcpy (var, tmp); |
42 | } | |
43 | return var; | |
44 | } | |
45 | ||
46 | int | |
47 | eget (HWND h, int id) | |
48 | { | |
49 | BOOL s; | |
50 | int r = GetDlgItemInt (h, id, &s, TRUE); | |
51 | return r; | |
52 | } | |
53 | ||
54 | void | |
85b43844 | 55 | eset (HWND h, int id, const char *val) |
23c9e63c DD |
56 | { |
57 | SetDlgItemText (h, id, val); | |
58 | } | |
59 | ||
60 | void | |
61 | eset (HWND h, int id, int val) | |
62 | { | |
63 | SetDlgItemInt (h, id, (UINT)val, TRUE); | |
64 | } | |
65 | ||
66 | int | |
67 | rbget (HWND h, int *ids) | |
68 | { | |
69 | int i; | |
70 | for (i=0; ids[i]; i++) | |
71 | if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED) | |
72 | return ids[i]; | |
73 | return 0; | |
74 | } | |
75 | ||
76 | void | |
77 | rbset (HWND h, int *ids, int id) | |
78 | { | |
79 | int i; | |
80 | for (i=0; ids[i]; i++) | |
81 | CheckDlgButton (h, ids[i], id==ids[i] ? BST_CHECKED : BST_UNCHECKED); | |
82 | } | |
83 | ||
84 | void | |
85 | fatal (char *msg) | |
86 | { | |
1fd6d0a2 | 87 | DWORD e = GetLastError (); |
23c9e63c DD |
88 | char *buf; |
89 | FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, | |
90 | 0, | |
91 | e, | |
92 | 0, | |
93 | (CHAR *)&buf, | |
94 | 0, | |
95 | 0); | |
96 | MessageBox (0, buf, msg, 0); | |
89b1a15b | 97 | exit_setup (1); |
23c9e63c | 98 | } |