root/branches/3.00/src/dialog.cc

Revision 644, 2.3 kB (checked in by fujii, 3 years ago)

Add new netinstall source.

Line 
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 #if 0
20 static const char *cvsid =
21   "\n%%% $Id: dialog.cc,v 2.8 2004/11/11 21:31:37 maxb Exp $\n";
22 #endif
23
24 #include "win32.h"
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include "dialog.h"
28 #include "msg.h"
29 #include "LogSingleton.h"
30 #include "mount.h"
31
32 char *
33 eget (HWND h, int id, char *var)
34 {
35   char tmp[4000];
36   if (var && var != get_root_dir ().cstr_oneuse())
37     {
38       delete [] var;
39       var = NULL;
40     }
41   if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
42     {
43       var = new char [strlen (tmp) + 1];
44       var [strlen (tmp)] = '\0';
45       strcpy (var, tmp);
46     }
47   return var;
48 }
49
50 String
51 egetString (HWND h, int id)
52 {
53   String aString;
54   char tmp[4000];
55   if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
56     aString = String (tmp);
57   return aString;
58 }
59
60 int
61 eget (HWND h, int id)
62 {
63   BOOL s;
64   int r = GetDlgItemInt (h, id, &s, TRUE);
65   return r;
66 }
67
68 void
69 eset (HWND h, int id, const char *val)
70 {
71   SetDlgItemText (h, id, val);
72 }
73
74 void
75 eset (HWND h, int id, String const aString)
76 {
77   SetDlgItemText (h, id, aString.cstr_oneuse());
78 }
79
80 void
81 eset (HWND h, int id, int val)
82 {
83   SetDlgItemInt (h, id, (UINT) val, TRUE);
84 }
85
86 int
87 rbget (HWND h, int *ids)
88 {
89   int i;
90   for (i = 0; ids[i]; i++)
91     if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED)
92       return ids[i];
93   return 0;
94 }
95
96 void
97 rbset (HWND h, int *ids, int id)
98 {
99   int i;
100   for (i = 0; ids[i]; i++)
101     CheckDlgButton (h, ids[i], id == ids[i] ? BST_CHECKED : BST_UNCHECKED);
102 }
103
104 void
105 fatal (const char *msg, DWORD err)
106 {
107   DWORD e = (err != ERROR_SUCCESS) ? err : GetLastError();
108   char *buf;
109   FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
110                  0, e, 0, (CHAR *) & buf, 0, 0);
111   MessageBox (0, buf, msg, 0);
112   LogSingleton::GetInstance().exit (1);
113   // Keep gcc happy - some sort of bug!
114   exit (1);
115 }
Note: See TracBrowser for help on using the browser.