ReactOS 0.4.15-dev-7918-g2a2556c
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{
52
53 this->lines[0][0] = this->lines[1][0] = this->lines[2][0] = UNICODE_NULL;
54 this->cancelMsg[0] = this->title[0] = UNICODE_NULL;
55
56 this->clockHand = -1;
57 this->progressClock[29].ullMark = 0ull;
58 this->dwStartTime = GetTickCount();
59
61}
CRITICAL_SECTION cs
progressMark progressClock[30]
#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
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ ~CProgressDialog()

CProgressDialog::~CProgressDialog ( )

Definition at line 63 of file CProgressDialog.cpp.

64{
65 if (this->hwnd)
66 this->end_dialog();
67 HeapFree(GetProcessHeap(), 0, this->lines[0]);
68 HeapFree(GetProcessHeap(), 0, this->lines[1]);
69 HeapFree(GetProcessHeap(), 0, this->lines[2]);
71 HeapFree(GetProcessHeap(), 0, this->title);
73}
#define HeapFree(x, y, z)
Definition: compat.h:735
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Member Function Documentation

◆ ContextSensitiveHelp()

HRESULT WINAPI CProgressDialog::ContextSensitiveHelp ( BOOL  fEnterMode)
override

Implements IOleWindow.

Definition at line 448 of file CProgressDialog.cpp.

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

◆ end_dialog()

void CProgressDialog::end_dialog ( )

Definition at line 140 of file CProgressDialog.cpp.

141{
142 SendMessageW(this->hwnd, WM_DLG_DESTROY, 0, 0);
143 /* native doesn't re-enable the window? */
144 if (this->hwndDisabledParent)
146 this->hwnd = NULL;
147}
#define WM_DLG_DESTROY
#define NULL
Definition: types.h:112
#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 440 of file CProgressDialog.cpp.

441{
442 EnterCriticalSection(&this->cs);
443 *phwnd = this->hwnd;
444 LeaveCriticalSection(&this->cs);
445 return S_OK;
446}
#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 102 of file CProgressDialog.cpp.

