https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ceb1e0b9ff1a4567923c6a...
commit ceb1e0b9ff1a4567923c6a32914296d8721f6332 Author: Ged Murphy gedmurphy@reactos.org AuthorDate: Tue Dec 5 12:25:14 2017 +0000
[Servman] Make the property sheets modeless so users can open multiple services at the same time (#166)
[SERVMAN] - Make the property sheets modeless so users can open multiple services at the same time - Untested in ros. In fact we have no code or tests cases to check that modeless property sheets work, so please raise a bug if you find any issues with the app. - Dedicated to reactosfanboy --- base/applications/mscutils/servman/precomp.h | 3 +- base/applications/mscutils/servman/propsheet.c | 65 ++++++++++++++++++++------ 2 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/base/applications/mscutils/servman/precomp.h b/base/applications/mscutils/servman/precomp.h index 661772ffb4..051634dc95 100644 --- a/base/applications/mscutils/servman/precomp.h +++ b/base/applications/mscutils/servman/precomp.h @@ -13,6 +13,7 @@ #include <shlobj.h> #include <commdlg.h> #include <strsafe.h> +#include <process.h>
#include "resource.h"
@@ -155,7 +156,7 @@ VOID TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPWS BOOL TV2_HasDependantServices(LPWSTR lpServiceName); LPENUM_SERVICE_STATUS TV2_GetDependants(LPWSTR lpServiceName, LPDWORD lpdwCount);
-LONG APIENTRY OpenPropSheet(PMAIN_WND_INFO Info); +VOID OpenPropSheet(PMAIN_WND_INFO Info);
/* propsheet window procs */ INT_PTR CALLBACK DependenciesPageProc(HWND hwndDlg, diff --git a/base/applications/mscutils/servman/propsheet.c b/base/applications/mscutils/servman/propsheet.c index dc978c8dc7..9557420ebb 100644 --- a/base/applications/mscutils/servman/propsheet.c +++ b/base/applications/mscutils/servman/propsheet.c @@ -9,32 +9,48 @@
#include "precomp.h"
+unsigned int __stdcall PropSheetThread(void* Param); + static VOID InitPropSheetPage(PROPSHEETPAGE *psp, PSERVICEPROPSHEET dlgInfo, WORD idDlg, DLGPROC DlgProc) { - ZeroMemory(psp, sizeof(PROPSHEETPAGE)); - psp->dwSize = sizeof(PROPSHEETPAGE); - psp->dwFlags = PSP_DEFAULT; - psp->hInstance = hInstance; - psp->pszTemplate = MAKEINTRESOURCE(idDlg); - psp->pfnDlgProc = DlgProc; - psp->lParam = (LPARAM)dlgInfo; + ZeroMemory(psp, sizeof(PROPSHEETPAGE)); + psp->dwSize = sizeof(PROPSHEETPAGE); + psp->dwFlags = PSP_DEFAULT; + psp->hInstance = hInstance; + psp->pszTemplate = MAKEINTRESOURCE(idDlg); + psp->pfnDlgProc = DlgProc; + psp->lParam = (LPARAM)dlgInfo; }
-LONG APIENTRY +VOID OpenPropSheet(PMAIN_WND_INFO Info) +{ + HANDLE hThread; + hThread = (HANDLE)_beginthreadex(NULL, 0, &PropSheetThread, Info, 0, NULL); + if (hThread) + { + CloseHandle(hThread); + } +} + + +unsigned int __stdcall PropSheetThread(void* Param) { PROPSHEETHEADER psh; PROPSHEETPAGE psp[4]; PSERVICEPROPSHEET pServicePropSheet; - LONG Ret = 0; + HWND hDlg = NULL; + MSG Msg; + + PMAIN_WND_INFO Info = (PMAIN_WND_INFO)Param;
ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USECALLBACK;// | PSH_MODELESS; + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_MODELESS; psh.hwndParent = Info->hMainWnd; psh.hInstance = hInstance; psh.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SM_ICON)); @@ -58,12 +74,31 @@ OpenPropSheet(PMAIN_WND_INFO Info) InitPropSheetPage(&psp[2], pServicePropSheet, IDD_RECOVERY, RecoveryPageProc); InitPropSheetPage(&psp[3], pServicePropSheet, IDD_DLG_DEPEND, DependenciesPageProc);
- Ret = (LONG)(PropertySheet(&psh) != -1); + hDlg = (HWND)PropertySheetW(&psh); + if (hDlg) + { + /* Pump the message queue */ + while (GetMessageW(&Msg, NULL, 0, 0)) + { + + if (PropSheet_GetCurrentPageHwnd(hDlg) == NULL) + { + /* The user hit the ok / cancel button, pull it down */ + EnableWindow(Info->hMainWnd, TRUE); + DestroyWindow(hDlg); + }
- HeapFree(ProcessHeap, - 0, - pServicePropSheet); + if (PropSheet_IsDialogMessage(hDlg, &Msg) != 0) + { + TranslateMessage(&Msg); + DispatchMessageW(&Msg); + } + } + } + + HeapFree(GetProcessHeap(), 0, pServicePropSheet); }
- return Ret; + return (hDlg != NULL); } +