]> cygwin.com Git - cygwin-apps/setup.git/blame - dialog.cc
2001-11-13 Robert Collins <rbtcollins@hotmail.com>
[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"
89b1a15b 29#include "log.h"
85b43844 30#include "mount.h"
23c9e63c
DD
31
32char *
33eget (HWND h, int id, char *var)
34{
35 char tmp[4000];
85b43844 36 if (var && var != get_root_dir ())
23c9e63c
DD
37 {
38 free (var);
85b43844 39 var = NULL;
23c9e63c 40 }
42bf5b92 41 if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
23c9e63c 42 {
85b43844 43 var = (char *) malloc (strlen (tmp) + 1);
23c9e63c
DD
44 strcpy (var, tmp);
45 }
46 return var;
47}
48
49int
50eget (HWND h, int id)
51{
52 BOOL s;
53 int r = GetDlgItemInt (h, id, &s, TRUE);
54 return r;
55}
56
57void
85b43844 58eset (HWND h, int id, const char *val)
23c9e63c
DD
59{
60 SetDlgItemText (h, id, val);
61}
62
63void
64eset (HWND h, int id, int val)
65{
b24c88b3 66 SetDlgItemInt (h, id, (UINT) val, TRUE);
23c9e63c
DD
67}
68
69int
70rbget (HWND h, int *ids)
71{
72 int i;
b24c88b3 73 for (i = 0; ids[i]; i++)
23c9e63c
DD
74 if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED)
75 return ids[i];
76 return 0;
77}
78
79void
80rbset (HWND h, int *ids, int id)
81{
82 int i;
b24c88b3
RC
83 for (i = 0; ids[i]; i++)
84 CheckDlgButton (h, ids[i], id == ids[i] ? BST_CHECKED : BST_UNCHECKED);
23c9e63c
DD
85}
86
87void
b24c88b3 88fatal (const char *msg)
23c9e63c 89{
1fd6d0a2 90 DWORD e = GetLastError ();
23c9e63c
DD
91 char *buf;
92 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
b24c88b3 93 0, e, 0, (CHAR *) & buf, 0, 0);
23c9e63c 94 MessageBox (0, buf, msg, 0);
89b1a15b 95 exit_setup (1);
23c9e63c 96}
This page took 0.076523 seconds and 5 git commands to generate.