mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 15:14:59 -06:00
9.06 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
829409452d
commit
c99f3ebdd6
@@ -1,15 +1,19 @@
|
||||
// ProgressDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "ProgressDialog.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static const UINT_PTR kTimerID = 3;
|
||||
static const UINT kTimerElapse = 50;
|
||||
static const UINT kTimerElapse = 100;
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
@@ -22,7 +26,7 @@ static CIDLangPair kIDLangPairs[] =
|
||||
};
|
||||
#endif
|
||||
|
||||
HRESULT CProgressSynch::ProcessStopAndPause()
|
||||
HRESULT CProgressSync::ProcessStopAndPause()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -48,30 +52,37 @@ void CProgressDialog::AddToTitle(LPCWSTR s)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
bool CProgressDialog::OnInit()
|
||||
{
|
||||
_range = UINT64(-1);
|
||||
_range = (UInt64)-1;
|
||||
_prevPercentValue = -1;
|
||||
|
||||
_wasCreated = true;
|
||||
_dialogCreatedEvent.Set();
|
||||
|
||||
#ifdef LANG
|
||||
// LangSetWindowText(HWND(*this), 0x02000C00);
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
#endif
|
||||
|
||||
m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
|
||||
|
||||
if (IconID >= 0)
|
||||
{
|
||||
HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IconID));
|
||||
SetIcon(ICON_BIG, icon);
|
||||
}
|
||||
|
||||
_timer = SetTimer(kTimerID, kTimerElapse);
|
||||
_dialogCreatedEvent.Set();
|
||||
SetText(_title);
|
||||
CheckNeedClose();
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
void CProgressDialog::OnCancel()
|
||||
{
|
||||
ProgressSynch.SetStopped(true);
|
||||
}
|
||||
void CProgressDialog::OnCancel() { Sync.SetStopped(true); }
|
||||
void CProgressDialog::OnOK() { }
|
||||
|
||||
void CProgressDialog::SetRange(UINT64 range)
|
||||
void CProgressDialog::SetRange(UInt64 range)
|
||||
{
|
||||
_range = range;
|
||||
_peviousPos = (UInt64)(Int64)-1;
|
||||
@@ -79,16 +90,16 @@ void CProgressDialog::SetRange(UINT64 range)
|
||||
m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100%
|
||||
}
|
||||
|
||||
void CProgressDialog::SetPos(UINT64 pos)
|
||||
void CProgressDialog::SetPos(UInt64 pos)
|
||||
{
|
||||
bool redraw = true;
|
||||
if (pos < _range && pos > _peviousPos)
|
||||
{
|
||||
UINT64 posDelta = pos - _peviousPos;
|
||||
UInt64 posDelta = pos - _peviousPos;
|
||||
if (posDelta < (_range >> 10))
|
||||
redraw = false;
|
||||
}
|
||||
if(redraw)
|
||||
if (redraw)
|
||||
{
|
||||
m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
|
||||
_peviousPos = pos;
|
||||
@@ -97,10 +108,13 @@ void CProgressDialog::SetPos(UINT64 pos)
|
||||
|
||||
bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
|
||||
{
|
||||
if (ProgressSynch.GetPaused())
|
||||
if (Sync.GetPaused())
|
||||
return true;
|
||||
UINT64 total, completed;
|
||||
ProgressSynch.GetProgress(total, completed);
|
||||
|
||||
CheckNeedClose();
|
||||
|
||||
UInt64 total, completed;
|
||||
Sync.GetProgress(total, completed);
|
||||
if (total != _range)
|
||||
SetRange(total);
|
||||
SetPos(completed);
|
||||
@@ -124,29 +138,6 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////
|
||||
// CU64ToI32Converter
|
||||
|
||||
static const UINT64 kMaxIntValue = 0x7FFFFFFF;
|
||||
|
||||
void CU64ToI32Converter::Init(UINT64 range)
|
||||
{
|
||||
_numShiftBits = 0;
|
||||
while(range > kMaxIntValue)
|
||||
{
|
||||
range >>= 1;
|
||||
_numShiftBits++;
|
||||
}
|
||||
}
|
||||
|
||||
int CU64ToI32Converter::Count(UINT64 aValue)
|
||||
{
|
||||
return int(aValue >> _numShiftBits);
|
||||
}
|
||||
|
||||
const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
|
||||
|
||||
bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(message)
|
||||
@@ -155,14 +146,20 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
KillTimer(_timer);
|
||||
_timer = 0;
|
||||
End(0);
|
||||
return true;
|
||||
if (_inCancelMessageBox)
|
||||
{
|
||||
_externalCloseMessageWasReceived = true;
|
||||
break;
|
||||
}
|
||||
return OnExternalCloseMessage();
|
||||
}
|
||||
/*
|
||||
case WM_SETTEXT:
|
||||
{
|
||||
if (_timer == 0)
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
return CModalDialog::OnMessage(message, wParam, lParam);
|
||||
}
|
||||
@@ -173,16 +170,35 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
case IDCANCEL:
|
||||
{
|
||||
bool paused = ProgressSynch.GetPaused();;
|
||||
ProgressSynch.SetPaused(true);
|
||||
int res = ::MessageBoxW(HWND(*this),
|
||||
L"Are you sure you want to cancel?",
|
||||
_title, MB_YESNOCANCEL);
|
||||
ProgressSynch.SetPaused(paused);
|
||||
bool paused = Sync.GetPaused();
|
||||
Sync.SetPaused(true);
|
||||
_inCancelMessageBox = true;
|
||||
int res = ::MessageBoxW(HWND(*this), L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL);
|
||||
_inCancelMessageBox = false;
|
||||
Sync.SetPaused(paused);
|
||||
if (res == IDCANCEL || res == IDNO)
|
||||
{
|
||||
if (_externalCloseMessageWasReceived)
|
||||
OnExternalCloseMessage();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
|
||||
}
|
||||
|
||||
void CProgressDialog::CheckNeedClose()
|
||||
{
|
||||
if (_needClose)
|
||||
{
|
||||
PostMessage(kCloseMessage);
|
||||
_needClose = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CProgressDialog::OnExternalCloseMessage()
|
||||
{
|
||||
End(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user