ReactOS 0.4.16-dev-1028-g8602629
CProgressDialog Class Reference

#include <CProgressDialog.h>

Inheritance diagram for CProgressDialog:
Collaboration diagram for CProgressDialog:

Classes

struct  progressMark
 

Public Member Functions

void set_progress_marquee ()
 
void update_dialog (DWORD dwUpdate)
 
void end_dialog ()
 
 CProgressDialog ()
 
 ~CProgressDialog ()
 
STDMETHOD() StartProgressDialog (HWND hwndParent, IUnknown *punkEnableModeless, DWORD dwFlags, LPCVOID reserved) override
 
STDMETHOD() StopProgressDialog () override
 
STDMETHOD() SetTitle (LPCWSTR pwzTitle) override
 
STDMETHOD() SetAnimation (HINSTANCE hInstance, UINT uiResourceId) override
 
 STDMETHOD_ (BOOL, HasUserCancelled)() override
 
STDMETHOD() SetProgress64 (ULONGLONG ullCompleted, ULONGLONG ullTotal) override
 
STDMETHOD() SetProgress (DWORD dwCompleted, DWORD dwTotal) override
 
STDMETHOD() SetLine (DWORD dwLineNum, LPCWSTR pwzLine, BOOL bPath, LPCVOID reserved) override
 
STDMETHOD() SetCancelMsg (LPCWSTR pwzMsg, LPCVOID reserved) override
 
STDMETHOD() Timer (DWORD dwTimerAction, LPCVOID reserved) override
 
STDMETHOD() GetWindow (HWND *phwnd) override
 
STDMETHOD() ContextSensitiveHelp (BOOL fEnterMode) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
HRESULT GetWindow ([out] HWND *phwnd)
 
HRESULT ContextSensitiveHelp ([in] BOOL fEnterMode)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Public Attributes

CRITICAL_SECTION cs
 
HWND hwnd
 
DWORD dwFlags
 
DWORD dwUpdate
 
LPWSTR lines [3]
 
LPWSTR cancelMsg
 
LPWSTR title
 
BOOL isCancelled
 
ULONGLONG ullCompleted
 
ULONGLONG ullTotal
 
HWND hwndDisabledParent
 
UINT clockHand
 
progressMark progressClock [30]
 
DWORD dwStartTime
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Additional Inherited Members

- Public Types inherited from IOleWindow
typedef IOleWindowLPOLEWINDOW
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Detailed Description

Definition at line 24 of file CProgressDialog.h.

Constructor & Destructor Documentation

◆ CProgressDialog()

CProgressDialog::CProgressDialog ( )

Definition at line 45 of file CProgressDialog.cpp.

46{
47 this->hwnd = NULL;
53
54 this->lines[0][0] = this->lines[1][0] = this->lines[2][0] = UNICODE_NULL;
55 this->cancelMsg[0] = this->title[0] = UNICODE_NULL;
56
57 this->clockHand = -1;
58 this->progressClock[29].ullMark = 0ull;
59 this->dwStartTime = GetTickCount();
60
62}
CRITICAL_SECTION cs
progressMark progressClock[30]
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define BUFFER_SIZE
Definition: freeldrpage.c:26
#define UNICODE_NULL
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ ~CProgressDialog()

CProgressDialog::~CProgressDialog ( )

Definition at line 64 of file CProgressDialog.cpp.

65{
66 if (this->hwnd)
67 this->end_dialog();
68 HeapFree(GetProcessHeap(), 0, this->lines[0]);
69 HeapFree(GetProcessHeap(), 0, this->lines[1]);
70 HeapFree(GetProcessHeap(), 0, this->lines[2]);
72 HeapFree(GetProcessHeap(), 0, this->title);
74}
#define HeapFree(x, y, z)
Definition: compat.h:735
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Member Function Documentation

◆ ContextSensitiveHelp()

HRESULT WINAPI CProgressDialog::ContextSensitiveHelp ( BOOL  fEnterMode)
override

Implements IOleWindow.

Definition at line 449 of file CProgressDialog.cpp.

450{
451 return E_NOTIMPL;
452}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ end_dialog()

void CProgressDialog::end_dialog ( )

Definition at line 141 of file CProgressDialog.cpp.

142{
143 SendMessageW(this->hwnd, WM_DLG_DESTROY, 0, 0);
144 /* native doesn't re-enable the window? */
145 if (this->hwndDisabledParent)
147 this->hwnd = NULL;
148}
#define WM_DLG_DESTROY
#define TRUE
Definition: types.h:120
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by StopProgressDialog(), and ~CProgressDialog().

