static const TCHAR *hdz[] = { _T("hdz"), _T("zip"), _T("rar"), _T("7z"), NULL };
-static int progressdialogreturn;
-static int progressdialogactive;
-
static INT_PTR CALLBACK ProgressDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
- PostQuitMessage (0);
- progressdialogactive = 0;
+ PostQuitMessage(0);
return TRUE;
case WM_CLOSE:
- if (progressdialogreturn < 0)
- progressdialogreturn = 0;
+ CustomDialogClose(hDlg, 0);
return TRUE;
case WM_INITDIALOG:
return TRUE;
switch (LOWORD(wParam))
{
case IDCANCEL:
- progressdialogreturn = 0;
+ CustomDialogClose(hDlg, 0);
return TRUE;
}
break;
return out + _tcslen(out);
}
-static int chsdialogactive, chs_secs, chs_cyls, chs_heads;
+static int chs_secs, chs_cyls, chs_heads;
static TCHAR *parse_identity(uae_u8 *data, struct ini_data *ini, TCHAR *s)
{
uae_u16 v;
infotxt = _T("Realtek hack, remove and insert the card.");
}
- progressdialogreturn = -1;
- progressdialogactive = 1;
- struct newresource *res;
- HWND hwnd = CustomCreateDialog(&res, IDD_PROGRESSBAR, hDlg, ProgressDialogProc);
- if (hwnd == NULL)
+ SAVECDS;
+ HWND hwnd = CustomCreateDialog(IDD_PROGRESSBAR, hDlg, ProgressDialogProc, &cdstate);
+ if (hwnd == NULL) {
+ RESTORECDS;
return false;
+ }
HWND hwndprogress = GetDlgItem (hwnd, IDC_PROGRESSBAR);
ShowWindow(hwndprogress, SW_HIDE);
HWND hwndprogresstxt = GetDlgItem (hwnd, IDC_PROGRESSBAR_TEXT);
ShowWindow(hwnd, SW_SHOW);
int tcnt = 0;
- for (;;) {
- if (progressdialogreturn >= 0)
- break;
+ while(cdstate.active) {
MSG msg;
SendMessage (hwndprogresstxt, WM_SETTEXT, 0, (LPARAM)infotxt);
while (PeekMessage (&msg, hwnd, 0, 0, PM_REMOVE)) {
tcnt = 0;
}
}
- freescaleresource(res);
- if (progressdialogactive) {
+ if (cdstate.active) {
DestroyWindow (hwnd);
MSG msg;
while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
DispatchMessage (&msg);
}
}
+ RESTORECDS;
memset(data, 0, 512);
memcpy(cmd, realtek_read, sizeof(realtek_read));
PostQuitMessage(0);
return TRUE;
case WM_CLOSE:
- chsdialogactive = 0;
- DestroyWindow(hDlg);
+ CustomDialogClose(hDlg, 0);
return TRUE;
case WM_INITDIALOG:
SetDlgItemInt(hDlg, IDC_CHS_SECTORS, chs_secs, FALSE);
chs_heads = GetDlgItemInt(hDlg, IDC_CHS_HEADS, NULL, FALSE);
break;
case IDOK:
- chsdialogactive = -1;
- DestroyWindow(hDlg);
+ CustomDialogClose(hDlg, 1);
return TRUE;
case IDCANCEL:
- chsdialogactive = 0;
- DestroyWindow(hDlg);
+ CustomDialogClose(hDlg, 0);
return TRUE;
}
break;
DWORD err = 0;
HFONT font;
HWND hwnd;
- struct newresource *res;
+
+ SAVECDS;
memset(data, 0, 512);
memset(cmd, 0, sizeof(cmd));
parse_identity(udi->identity, NULL, NULL);
}
- chsdialogactive = 1;
- hwnd = CustomCreateDialog(&res, IDD_CHSQUERY, hDlg, CHSDialogProc);
+ hwnd = CustomCreateDialog(IDD_CHSQUERY, hDlg, CHSDialogProc, &cdstate);
if (hwnd == NULL) {
err = -15;
goto end;
font = CreateFont(getscaledfontsize(-1, hDlg), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
if (font)
SendMessage(GetDlgItem(hwnd, IDD_CHSQUERY), WM_SETFONT, WPARAM(font), FALSE);
- while (chsdialogactive == 1) {
+ while (cdstate.active) {
MSG msg;
int ret;
WaitMessage();
}
}
}
- freescaleresource(res);
- DeleteObject(font);
- if (chsdialogactive == 0) {
+ if (font) {
+ DeleteObject(font);
+ }
+ if (cdstate.status == 0) {
err = -100;
goto end;
}
goto end;
}
end:
+ RESTORECDS;
VirtualFree(data, 0, MEM_RELEASE);
if (cylsp)
*cylsp = cyls;
}
-static int stringboxdialogactive;
static TCHAR geometry_file[MAX_DPATH];
static struct ini_data *hdini;
static INT_PTR CALLBACK StringBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
PostQuitMessage (0);
return TRUE;
case WM_CLOSE:
- stringboxdialogactive = 0;
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 0);
return TRUE;
case WM_INITDIALOG:
ShowWindow(GetDlgItem (hDlg, IDC_SAVEBOOTBLOCK), SW_SHOW);
break;
}
case IDOK:
- stringboxdialogactive = -1;
+ CustomDialogClose(hDlg, 1);
DestroyWindow (hDlg);
return TRUE;
case IDCANCEL:
- stringboxdialogactive = 0;
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 0);
return TRUE;
}
break;
bool atapi = false;
HWND hwnd;
bool empty = true;
- struct newresource *res;
geometryfile[0] = 0;
text = xcalloc(TCHAR, 100000);
_tcscat(geometry_file, _T(".geo"));
makesafefilename(geometry_file, true);
- stringboxdialogactive = 1;
+ SAVECDS;
hdini = ini;
- hwnd = CustomCreateDialog(&res, IDD_DISKINFO, hDlg, StringBoxDialogProc);
+ hwnd = CustomCreateDialog(IDD_DISKINFO, hDlg, StringBoxDialogProc, &cdstate);
if (hwnd != NULL) {
HFONT font = CreateFont (getscaledfontsize(-1, hDlg), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
if (font)
SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
- while (stringboxdialogactive == 1) {
+ while (cdstate.active) {
MSG msg;
int ret;
WaitMessage ();
DispatchMessage (&msg);
}
}
- if (stringboxdialogactive == -1)
- break;
}
- DeleteObject (font);
- freescaleresource(res);
+ if (font) {
+ DeleteObject (font);
+ }
}
+ RESTORECDS;
end:
if (ini)
TCHAR path[MAX_DPATH], tmp[MAX_DPATH], tmp2[MAX_DPATH];
DWORD retcode = 0;
HWND hwnd, hwndprogress, hwndprogresstxt;
- struct newresource *res;
MSG msg;
- int pct, cnt;
+ int pct;
DWORD r;
bool chsmode = false;
DWORD erc = 0;
int cyls = 0, heads = 0, secs = 0;
int cyl = 0, head = 0;
int specialaccessmode = 0;
+ int progressdialogreturn = 0;
+ int seconds = -1;
+
+ SAVECDS;
cache = VirtualAlloc (NULL, COPY_CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE);
if (!cache)
SetFilePointer (hdst, 0, &li.HighPart, FILE_BEGIN);
li.QuadPart = 0;
SetFilePointer (h, 0, &li.HighPart, FILE_BEGIN);
- progressdialogreturn = -1;
- progressdialogactive = 1;
- hwnd = CustomCreateDialog(&res, IDD_PROGRESSBAR, hDlg, ProgressDialogProc);
+ hwnd = CustomCreateDialog(IDD_PROGRESSBAR, hDlg, ProgressDialogProc, &cdstate);
if (hwnd == NULL)
goto err;
hwndprogress = GetDlgItem (hwnd, IDC_PROGRESSBAR);
hwndprogresstxt = GetDlgItem (hwnd, IDC_PROGRESSBAR_TEXT);
ShowWindow (hwnd, SW_SHOW);
pct = 0;
- cnt = 1000;
sizecnt = 0;
written = 0;
+
for (;;) {
+ progressdialogreturn = cdstate.active > 0 ? -1 : 0;
if (progressdialogreturn >= 0)
break;
- if (cnt >= 100) {
+ SYSTEMTIME t;
+ GetLocalTime(&t);
+ if (t.wSecond != seconds) {
+ seconds = t.wSecond;
SendMessage (hwndprogress, PBM_SETPOS, (WPARAM)pct, 0);
if (chsmode) {
_stprintf(tmp2, _T("Cyl %d/%d Head %d/%d"), cyl, cyls, head, heads);
DispatchMessage (&msg);
}
}
- cnt = 0;
}
got = gotdst = 0;
li.QuadPart = sizecnt;
progressdialogreturn = 2;
break;
}
- cnt++;
sizecnt += got;
pct = (int)(sizecnt * 100 / size);
}
- freescaleresource(res);
- if (progressdialogactive) {
+ if (cdstate.active) {
DestroyWindow (hwnd);
while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
TranslateMessage (&msg);
}
ok:
+ RESTORECDS;
if (h != INVALID_HANDLE_VALUE)
CloseHandle (h);
if (cache)
CONTROL "Disable sound output",IDC_AVIOUTPUT_NOSOUNDOUTPUT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,114,176,10
CONTROL "Disable sound sync",IDC_AVIOUTPUT_NOSOUNDSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,114,171,10
- CONTROL "AVI output enabled",IDC_AVIOUTPUT_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,15,129,144,14
+ CONTROL "AVI output enabled",IDC_AVIOUTPUT_ACTIVATED,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,15,129,144,14
GROUPBOX "Ripper",IDC_STATIC,1,155,393,65
PUSHBUTTON "Save screenshot",IDC_SCREENSHOT,28,169,87,14
PUSHBUTTON "Pro Wizard 1.62",IDC_PROWIZARD,162,169,87,14,WS_DISABLED
- CONTROL "Sample ripper",IDC_SAMPLERIPPER_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,280,169,87,14
+ CONTROL "Sample ripper",IDC_SAMPLERIPPER_ACTIVATED,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,280,169,87,14
CONTROL "Take screenshot before filtering",IDC_SCREENSHOT_ORIGINALSIZE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,192,130,10
CONTROL "Create 256 color palette indexed screenshot if possible",IDC_SCREENSHOT_PALETTED,
CONTROL "Autoclip screenshot",IDC_SCREENSHOT_CLIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,192,169,10
CONTROL "Continuous screenshots",IDC_SCREENSHOT_AUTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,206,169,10
GROUPBOX "Re-recorder",IDC_STATIC,1,227,393,70
- CONTROL "Play recording",IDC_STATEREC_PLAY,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,53,239,87,14
- CONTROL "Re-recording enabled",IDC_STATEREC_RECORD,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,214,239,118,14
+ CONTROL "Play recording",IDC_STATEREC_PLAY,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,53,239,87,14
+ CONTROL "Re-recording enabled",IDC_STATEREC_RECORD,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,214,239,118,14
CONTROL "Automatic replay",IDC_STATEREC_AUTOPLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,262,129,10
PUSHBUTTON "Save recording",IDC_STATEREC_SAVE,214,257,118,14
RTEXT "Recording rate (seconds):",IDC_STATIC,15,280,121,10,SS_CENTERIMAGE | WS_TABSTOP
END
IDD_INFOBOX DIALOGEX 0, 0, 420, 68
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Scanning ROM image files..."
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
END
IDD_LIST DIALOGEX 0, 0, 316, 206
-STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Options"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
+FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,205,185,50,14
PUSHBUTTON "Cancel",IDCANCEL,259,185,50,14
pathtype path_type;
int externaldialogactive;
-static int stringboxdialogactive;
-static int customdialogactive;
-static struct newresource *customdialogres;
-static HWND customdialoghwnd;
+
+struct customdialogstate cdstate;
static int CustomCreateDialogBox(int templ, HWND hDlg, DLGPROC proc);
if (ha) {
HWND p = GetParent(ha);
HWND mainhwnd = AMonitors[0].hAmigaWnd;
- if (p && (p == customdialoghwnd || p == guiDlg || p == mainhwnd)) {
+ if (p && (p == cdstate.hwnd || p == guiDlg || p == mainhwnd)) {
process_gui_control(ha, NULL);
}
}
- } else if (customdialogactive > 0 && customdialogres && customdialoghwnd) {
- if (ha == customdialoghwnd) {
- process_gui_control(customdialoghwnd, customdialogres);
+ } else if (cdstate.active) {
+ if (ha == cdstate.hwnd) {
+ process_gui_control(cdstate.hwnd, cdstate.res);
}
} else {
if (ha == h) {
PostQuitMessage (0);
return TRUE;
case WM_CLOSE:
- stringboxdialogactive = 0;
+ CustomDialogClose(hDlg, 0);
DestroyWindow (hDlg);
return TRUE;
case WM_INITDIALOG:
switch (LOWORD (wParam))
{
case IDOK:
- stringboxdialogactive = -1;
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 1);
return TRUE;
case IDCANCEL:
- stringboxdialogactive = 0;
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 0);
return TRUE;
}
break;
return 0;
}
-static bool infoboxdialogstate;
-static HWND infoboxhwnd;
static INT_PTR CALLBACK InfoBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
bool handled;
{
case WM_DESTROY:
PostQuitMessage (0);
- infoboxdialogstate = false;
+ CustomDialogClose(hDlg, 1);
return TRUE;
case WM_CLOSE:
- DestroyWindow (hDlg);
- infoboxdialogstate = false;
+ CustomDialogClose(hDlg, 1);
return TRUE;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDCANCEL:
- infoboxdialogstate = false;
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 1);
return TRUE;
}
break;
static bool scan_rom_hook (const TCHAR *name, int line)
{
MSG msg;
- if (!infoboxhwnd)
+ if (cdstate.status)
+ return false;
+ if (!cdstate.active)
return true;
if (name != NULL) {
const TCHAR *s = NULL;
if (s)
s++;
}
- SetWindowText (GetDlgItem (infoboxhwnd, line == 1 ? IDC_INFOBOX_TEXT1 : (line == 2 ? IDC_INFOBOX_TEXT2 : IDC_INFOBOX_TEXT3)), s ? s : name);
+ SetWindowText (GetDlgItem (cdstate.hwnd, line == 1 ? IDC_INFOBOX_TEXT1 : (line == 2 ? IDC_INFOBOX_TEXT2 : IDC_INFOBOX_TEXT3)), s ? s : name);
}
- while (PeekMessage (&msg, infoboxhwnd, 0, 0, PM_REMOVE)) {
- if (!IsDialogMessage (infoboxhwnd, &msg)) {
+ while (PeekMessage (&msg, cdstate.hwnd, 0, 0, PM_REMOVE)) {
+ if (!IsDialogMessage (cdstate.hwnd, &msg)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
- return infoboxdialogstate;
+ return cdstate.active;
}
static int scan_rom_2 (struct zfile *f, void *vrsd)
UAEREG *fkey, *fkey2;
TCHAR *paths[MAX_ROM_PATHS];
MSG msg;
- struct newresource *res = NULL;
+ HWND hwnd = NULL;
if (recursive)
return 0;
ret = 0;
+ SAVECDS;
+
regdeletetree (NULL, _T("DetectedROMs"));
fkey = regcreatetree (NULL, _T("DetectedROMs"));
if (fkey == NULL)
goto end;
- infoboxdialogstate = true;
- infoboxhwnd = NULL;
+
if (!rp_isactive ()) {
- HWND hwnd = CustomCreateDialog(&res, IDD_INFOBOX, hDlg, InfoBoxDialogProc);
+ hwnd = CustomCreateDialog(IDD_INFOBOX, hDlg, InfoBoxDialogProc, &cdstate);
if (!hwnd)
goto end;
- infoboxhwnd = hwnd;
}
cnt = 0;
}
end:
- if (infoboxhwnd) {
- HWND hwnd = infoboxhwnd;
- infoboxhwnd = NULL;
+ if (hwnd) {
DestroyWindow (hwnd);
while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
- FreeResource(res);
}
+
+ RESTORECDS;
+
read_rom_list(false);
if (show)
show_rom_list ();
void gui_infotextbox(HWND hDlg, const TCHAR *text)
{
- stringboxdialogactive = 1;
- struct newresource *res;
- HWND hwnd = CustomCreateDialog(&res, IDD_DISKINFO, hDlg ? hDlg : hGUIWnd, StringBoxDialogProc);
- if (hwnd == NULL)
- return;
-
- HFONT font = CreateFont (getscaledfontsize(-1, hDlg), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
- if (font)
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
- while (stringboxdialogactive == 1) {
- MSG msg;
- int ret;
- WaitMessage ();
- while ((ret = GetMessage (&msg, NULL, 0, 0))) {
- if (ret == -1)
- break;
- if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
+ SAVECDS;
+ HWND hwnd = CustomCreateDialog(IDD_DISKINFO, hDlg ? hDlg : hGUIWnd, StringBoxDialogProc, &cdstate);
+ if (hwnd != NULL) {
+ HFONT font = CreateFont (getscaledfontsize(-1, hDlg), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
+ if (font)
+ SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
+ SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
+ while (cdstate.active) {
+ MSG msg;
+ int ret;
+ WaitMessage();
+ while ((ret = GetMessage(&msg, NULL, 0, 0))) {
+ if (ret == -1)
+ break;
+ if (!IsWindow(hwnd) || !IsDialogMessage(hwnd, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
- if (stringboxdialogactive == -1)
- break;
+ }
+ if (font) {
+ DeleteObject(font);
}
}
- freescaleresource(res);
- if (font) {
- DeleteObject(font);
- }
+ RESTORECDS;
}
static void infofloppy (HWND hDlg, int n)
struct diskinfo di;
TCHAR tmp2[MAX_DPATH], tmp1[MAX_DPATH], tmp3[MAX_DPATH];
TCHAR text[20000];
- struct newresource *res;
DISK_examine_image (&workprefs, n, &di, true, tmp3);
DISK_validate_filename(&workprefs, workprefs.floppyslots[n].df, n, tmp1, 0, NULL, NULL, NULL);
_tcscat (text, _T("\r\n"));
}
- stringboxdialogactive = 1;
- HWND hwnd = CustomCreateDialog(&res, IDD_DISKINFO, hDlg, StringBoxDialogProc);
- if (hwnd == NULL)
- return;
-
- HFONT font = CreateFont (getscaledfontsize(-1, hDlg), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
- if (font)
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
- while (stringboxdialogactive == 1) {
- MSG msg;
- int ret;
- WaitMessage ();
- while ((ret = GetMessage (&msg, NULL, 0, 0))) {
- if (ret == -1)
- break;
- if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
+ SAVECDS;
+ HWND hwnd = CustomCreateDialog(IDD_DISKINFO, hDlg, StringBoxDialogProc, &cdstate);
+ if (hwnd != NULL) {
+ HFONT font = CreateFont (getscaledfontsize(-1, hDlg), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
+ if (font)
+ SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
+ SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
+ while (cdstate.active) {
+ MSG msg;
+ int ret;
+ WaitMessage ();
+ while ((ret = GetMessage (&msg, NULL, 0, 0))) {
+ if (ret == -1)
+ break;
+ if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
+ TranslateMessage (&msg);
+ DispatchMessage (&msg);
+ }
}
- if (stringboxdialogactive == -1)
- break;
+ }
+ if (font) {
+ DeleteObject(font);
}
}
- freescaleresource(res);
- DeleteObject (font);
+ RESTORECDS;
}
static void ejectfloppy (int n)
static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid)
{
HWND hwnd;
- struct newresource *res;
TCHAR txt[MAX_DPATH];
- stringboxdialogactive = 1;
- hwnd = CustomCreateDialog(&res, IDD_STRINGBOX, hDlg, StringBoxDialogProc);
- if (hwnd == NULL)
- return 0;
- if (titleid != 0) {
- LoadString (hUIDLL, titleid, txt, MAX_DPATH);
- SetWindowText (hwnd, txt);
- }
- txt[0] = 0;
- SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_SETTEXT, 0, (LPARAM)custom);
- while (stringboxdialogactive == 1) {
- MSG msg;
- int ret;
- WaitMessage ();
- while ((ret = GetMessage (&msg, NULL, 0, 0))) {
- if (ret == -1)
- break;
- if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
+ SAVECDS;
+ hwnd = CustomCreateDialog(IDD_STRINGBOX, hDlg, StringBoxDialogProc, &cdstate);
+ if (hwnd != NULL) {
+ if (titleid != 0) {
+ LoadString (hUIDLL, titleid, txt, MAX_DPATH);
+ SetWindowText (hwnd, txt);
+ }
+ txt[0] = 0;
+ SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_SETTEXT, 0, (LPARAM)custom);
+ while (cdstate.active) {
+ MSG msg;
+ int ret;
+ WaitMessage ();
+ while ((ret = GetMessage (&msg, NULL, 0, 0))) {
+ if (ret == -1)
+ break;
+ if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
+ TranslateMessage (&msg);
+ DispatchMessage (&msg);
+ }
+ SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_GETTEXT, sizeof txt / sizeof (TCHAR), (LPARAM)txt);
}
- SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_GETTEXT, sizeof txt / sizeof (TCHAR), (LPARAM)txt);
}
- if (stringboxdialogactive == -1) {
- _tcscpy (custom, txt);
- freescaleresource(res);
+ if (cdstate.status == 1) {
+ _tcscpy(custom, txt);
+ RESTORECDS;
return 1;
}
}
- freescaleresource(res);
+ RESTORECDS;
return 0;
}
static void input_remapspecials(HWND hDlg)
{
- struct newresource *res;
- CustomCreateDialog(&res, IDD_LIST, hDlg, RemapSpecialsProc);
- freescaleresource(res);
+ CustomCreateDialogBox(IDD_LIST, hDlg, RemapSpecialsProc);
}
static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
switch (msg)
{
case WM_CLOSE:
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 1);
return TRUE;
case WM_INITDIALOG:
{
case IDOK:
case IDC_INPUTMAP_EXIT:
pages[INPUTMAP_ID] = NULL;
- DestroyWindow (hDlg);
+ CustomDialogClose(hDlg, 1);
recursive--;
return TRUE;
case IDC_INPUTMAP_TEST:
static void ports_remap (HWND hDlg, int port, int sub)
{
- struct newresource *res;
+ SAVECDS;
inputmap_port = port;
if (sub < 0) {
sub = 0;
}
inputmap_port_sub = sub;
- HWND dlg = CustomCreateDialog(&res, IDD_INPUTMAP, hDlg, InputMapDlgProc);
- if (dlg == NULL)
- return;
- MSG msg;
- for (;;) {
- DWORD ret = GetMessage (&msg, NULL, 0, 0);
- if (ret == -1 || ret == 0)
- break;
- if (rawmode) {
- if (msg.message == WM_INPUT) {
- handlerawinput (msg.hwnd, msg.message, msg.wParam, msg.lParam);
- continue;
+ HWND dlg = CustomCreateDialog(IDD_INPUTMAP, hDlg, InputMapDlgProc, &cdstate);
+ if (dlg != NULL) {
+ MSG msg;
+ while(cdstate.active) {
+ DWORD ret = GetMessage (&msg, NULL, 0, 0);
+ if (ret == -1 || ret == 0)
+ break;
+ if (rawmode) {
+ if (msg.message == WM_INPUT) {
+ handlerawinput (msg.hwnd, msg.message, msg.wParam, msg.lParam);
+ continue;
+ }
+ // eat all accelerators
+ if (msg.message == WM_KEYDOWN || msg.message == WM_MOUSEMOVE || msg.message == WM_MOUSEWHEEL
+ || msg.message == WM_MOUSEHWHEEL || msg.message == WM_LBUTTONDOWN)
+ continue;
}
- // eat all accelerators
- if (msg.message == WM_KEYDOWN || msg.message == WM_MOUSEMOVE || msg.message == WM_MOUSEWHEEL
- || msg.message == WM_MOUSEHWHEEL || msg.message == WM_LBUTTONDOWN)
+ // IsDialogMessage() eats WM_INPUT messages?!?!
+ if (!rawmode && IsDialogMessage (dlg, &msg))
continue;
+ TranslateMessage (&msg);
+ DispatchMessage (&msg);
}
- // IsDialogMessage() eats WM_INPUT messages?!?!
- if (!rawmode && IsDialogMessage (dlg, &msg))
- continue;
- TranslateMessage (&msg);
- DispatchMessage (&msg);
}
- freescaleresource(res);
+ RESTORECDS;
}
static void input_togglesetmode (void)
int evt;
TCHAR name[256];
TCHAR custom[MAX_DPATH];
- struct newresource *res;
if (input_selected_device < 0 || input_selected_widget < 0)
return;
if (evt <= 0)
name[0] = 0;
- CustomCreateDialog(&res, IDD_LIST, hDlg, QualifierProc);
- freescaleresource(res);
+ CustomCreateDialogBox(IDD_LIST, hDlg, QualifierProc);
#if 0
int item = genericpopupmenu (hDlg, names, mflags, MAX_INPUT_QUALIFIERS * 2);
if (item >= 0)
break;
#endif
case IDC_SAMPLERIPPER_ACTIVATED:
- sampleripper_enabled = !sampleripper_enabled;
- audio_sampleripper (-1);
+ if (ischecked(hDlg, IDC_AVIOUTPUT_ACTIVATED) != (sampleripper_enabled != 0)) {
+ sampleripper_enabled = !sampleripper_enabled;
+ audio_sampleripper (-1);
+ }
break;
case IDC_AVIOUTPUT_ACTIVATED:
- AVIOutput_Toggle (!avioutput_requested, false);
+ if (ischecked(hDlg, IDC_AVIOUTPUT_ACTIVATED) != (avioutput_requested != 0)) {
+ AVIOutput_Toggle (!avioutput_requested, false);
+ }
break;
case IDC_SCREENSHOT:
screenshot(-1, 1, 0);
if (!size)
return NULL;
nr = xcalloc (struct newresource, 1);
+ if (!nr)
+ return NULL;
newres = (LPCDLGTEMPLATEW)xmalloc (uae_u8, size);
- if (!newres)
+ if (!newres) {
+ xfree(nr);
return NULL;
+ }
memcpy ((void*)newres, resdata, size);
nr->sourceresource = newres;
nr->sourcesize = size;
void CustomDialogClose(HWND hDlg, int status)
{
- if (hGUIWnd) {
- EnableWindow(hGUIWnd, TRUE);
+ if (cdstate.parent) {
+ EnableWindow(cdstate.parent, TRUE);
+ cdstate.parent = NULL;
}
- customdialogactive = status;
- customdialoghwnd = NULL;
- freescaleresource(customdialogres);
- customdialogres = NULL;
+ cdstate.status = status;
+ cdstate.active = 0;
+ cdstate.hwnd = NULL;
+ freescaleresource(cdstate.res);
+ cdstate.res = NULL;
DestroyWindow(hDlg);
}
return h;
}
-HWND CustomCreateDialog(struct newresource **resp, int templ, HWND hDlg, DLGPROC proc)
+static HWND getparent(HWND owner)
+{
+ for (;;) {
+ if (GetWindowLongW(owner, GWL_STYLE) & WS_POPUP) {
+ return owner;
+ }
+ owner = GetParent(owner);
+ if (!owner || owner == GetDesktopWindow())
+ break;
+ }
+ return NULL;
+}
+
+HWND CustomCreateDialog(int templ, HWND hDlg, DLGPROC proc, struct customdialogstate *cds)
{
struct newresource *res;
struct dlgcontext dctx;
HWND h = NULL;
- *resp = NULL;
- res = getresource (templ);
+ memset(cds, 0, sizeof(customdialogstate));
+ res = getresource(templ);
if (!res)
return h;
- if (scaleresource (res, &dctx, hDlg, -1, 0, 0, -1)) {
+ HWND parent = getparent(hDlg);
+ if (scaleresource(res, &dctx, hDlg, -1, 0, 0, -1)) {
res->parent = panelresource;
+ cds->parent = parent;
+ if (parent) {
+ EnableWindow(parent, FALSE);
+ }
h = x_CreateDialogIndirectParam(res->inst, res->resource, hDlg, proc, NULL, res);
+ if (!h) {
+ if (parent) {
+ EnableWindow(parent, TRUE);
+ }
+ freescaleresource(res);
+ res = NULL;
+ }
+ }
+ if (h) {
+ cds->res = res;
+ cds->active = 1;
+ cds->hwnd = h;
}
- *resp = res;
return h;
}
static int CustomCreateDialogBox(int templ, HWND hDlg, DLGPROC proc)
{
- struct newresource *res;
- customdialogactive = 1;
- if (hGUIWnd) {
- EnableWindow(hGUIWnd, FALSE);
- }
- HWND hwnd = CustomCreateDialog(&res, templ, hDlg, proc);
+ struct customdialogstate prevstate;
+ memcpy(&prevstate, &cdstate, sizeof(customdialogstate));
+
+ memset(&cdstate, 0, sizeof(customdialogstate));
+ cdstate.active = 1;
+ HWND hwnd = CustomCreateDialog(templ, hDlg, proc, &cdstate);
if (!hwnd) {
- if (hGUIWnd) {
- EnableWindow(hGUIWnd, TRUE);
- }
return 0;
}
- customdialogres = res;
- customdialoghwnd = hwnd;
- while (customdialogactive == 1) {
+ if (!IsWindowVisible(hwnd)) {
+ ShowWindow(hwnd, SW_SHOW);
+ }
+ while (cdstate.active) {
MSG msg;
int ret;
WaitMessage();
if (!IsWindow(hwnd)) {
break;
}
- if (customdialogactive == -1)
- break;
}
}
- if (hGUIWnd) {
- if (!IsWindowEnabled(hGUIWnd)) {
- EnableWindow(hGUIWnd, TRUE);
- }
- }
- return customdialogactive;
+ int ret = cdstate.status;
+ memcpy(&cdstate, &prevstate, sizeof(customdialogstate));
+ return ret;
}
static int init_page (int tmpl, int icon, int title,