2 * Copyright (c) 2000, Red Hat, Inc.
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.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to provide common functionality for
17 all the dialogs in the program. */
20 static const char *cvsid
=
33 eget (HWND h
, int id
, char *var
)
36 if (var
&& var
!= get_root_dir ().c_str())
41 if (GetDlgItemText (h
, id
, tmp
, sizeof (tmp
)) > 0)
43 var
= new char [strlen (tmp
) + 1];
44 var
[strlen (tmp
)] = '\0';
51 egetString (HWND h
, int id
)
55 if (GetDlgItemText (h
, id
, tmp
, sizeof (tmp
)) > 0)
56 aString
= std::string (tmp
);
64 int r
= GetDlgItemInt (h
, id
, &s
, TRUE
);
69 eset (HWND h
, int id
, const char *val
)
71 SetDlgItemText (h
, id
, val
);
75 eset (HWND h
, int id
, const std::string aString
)
77 SetDlgItemText (h
, id
, aString
.c_str());
81 eset (HWND h
, int id
, int val
)
83 SetDlgItemInt (h
, id
, (UINT
) val
, TRUE
);
87 rbget (HWND h
, int *ids
)
90 for (i
= 0; ids
[i
]; i
++)
91 if (IsDlgButtonChecked (h
, ids
[i
]) == BST_CHECKED
)
97 rbset (HWND h
, int *ids
, int id
)
100 for (i
= 0; ids
[i
]; i
++)
101 CheckDlgButton (h
, ids
[i
], id
== ids
[i
] ? BST_CHECKED
: BST_UNCHECKED
);
105 fatal (const char *msg
, DWORD err
)
107 DWORD e
= (err
!= ERROR_SUCCESS
) ? err
: GetLastError();
109 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
110 0, e
, 0, (CHAR
*) & buf
, 0, 0);
111 mbox (0, buf
, msg
, MB_OK
);
113 // Keep gcc happy - some sort of bug!