103{
104 HWND hProgress = GetDlgItem(this->hwnd, IDC_PROGRESS_BAR);
105 SetWindowLongW(hProgress, GWL_STYLE,
107}
#define IDC_PROGRESS_BAR
Definition: resource.h:138
#define PBS_MARQUEE
Definition: commctrl.h:2198
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:852

◆ SetAnimation()

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

Definition at line 344 of file CProgressDialog.cpp.

345{
346 HWND hAnimation = GetDlgItem(this->hwnd, IDD_PROGRESS_DLG);
347 SetWindowLongW(hAnimation, GWL_STYLE,
349
350 if(!Animate_OpenEx(hAnimation,hInstance,MAKEINTRESOURCEW(uiResourceId)))
351 return S_FALSE;
352
353 return S_OK;
354}
HINSTANCE hInstance
Definition: charmap.c:19
#define IDD_PROGRESS_DLG
Definition: resource.h:140
#define Animate_OpenEx(hwnd, hInst, szName)
Definition: commctrl.h:4165
#define ACS_TRANSPARENT
Definition: commctrl.h:4147
#define ACS_AUTOPLAY
Definition: commctrl.h:4148
#define ACS_CENTER
Definition: commctrl.h:4146
#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 413 of file CProgressDialog.cpp.

414{
415 HWND hwnd;
416
417 if (reserved)
418 FIXME("reserved pointer not null (%p)\n", reserved);
419
420 EnterCriticalSection(&this->cs);
421 set_buffer(&this->cancelMsg, pwzMsg);
423 hwnd = (this->isCancelled ? this->hwnd : NULL); /* no sense to send the message if window not cancelled */
424 LeaveCriticalSection(&this->cs);
425
426 if (hwnd)
428
429 return S_OK;
430}
#define WM_DLG_UPDATE
#define CANCEL_MSG_LINE
#define UPDATE_LINE1
#define FIXME(fmt,...)
Definition: debug.h:111
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 390 of file CProgressDialog.cpp.

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

◆ SetProgress()

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

Definition at line 385 of file CProgressDialog.cpp.

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

◆ SetProgress64()

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

Definition at line 361 of file CProgressDialog.cpp.

362{
363 HWND hwnd;
364
365 EnterCriticalSection(&this->cs);
366 this->ullTotal = ullTotal;
368
369 if (GetTickCount() - this->progressClock[(this->clockHand + 29) % 30].dwTime > 20) {
370 this->clockHand = (this->clockHand + 1) % 30;
373 }
374
375 this->dwUpdate |= UPDATE_PROGRESS;
376 hwnd = this->hwnd;
377 LeaveCriticalSection(&this->cs);
378
379 if (hwnd)
381
382 return S_OK; /* Windows sometimes returns S_FALSE */
383}
#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 328 of file CProgressDialog.cpp.

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

◆ StartProgressDialog()

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

Definition at line 271 of file CProgressDialog.cpp.

272{
273 static const INITCOMMONCONTROLSEX init = { sizeof(init), ICC_ANIMATE_CLASS };
274
275 struct create_params params;
277
278 // TRACE("(%p, %p, %x, %p)\n", this, punkEnableModeless, dwFlags, reserved);
279 if (punkEnableModeless || reserved)
280 FIXME("Reserved parameters not null (%p, %p)\n", punkEnableModeless, reserved);
282 FIXME("Flags PROGDLG_AUTOTIME not supported\n");
284 FIXME("Flags PROGDLG_NOTIME not supported\n");
285
287
288 EnterCriticalSection(&this->cs);
289
290 if (this->hwnd)
291 {
292 LeaveCriticalSection(&this->cs);
293 return S_OK; /* as on XP */
294 }
295 this->dwFlags = dwFlags;
296 params.This = this;
297 params.hwndParent = hwndParent;
298 params.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
299
302 CloseHandle(params.hEvent);
304
305 this->hwndDisabledParent = NULL;
306 if (hwndParent && (dwFlags & PROGDLG_MODAL))
307 {
308 HWND hwndDisable = GetAncestor(hwndParent, GA_ROOT);
309 if (EnableWindow(hwndDisable, FALSE))
310 this->hwndDisabledParent = hwndDisable;
311 }
312
313 LeaveCriticalSection(&this->cs);
314
315 return S_OK;
316}
static DWORD WINAPI dialog_thread(LPVOID lpParameter)
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
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:960
#define PROGDLG_AUTOTIME
Definition: shlobj.h:959
#define PROGDLG_MODAL
Definition: shlobj.h:958
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:2789
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)

◆ STDMETHOD_()

CProgressDialog::STDMETHOD_ ( BOOL  ,
HasUserCancelled   
)
override

◆ StopProgressDialog()

HRESULT WINAPI CProgressDialog::StopProgressDialog ( )
override

Definition at line 318 of file CProgressDialog.cpp.

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

◆ Timer()

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

Definition at line 432 of file CProgressDialog.cpp.

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

◆ update_dialog()

void CProgressDialog::update_dialog ( DWORD  dwUpdate)

Definition at line 109 of file CProgressDialog.cpp.

110{
111 WCHAR empty[] = {0};
112
114 SetWindowTextW(this->hwnd, this->title);
115
117 SetDlgItemTextW(this->hwnd, IDC_TEXT_LINE, (this->isCancelled ? empty : this->lines[0]));
119 SetDlgItemTextW(this->hwnd, IDC_TEXT_LINE+1, (this->isCancelled ? empty : this->lines[1]));
121 SetDlgItemTextW(this->hwnd, IDC_TEXT_LINE+2, (this->isCancelled ? this->cancelMsg : this->lines[2]));
122
124 {
127
128 /* progress bar requires 32-bit coordinates */
129 while (ullTotal >> 32)
130 {
131 ullTotal >>= 1;
132 ullCompleted >>= 1;
133 }
134
137 }
138}
#define UPDATE_LINE2
#define UPDATE_LINE3
#define IDC_TEXT_LINE
Definition: resource.h:139
static const WCHAR empty[]
Definition: main.c:47
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PBM_SETRANGE32
Definition: commctrl.h:2188
#define PBM_SETPOS
Definition: commctrl.h:2184
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: