ReactOS  0.4.15-dev-5112-g22d8c0f
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  :
26  m_PointedItem(0),
27  m_RunOnceExInst(RunOnceExInst)
28 { ; }
INT m_PointedItem
Definition: dialog.h:28
HFONT m_hBoldFont
Definition: dialog.h:25
#define NULL
Definition: types.h:112
HWND m_hListBox
Definition: dialog.h:24
RunOnceExInstance & m_RunOnceExInst
Definition: dialog.h:33

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 }
HDC WINAPI GetDC(_In_opt_ HWND)
#define DT_WORDBREAK
Definition: winuser.h:544
static HDC
Definition: imagelist.c:92
#define ITEM_LEFTPADDING
Definition: dialog.cpp:12
#define DT_CALCRECT
Definition: winuser.h:526
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ITEM_VPADDING
Definition: dialog.cpp:11
HDC hdc
Definition: main.c:9
#define SelectFont(hdc, hfont)
Definition: windowsx.h:491
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HWND m_hListBox
Definition: dialog.h:24
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

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.
136  HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, RunOnceExExecThread, (void *)this, 0, NULL);
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 
173  ListBox_GetText(m_hListBox, pDrawItem->itemID,
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.
216  EndDialog(lParam);
217  }
220  break;
221  }
222 
223  case WM_CTLCOLORLISTBOX:
224  {
225  lResult = (LRESULT)GetStockBrush(NULL_BRUSH);
226  break;
227  }
228 
229  case WM_DESTROY:
230  {
233  break;
234  }
235  }
236  return TRUE;
237 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
Definition: tftpd.h:59
#define CloseHandle
Definition: compat.h:598
HBITMAP m_hArrowBmp
Definition: dialog.h:26
struct tagDRAWITEMSTRUCT * PDRAWITEMSTRUCT
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
#define TRUE
Definition: types.h:120
void CalcTextRect(_In_ LPCWSTR lpText, _Inout_ RECT *pRect)
Definition: dialog.cpp:40
#define NULL_BRUSH
Definition: wingdi.h:901
#define DT_WORDBREAK
Definition: winuser.h:544
static HDC
Definition: imagelist.c:92
ULONG_PTR itemData
Definition: winuser.h:3083
LONG top
Definition: windef.h:307
#define ListBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:447
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GWL_EXSTYLE
Definition: winuser.h:845
#define ITEM_LEFTPADDING
Definition: dialog.cpp:12
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
LONG left
Definition: windef.h:306
_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)
LONG right
Definition: windef.h:308
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1758
int GetSize() const
Definition: atlsimpcoll.h:104
int32_t INT
Definition: typedefs.h:58
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
unsigned int __stdcall RunOnceExExecThread(_In_ void *Param)
Definition: dialog.cpp:82
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
struct tagMEASUREITEMSTRUCT * PMEASUREITEMSTRUCT
BITMAP m_ArrowBmp
Definition: dialog.h:27
INT m_PointedItem
Definition: dialog.h:28
#define TRANSPARENT
Definition: wingdi.h:950
#define IDC_LB_ITEMS
Definition: resource.h:7
#define ListBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:477
#define WM_DESTROY
Definition: winuser.h:1599
ATL::CStringW m_SectionTitle
Definition: registry.h:63
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define GetStockBrush(i)
Definition: windowsx.h:282
_In_ WDFCOLLECTION _In_ ULONG Index
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
PVOID HANDLE
Definition: typedefs.h:73
#define ITEM_VPADDING
Definition: dialog.cpp:11
#define WM_MEASUREITEM
Definition: winuser.h:1636
#define ListBox_GetText(hwndCtl, index, lpszBuffer)
Definition: windowsx.h:464
#define ListBox_GetItemHeight(hwndCtl, index)
Definition: windowsx.h:459
#define LRESULT
Definition: ole.h:14
#define ListBox_GetTextLen(hwndCtl, index)
Definition: windowsx.h:465
#define WM_SETINDEX
Definition: dialog.h:18
#define SelectFont(hdc, hfont)
Definition: windowsx.h:491
bool IsEmpty() const
Definition: atlsimpstr.h:379
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HFONT m_hBoldFont
Definition: dialog.h:25
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
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
BOOL WINAPI DeleteDC(_In_ HDC)
#define OBM_MNARROW
Definition: winuser.h:1107
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2132
void ResizeListBoxAndDialog(_In_ int NewHeight)
Definition: dialog.cpp:62
Definition: bl.h:1330
#define SRCAND
Definition: wingdi.h:330
HFONT CreateBoldFont(_In_ HFONT hOrigFont)
Definition: dialog.cpp:14
#define NULL
Definition: types.h:112
#define SelectBitmap(hdc, hbm)
Definition: windowsx.h:489
CStringW m_Title
Definition: registry.h:99
HANDLE hThread
Definition: wizard.c:28
#define WM_DRAWITEM
Definition: winuser.h:1635
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG bottom
Definition: windef.h:309
CAtlStringW CStringW
Definition: atlstr.h:130
#define GetWindowLongPtr
Definition: treelist.c:73
HWND m_hListBox
Definition: dialog.h:24
RunOnceExInstance & m_RunOnceExInst
Definition: dialog.h:33
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
static VOID NTAPI 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:49
#define DeleteFont(hfont)
Definition: windowsx.h:53
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

◆ 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 
75  SetWindowPos(HWND_TOP, 0, 0,
76  DlgRect.right - DlgRect.left,
77  DlgRect.bottom - DlgRect.top + HeightDiff,
79 }
LONG top
Definition: windef.h:307
#define HWND_TOP
Definition: winuser.h:1197
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1237
LONG right
Definition: windef.h:308
#define NULL
Definition: types.h:112
#define SWP_SHOWWINDOW
Definition: winuser.h:1238
LONG bottom
Definition: windef.h:309
#define SWP_NOMOVE
Definition: winuser.h:1234
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)
HWND m_hListBox
Definition: dialog.h:24

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 }
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
#define TRUE
Definition: types.h:120
int GetSize() const
Definition: atlsimpcoll.h:104
RunOnceExInstance & m_RunOnceExInst
Definition: dialog.h:33

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: