]> cygwin.com Git - cygwin-apps/setup.git/blob - dialog.cc
* coding standards fixups, many files
[cygwin-apps/setup.git] / dialog.cc
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
19 #include "win32.h"
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include "dialog.h"
23 #include "msg.h"
24
25 char *
26 eget (HWND h, int id, char *var)
27 {
28 char tmp[4000];
29 if (var)
30 {
31 free (var);
32 var = 0;
33 }
34 if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
35 {
36 var = (char *) malloc (strlen (tmp)+1);
37 strcpy (var, tmp);
38 }
39 return var;
40 }
41
42 int
43 eget (HWND h, int id)
44 {
45 BOOL s;
46 int r = GetDlgItemInt (h, id, &s, TRUE);
47 return r;
48 }
49
50 void
51 eset (HWND h, int id, char *val)
52 {
53 SetDlgItemText (h, id, val);
54 }
55
56 void
57 eset (HWND h, int id, int val)
58 {
59 SetDlgItemInt (h, id, (UINT)val, TRUE);
60 }
61
62 int
63 rbget (HWND h, int *ids)
64 {
65 int i;
66 for (i=0; ids[i]; i++)
67 if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED)
68 return ids[i];
69 return 0;
70 }
71
72 void
73 rbset (HWND h, int *ids, int id)
74 {
75 int i;
76 for (i=0; ids[i]; i++)
77 CheckDlgButton (h, ids[i], id==ids[i] ? BST_CHECKED : BST_UNCHECKED);
78 }
79
80 void
81 fatal (char *msg)
82 {
83 DWORD e = GetLastError ();
84 char *buf;
85 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
86 0,
87 e,
88 0,
89 (CHAR *)&buf,
90 0,
91 0);
92 MessageBox (0, buf, msg, 0);
93 ExitProcess (0);
94 }
This page took 0.039213 seconds and 5 git commands to generate.