ReactOS 0.4.15-dev-7931-gfd331f1
ProgressDlg Class Reference

#include <dialog.h>

Inheritance diagram for ProgressDlg:
Collaboration diagram for ProgressDlg:

Public Types

enum  { IDD = IDD_DIALOG }
 

Public Member Functions

 ProgressDlg (_In_ RunOnceExInstance &RunOnceExInst)
 
BOOL RunDialogBox ()
 
void CalcTextRect (_In_ LPCWSTR lpText, _Inout_ RECT *pRect)
 
void ResizeListBoxAndDialog (_In_ int NewHeight)
 
BOOL ProcessWindowMessage (_In_ HWND hwnd, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam, _Out_ LRESULT &lResult, _In_ DWORD dwMsgMapID)
 

Public Attributes

RunOnceExInstancem_RunOnceExInst
 

Private Attributes

INT_PTR m_DialogID
 
HWND m_hListBox
 
HFONT m_hBoldFont
 
HBITMAP m_hArrowBmp
 
BITMAP m_ArrowBmp
 
INT m_PointedItem
 

Detailed Description

Definition at line 20 of file dialog.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
IDD 

Definition at line 31 of file dialog.h.

31{ IDD = IDD_DIALOG };
#define IDD_DIALOG
Definition: resource.h:5

Constructor & Destructor Documentation

◆ ProgressDlg()

ProgressDlg::ProgressDlg ( _In_ RunOnceExInstance RunOnceExInst)

Definition at line 23 of file dialog.cpp.

23 :
27 m_RunOnceExInst(RunOnceExInst)
28{ ; }
HWND m_hListBox
Definition: dialog.h:24
HFONT m_hBoldFont
Definition: dialog.h:25
RunOnceExInstance & m_RunOnceExInst
Definition: dialog.h:33
INT m_PointedItem
Definition: dialog.h:28
#define NULL
Definition: types.h:112

Member Function Documentation

◆ CalcTextRect()

void ProgressDlg::CalcTextRect ( _In_ LPCWSTR  lpText,
_Inout_ RECT pRect 
)

Definition at line 40 of file dialog.cpp.

43{
46
47 pRect->bottom = pRect->top;
48 pRect->left += ITEM_LEFTPADDING;
49
50 HFONT OldFont = SelectFont(hdc, GetFont());
51 DrawTextW(hdc, lpText, -1, pRect, DT_CALCRECT | DT_WORDBREAK);
54
55 pRect->bottom -= pRect->top;
56 pRect->bottom += ITEM_VPADDING * 2;
57 pRect->top = 0;
58 pRect->right -= pRect->left;
59 pRect->left = 0;
60}
#define ITEM_VPADDING
Definition: dialog.cpp:11
#define ITEM_LEFTPADDING
Definition: dialog.cpp:12
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define SelectFont(hdc, hfont)
Definition: windowsx.h:516
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_WORDBREAK
Definition: winuser.h:544
HDC WINAPI GetDC(_In_opt_ HWND)
#define DT_CALCRECT
Definition: winuser.h:526

Referenced by ProcessWindowMessage().

◆ ProcessWindowMessage()

BOOL ProgressDlg::ProcessWindowMessage ( _In_ HWND  hwnd,
_In_ UINT  message,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam,
_Out_ LRESULT lResult,
_In_ DWORD  dwMsgMapID 
)

Definition at line 91 of file dialog.cpp.

