#include "win.h"
extern Bool g_fCursor;
BOOL CALLBACK
winExitDlgProc (HWND hDialog, UINT message,
WPARAM wParam, LPARAM lParam);
BOOL CALLBACK
winChangeDepthDlgProc (HWND hDialog, UINT message,
WPARAM wParam, LPARAM lParam);
void
winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
{
if (g_hDlgExit != NULL)
{
ShowWindow (g_hDlgExit, SW_SHOWDEFAULT);
SetForegroundWindow (g_hDlgExit);
return;
}
g_hDlgExit = CreateDialogParam (g_hInstance,
"EXIT_DIALOG",
pScreenPriv->hwndScreen,
winExitDlgProc,
(int) pScreenPriv);
SetWindowLong (g_hDlgExit, GWL_STYLE,
GetWindowLong (g_hDlgExit, GWL_STYLE)
& ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
SetWindowLong (g_hDlgExit, GWL_EXSTYLE,
GetWindowLong (g_hDlgExit, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
SetWindowPos (g_hDlgExit, 0, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE);
ShowWindow (g_hDlgExit, SW_SHOW);
SetForegroundWindow (g_hDlgExit);
PostMessage (g_hDlgExit, WM_NEXTDLGCTL,
(int) GetDlgItem (g_hDlgExit, IDCANCEL), TRUE);
}
BOOL CALLBACK
winExitDlgProc (HWND hDialog, UINT message,
WPARAM wParam, LPARAM lParam)
{
static winPrivScreenPtr s_pScreenPriv = NULL;
static winScreenInfo *s_pScreenInfo = NULL;
static ScreenPtr s_pScreen = NULL;
switch (message)
{
case WM_INITDIALOG:
s_pScreenPriv = (winPrivScreenPtr) lParam;
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
s_pScreen = s_pScreenInfo->pScreen;
PostMessage (hDialog,
WM_SETICON,
ICON_SMALL,
(LPARAM) LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)));
return TRUE;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDOK:
PostMessage (s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
DestroyWindow (g_hDlgExit);
g_hDlgExit = NULL;
PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
return TRUE;
case IDCANCEL:
DestroyWindow (g_hDlgExit);
g_hDlgExit = NULL;
PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
return TRUE;
}
break;
case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE:
if (!g_fCursor)
{
g_fCursor = TRUE;
ShowCursor (TRUE);
}
return TRUE;
case WM_CLOSE:
DestroyWindow (g_hDlgExit);
g_hDlgExit = NULL;
PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
return TRUE;
}
return FALSE;
}
void
winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv)
{
if (g_hDlgDepthChange != NULL)
{
ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
SetForegroundWindow (g_hDlgDepthChange);
return;
}
g_hDlgDepthChange = CreateDialogParam (g_hInstance,
"DEPTH_CHANGE_BOX",
pScreenPriv->hwndScreen,
winChangeDepthDlgProc,
(int) pScreenPriv);
SetWindowLong (g_hDlgDepthChange, GWL_STYLE,
GetWindowLong (g_hDlgDepthChange, GWL_STYLE)
& ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
SetWindowLong (g_hDlgDepthChange, GWL_EXSTYLE,
GetWindowLong (g_hDlgDepthChange, GWL_EXSTYLE)
& ~WS_EX_APPWINDOW );
SetWindowPos (g_hDlgDepthChange, 0, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE);
ShowWindow (g_hDlgDepthChange, SW_SHOW);
ErrorF ("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
g_hDlgDepthChange);
ErrorF ("winDisplayDepthChangeDialog - GetLastError: %d\n", GetLastError ());
ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
}
BOOL CALLBACK
winChangeDepthDlgProc (HWND hwndDialog, UINT message,
WPARAM wParam, LPARAM lParam)
{
static winPrivScreenPtr s_pScreenPriv = NULL;
static winScreenInfo *s_pScreenInfo = NULL;
static ScreenPtr s_pScreen = NULL;
#if CYGDEBUG
ErrorF ("winChangeDepthDlgProc\n");
#endif
switch (message)
{
case WM_INITDIALOG:
#if CYGDEBUG
ErrorF ("winChangeDepthDlgProc - WM_INITDIALOG\n");
#endif
s_pScreenPriv = (winPrivScreenPtr) lParam;
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
s_pScreen = s_pScreenInfo->pScreen;
#if CYGDEBUG
ErrorF ("winChangeDepthDlgProc - WM_INITDIALG - s_pScreenPriv: %08x, "
"s_pScreenInfo: %08x, s_pScreen: %08x\n",
s_pScreenPriv, s_pScreenInfo, s_pScreen);
#endif
#if CYGDEBUG
ErrorF ("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
"last bpp: %d\n",
s_pScreenInfo->dwBPP,
s_pScreenPriv->dwLastWindowsBitsPixel);
#endif
PostMessage (hwndDialog,
WM_SETICON,
ICON_SMALL,
(LPARAM) LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)));
return TRUE;
case WM_DISPLAYCHANGE:
#if CYGDEBUG
ErrorF ("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
"last bpp: %d, new bpp: %d\n",
s_pScreenInfo->dwBPP,
s_pScreenPriv->dwLastWindowsBitsPixel,
wParam);
#endif
if (wParam == s_pScreenInfo->dwBPP)
{
ErrorF ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
DestroyWindow (g_hDlgDepthChange);
g_hDlgDepthChange = NULL;
s_pScreenPriv->fBadDepth = FALSE;
}
return TRUE;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDOK:
case IDCANCEL:
ErrorF ("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
ShowWindow (g_hDlgDepthChange, SW_HIDE);
return TRUE;
}
break;
case WM_CLOSE:
ErrorF ("winChangeDepthDlgProc - WM_CLOSE\n");
ShowWindow (g_hDlgDepthChange, SW_HIDE);
return TRUE;
}
return FALSE;
}