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