◆ GetWindow()

HRESULT WINAPI CProgressDialog::GetWindow ( HWND phwnd)
override

Implements IOleWindow.

Definition at line 441 of file CProgressDialog.cpp.

442{
443 EnterCriticalSection(&this->cs);
444 *phwnd = this->hwnd;
445 LeaveCriticalSection(&this->cs);
446 return S_OK;
447}
#define S_OK
Definition: intsafe.h:52
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ set_progress_marquee()

void CProgressDialog::set_progress_marquee ( )

Definition at line 103 of file CProgressDialog.cpp.

104{
105 HWND hProgress = GetDlgItem(this->hwnd, IDC_PROGRESS_BAR);
106 SetWindowLongW(hProgress, GWL_STYLE,
108}
#define IDC_PROGRESS_BAR
Definition: resource.h:140
#define PBS_MARQUEE
Definition: commctrl.h:2203
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define GWL_STYLE
Definition: winuser.h:863

◆ SetAnimation()

HRESULT WINAPI CProgressDialog::SetAnimation ( HINSTANCE  hInstance,
UINT  uiResourceId 
)
override

Definition at line 345 of file CProgressDialog.cpp.

346{
347 HWND hAnimation = GetDlgItem(this->hwnd, IDD_PROGRESS_DLG);
348 SetWindowLongW(hAnimation, GWL_STYLE,
350
351 if(!Animate_OpenEx(hAnimation,hInstance,MAKEINTRESOURCEW(uiResourceId)))
352 return S_FALSE;
353
354 return S_OK;
355}
HINSTANCE hInstance
Definition: charmap.c:19
#define IDD_PROGRESS_DLG
Definition: resource.h:142
#define Animate_OpenEx(hwnd, hInst, szName)
Definition: commctrl.h:4170
#define ACS_TRANSPARENT
Definition: commctrl.h:4152
#define ACS_AUTOPLAY
Definition: commctrl.h:4153
#define ACS_CENTER
Definition: commctrl.h:4151
#define S_FALSE
Definition: winerror.h:2357
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ SetCancelMsg()

HRESULT WINAPI CProgressDialog::SetCancelMsg ( LPCWSTR  pwzMsg,
LPCVOID  reserved 
)
override

Definition at line 414 of file CProgressDialog.cpp.

415{
416 HWND hwnd;
417
418 if (reserved)
419 FIXME("reserved pointer not null (%p)\n", reserved);
420
421 EnterCriticalSection(&this->cs);
422 set_buffer(&this->cancelMsg, pwzMsg);
424 hwnd = (this->isCancelled ? this->hwnd : NULL); /* no sense to send the message if window not cancelled */
425 LeaveCriticalSection(&this->cs);
426
427 if (hwnd)
429
430 return S_OK;
431}
#define WM_DLG_UPDATE
#define CANCEL_MSG_LINE
#define UPDATE_LINE1
#define FIXME(fmt,...)
Definition: precomp.h:53
r reserved
Definition: btrfs.c:3006
static GLboolean set_buffer(GLcontext *ctx, GLenum mode)
Definition: swimpl.c:872

◆ SetLine()

HRESULT WINAPI CProgressDialog::SetLine ( DWORD  dwLineNum,
LPCWSTR  pwzLine,
BOOL  bPath,
LPCVOID  reserved 
)
override

Definition at line 391 of file CProgressDialog.cpp.

392{
393 HWND hwnd;
394
395 if (reserved)
396 FIXME("reserved pointer not null (%p)\n", reserved);
397
398 dwLineNum--;
399 if (dwLineNum >= 3) /* Windows seems to do something like that */
400 dwLineNum = 0;
401
402 EnterCriticalSection(&this->cs);
403 set_buffer(&this->lines[dwLineNum], pwzLine);
404 this->dwUpdate |= UPDATE_LINE1 << dwLineNum;
405 hwnd = (this->isCancelled ? NULL : this->hwnd); /* no sense to send the message if window cancelled */
406 LeaveCriticalSection(&this->cs);
407
408 if (hwnd)
410
411 return S_OK;
412}

◆ SetProgress()

HRESULT WINAPI CProgressDialog::SetProgress ( DWORD  dwCompleted,
DWORD  dwTotal 
)
override

Definition at line 386 of file CProgressDialog.cpp.

387{
388 return this->SetProgress64(dwCompleted, dwTotal);
389}
STDMETHOD() SetProgress64(ULONGLONG ullCompleted, ULONGLONG ullTotal) override

◆ SetProgress64()

HRESULT WINAPI CProgressDialog::SetProgress64 ( ULONGLONG  ullCompleted,
ULONGLONG  ullTotal 
)
override

Definition at line 362 of file CProgressDialog.cpp.

363{
364 HWND hwnd;
365
366 EnterCriticalSection(&this->cs);
367 this->ullTotal = ullTotal;
369
370 if (GetTickCount() - this->progressClock[(this->clockHand + 29) % 30].dwTime > 20) {
371 this->clockHand = (this->clockHand + 1) % 30;
374 }
375
376 this->dwUpdate |= UPDATE_PROGRESS;
377 hwnd = this->hwnd;
378 LeaveCriticalSection(&this->cs);
379
380 if (hwnd)
382
383 return S_OK; /* Windows sometimes returns S_FALSE */
384}
#define UPDATE_PROGRESS
ULONGLONG ullTotal
ULONGLONG ullCompleted
DWORD dwTime
Definition: solitaire.cpp:27

Referenced by SetProgress().

◆ SetTitle()

HRESULT WINAPI CProgressDialog::SetTitle ( LPCWSTR  pwzTitle)
override

Definition at line 329 of file CProgressDialog.cpp.

330{
331 HWND hwnd;
332
333 EnterCriticalSection(&this->cs);
334 set_buffer(&this->title, pwzTitle);
335 this->dwUpdate |= UPDATE_TITLE;
336 hwnd = this->hwnd;
337 LeaveCriticalSection(&this->cs);
338
339 if (hwnd)
341
342 return S_OK;
343}
#define UPDATE_TITLE

◆ StartProgressDialog()

HRESULT WINAPI CProgressDialog::StartProgressDialog ( HWND  hwndParent,
IUnknown punkEnableModeless,
DWORD  dwFlags,
LPCVOID  reserved 
)
override

Definition at line 272 of file CProgressDialog.cpp.

273{
274 static const INITCOMMONCONTROLSEX init = { sizeof(init), ICC_ANIMATE_CLASS };
275
276 struct create_params params;
278
279 // TRACE("(%p, %p, %x, %p)\n", this, punkEnableModeless, dwFlags, reserved);
280 if (punkEnableModeless || reserved)
281 FIXME("Reserved parameters not null (%p, %p)\n", punkEnableModeless, reserved);
283 FIXME("Flags PROGDLG_AUTOTIME not supported\n");
285 FIXME("Flags PROGDLG_NOTIME not supported\n");
286
288
289 EnterCriticalSection(&this->cs);
290
291 if (this->hwnd)
292 {
293 LeaveCriticalSection(&this->cs);
294 return S_OK; /* as on XP */
295 }
296 this->dwFlags = dwFlags;
297 params.This = this;
298 params.hwndParent = hwndParent;
299 params.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
300
303 CloseHandle(params.hEvent);
305
306 this->hwndDisabledParent = NULL;
307 if (hwndParent && (dwFlags & PROGDLG_MODAL))
308 {
309 HWND hwndDisable = GetAncestor(hwndParent, GA_ROOT);
310 if (EnableWindow(hwndDisable, FALSE))
311 this->hwndDisabledParent = hwndDisable;
312 }
313
314 LeaveCriticalSection(&this->cs);
315
316 return S_OK;
317}
static DWORD WINAPI dialog_thread(LPVOID lpParameter)
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
static HWND hwndParent
Definition: cryptui.c:300
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define INFINITE
Definition: serial.h:102
GLenum const GLfloat * params
Definition: glext.h:5645
HANDLE hThread
Definition: wizard.c:28
#define ICC_ANIMATE_CLASS
Definition: commctrl.h:65
#define PROGDLG_NOTIME
Definition: shlobj.h:975
#define PROGDLG_AUTOTIME
Definition: shlobj.h:974
#define PROGDLG_MODAL
Definition: shlobj.h:973
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
static int init
Definition: wintirpc.c:33
#define GA_ROOT
Definition: winuser.h:2800
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)

◆ STDMETHOD_()

CProgressDialog::STDMETHOD_ ( BOOL  ,
HasUserCancelled   
)
override

◆ StopProgressDialog()

HRESULT WINAPI CProgressDialog::StopProgressDialog ( )
override

Definition at line 319 of file CProgressDialog.cpp.

320{
321 EnterCriticalSection(&this->cs);
322 if (this->hwnd)
323 this->end_dialog();
324 LeaveCriticalSection(&this->cs);
325
326 return S_OK;
327}

◆ Timer()

HRESULT WINAPI CProgressDialog::Timer ( DWORD  dwTimerAction,
LPCVOID  reserved 
)
override

Definition at line 433 of file CProgressDialog.cpp.

434{
435 if (reserved)
436 FIXME("Reserved field not NULL but %p\n", reserved);
437
438 return S_OK;
439}

◆ update_dialog()

void CProgressDialog::update_dialog ( DWORD  dwUpdate)

Definition at line 110 of file CProgressDialog.cpp.

111{
112 WCHAR empty[] = {0};
113
115 SetWindowTextW(this->hwnd, this->title);
116
118 SetDlgItemTextW(this->hwnd, IDC_TEXT_LINE, (this->isCancelled ? empty : this->lines[0]));
120 SetDlgItemTextW(this->hwnd, IDC_TEXT_LINE+1, (this->isCancelled ? empty : this->lines[1]));
122 SetDlgItemTextW(this->hwnd, IDC_TEXT_LINE+2, (this->isCancelled ? this->cancelMsg : this->lines[2]));
123
125 {
128
129 /* progress bar requires 32-bit coordinates */
130 while (ullTotal >> 32)
131 {
132 ullTotal >>= 1;
133 ullCompleted >>= 1;
134 }
135
138 }
139}
#define UPDATE_LINE2
#define UPDATE_LINE3
#define IDC_TEXT_LINE
Definition: resource.h:141
static const WCHAR empty[]
Definition: main.c:47
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PBM_SETRANGE32
Definition: commctrl.h:2193
#define PBM_SETPOS
Definition: commctrl.h:2189
uint64_t ULONGLONG
Definition: typedefs.h:67
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Member Data Documentation

◆ cancelMsg

LPWSTR CProgressDialog::cancelMsg

Definition at line 36 of file CProgressDialog.h.

Referenced by CProgressDialog(), SetCancelMsg(), update_dialog(), and ~CProgressDialog().

◆ clockHand

UINT CProgressDialog::clockHand

Definition at line 46 of file CProgressDialog.h.

Referenced by CProgressDialog(), and SetProgress64().

◆ cs

◆ dwFlags

DWORD CProgressDialog::dwFlags

Definition at line 33 of file CProgressDialog.h.

Referenced by StartProgressDialog().

◆ dwStartTime

DWORD CProgressDialog::dwStartTime

Definition at line 52 of file CProgressDialog.h.

Referenced by CProgressDialog().

◆ dwUpdate

DWORD CProgressDialog::dwUpdate

Definition at line 34 of file CProgressDialog.h.

Referenced by SetCancelMsg(), SetLine(), SetProgress64(), SetTitle(), and update_dialog().

◆ hwnd

HWND CProgressDialog::hwnd

Definition at line 32 of file CProgressDialog.h.

Referenced by GetWindow(), SetCancelMsg(), SetLine(), SetProgress64(), and SetTitle().

◆ hwndDisabledParent

HWND CProgressDialog::hwndDisabledParent

Definition at line 41 of file CProgressDialog.h.

Referenced by end_dialog(), and StartProgressDialog().

◆ isCancelled

BOOL CProgressDialog::isCancelled

Definition at line 38 of file CProgressDialog.h.

Referenced by SetCancelMsg(), SetLine(), and update_dialog().

◆ lines

LPWSTR CProgressDialog::lines[3]

Definition at line 35 of file CProgressDialog.h.

Referenced by CProgressDialog(), SetLine(), update_dialog(), and ~CProgressDialog().

◆ progressClock

progressMark CProgressDialog::progressClock[30]

Definition at line 51 of file CProgressDialog.h.

Referenced by CProgressDialog(), and SetProgress64().

◆ title

LPWSTR CProgressDialog::title

Definition at line 37 of file CProgressDialog.h.

Referenced by CProgressDialog(), SetTitle(), update_dialog(), and ~CProgressDialog().

◆ ullCompleted

ULONGLONG CProgressDialog::ullCompleted

Definition at line 39 of file CProgressDialog.h.

Referenced by SetProgress64(), and update_dialog().

◆ ullTotal

ULONGLONG CProgressDialog::ullTotal

Definition at line 40 of file CProgressDialog.h.

Referenced by SetProgress64(), and update_dialog().


The documentation for this class was generated from the following files: