Commit 2e301ceb authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

For modal propsheets we should run our own message loop rather than

use a modal dialogbox just like Windows does. This helps apps that subclass the propsheet's wndproc.
parent 118ea908
...@@ -131,6 +131,7 @@ typedef struct tagPropSheetInfo ...@@ -131,6 +131,7 @@ typedef struct tagPropSheetInfo
int width; int width;
int height; int height;
HIMAGELIST hImageList; HIMAGELIST hImageList;
BOOL ended;
} PropSheetInfo; } PropSheetInfo;
typedef struct typedef struct
...@@ -707,39 +708,21 @@ int PROPSHEET_CreateDialog(PropSheetInfo* psInfo) ...@@ -707,39 +708,21 @@ int PROPSHEET_CreateDialog(PropSheetInfo* psInfo)
* -1 (error). */ * -1 (error). */
if( psInfo->unicode ) if( psInfo->unicode )
{ {
if (!(psInfo->ppshheader.dwFlags & PSH_MODELESS)) ret = (int)CreateDialogIndirectParamW(psInfo->ppshheader.hInstance,
ret = DialogBoxIndirectParamW(psInfo->ppshheader.hInstance, (LPDLGTEMPLATEW) temp,
(LPDLGTEMPLATEW) temp, psInfo->ppshheader.hwndParent,
psInfo->ppshheader.hwndParent, PROPSHEET_DialogProc,
PROPSHEET_DialogProc, (LPARAM)psInfo);
(LPARAM)psInfo); if ( !ret ) ret = -1;
else
{
ret = (int)CreateDialogIndirectParamW(psInfo->ppshheader.hInstance,
(LPDLGTEMPLATEW) temp,
psInfo->ppshheader.hwndParent,
PROPSHEET_DialogProc,
(LPARAM)psInfo);
if ( !ret ) ret = -1;
}
} }
else else
{ {
if (!(psInfo->ppshheader.dwFlags & PSH_MODELESS)) ret = (int)CreateDialogIndirectParamA(psInfo->ppshheader.hInstance,
ret = DialogBoxIndirectParamA(psInfo->ppshheader.hInstance, (LPDLGTEMPLATEA) temp,
(LPDLGTEMPLATEA) temp, psInfo->ppshheader.hwndParent,
psInfo->ppshheader.hwndParent, PROPSHEET_DialogProc,
PROPSHEET_DialogProc, (LPARAM)psInfo);
(LPARAM)psInfo); if ( !ret ) ret = -1;
else
{
ret = (int)CreateDialogIndirectParamA(psInfo->ppshheader.hInstance,
(LPDLGTEMPLATEA) temp,
psInfo->ppshheader.hwndParent,
PROPSHEET_DialogProc,
(LPARAM)psInfo);
if ( !ret ) ret = -1;
}
} }
Free(temp); Free(temp);
...@@ -1757,7 +1740,7 @@ static BOOL PROPSHEET_Finish(HWND hwndDlg) ...@@ -1757,7 +1740,7 @@ static BOOL PROPSHEET_Finish(HWND hwndDlg)
if (psInfo->isModeless) if (psInfo->isModeless)
psInfo->activeValid = FALSE; psInfo->activeValid = FALSE;
else else
EndDialog(hwndDlg, TRUE); psInfo->ended = TRUE;
return TRUE; return TRUE;
} }
...@@ -1870,7 +1853,7 @@ static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam) ...@@ -1870,7 +1853,7 @@ static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam)
psInfo->activeValid = FALSE; psInfo->activeValid = FALSE;
} }
else else
EndDialog(hwndDlg, FALSE); psInfo->ended = TRUE;
} }
/****************************************************************************** /******************************************************************************
...@@ -2396,7 +2379,7 @@ static BOOL PROPSHEET_RemovePage(HWND hwndDlg, ...@@ -2396,7 +2379,7 @@ static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
psInfo->active_page = -1; psInfo->active_page = -1;
if (!psInfo->isModeless) if (!psInfo->isModeless)
{ {
EndDialog(hwndDlg, FALSE); psInfo->ended = TRUE;
return TRUE; return TRUE;
} }
} }
...@@ -2737,6 +2720,34 @@ static void PROPSHEET_CleanUp(HWND hwndDlg) ...@@ -2737,6 +2720,34 @@ static void PROPSHEET_CleanUp(HWND hwndDlg)
GlobalFree((HGLOBAL)psInfo); GlobalFree((HGLOBAL)psInfo);
} }
static INT do_loop(PropSheetInfo *psInfo)
{
MSG msg;
INT ret = -1;
HWND hwnd = psInfo->hwnd;
while(IsWindow(hwnd) && !psInfo->ended && (ret = GetMessageW(&msg, NULL, 0, 0)))
{
if(ret == -1)
break;
if(!IsDialogMessageW(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
if(ret == 0)
{
PostQuitMessage(msg.wParam);
ret = -1;
}
DestroyWindow(hwnd);
return ret;
}
/****************************************************************************** /******************************************************************************
* PropertySheet (COMCTL32.@) * PropertySheet (COMCTL32.@)
* PropertySheetA (COMCTL32.@) * PropertySheetA (COMCTL32.@)
...@@ -2787,7 +2798,11 @@ INT WINAPI PropertySheetA(LPCPROPSHEETHEADERA lppsh) ...@@ -2787,7 +2798,11 @@ INT WINAPI PropertySheetA(LPCPROPSHEETHEADERA lppsh)
} }
psInfo->unicode = FALSE; psInfo->unicode = FALSE;
psInfo->ended = FALSE;
bRet = PROPSHEET_CreateDialog(psInfo); bRet = PROPSHEET_CreateDialog(psInfo);
if(!psInfo->isModeless)
bRet = do_loop(psInfo);
return bRet; return bRet;
} }
...@@ -2834,7 +2849,11 @@ INT WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh) ...@@ -2834,7 +2849,11 @@ INT WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
} }
psInfo->unicode = TRUE; psInfo->unicode = TRUE;
psInfo->ended = FALSE;
bRet = PROPSHEET_CreateDialog(psInfo); bRet = PROPSHEET_CreateDialog(psInfo);
if(!psInfo->isModeless)
bRet = do_loop(psInfo);
return bRet; return bRet;
} }
...@@ -3039,7 +3058,7 @@ static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID) ...@@ -3039,7 +3058,7 @@ static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID)
if (psInfo->isModeless) if (psInfo->isModeless)
psInfo->activeValid = FALSE; psInfo->activeValid = FALSE;
else else
EndDialog(hwnd, result); psInfo->ended = TRUE;
} }
else else
EnableWindow(hwndApplyBtn, FALSE); EnableWindow(hwndApplyBtn, FALSE);
...@@ -3424,6 +3443,17 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -3424,6 +3443,17 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
return TRUE; return TRUE;
case WM_SYSCOMMAND:
switch(wParam & 0xfff0)
{
case SC_CLOSE:
PROPSHEET_Cancel(hwnd, 1);
return TRUE;
default:
return FALSE;
}
case WM_NOTIFY: case WM_NOTIFY:
{ {
NMHDR* pnmh = (LPNMHDR) lParam; NMHDR* pnmh = (LPNMHDR) lParam;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment