]> cygwin.com Git - cygwin-apps/setup.git/blob - dialog.cc
Increase buffer size in LogPrintf adaptors
[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 #include "LogFile.h"
25 #include "mount.h"
26
27 char *
28 eget (HWND h, int id, char *var)
29 {
30 char tmp[4000];
31 if (var && var != get_root_dir ().c_str())
32 {
33 delete [] var;
34 var = NULL;
35 }
36 if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
37 {
38 var = new char [strlen (tmp) + 1];
39 var [strlen (tmp)] = '\0';
40 strcpy (var, tmp);
41 }
42 return var;
43 }
44
45 std::string
46 egetString (HWND h, int id)
47 {
48 std::string aString;
49 char tmp[4000];
50 if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
51 aString = std::string (tmp);
52 return aString;
53 }
54
55 int
56 eget (HWND h, int id)
57 {
58 BOOL s;
59 int r = GetDlgItemInt (h, id, &s, TRUE);
60 return r;
61 }
62
63 void
64 eset (HWND h, int id, const char *val)
65 {
66 SetDlgItemText (h, id, val);
67 }
68
69 void
70 eset (HWND h, int id, const std::string aString)
71 {
72 SetDlgItemText (h, id, aString.c_str());
73 }
74
75 void
76 eset (HWND h, int id, int val)
77 {
78 SetDlgItemInt (h, id, (UINT) val, TRUE);
79 }
80
81 int
82 rbget (HWND h, int *ids)
83 {
84 int i;
85 for (i = 0; ids[i]; i++)
86 if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED)
87 return ids[i];
88 return 0;
89 }
90
91 void
92 rbset (HWND h, int *ids, int id)
93 {
94 int i;
95 for (i = 0; ids[i]; i++)
96 CheckDlgButton (h, ids[i], id == ids[i] ? BST_CHECKED : BST_UNCHECKED);
97 }
98
99 void
100 fatal (const char *msg, DWORD err)
101 {
102 DWORD e = (err != ERROR_SUCCESS) ? err : GetLastError();
103 char *buf;
104 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
105 0, e, 0, (CHAR *) & buf, 0, 0);
106 mbox (0, buf, msg, MB_OK);
107 Logger ().exit (1);
108 // Keep gcc happy - some sort of bug!
109 exit (1);
110 }
This page took 0.037766 seconds and 5 git commands to generate.