98{
99 lResult = 0;
100 switch (message)
101 {
102 case WM_INITDIALOG:
103 {
104 if (!m_RunOnceExInst.m_Title.IsEmpty())
105 {
107 }
108
110
111 m_hBoldFont = CreateBoldFont(GetFont());
112
115
116 // Add all sections with non-empty title into listbox
117 int TotalHeight = 0;
118 for (int i = 0; i < m_RunOnceExInst.m_SectionList.GetSize(); i++)
119 {
121
122 if (!Section.m_SectionTitle.IsEmpty())
123 {
125 TotalHeight += ListBox_GetItemHeight(m_hListBox, Index);
127 }
128 }
129
130 // Remove the sunken-edged border from the listbox.
132
133 ResizeListBoxAndDialog(TotalHeight);
134
135 // Launch a thread to execute tasks.
138 {
139 EndDialog(0);
140 return TRUE;
141 }
143
144 lResult = TRUE; // set keyboard focus to the dialog box control.
145 break;
146 }
147
148 case WM_MEASUREITEM:
149 {
151 RECT TextRect = { 0 };
152
153 CStringW ItemText;
154 ListBox_GetText(m_hListBox, pMeasureItem->itemID,
155 ItemText.GetBuffer(ListBox_GetTextLen(m_hListBox,
156 pMeasureItem->itemID) + 1));
157
158 CalcTextRect(ItemText, &TextRect);
159
160 ItemText.ReleaseBuffer();
161
162 pMeasureItem->itemHeight = TextRect.bottom - TextRect.top;
163 pMeasureItem->itemWidth = TextRect.right - TextRect.left;
164
165 break;
166 }
167
168 case WM_DRAWITEM:
169 {
171 CStringW ItemText;
172
174 ItemText.GetBuffer(ListBox_GetTextLen(m_hListBox,
175 pDrawItem->itemID) + 1));
176
177 SetBkMode(pDrawItem->hDC, TRANSPARENT);
178
179 HFONT hOldFont = NULL;
180 if (m_PointedItem == (INT)pDrawItem->itemData)
181 {
182 HDC hCompDC = CreateCompatibleDC(pDrawItem->hDC);
183
184 SelectBitmap(hCompDC, m_hArrowBmp);
185
186 int IconLeftPadding = (ITEM_LEFTPADDING - m_ArrowBmp.bmWidth) / 2;
187 int IconTopPadding = (pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - m_ArrowBmp.bmHeight) / 2;
188
189 BitBlt(pDrawItem->hDC, IconLeftPadding, pDrawItem->rcItem.top + IconTopPadding,
190 m_ArrowBmp.bmWidth, m_ArrowBmp.bmHeight, hCompDC, 0, 0, SRCAND);
191
192 DeleteDC(hCompDC);
193
194 hOldFont = SelectFont(pDrawItem->hDC, m_hBoldFont);
195 }
196
197 pDrawItem->rcItem.left += ITEM_LEFTPADDING;
198 pDrawItem->rcItem.top += ITEM_VPADDING;
199 DrawTextW(pDrawItem->hDC, ItemText, -1,
200 &(pDrawItem->rcItem), DT_WORDBREAK);
201
202 if (hOldFont)
203 {
204 SelectFont(pDrawItem->hDC, hOldFont);
205 }
206 ItemText.ReleaseBuffer();
207
208 break;
209 }
210
211 case WM_SETINDEX:
212 {
214 {
215 // All sections are handled, lParam is bSuccess.
217 }
220 break;
221 }
222
224 {
225 lResult = (LRESULT)GetStockBrush(NULL_BRUSH);
226 break;
227 }
228
229 case WM_DESTROY:
230 {
233 break;
234 }
235 }
236 return TRUE;
237}
int GetSize() const
Definition: atlsimpcoll.h:104
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
BITMAP m_ArrowBmp
Definition: dialog.h:27
HBITMAP m_hArrowBmp
Definition: dialog.h:26
void CalcTextRect(_In_ LPCWSTR lpText, _Inout_ RECT *pRect)
Definition: dialog.cpp:40
void ResizeListBoxAndDialog(_In_ int NewHeight)
Definition: dialog.cpp:62
CStringW m_Title
Definition: registry.h:99
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
ATL::CStringW m_SectionTitle
Definition: registry.h:63
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
unsigned int __stdcall RunOnceExExecThread(_In_ void *Param)
Definition: dialog.cpp:82
HFONT CreateBoldFont(_In_ HFONT hOrigFont)
Definition: dialog.cpp:14
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define WM_SETINDEX
Definition: dialog.h:18
#define IDC_LB_ITEMS
Definition: resource.h:7
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
pKey DeleteObject()
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CAtlStringW CStringW
Definition: atlstr.h:130
HANDLE hThread
Definition: wizard.c:28
#define LRESULT
Definition: ole.h:14
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
Definition: bl.h:1331
Definition: tftpd.h:60
ULONG_PTR itemData
Definition: winuser.h:3093
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
_In_ WDFCOLLECTION _In_ ULONG Index
#define GetStockBrush(i)
Definition: windowsx.h:307
#define ListBox_GetTextLen(hwndCtl, index)
Definition: windowsx.h:490
#define DeleteFont(hfont)
Definition: windowsx.h:78
#define ListBox_GetItemHeight(hwndCtl, index)
Definition: windowsx.h:484
#define ListBox_GetText(hwndCtl, index, lpszBuffer)
Definition: windowsx.h:489
#define SelectBitmap(hdc, hbm)
Definition: windowsx.h:514
#define ListBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:502
#define ListBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:472
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
#define NULL_BRUSH
Definition: wingdi.h:901
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
BOOL WINAPI DeleteDC(_In_ HDC)
#define SRCAND
Definition: wingdi.h:330
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1645
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define WM_MEASUREITEM
Definition: winuser.h:1646
struct tagMEASUREITEMSTRUCT * PMEASUREITEMSTRUCT
struct tagDRAWITEMSTRUCT * PDRAWITEMSTRUCT
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1768
#define WM_DESTROY
Definition: winuser.h:1609
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2163
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define GWL_EXSTYLE
Definition: winuser.h:851

