2004-01-15 02:48:05 +01:00
|
|
|
/*
|
|
|
|
* GUI support
|
|
|
|
*
|
|
|
|
* Copyright 2004 Ferenc Wagner
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-01-15 02:48:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
2004-06-16 00:45:15 +02:00
|
|
|
#include "resource.h"
|
2004-01-15 02:48:05 +01:00
|
|
|
#include "winetest.h"
|
|
|
|
|
|
|
|
/* Event object to signal successful window creation to main thread.
|
|
|
|
*/
|
2005-06-02 17:11:32 +02:00
|
|
|
static HANDLE initEvent;
|
2004-01-15 02:48:05 +01:00
|
|
|
|
|
|
|
/* Dialog handle
|
|
|
|
*/
|
2005-06-02 17:11:32 +02:00
|
|
|
static HWND dialog;
|
2004-01-15 02:48:05 +01:00
|
|
|
|
|
|
|
/* Progress data for the text* functions and for scaling.
|
|
|
|
*/
|
2005-06-02 17:11:32 +02:00
|
|
|
static unsigned int progressMax, progressCurr;
|
|
|
|
static double progressScale;
|
2004-01-15 02:48:05 +01:00
|
|
|
|
|
|
|
/* Progress group counter for the gui* functions.
|
|
|
|
*/
|
2005-06-02 17:11:32 +02:00
|
|
|
static int progressGroup;
|
2004-01-15 02:48:05 +01:00
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static WNDPROC DefEditProc;
|
2005-04-18 11:54:24 +02:00
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
MBdefault (int uType)
|
|
|
|
{
|
|
|
|
static const int matrix[][4] = {{IDOK, 0, 0, 0},
|
|
|
|
{IDOK, IDCANCEL, 0, 0},
|
|
|
|
{IDABORT, IDRETRY, IDIGNORE, 0},
|
|
|
|
{IDYES, IDNO, IDCANCEL, 0},
|
|
|
|
{IDYES, IDNO, 0, 0},
|
|
|
|
{IDRETRY, IDCANCEL, 0, 0}};
|
|
|
|
int type = uType & MB_TYPEMASK;
|
|
|
|
int def = (uType & MB_DEFMASK) / MB_DEFBUTTON2;
|
|
|
|
|
|
|
|
return matrix[type][def];
|
|
|
|
}
|
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
/* report (R_STATUS, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textStatus (va_list ap)
|
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
fputs (str, stderr);
|
|
|
|
fputc ('\n', stderr);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiStatus (va_list ap)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
char *str = vstrmake (&len, ap);
|
|
|
|
|
|
|
|
if (len > 128) str[129] = 0;
|
2012-01-19 21:05:28 +01:00
|
|
|
SetDlgItemTextA (dialog, IDC_SB, str);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-02-21 05:01:56 +01:00
|
|
|
/* report (R_PROGRESS, barnum, steps) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textProgress (va_list ap)
|
|
|
|
{
|
2004-03-19 02:54:10 +01:00
|
|
|
progressGroup = va_arg (ap, int);
|
2004-01-15 02:48:05 +01:00
|
|
|
progressMax = va_arg (ap, int);
|
|
|
|
progressCurr = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiProgress (va_list ap)
|
|
|
|
{
|
2004-02-21 05:01:56 +01:00
|
|
|
unsigned int max;
|
|
|
|
HWND pb;
|
2004-01-15 02:48:05 +01:00
|
|
|
|
2004-02-21 05:01:56 +01:00
|
|
|
progressGroup = va_arg (ap, int);
|
|
|
|
progressMax = max = va_arg (ap, int);
|
2004-01-15 02:48:05 +01:00
|
|
|
progressCurr = 0;
|
|
|
|
if (max > 0xffff) {
|
|
|
|
progressScale = (double)0xffff / max;
|
|
|
|
max = 0xffff;
|
|
|
|
}
|
|
|
|
else progressScale = 1;
|
2004-02-21 05:01:56 +01:00
|
|
|
pb = GetDlgItem (dialog, IDC_PB0 + progressGroup * 2);
|
2012-01-19 21:05:28 +01:00
|
|
|
SendMessageA(pb, PBM_SETRANGE, 0, MAKELPARAM (0, max));
|
|
|
|
SendMessageA(pb, PBM_SETSTEP, 1, 0);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* report (R_STEP, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textStep (va_list ap)
|
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
progressCurr++;
|
|
|
|
fputs (str, stderr);
|
|
|
|
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiStep (va_list ap)
|
|
|
|
{
|
|
|
|
const int pgID = IDC_ST0 + progressGroup * 2;
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
progressCurr++;
|
2012-01-19 21:05:28 +01:00
|
|
|
SetDlgItemTextA (dialog, pgID, str);
|
|
|
|
SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS,
|
2009-12-29 23:16:17 +01:00
|
|
|
progressScale * progressCurr, 0);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* report (R_DELTA, inc, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textDelta (va_list ap)
|
|
|
|
{
|
|
|
|
const int inc = va_arg (ap, int);
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
progressCurr += inc;
|
|
|
|
fputs (str, stderr);
|
|
|
|
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiDelta (va_list ap)
|
|
|
|
{
|
|
|
|
const int inc = va_arg (ap, int);
|
|
|
|
const int pgID = IDC_ST0 + progressGroup * 2;
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
progressCurr += inc;
|
2012-01-19 21:05:28 +01:00
|
|
|
SetDlgItemTextA (dialog, pgID, str);
|
|
|
|
SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS,
|
2009-12-29 23:16:17 +01:00
|
|
|
progressScale * progressCurr, 0);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-03-31 17:22:41 +02:00
|
|
|
/* report (R_TAG) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2005-03-31 17:22:41 +02:00
|
|
|
textTag (va_list ap)
|
|
|
|
{
|
|
|
|
fputs ("Tag: ", stderr);
|
|
|
|
fputs (tag, stderr);
|
|
|
|
fputc ('\n', stderr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2005-03-31 17:22:41 +02:00
|
|
|
guiTag (va_list ap)
|
|
|
|
{
|
2012-01-19 21:05:28 +01:00
|
|
|
SetDlgItemTextA (dialog, IDC_TAG, tag);
|
2005-03-31 17:22:41 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
/* report (R_DIR, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textDir (va_list ap)
|
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
fputs ("Temporary directory: ", stderr);
|
|
|
|
fputs (str, stderr);
|
|
|
|
fputc ('\n', stderr);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiDir (va_list ap)
|
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
2012-01-19 21:05:28 +01:00
|
|
|
SetDlgItemTextA (dialog, IDC_DIR, str);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* report (R_OUT, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textOut (va_list ap)
|
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
|
|
|
fputs ("Log file: ", stderr);
|
|
|
|
fputs (str, stderr);
|
|
|
|
fputc ('\n', stderr);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiOut (va_list ap)
|
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
2012-01-19 21:05:28 +01:00
|
|
|
SetDlgItemTextA (dialog, IDC_OUT, str);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
/* report (R_WARNING, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
textWarning (va_list ap)
|
2004-01-15 02:48:05 +01:00
|
|
|
{
|
2004-02-19 05:12:42 +01:00
|
|
|
fputs ("Warning: ", stderr);
|
|
|
|
textStatus (ap);
|
|
|
|
return 0;
|
2004-01-15 02:48:05 +01:00
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
guiWarning (va_list ap)
|
2004-01-15 02:48:05 +01:00
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
2012-01-19 21:05:28 +01:00
|
|
|
MessageBoxA (dialog, str, "Warning", MB_ICONWARNING | MB_OK);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-02-19 05:12:42 +01:00
|
|
|
return 0;
|
2004-01-15 02:48:05 +01:00
|
|
|
}
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
/* report (R_ERROR, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
textError (va_list ap)
|
2004-01-15 02:48:05 +01:00
|
|
|
{
|
2004-02-19 05:12:42 +01:00
|
|
|
fputs ("Error: ", stderr);
|
|
|
|
textStatus (ap);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
guiError (va_list ap)
|
2004-01-15 02:48:05 +01:00
|
|
|
{
|
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
2012-01-19 21:05:28 +01:00
|
|
|
MessageBoxA (dialog, str, "Error", MB_ICONERROR | MB_OK);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
/* report (R_FATAL, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
textFatal (va_list ap)
|
|
|
|
{
|
|
|
|
textError (ap);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
guiFatal (va_list ap)
|
|
|
|
{
|
|
|
|
guiError (ap);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
/* report (R_ASK, type, fmt, ...) */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
textAsk (va_list ap)
|
|
|
|
{
|
|
|
|
int uType = va_arg (ap, int);
|
2004-02-19 05:12:42 +01:00
|
|
|
int ret = MBdefault (uType);
|
2004-01-15 02:48:05 +01:00
|
|
|
char *str = vstrmake (NULL, ap);
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
fprintf (stderr, "Question of type %d: %s\n"
|
|
|
|
"Returning default: %d\n", uType, str, ret);
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-02-19 05:12:42 +01:00
|
|
|
return ret;
|
2004-01-15 02:48:05 +01:00
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-01-15 02:48:05 +01:00
|
|
|
guiAsk (va_list ap)
|
|
|
|
{
|
|
|
|
int uType = va_arg (ap, int);
|
|
|
|
char *str = vstrmake (NULL, ap);
|
2012-01-19 21:05:28 +01:00
|
|
|
int ret = MessageBoxA (dialog, str, "Question", MB_ICONQUESTION | uType);
|
2004-01-15 02:48:05 +01:00
|
|
|
|
2009-05-17 13:28:23 +02:00
|
|
|
heap_free (str);
|
2004-01-15 02:48:05 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static BOOL CALLBACK
|
2005-04-18 11:54:24 +02:00
|
|
|
EditTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_CHAR:
|
|
|
|
if (wParam == 8) break; /* backspace is OK */
|
|
|
|
if (GetWindowTextLengthA (hwnd) == MAXTAGLEN ||
|
|
|
|
!goodtagchar (wParam)) return TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProcA (DefEditProc, hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2006-06-06 07:21:13 +02:00
|
|
|
static INT_PTR CALLBACK
|
2005-03-31 17:22:41 +02:00
|
|
|
AskTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
switch (msg) {
|
2005-04-18 11:54:24 +02:00
|
|
|
case WM_INITDIALOG:
|
2012-01-19 21:05:28 +01:00
|
|
|
DefEditProc = (WNDPROC)SetWindowLongPtrA
|
2005-04-18 11:54:24 +02:00
|
|
|
(GetDlgItem (hwnd, IDC_TAG), GWLP_WNDPROC, (LONG_PTR)EditTagProc);
|
|
|
|
return TRUE;
|
2005-03-31 17:22:41 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD (wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
len = GetWindowTextLengthA (GetDlgItem (hwnd, IDC_TAG));
|
2008-09-04 10:06:46 +02:00
|
|
|
if(!len) {
|
|
|
|
report (R_WARNING, "You must enter a tag to continue");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-05-17 13:28:23 +02:00
|
|
|
tag = heap_alloc (len+1);
|
2005-04-18 11:54:24 +02:00
|
|
|
GetDlgItemTextA (hwnd, IDC_TAG, tag, len+1);
|
|
|
|
EndDialog (hwnd, IDOK);
|
2005-03-31 17:22:41 +02:00
|
|
|
return TRUE;
|
|
|
|
case IDABORT:
|
|
|
|
EndDialog (hwnd, IDABORT);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
guiAskTag (void)
|
|
|
|
{
|
2012-01-19 21:05:28 +01:00
|
|
|
return DialogBoxA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDD_TAG), dialog, AskTagProc);
|
2005-03-31 17:22:41 +02:00
|
|
|
}
|
|
|
|
|
2010-02-06 10:21:22 +01:00
|
|
|
static INT_PTR CALLBACK
|
|
|
|
AskEmailProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD (wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
len = GetWindowTextLengthA (GetDlgItem (hwnd, IDC_EMAIL));
|
|
|
|
if(!len) {
|
|
|
|
report (R_WARNING, "You must enter an email address to continue");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
email = heap_alloc (len+1);
|
|
|
|
GetDlgItemTextA (hwnd, IDC_EMAIL, email, len+1);
|
|
|
|
EndDialog (hwnd, IDOK);
|
|
|
|
return TRUE;
|
|
|
|
case IDABORT:
|
|
|
|
EndDialog (hwnd, IDABORT);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
guiAskEmail (void)
|
|
|
|
{
|
2012-01-19 21:05:28 +01:00
|
|
|
return DialogBoxA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDD_EMAIL), dialog, AskEmailProc);
|
2010-02-06 10:21:22 +01:00
|
|
|
}
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
/* Quiet functions */
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
qNoOp (va_list ap)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static int
|
2004-02-19 05:12:42 +01:00
|
|
|
qAsk (va_list ap)
|
|
|
|
{
|
|
|
|
return MBdefault (va_arg (ap, int));
|
|
|
|
}
|
|
|
|
|
2006-06-06 07:21:13 +02:00
|
|
|
static INT_PTR CALLBACK
|
2004-01-15 02:48:05 +01:00
|
|
|
AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD (wParam)) {
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog (hwnd, IDCANCEL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-06-06 07:21:13 +02:00
|
|
|
static INT_PTR CALLBACK
|
2004-01-15 02:48:05 +01:00
|
|
|
DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2012-01-19 21:05:28 +01:00
|
|
|
SendMessageA(hwnd, WM_SETICON, ICON_SMALL,
|
|
|
|
(LPARAM)LoadImageA( GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDI_WINE), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
|
|
|
|
LR_SHARED ));
|
|
|
|
SendMessageA(hwnd, WM_SETICON, ICON_BIG,
|
|
|
|
(LPARAM)LoadIconA( GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDI_WINE)));
|
2004-01-15 02:48:05 +01:00
|
|
|
dialog = hwnd;
|
|
|
|
if (!SetEvent (initEvent)) {
|
|
|
|
report (R_STATUS, "Can't signal main thread: %d",
|
|
|
|
GetLastError ());
|
|
|
|
EndDialog (hwnd, 2);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog (hwnd, 3);
|
|
|
|
return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD (wParam)) {
|
|
|
|
case IDHELP:
|
2012-01-19 21:05:28 +01:00
|
|
|
DialogBoxA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDD_ABOUT), hwnd, AboutProc);
|
2004-01-15 02:48:05 +01:00
|
|
|
return TRUE;
|
|
|
|
case IDABORT:
|
2010-06-22 19:36:08 +02:00
|
|
|
report (R_STATUS, "Aborting, please wait...");
|
|
|
|
aborting = TRUE;
|
2004-01-15 02:48:05 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static DWORD WINAPI
|
|
|
|
DlgThreadProc (LPVOID param)
|
2004-01-15 02:48:05 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
InitCommonControls ();
|
2012-01-19 21:05:28 +01:00
|
|
|
ret = DialogBoxA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDD_STATUS), NULL, DlgProc);
|
2004-01-15 02:48:05 +01:00
|
|
|
switch (ret) {
|
|
|
|
case 0:
|
2010-03-05 13:10:16 +01:00
|
|
|
report (R_FATAL, "Cannot display dialog");
|
2004-01-15 02:48:05 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
report (R_WARNING, "DialogBox failed: %d",
|
|
|
|
GetLastError ());
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
exit (0);
|
|
|
|
default:
|
|
|
|
report (R_STATUS, "Dialog exited: %d", ret);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
report (enum report_type t, ...)
|
|
|
|
{
|
|
|
|
typedef int r_fun_t (va_list);
|
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
int ret = 0;
|
|
|
|
static r_fun_t * const text_funcs[] =
|
|
|
|
{textStatus, textProgress, textStep, textDelta,
|
2005-03-31 17:22:41 +02:00
|
|
|
textTag, textDir, textOut,
|
2004-03-19 02:54:10 +01:00
|
|
|
textWarning, textError, textFatal, textAsk};
|
2004-01-15 02:48:05 +01:00
|
|
|
static r_fun_t * const GUI_funcs[] =
|
|
|
|
{guiStatus, guiProgress, guiStep, guiDelta,
|
2005-03-31 17:22:41 +02:00
|
|
|
guiTag, guiDir, guiOut,
|
2004-03-19 02:54:10 +01:00
|
|
|
guiWarning, guiError, guiFatal, guiAsk};
|
2004-02-19 05:12:42 +01:00
|
|
|
static r_fun_t * const quiet_funcs[] =
|
|
|
|
{qNoOp, qNoOp, qNoOp, qNoOp,
|
2005-03-31 17:22:41 +02:00
|
|
|
qNoOp, qNoOp, qNoOp,
|
2011-12-28 10:42:11 +01:00
|
|
|
qNoOp, textError, textFatal, qAsk};
|
2004-01-15 02:48:05 +01:00
|
|
|
static r_fun_t * const * funcs = NULL;
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
switch (t) {
|
|
|
|
case R_TEXTMODE:
|
|
|
|
funcs = text_funcs;
|
|
|
|
return 0;
|
|
|
|
case R_QUIET:
|
|
|
|
funcs = quiet_funcs;
|
|
|
|
return 0;
|
|
|
|
default:
|
2004-02-20 02:09:31 +01:00
|
|
|
break;
|
2004-02-19 05:12:42 +01:00
|
|
|
}
|
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
if (!funcs) {
|
|
|
|
HANDLE DlgThread;
|
|
|
|
DWORD DlgThreadID;
|
|
|
|
|
|
|
|
funcs = text_funcs;
|
2012-01-19 21:05:28 +01:00
|
|
|
initEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
2004-01-15 02:48:05 +01:00
|
|
|
if (!initEvent)
|
|
|
|
report (R_STATUS, "Can't create event object: %d",
|
|
|
|
GetLastError ());
|
|
|
|
else {
|
|
|
|
DlgThread = CreateThread (NULL, 0, DlgThreadProc,
|
|
|
|
NULL, 0, &DlgThreadID);
|
|
|
|
if (!DlgThread)
|
|
|
|
report (R_STATUS, "Can't create GUI thread: %d",
|
|
|
|
GetLastError ());
|
|
|
|
else {
|
|
|
|
DWORD ret = WaitForSingleObject (initEvent, INFINITE);
|
2011-12-30 21:56:16 +01:00
|
|
|
CloseHandle(DlgThread);
|
2004-01-15 02:48:05 +01:00
|
|
|
switch (ret) {
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
funcs = GUI_funcs;
|
|
|
|
break;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
report (R_STATUS, "GUI creation timed out");
|
|
|
|
break;
|
|
|
|
case WAIT_FAILED:
|
|
|
|
report (R_STATUS, "Wait for GUI failed: %d",
|
|
|
|
GetLastError ());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
report (R_STATUS, "Wait returned %d",
|
|
|
|
ret);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
va_start (ap, t);
|
2016-07-31 20:04:10 +02:00
|
|
|
if (t < sizeof text_funcs / sizeof text_funcs[0]) ret = funcs[t](ap);
|
2004-01-15 02:48:05 +01:00
|
|
|
else report (R_WARNING, "unimplemented report type: %d", t);
|
|
|
|
va_end (ap);
|
|
|
|
return ret;
|
|
|
|
}
|