|
|
|
@ -2917,7 +2917,7 @@ const int Progress::cBTNheight = 25;
|
|
|
|
|
volatile LONG Progress::refCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Progress::Progress(HINSTANCE hInst) : _hwnd(NULL)
|
|
|
|
|
Progress::Progress(HINSTANCE hInst) : _hwnd(NULL), _hCallerWnd(NULL)
|
|
|
|
|
{
|
|
|
|
|
if (::InterlockedIncrement(&refCount) == 1)
|
|
|
|
|
{
|
|
|
|
@ -2955,23 +2955,26 @@ Progress::~Progress()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HWND Progress::open(HWND hOwner, const TCHAR* header)
|
|
|
|
|
HWND Progress::open(HWND hCallerWnd, const TCHAR* header)
|
|
|
|
|
{
|
|
|
|
|
if (_hwnd)
|
|
|
|
|
return _hwnd;
|
|
|
|
|
|
|
|
|
|
_hOwner = hOwner;
|
|
|
|
|
// Create manually reset non-signaled event
|
|
|
|
|
_hActiveState = ::CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
|
|
|
if (!_hActiveState)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
_hCallerWnd = hCallerWnd;
|
|
|
|
|
|
|
|
|
|
for (HWND hwnd = _hCallerWnd; hwnd; hwnd = ::GetParent(hwnd))
|
|
|
|
|
::UpdateWindow(hwnd);
|
|
|
|
|
|
|
|
|
|
if (header)
|
|
|
|
|
_tcscpy_s(_header, _countof(_header), header);
|
|
|
|
|
else
|
|
|
|
|
_tcscpy_s(_header, _countof(_header), cDefaultHeader);
|
|
|
|
|
|
|
|
|
|
// Create manually reset non-signaled event
|
|
|
|
|
_hActiveState = ::CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
|
|
|
if (!_hActiveState)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
_hThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadFunc,
|
|
|
|
|
(LPVOID)this, 0, NULL);
|
|
|
|
|
if (!_hThread)
|
|
|
|
@ -2995,11 +2998,17 @@ HWND Progress::open(HWND hOwner, const TCHAR* header)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Progress::isCancelled() const
|
|
|
|
|
void Progress::close()
|
|
|
|
|
{
|
|
|
|
|
if (_hwnd)
|
|
|
|
|
return (::WaitForSingleObject(_hActiveState, 0) != WAIT_OBJECT_0);
|
|
|
|
|
return false;
|
|
|
|
|
{
|
|
|
|
|
::SendMessage(_hwnd, WM_CLOSE, 0, 0);
|
|
|
|
|
_hwnd = NULL;
|
|
|
|
|
::WaitForSingleObject(_hThread, INFINITE);
|
|
|
|
|
|
|
|
|
|
::CloseHandle(_hThread);
|
|
|
|
|
::CloseHandle(_hActiveState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3007,21 +3016,22 @@ void Progress::setPercent(unsigned percent, const TCHAR *fileName) const
|
|
|
|
|
{
|
|
|
|
|
if (_hwnd)
|
|
|
|
|
{
|
|
|
|
|
::SendNotifyMessage(_hPBar, PBM_SETPOS, (WPARAM)percent, 0);
|
|
|
|
|
::PostMessage(_hPBar, PBM_SETPOS, (WPARAM)percent, 0);
|
|
|
|
|
::SendMessage(_hPText, WM_SETTEXT, 0, (LPARAM)fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Progress::close()
|
|
|
|
|
void Progress::flushCallerUserInput() const
|
|
|
|
|
{
|
|
|
|
|
if (_hwnd)
|
|
|
|
|
MSG msg;
|
|
|
|
|
for (HWND hwnd = _hCallerWnd; hwnd; hwnd = ::GetParent(hwnd))
|
|
|
|
|
{
|
|
|
|
|
::SendMessage(_hwnd, WM_CLOSE, 0, 0);
|
|
|
|
|
_hwnd = NULL;
|
|
|
|
|
::WaitForSingleObject(_hThread, INFINITE);
|
|
|
|
|
::CloseHandle(_hThread);
|
|
|
|
|
::CloseHandle(_hActiveState);
|
|
|
|
|
if (::PeekMessage(&msg, hwnd, 0, 0, PM_QS_INPUT | PM_REMOVE))
|
|
|
|
|
{
|
|
|
|
|
while (::PeekMessage(&msg, hwnd, 0, 0, PM_QS_INPUT | PM_REMOVE));
|
|
|
|
|
::UpdateWindow(hwnd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3054,14 +3064,11 @@ int Progress::thread()
|
|
|
|
|
|
|
|
|
|
int Progress::createProgressWindow()
|
|
|
|
|
{
|
|
|
|
|
DWORD styleEx = WS_EX_OVERLAPPEDWINDOW;
|
|
|
|
|
if (_hOwner)
|
|
|
|
|
styleEx |= WS_EX_TOOLWINDOW;
|
|
|
|
|
|
|
|
|
|
_hwnd = ::CreateWindowEx(styleEx,
|
|
|
|
|
_hwnd = ::CreateWindowEx(
|
|
|
|
|
WS_EX_TOOLWINDOW | WS_EX_OVERLAPPEDWINDOW | WS_EX_TOPMOST,
|
|
|
|
|
cClassName, _header, WS_POPUP | WS_CAPTION,
|
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
|
_hOwner, NULL, _hInst, (LPVOID)this);
|
|
|
|
|
NULL, NULL, _hInst, (LPVOID)this);
|
|
|
|
|
if (!_hwnd)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
@ -3094,7 +3101,6 @@ int Progress::createProgressWindow()
|
|
|
|
|
(width - cBTNwidth) / 2, height - cBTNheight - 5,
|
|
|
|
|
cBTNwidth, cBTNheight, _hwnd, NULL, _hInst, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hf)
|
|
|
|
|
::SendMessage(_hBtn, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
|
|
|
|
|
|
|
|
|