mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2025-01-24 07:14:06 +01:00
Utility: Implemented "Please wait" pop-up
This commit is contained in:
parent
0e498aaa91
commit
874b82f49f
@ -1211,3 +1211,71 @@ HRESULT InputBox(BOOL bPassword, HWND hWnd, LPCWSTR wszPrompt, LPCWSTR wszTitle,
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
UINT PleaseWaitTimeout = 0;
|
||||
HHOOK PleaseWaitHook = NULL;
|
||||
HWND PleaseWaitHWND = NULL;
|
||||
void* PleaseWaitCallbackData = NULL;
|
||||
BOOL (*PleaseWaitCallbackFunc)(void* data) = NULL;
|
||||
BOOL PleaseWait_UpdateTimeout(int timeout)
|
||||
{
|
||||
if (PleaseWaitHWND)
|
||||
{
|
||||
KillTimer(PleaseWaitHWND, 'EPPW');
|
||||
PleaseWaitTimeout = timeout;
|
||||
return SetTimer(PleaseWaitHWND, 'EPPW', PleaseWaitTimeout, PleaseWait_TimerProc);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID CALLBACK PleaseWait_TimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
|
||||
{
|
||||
if (idEvent == 'EPPW')
|
||||
{
|
||||
if (PleaseWaitCallbackFunc)
|
||||
{
|
||||
if (PleaseWaitCallbackFunc(PleaseWaitCallbackData))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PleaseWaitCallbackData = NULL;
|
||||
PleaseWaitCallbackFunc = NULL;
|
||||
}
|
||||
KillTimer(hWnd, 'EPPW');
|
||||
SetTimer(hWnd, 'EPPW', 0, NULL); // <- this closes the message box
|
||||
PleaseWaitHWND = NULL;
|
||||
PleaseWaitTimeout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK PleaseWait_HookProc(int code, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (code < 0)
|
||||
{
|
||||
return CallNextHookEx(NULL, code, wParam, lParam);
|
||||
}
|
||||
|
||||
CWPSTRUCT* msg = (CWPSTRUCT*)lParam;
|
||||
/*if (msg->message == WM_CREATE)
|
||||
{
|
||||
CREATESTRUCT* pCS = (CREATESTRUCT*)msg->lParam;
|
||||
if (pCS->lpszClass == RegisterWindowMessageW(L"Button"))
|
||||
{
|
||||
}
|
||||
}*/
|
||||
LRESULT result = CallNextHookEx(NULL, code, wParam, lParam);
|
||||
|
||||
if (msg->message == WM_INITDIALOG)
|
||||
{
|
||||
PleaseWaitHWND = msg->hwnd;
|
||||
LONG_PTR style = GetWindowLongPtrW(PleaseWaitHWND, GWL_STYLE);
|
||||
SetWindowLongPtrW(PleaseWaitHWND, GWL_STYLE, style & ~WS_SYSMENU);
|
||||
RECT rc;
|
||||
GetWindowRect(PleaseWaitHWND, &rc);
|
||||
SetWindowPos(PleaseWaitHWND, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - MulDiv(50, GetDpiForWindow(PleaseWaitHWND), 96), SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
SetTimer(PleaseWaitHWND, 'EPPW', PleaseWaitTimeout, PleaseWait_TimerProc);
|
||||
UnhookWindowsHookEx(PleaseWaitHook);
|
||||
PleaseWaitHook = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
@ -553,4 +553,13 @@ inline BOOL WINAPI PatchContextMenuOfNewMicrosoftIME(BOOL* bFound)
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
extern UINT PleaseWaitTimeout;
|
||||
extern HHOOK PleaseWaitHook;
|
||||
extern HWND PleaseWaitHWND;
|
||||
extern void* PleaseWaitCallbackData;
|
||||
extern BOOL (*PleaseWaitCallbackFunc)(void* data);
|
||||
BOOL PleaseWait_UpdateTimeout(int timeout);
|
||||
VOID CALLBACK PleaseWait_TimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime);
|
||||
LRESULT CALLBACK PleaseWait_HookProc(int code, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user