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