◆ ResizeListBoxAndDialog()

void ProgressDlg::ResizeListBoxAndDialog ( _In_ int  NewHeight)

Definition at line 62 of file dialog.cpp.

63{
64 RECT ListBoxRect;
65 RECT DlgRect;
66 ::GetWindowRect(m_hListBox, &ListBoxRect);
67 GetWindowRect(&DlgRect);
68
69 int HeightDiff = NewHeight - (ListBoxRect.bottom - ListBoxRect.top);
70
72 ListBoxRect.right - ListBoxRect.left, NewHeight,
74
76 DlgRect.right - DlgRect.left,
77 DlgRect.bottom - DlgRect.top + HeightDiff,
79}
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1244
#define HWND_TOP
Definition: winuser.h:1207
#define SWP_SHOWWINDOW
Definition: winuser.h:1248
#define SWP_NOZORDER
Definition: winuser.h:1247

Referenced by ProcessWindowMessage().

◆ RunDialogBox()

BOOL ProgressDlg::RunDialogBox ( )

Definition at line 30 of file dialog.cpp.

31{
32 // Show the dialog and run the items only when the list is not empty.
34 {
35 return (DoModal() == 1);
36 }
37 return TRUE;
38}

Referenced by RunOnceExInstance::Run().

Member Data Documentation

◆ m_ArrowBmp

BITMAP ProgressDlg::m_ArrowBmp
private

Definition at line 27 of file dialog.h.

Referenced by ProcessWindowMessage().

◆ m_DialogID

INT_PTR ProgressDlg::m_DialogID
private

Definition at line 23 of file dialog.h.

◆ m_hArrowBmp

HBITMAP ProgressDlg::m_hArrowBmp
private

Definition at line 26 of file dialog.h.

Referenced by ProcessWindowMessage().

◆ m_hBoldFont

HFONT ProgressDlg::m_hBoldFont
private

Definition at line 25 of file dialog.h.

Referenced by ProcessWindowMessage().

◆ m_hListBox

HWND ProgressDlg::m_hListBox
private

Definition at line 24 of file dialog.h.

Referenced by CalcTextRect(), ProcessWindowMessage(), and ResizeListBoxAndDialog().

◆ m_PointedItem

INT ProgressDlg::m_PointedItem
private

Definition at line 28 of file dialog.h.

Referenced by ProcessWindowMessage().

◆ m_RunOnceExInst

RunOnceExInstance& ProgressDlg::m_RunOnceExInst

Definition at line 33 of file dialog.h.

Referenced by ProcessWindowMessage(), RunDialogBox(), and RunOnceExExecThread().


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