Mercurial > foo_out_sdl
comparison foosdk/wtl/Include/atlctrls.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 // Windows Template Library - WTL version 10.0 | |
| 2 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved. | |
| 3 // | |
| 4 // This file is a part of the Windows Template Library. | |
| 5 // The use and distribution terms for this software are covered by the | |
| 6 // Microsoft Public License (http://opensource.org/licenses/MS-PL) | |
| 7 // which can be found in the file MS-PL.txt at the root folder. | |
| 8 | |
| 9 #ifndef __ATLCTRLS_H__ | |
| 10 #define __ATLCTRLS_H__ | |
| 11 | |
| 12 #pragma once | |
| 13 | |
| 14 #ifndef __ATLAPP_H__ | |
| 15 #error atlctrls.h requires atlapp.h to be included first | |
| 16 #endif | |
| 17 | |
| 18 #ifndef __ATLWIN_H__ | |
| 19 #error atlctrls.h requires atlwin.h to be included first | |
| 20 #endif | |
| 21 | |
| 22 #include <richedit.h> | |
| 23 #include <richole.h> | |
| 24 | |
| 25 #if (_RICHEDIT_VER < 0x0300) | |
| 26 #error WTL10 requires RichEdit version 3 or higher | |
| 27 #endif | |
| 28 | |
| 29 // protect template members from windowsx.h macros | |
| 30 #ifdef _INC_WINDOWSX | |
| 31 #undef GetNextSibling | |
| 32 #undef GetPrevSibling | |
| 33 #endif // _INC_WINDOWSX | |
| 34 | |
| 35 | |
| 36 /////////////////////////////////////////////////////////////////////////////// | |
| 37 // Classes in this file: | |
| 38 // | |
| 39 // CStaticT<TBase> - CStatic | |
| 40 // CButtonT<TBase> - CButton | |
| 41 // CListBoxT<TBase> - CListBox | |
| 42 // CComboBoxT<TBase> - CComboBox | |
| 43 // CEditT<TBase> - CEdit | |
| 44 // CEditCommands<T> | |
| 45 // CScrollBarT<TBase> - CScrollBar | |
| 46 // | |
| 47 // CImageListT<t_bManaged> - CImageList, CImageListManaged | |
| 48 // CListViewCtrlT<TBase> - CListViewCtrl | |
| 49 // CTreeViewCtrlT<TBase> - CTreeViewCtrl | |
| 50 // CTreeItemT<TBase> - CTreeItem | |
| 51 // CTreeViewCtrlExT<TBase> - CTreeViewCtrlEx | |
| 52 // CHeaderCtrlT<TBase> - CHeaderCtrl | |
| 53 // CToolBarCtrlT<TBase> - CToolBarCtrl | |
| 54 // CStatusBarCtrlT<TBase> - CStatusBarCtrl | |
| 55 // CTabCtrlT<TBase> - CTabCtrl | |
| 56 // CToolInfo | |
| 57 // CToolTipCtrlT<TBase> - CToolTipCtrl | |
| 58 // CTrackBarCtrlT<TBase> - CTrackBarCtrl | |
| 59 // CUpDownCtrlT<TBase> - CUpDownCtrl | |
| 60 // CProgressBarCtrlT<TBase> - CProgressBarCtrl | |
| 61 // CHotKeyCtrlT<TBase> - CHotKeyCtrl | |
| 62 // CAnimateCtrlT<TBase> - CAnimateCtrl | |
| 63 // CRichEditCtrlT<TBase> - CRichEditCtrl | |
| 64 // CRichEditCommands<T> | |
| 65 // CDragListBoxT<TBase> - CDragListBox | |
| 66 // CDragListNotifyImpl<T> | |
| 67 // CReBarCtrlT<TBase> - CReBarCtrl | |
| 68 // CComboBoxExT<TBase> - CComboBoxEx | |
| 69 // CDateTimePickerCtrlT<TBase> - CDateTimePickerCtrl | |
| 70 // CMonthCalendarCtrlT<TBase> - CMonthCalendarCtrl | |
| 71 // CFlatScrollBarImpl<T> | |
| 72 // CFlatScrollBarT<TBase> - CFlatScrollBar | |
| 73 // CIPAddressCtrlT<TBase> - CIPAddressCtrl | |
| 74 // CPagerCtrlT<TBase> - CPagerCtrl | |
| 75 // CLinkCtrlT<TBase> - CLinkCtrl | |
| 76 // | |
| 77 // CCustomDraw<T> | |
| 78 | |
| 79 | |
| 80 namespace WTL | |
| 81 { | |
| 82 | |
| 83 // These are wrapper classes for Windows standard and common controls. | |
| 84 // To implement a window based on a control, use following: | |
| 85 // Example: Implementing a window based on a list box | |
| 86 // | |
| 87 // class CMyListBox : CWindowImpl<CMyListBox, CListBox> | |
| 88 // { | |
| 89 // public: | |
| 90 // BEGIN_MSG_MAP(CMyListBox) | |
| 91 // // put your message handler entries here | |
| 92 // END_MSG_MAP() | |
| 93 // }; | |
| 94 | |
| 95 | |
| 96 | |
| 97 // --- Standard Windows controls --- | |
| 98 | |
| 99 /////////////////////////////////////////////////////////////////////////////// | |
| 100 // CStatic - client side for a Windows STATIC control | |
| 101 | |
| 102 template <class TBase> | |
| 103 class CStaticT : public TBase | |
| 104 { | |
| 105 public: | |
| 106 // Constructors | |
| 107 CStaticT(HWND hWnd = NULL) : TBase(hWnd) | |
| 108 { } | |
| 109 | |
| 110 CStaticT< TBase >& operator =(HWND hWnd) | |
| 111 { | |
| 112 this->m_hWnd = hWnd; | |
| 113 return *this; | |
| 114 } | |
| 115 | |
| 116 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 117 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 118 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 119 { | |
| 120 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 121 } | |
| 122 | |
| 123 // Attributes | |
| 124 static LPCTSTR GetWndClassName() | |
| 125 { | |
| 126 return _T("STATIC"); | |
| 127 } | |
| 128 | |
| 129 HICON GetIcon() const | |
| 130 { | |
| 131 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 132 return (HICON)::SendMessage(this->m_hWnd, STM_GETICON, 0, 0L); | |
| 133 } | |
| 134 | |
| 135 HICON SetIcon(HICON hIcon) | |
| 136 { | |
| 137 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 138 return (HICON)::SendMessage(this->m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L); | |
| 139 } | |
| 140 | |
| 141 HENHMETAFILE GetEnhMetaFile() const | |
| 142 { | |
| 143 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 144 return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L); | |
| 145 } | |
| 146 | |
| 147 HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) | |
| 148 { | |
| 149 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 150 return (HENHMETAFILE)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile); | |
| 151 } | |
| 152 | |
| 153 CBitmapHandle GetBitmap() const | |
| 154 { | |
| 155 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 156 return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L)); | |
| 157 } | |
| 158 | |
| 159 CBitmapHandle SetBitmap(HBITMAP hBitmap) | |
| 160 { | |
| 161 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 162 return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); | |
| 163 } | |
| 164 | |
| 165 HCURSOR GetCursor() const | |
| 166 { | |
| 167 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 168 return (HCURSOR)::SendMessage(this->m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L); | |
| 169 } | |
| 170 | |
| 171 HCURSOR SetCursor(HCURSOR hCursor) | |
| 172 { | |
| 173 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 174 return (HCURSOR)::SendMessage(this->m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor); | |
| 175 } | |
| 176 }; | |
| 177 | |
| 178 typedef CStaticT<ATL::CWindow> CStatic; | |
| 179 | |
| 180 | |
| 181 /////////////////////////////////////////////////////////////////////////////// | |
| 182 // CButton - client side for a Windows BUTTON control | |
| 183 | |
| 184 template <class TBase> | |
| 185 class CButtonT : public TBase | |
| 186 { | |
| 187 public: | |
| 188 // Constructors | |
| 189 CButtonT(HWND hWnd = NULL) : TBase(hWnd) | |
| 190 { } | |
| 191 | |
| 192 CButtonT< TBase >& operator =(HWND hWnd) | |
| 193 { | |
| 194 this->m_hWnd = hWnd; | |
| 195 return *this; | |
| 196 } | |
| 197 | |
| 198 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 199 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 200 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 201 { | |
| 202 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 203 } | |
| 204 | |
| 205 // Attributes | |
| 206 static LPCTSTR GetWndClassName() | |
| 207 { | |
| 208 return _T("BUTTON"); | |
| 209 } | |
| 210 | |
| 211 UINT GetState() const | |
| 212 { | |
| 213 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 214 return (UINT)::SendMessage(this->m_hWnd, BM_GETSTATE, 0, 0L); | |
| 215 } | |
| 216 | |
| 217 void SetState(BOOL bHighlight) | |
| 218 { | |
| 219 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 220 ::SendMessage(this->m_hWnd, BM_SETSTATE, bHighlight, 0L); | |
| 221 } | |
| 222 | |
| 223 int GetCheck() const | |
| 224 { | |
| 225 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 226 return (int)::SendMessage(this->m_hWnd, BM_GETCHECK, 0, 0L); | |
| 227 } | |
| 228 | |
| 229 void SetCheck(int nCheck) | |
| 230 { | |
| 231 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 232 ::SendMessage(this->m_hWnd, BM_SETCHECK, nCheck, 0L); | |
| 233 } | |
| 234 | |
| 235 UINT GetButtonStyle() const | |
| 236 { | |
| 237 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 238 return (UINT)::GetWindowLong(this->m_hWnd, GWL_STYLE) & 0xFFFF; | |
| 239 } | |
| 240 | |
| 241 void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE) | |
| 242 { | |
| 243 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 244 ::SendMessage(this->m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); | |
| 245 } | |
| 246 | |
| 247 HICON GetIcon() const | |
| 248 { | |
| 249 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 250 return (HICON)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L); | |
| 251 } | |
| 252 | |
| 253 HICON SetIcon(HICON hIcon) | |
| 254 { | |
| 255 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 256 return (HICON)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); | |
| 257 } | |
| 258 | |
| 259 CBitmapHandle GetBitmap() const | |
| 260 { | |
| 261 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 262 return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L)); | |
| 263 } | |
| 264 | |
| 265 CBitmapHandle SetBitmap(HBITMAP hBitmap) | |
| 266 { | |
| 267 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 268 return CBitmapHandle((HBITMAP)::SendMessage(this->m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap)); | |
| 269 } | |
| 270 | |
| 271 BOOL GetIdealSize(LPSIZE lpSize) const | |
| 272 { | |
| 273 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 274 return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize); | |
| 275 } | |
| 276 | |
| 277 BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const | |
| 278 { | |
| 279 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 280 return (BOOL)::SendMessage(this->m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist); | |
| 281 } | |
| 282 | |
| 283 BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist) | |
| 284 { | |
| 285 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 286 return (BOOL)::SendMessage(this->m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist); | |
| 287 } | |
| 288 | |
| 289 BOOL GetTextMargin(LPRECT lpRect) const | |
| 290 { | |
| 291 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 292 return (BOOL)::SendMessage(this->m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect); | |
| 293 } | |
| 294 | |
| 295 BOOL SetTextMargin(LPRECT lpRect) | |
| 296 { | |
| 297 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 298 return (BOOL)::SendMessage(this->m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect); | |
| 299 } | |
| 300 | |
| 301 #if (WINVER >= 0x0600) | |
| 302 void SetDontClick(BOOL bDontClick) | |
| 303 { | |
| 304 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 305 ::SendMessage(this->m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); | |
| 306 } | |
| 307 #endif // (WINVER >= 0x0600) | |
| 308 | |
| 309 #if (_WIN32_WINNT >= 0x0600) | |
| 310 BOOL SetDropDownState(BOOL bDropDown) | |
| 311 { | |
| 312 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 313 ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); | |
| 314 return (BOOL)::SendMessage(this->m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L); | |
| 315 } | |
| 316 | |
| 317 BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const | |
| 318 { | |
| 319 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 320 ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); | |
| 321 return (BOOL)::SendMessage(this->m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo); | |
| 322 } | |
| 323 | |
| 324 BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) | |
| 325 { | |
| 326 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 327 ATLASSERT((this->GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0); | |
| 328 return (BOOL)::SendMessage(this->m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo); | |
| 329 } | |
| 330 | |
| 331 int GetNoteLength() const | |
| 332 { | |
| 333 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 334 ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); | |
| 335 return (int)::SendMessage(this->m_hWnd, BCM_GETNOTELENGTH, 0, 0L); | |
| 336 } | |
| 337 | |
| 338 BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const | |
| 339 { | |
| 340 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 341 ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); | |
| 342 return (BOOL)::SendMessage(this->m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText); | |
| 343 } | |
| 344 | |
| 345 BOOL SetNote(LPCWSTR lpstrNoteText) | |
| 346 { | |
| 347 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 348 ATLASSERT((this->GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0); | |
| 349 return (BOOL)::SendMessage(this->m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText); | |
| 350 } | |
| 351 | |
| 352 LRESULT SetElevationRequiredState(BOOL bSet) | |
| 353 { | |
| 354 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 355 return ::SendMessage(this->m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); | |
| 356 } | |
| 357 #endif // (_WIN32_WINNT >= 0x0600) | |
| 358 | |
| 359 // Operations | |
| 360 void Click() | |
| 361 { | |
| 362 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 363 ::SendMessage(this->m_hWnd, BM_CLICK, 0, 0L); | |
| 364 } | |
| 365 }; | |
| 366 | |
| 367 typedef CButtonT<ATL::CWindow> CButton; | |
| 368 | |
| 369 | |
| 370 /////////////////////////////////////////////////////////////////////////////// | |
| 371 // CListBox - client side for a Windows LISTBOX control | |
| 372 | |
| 373 template <class TBase> | |
| 374 class CListBoxT : public TBase | |
| 375 { | |
| 376 public: | |
| 377 // Constructors | |
| 378 CListBoxT(HWND hWnd = NULL) : TBase(hWnd) | |
| 379 { } | |
| 380 | |
| 381 CListBoxT< TBase >& operator =(HWND hWnd) | |
| 382 { | |
| 383 this->m_hWnd = hWnd; | |
| 384 return *this; | |
| 385 } | |
| 386 | |
| 387 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 388 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 389 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 390 { | |
| 391 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 392 } | |
| 393 | |
| 394 // Attributes | |
| 395 static LPCTSTR GetWndClassName() | |
| 396 { | |
| 397 return _T("LISTBOX"); | |
| 398 } | |
| 399 | |
| 400 // for entire listbox | |
| 401 int GetCount() const | |
| 402 { | |
| 403 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 404 return (int)::SendMessage(this->m_hWnd, LB_GETCOUNT, 0, 0L); | |
| 405 } | |
| 406 | |
| 407 int SetCount(int cItems) | |
| 408 { | |
| 409 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 410 ATLASSERT(((this->GetStyle() & LBS_NODATA) != 0) && ((this->GetStyle() & LBS_HASSTRINGS) == 0)); | |
| 411 return (int)::SendMessage(this->m_hWnd, LB_SETCOUNT, cItems, 0L); | |
| 412 } | |
| 413 | |
| 414 int GetHorizontalExtent() const | |
| 415 { | |
| 416 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 417 return (int)::SendMessage(this->m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L); | |
| 418 } | |
| 419 | |
| 420 void SetHorizontalExtent(int cxExtent) | |
| 421 { | |
| 422 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 423 ::SendMessage(this->m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); | |
| 424 } | |
| 425 | |
| 426 int GetTopIndex() const | |
| 427 { | |
| 428 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 429 return (int)::SendMessage(this->m_hWnd, LB_GETTOPINDEX, 0, 0L); | |
| 430 } | |
| 431 | |
| 432 int SetTopIndex(int nIndex) | |
| 433 { | |
| 434 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 435 return (int)::SendMessage(this->m_hWnd, LB_SETTOPINDEX, nIndex, 0L); | |
| 436 } | |
| 437 | |
| 438 LCID GetLocale() const | |
| 439 { | |
| 440 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 441 return (LCID)::SendMessage(this->m_hWnd, LB_GETLOCALE, 0, 0L); | |
| 442 } | |
| 443 | |
| 444 LCID SetLocale(LCID nNewLocale) | |
| 445 { | |
| 446 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 447 return (LCID)::SendMessage(this->m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L); | |
| 448 } | |
| 449 | |
| 450 DWORD GetListBoxInfo() const | |
| 451 { | |
| 452 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 453 return (DWORD)::SendMessage(this->m_hWnd, LB_GETLISTBOXINFO, 0, 0L); | |
| 454 } | |
| 455 | |
| 456 // for single-selection listboxes | |
| 457 int GetCurSel() const | |
| 458 { | |
| 459 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 460 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); | |
| 461 return (int)::SendMessage(this->m_hWnd, LB_GETCURSEL, 0, 0L); | |
| 462 } | |
| 463 | |
| 464 int SetCurSel(int nSelect) | |
| 465 { | |
| 466 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 467 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); | |
| 468 return (int)::SendMessage(this->m_hWnd, LB_SETCURSEL, nSelect, 0L); | |
| 469 } | |
| 470 | |
| 471 // for multiple-selection listboxes | |
| 472 int GetSel(int nIndex) const // also works for single-selection | |
| 473 { | |
| 474 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 475 return (int)::SendMessage(this->m_hWnd, LB_GETSEL, nIndex, 0L); | |
| 476 } | |
| 477 | |
| 478 int SetSel(int nIndex, BOOL bSelect = TRUE) | |
| 479 { | |
| 480 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 481 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); | |
| 482 return (int)::SendMessage(this->m_hWnd, LB_SETSEL, bSelect, nIndex); | |
| 483 } | |
| 484 | |
| 485 int GetSelCount() const | |
| 486 { | |
| 487 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 488 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); | |
| 489 return (int)::SendMessage(this->m_hWnd, LB_GETSELCOUNT, 0, 0L); | |
| 490 } | |
| 491 | |
| 492 int GetSelItems(int nMaxItems, LPINT rgIndex) const | |
| 493 { | |
| 494 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 495 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); | |
| 496 return (int)::SendMessage(this->m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex); | |
| 497 } | |
| 498 | |
| 499 int GetAnchorIndex() const | |
| 500 { | |
| 501 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 502 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); | |
| 503 return (int)::SendMessage(this->m_hWnd, LB_GETANCHORINDEX, 0, 0L); | |
| 504 } | |
| 505 | |
| 506 void SetAnchorIndex(int nIndex) | |
| 507 { | |
| 508 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 509 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); | |
| 510 ::SendMessage(this->m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); | |
| 511 } | |
| 512 | |
| 513 int GetCaretIndex() const | |
| 514 { | |
| 515 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 516 return (int)::SendMessage(this->m_hWnd, LB_GETCARETINDEX, 0, 0); | |
| 517 } | |
| 518 | |
| 519 int SetCaretIndex(int nIndex, BOOL bScroll = TRUE) | |
| 520 { | |
| 521 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 522 return (int)::SendMessage(this->m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0)); | |
| 523 } | |
| 524 | |
| 525 // for listbox items | |
| 526 DWORD_PTR GetItemData(int nIndex) const | |
| 527 { | |
| 528 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 529 return (DWORD_PTR)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); | |
| 530 } | |
| 531 | |
| 532 int SetItemData(int nIndex, DWORD_PTR dwItemData) | |
| 533 { | |
| 534 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 535 return (int)::SendMessage(this->m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData); | |
| 536 } | |
| 537 | |
| 538 void* GetItemDataPtr(int nIndex) const | |
| 539 { | |
| 540 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 541 return (void*)::SendMessage(this->m_hWnd, LB_GETITEMDATA, nIndex, 0L); | |
| 542 } | |
| 543 | |
| 544 int SetItemDataPtr(int nIndex, void* pData) | |
| 545 { | |
| 546 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 547 return SetItemData(nIndex, (DWORD_PTR)pData); | |
| 548 } | |
| 549 | |
| 550 int GetItemRect(int nIndex, LPRECT lpRect) const | |
| 551 { | |
| 552 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 553 return (int)::SendMessage(this->m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect); | |
| 554 } | |
| 555 | |
| 556 int GetText(int nIndex, LPTSTR lpszBuffer) const | |
| 557 { | |
| 558 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 559 return (int)::SendMessage(this->m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer); | |
| 560 } | |
| 561 | |
| 562 #ifdef _OLEAUTO_H_ | |
| 563 BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const | |
| 564 { | |
| 565 USES_CONVERSION; | |
| 566 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 567 ATLASSERT(bstrText == NULL); | |
| 568 | |
| 569 int nLen = GetTextLen(nIndex); | |
| 570 if(nLen == LB_ERR) | |
| 571 return FALSE; | |
| 572 | |
| 573 ATL::CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; | |
| 574 LPTSTR lpstrText = buff.Allocate(nLen + 1); | |
| 575 if(lpstrText == NULL) | |
| 576 return FALSE; | |
| 577 | |
| 578 if(GetText(nIndex, lpstrText) == LB_ERR) | |
| 579 return FALSE; | |
| 580 | |
| 581 bstrText = ::SysAllocString(T2OLE(lpstrText)); | |
| 582 return (bstrText != NULL) ? TRUE : FALSE; | |
| 583 } | |
| 584 #endif // _OLEAUTO_H_ | |
| 585 | |
| 586 #ifdef __ATLSTR_H__ | |
| 587 int GetText(int nIndex, ATL::CString& strText) const | |
| 588 { | |
| 589 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 590 int cchLen = GetTextLen(nIndex); | |
| 591 if(cchLen == LB_ERR) | |
| 592 return LB_ERR; | |
| 593 int nRet = LB_ERR; | |
| 594 LPTSTR lpstr = strText.GetBufferSetLength(cchLen); | |
| 595 if(lpstr != NULL) | |
| 596 { | |
| 597 nRet = GetText(nIndex, lpstr); | |
| 598 strText.ReleaseBuffer(); | |
| 599 } | |
| 600 return nRet; | |
| 601 } | |
| 602 #endif // __ATLSTR_H__ | |
| 603 | |
| 604 int GetTextLen(int nIndex) const | |
| 605 { | |
| 606 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 607 return (int)::SendMessage(this->m_hWnd, LB_GETTEXTLEN, nIndex, 0L); | |
| 608 } | |
| 609 | |
| 610 int GetItemHeight(int nIndex) const | |
| 611 { | |
| 612 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 613 return (int)::SendMessage(this->m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); | |
| 614 } | |
| 615 | |
| 616 int SetItemHeight(int nIndex, UINT cyItemHeight) | |
| 617 { | |
| 618 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 619 return (int)::SendMessage(this->m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); | |
| 620 } | |
| 621 | |
| 622 // Settable only attributes | |
| 623 void SetColumnWidth(int cxWidth) | |
| 624 { | |
| 625 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 626 ::SendMessage(this->m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); | |
| 627 } | |
| 628 | |
| 629 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) | |
| 630 { | |
| 631 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 632 ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); | |
| 633 return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); | |
| 634 } | |
| 635 | |
| 636 BOOL SetTabStops() | |
| 637 { | |
| 638 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 639 ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); | |
| 640 return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 0, 0L); | |
| 641 } | |
| 642 | |
| 643 BOOL SetTabStops(const int& cxEachStop) // takes an 'int' | |
| 644 { | |
| 645 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 646 ATLASSERT((this->GetStyle() & LBS_USETABSTOPS) != 0); | |
| 647 return (BOOL)::SendMessage(this->m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); | |
| 648 } | |
| 649 | |
| 650 // Operations | |
| 651 int InitStorage(int nItems, UINT nBytes) | |
| 652 { | |
| 653 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 654 return (int)::SendMessage(this->m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes); | |
| 655 } | |
| 656 | |
| 657 void ResetContent() | |
| 658 { | |
| 659 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 660 ::SendMessage(this->m_hWnd, LB_RESETCONTENT, 0, 0L); | |
| 661 } | |
| 662 | |
| 663 UINT ItemFromPoint(POINT pt, BOOL& bOutside) const | |
| 664 { | |
| 665 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 666 DWORD dw = (DWORD)::SendMessage(this->m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); | |
| 667 bOutside = (BOOL)HIWORD(dw); | |
| 668 return (UINT)LOWORD(dw); | |
| 669 } | |
| 670 | |
| 671 // manipulating listbox items | |
| 672 int AddString(LPCTSTR lpszItem) | |
| 673 { | |
| 674 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 675 return (int)::SendMessage(this->m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem); | |
| 676 } | |
| 677 | |
| 678 int DeleteString(UINT nIndex) | |
| 679 { | |
| 680 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 681 return (int)::SendMessage(this->m_hWnd, LB_DELETESTRING, nIndex, 0L); | |
| 682 } | |
| 683 | |
| 684 int InsertString(int nIndex, LPCTSTR lpszItem) | |
| 685 { | |
| 686 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 687 return (int)::SendMessage(this->m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem); | |
| 688 } | |
| 689 | |
| 690 int Dir(UINT attr, LPCTSTR lpszWildCard) | |
| 691 { | |
| 692 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 693 return (int)::SendMessage(this->m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard); | |
| 694 } | |
| 695 | |
| 696 int AddFile(LPCTSTR lpstrFileName) | |
| 697 { | |
| 698 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 699 return (int)::SendMessage(this->m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName); | |
| 700 } | |
| 701 | |
| 702 // selection helpers | |
| 703 int FindString(int nStartAfter, LPCTSTR lpszItem) const | |
| 704 { | |
| 705 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 706 return (int)::SendMessage(this->m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem); | |
| 707 } | |
| 708 | |
| 709 int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const | |
| 710 { | |
| 711 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 712 return (int)::SendMessage(this->m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); | |
| 713 } | |
| 714 | |
| 715 int SelectString(int nStartAfter, LPCTSTR lpszItem) | |
| 716 { | |
| 717 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 718 return (int)::SendMessage(this->m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem); | |
| 719 } | |
| 720 | |
| 721 int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) | |
| 722 { | |
| 723 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 724 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0); | |
| 725 ATLASSERT(nFirstItem <= nLastItem); | |
| 726 return bSelect ? (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(this->m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem); | |
| 727 } | |
| 728 }; | |
| 729 | |
| 730 typedef CListBoxT<ATL::CWindow> CListBox; | |
| 731 | |
| 732 | |
| 733 /////////////////////////////////////////////////////////////////////////////// | |
| 734 // CComboBox - client side for a Windows COMBOBOX control | |
| 735 | |
| 736 template <class TBase> | |
| 737 class CComboBoxT : public TBase | |
| 738 { | |
| 739 public: | |
| 740 // Constructors | |
| 741 CComboBoxT(HWND hWnd = NULL) : TBase(hWnd) | |
| 742 { } | |
| 743 | |
| 744 CComboBoxT< TBase >& operator =(HWND hWnd) | |
| 745 { | |
| 746 this->m_hWnd = hWnd; | |
| 747 return *this; | |
| 748 } | |
| 749 | |
| 750 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 751 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 752 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 753 { | |
| 754 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 755 } | |
| 756 | |
| 757 // Attributes | |
| 758 static LPCTSTR GetWndClassName() | |
| 759 { | |
| 760 return _T("COMBOBOX"); | |
| 761 } | |
| 762 | |
| 763 // for entire combo box | |
| 764 int GetCount() const | |
| 765 { | |
| 766 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 767 return (int)::SendMessage(this->m_hWnd, CB_GETCOUNT, 0, 0L); | |
| 768 } | |
| 769 | |
| 770 int GetCurSel() const | |
| 771 { | |
| 772 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 773 return (int)::SendMessage(this->m_hWnd, CB_GETCURSEL, 0, 0L); | |
| 774 } | |
| 775 | |
| 776 int SetCurSel(int nSelect) | |
| 777 { | |
| 778 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 779 return (int)::SendMessage(this->m_hWnd, CB_SETCURSEL, nSelect, 0L); | |
| 780 } | |
| 781 | |
| 782 LCID GetLocale() const | |
| 783 { | |
| 784 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 785 return (LCID)::SendMessage(this->m_hWnd, CB_GETLOCALE, 0, 0L); | |
| 786 } | |
| 787 | |
| 788 LCID SetLocale(LCID nNewLocale) | |
| 789 { | |
| 790 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 791 return (LCID)::SendMessage(this->m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L); | |
| 792 } | |
| 793 | |
| 794 int GetTopIndex() const | |
| 795 { | |
| 796 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 797 return (int)::SendMessage(this->m_hWnd, CB_GETTOPINDEX, 0, 0L); | |
| 798 } | |
| 799 | |
| 800 int SetTopIndex(int nIndex) | |
| 801 { | |
| 802 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 803 return (int)::SendMessage(this->m_hWnd, CB_SETTOPINDEX, nIndex, 0L); | |
| 804 } | |
| 805 | |
| 806 UINT GetHorizontalExtent() const | |
| 807 { | |
| 808 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 809 return (UINT)::SendMessage(this->m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L); | |
| 810 } | |
| 811 | |
| 812 void SetHorizontalExtent(UINT nExtent) | |
| 813 { | |
| 814 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 815 ::SendMessage(this->m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); | |
| 816 } | |
| 817 | |
| 818 int GetDroppedWidth() const | |
| 819 { | |
| 820 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 821 return (int)::SendMessage(this->m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); | |
| 822 } | |
| 823 | |
| 824 int SetDroppedWidth(UINT nWidth) | |
| 825 { | |
| 826 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 827 return (int)::SendMessage(this->m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L); | |
| 828 } | |
| 829 | |
| 830 BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const | |
| 831 { | |
| 832 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 833 return (BOOL)::SendMessage(this->m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo); | |
| 834 } | |
| 835 | |
| 836 // for edit control | |
| 837 DWORD GetEditSel() const | |
| 838 { | |
| 839 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 840 return (DWORD)::SendMessage(this->m_hWnd, CB_GETEDITSEL, 0, 0L); | |
| 841 } | |
| 842 | |
| 843 BOOL SetEditSel(int nStartChar, int nEndChar) | |
| 844 { | |
| 845 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 846 return (BOOL)::SendMessage(this->m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); | |
| 847 } | |
| 848 | |
| 849 // for combobox item | |
| 850 DWORD_PTR GetItemData(int nIndex) const | |
| 851 { | |
| 852 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 853 return (DWORD_PTR)::SendMessage(this->m_hWnd, CB_GETITEMDATA, nIndex, 0L); | |
| 854 } | |
| 855 | |
| 856 int SetItemData(int nIndex, DWORD_PTR dwItemData) | |
| 857 { | |
| 858 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 859 return (int)::SendMessage(this->m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); | |
| 860 } | |
| 861 | |
| 862 void* GetItemDataPtr(int nIndex) const | |
| 863 { | |
| 864 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 865 return (void*)GetItemData(nIndex); | |
| 866 } | |
| 867 | |
| 868 int SetItemDataPtr(int nIndex, void* pData) | |
| 869 { | |
| 870 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 871 return SetItemData(nIndex, (DWORD_PTR)pData); | |
| 872 } | |
| 873 | |
| 874 int GetLBText(int nIndex, LPTSTR lpszText) const | |
| 875 { | |
| 876 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 877 return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText); | |
| 878 } | |
| 879 | |
| 880 BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const | |
| 881 { | |
| 882 USES_CONVERSION; | |
| 883 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 884 ATLASSERT(bstrText == NULL); | |
| 885 | |
| 886 int nLen = GetLBTextLen(nIndex); | |
| 887 if(nLen == CB_ERR) | |
| 888 return FALSE; | |
| 889 | |
| 890 ATL::CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; | |
| 891 LPTSTR lpstrText = buff.Allocate(nLen + 1); | |
| 892 if(lpstrText == NULL) | |
| 893 return FALSE; | |
| 894 | |
| 895 if(GetLBText(nIndex, lpstrText) == CB_ERR) | |
| 896 return FALSE; | |
| 897 | |
| 898 bstrText = ::SysAllocString(T2OLE(lpstrText)); | |
| 899 return (bstrText != NULL) ? TRUE : FALSE; | |
| 900 } | |
| 901 | |
| 902 #ifdef __ATLSTR_H__ | |
| 903 int GetLBText(int nIndex, ATL::CString& strText) const | |
| 904 { | |
| 905 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 906 int cchLen = GetLBTextLen(nIndex); | |
| 907 if(cchLen == CB_ERR) | |
| 908 return CB_ERR; | |
| 909 int nRet = CB_ERR; | |
| 910 LPTSTR lpstr = strText.GetBufferSetLength(cchLen); | |
| 911 if(lpstr != NULL) | |
| 912 { | |
| 913 nRet = GetLBText(nIndex, lpstr); | |
| 914 strText.ReleaseBuffer(); | |
| 915 } | |
| 916 return nRet; | |
| 917 } | |
| 918 #endif // __ATLSTR_H__ | |
| 919 | |
| 920 int GetLBTextLen(int nIndex) const | |
| 921 { | |
| 922 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 923 return (int)::SendMessage(this->m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); | |
| 924 } | |
| 925 | |
| 926 int GetItemHeight(int nIndex) const | |
| 927 { | |
| 928 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 929 return (int)::SendMessage(this->m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); | |
| 930 } | |
| 931 | |
| 932 int SetItemHeight(int nIndex, UINT cyItemHeight) | |
| 933 { | |
| 934 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 935 return (int)::SendMessage(this->m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); | |
| 936 } | |
| 937 | |
| 938 BOOL GetExtendedUI() const | |
| 939 { | |
| 940 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 941 return (BOOL)::SendMessage(this->m_hWnd, CB_GETEXTENDEDUI, 0, 0L); | |
| 942 } | |
| 943 | |
| 944 int SetExtendedUI(BOOL bExtended = TRUE) | |
| 945 { | |
| 946 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 947 return (int)::SendMessage(this->m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L); | |
| 948 } | |
| 949 | |
| 950 void GetDroppedControlRect(LPRECT lprect) const | |
| 951 { | |
| 952 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 953 ::SendMessage(this->m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect); | |
| 954 } | |
| 955 | |
| 956 BOOL GetDroppedState() const | |
| 957 { | |
| 958 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 959 return (BOOL)::SendMessage(this->m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); | |
| 960 } | |
| 961 | |
| 962 int GetMinVisible() const | |
| 963 { | |
| 964 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 965 return (int)::SendMessage(this->m_hWnd, CB_GETMINVISIBLE, 0, 0L); | |
| 966 } | |
| 967 | |
| 968 BOOL SetMinVisible(int nMinVisible) | |
| 969 { | |
| 970 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 971 return (BOOL)::SendMessage(this->m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L); | |
| 972 } | |
| 973 | |
| 974 // Vista only | |
| 975 BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const | |
| 976 { | |
| 977 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 978 return (BOOL)::SendMessage(this->m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText); | |
| 979 } | |
| 980 | |
| 981 // Vista only | |
| 982 BOOL SetCueBannerText(LPCWSTR lpcwText) | |
| 983 { | |
| 984 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 985 return (BOOL)::SendMessage(this->m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText); | |
| 986 } | |
| 987 | |
| 988 // Operations | |
| 989 int InitStorage(int nItems, UINT nBytes) | |
| 990 { | |
| 991 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 992 return (int)::SendMessage(this->m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes); | |
| 993 } | |
| 994 | |
| 995 void ResetContent() | |
| 996 { | |
| 997 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 998 ::SendMessage(this->m_hWnd, CB_RESETCONTENT, 0, 0L); | |
| 999 } | |
| 1000 | |
| 1001 // for edit control | |
| 1002 BOOL LimitText(int nMaxChars) | |
| 1003 { | |
| 1004 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1005 return (BOOL)::SendMessage(this->m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); | |
| 1006 } | |
| 1007 | |
| 1008 // for drop-down combo boxes | |
| 1009 void ShowDropDown(BOOL bShowIt = TRUE) | |
| 1010 { | |
| 1011 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1012 ::SendMessage(this->m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); | |
| 1013 } | |
| 1014 | |
| 1015 // manipulating listbox items | |
| 1016 int AddString(LPCTSTR lpszString) | |
| 1017 { | |
| 1018 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1019 return (int)::SendMessage(this->m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString); | |
| 1020 } | |
| 1021 | |
| 1022 int DeleteString(UINT nIndex) | |
| 1023 { | |
| 1024 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1025 return (int)::SendMessage(this->m_hWnd, CB_DELETESTRING, nIndex, 0L); | |
| 1026 } | |
| 1027 | |
| 1028 int InsertString(int nIndex, LPCTSTR lpszString) | |
| 1029 { | |
| 1030 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1031 return (int)::SendMessage(this->m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); | |
| 1032 } | |
| 1033 | |
| 1034 int Dir(UINT attr, LPCTSTR lpszWildCard) | |
| 1035 { | |
| 1036 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1037 return (int)::SendMessage(this->m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard); | |
| 1038 } | |
| 1039 | |
| 1040 // selection helpers | |
| 1041 int FindString(int nStartAfter, LPCTSTR lpszString) const | |
| 1042 { | |
| 1043 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1044 return (int)::SendMessage(this->m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString); | |
| 1045 } | |
| 1046 | |
| 1047 int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const | |
| 1048 { | |
| 1049 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1050 return (int)::SendMessage(this->m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); | |
| 1051 } | |
| 1052 | |
| 1053 int SelectString(int nStartAfter, LPCTSTR lpszString) | |
| 1054 { | |
| 1055 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1056 return (int)::SendMessage(this->m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); | |
| 1057 } | |
| 1058 | |
| 1059 // Clipboard operations | |
| 1060 void Clear() | |
| 1061 { | |
| 1062 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1063 ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); | |
| 1064 } | |
| 1065 | |
| 1066 void Copy() | |
| 1067 { | |
| 1068 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1069 ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); | |
| 1070 } | |
| 1071 | |
| 1072 void Cut() | |
| 1073 { | |
| 1074 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1075 ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); | |
| 1076 } | |
| 1077 | |
| 1078 void Paste() | |
| 1079 { | |
| 1080 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1081 ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); | |
| 1082 } | |
| 1083 }; | |
| 1084 | |
| 1085 typedef CComboBoxT<ATL::CWindow> CComboBox; | |
| 1086 | |
| 1087 | |
| 1088 /////////////////////////////////////////////////////////////////////////////// | |
| 1089 // CEdit - client side for a Windows EDIT control | |
| 1090 | |
| 1091 template <class TBase> | |
| 1092 class CEditT : public TBase | |
| 1093 { | |
| 1094 public: | |
| 1095 // Constructors | |
| 1096 CEditT(HWND hWnd = NULL) : TBase(hWnd) | |
| 1097 { } | |
| 1098 | |
| 1099 CEditT< TBase >& operator =(HWND hWnd) | |
| 1100 { | |
| 1101 this->m_hWnd = hWnd; | |
| 1102 return *this; | |
| 1103 } | |
| 1104 | |
| 1105 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 1106 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 1107 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 1108 { | |
| 1109 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 1110 } | |
| 1111 | |
| 1112 // Attributes | |
| 1113 static LPCTSTR GetWndClassName() | |
| 1114 { | |
| 1115 return _T("EDIT"); | |
| 1116 } | |
| 1117 | |
| 1118 BOOL CanUndo() const | |
| 1119 { | |
| 1120 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1121 return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); | |
| 1122 } | |
| 1123 | |
| 1124 int GetLineCount() const | |
| 1125 { | |
| 1126 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1127 return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); | |
| 1128 } | |
| 1129 | |
| 1130 BOOL GetModify() const | |
| 1131 { | |
| 1132 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1133 return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); | |
| 1134 } | |
| 1135 | |
| 1136 void SetModify(BOOL bModified = TRUE) | |
| 1137 { | |
| 1138 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1139 ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); | |
| 1140 } | |
| 1141 | |
| 1142 void GetRect(LPRECT lpRect) const | |
| 1143 { | |
| 1144 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1145 ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); | |
| 1146 } | |
| 1147 | |
| 1148 DWORD GetSel() const | |
| 1149 { | |
| 1150 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1151 return (DWORD)::SendMessage(this->m_hWnd, EM_GETSEL, 0, 0L); | |
| 1152 } | |
| 1153 | |
| 1154 void GetSel(int& nStartChar, int& nEndChar) const | |
| 1155 { | |
| 1156 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1157 ::SendMessage(this->m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar); | |
| 1158 } | |
| 1159 | |
| 1160 HLOCAL GetHandle() const | |
| 1161 { | |
| 1162 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1163 return (HLOCAL)::SendMessage(this->m_hWnd, EM_GETHANDLE, 0, 0L); | |
| 1164 } | |
| 1165 | |
| 1166 void SetHandle(HLOCAL hBuffer) | |
| 1167 { | |
| 1168 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1169 ::SendMessage(this->m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); | |
| 1170 } | |
| 1171 | |
| 1172 DWORD GetMargins() const | |
| 1173 { | |
| 1174 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1175 return (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); | |
| 1176 } | |
| 1177 | |
| 1178 void GetMargins(UINT& nLeft, UINT& nRight) const | |
| 1179 { | |
| 1180 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1181 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETMARGINS, 0, 0L); | |
| 1182 nLeft = LOWORD(dwRet); | |
| 1183 nRight = HIWORD(dwRet); | |
| 1184 } | |
| 1185 | |
| 1186 void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) | |
| 1187 { | |
| 1188 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1189 ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); | |
| 1190 } | |
| 1191 | |
| 1192 UINT GetLimitText() const | |
| 1193 { | |
| 1194 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1195 return (UINT)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); | |
| 1196 } | |
| 1197 | |
| 1198 void SetLimitText(UINT nMax) | |
| 1199 { | |
| 1200 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1201 ::SendMessage(this->m_hWnd, EM_SETLIMITTEXT, nMax, 0L); | |
| 1202 } | |
| 1203 | |
| 1204 POINT PosFromChar(UINT nChar) const | |
| 1205 { | |
| 1206 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1207 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_POSFROMCHAR, nChar, 0); | |
| 1208 POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; | |
| 1209 return point; | |
| 1210 } | |
| 1211 | |
| 1212 int CharFromPos(POINT pt, int* pLine = NULL) const | |
| 1213 { | |
| 1214 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1215 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); | |
| 1216 if(pLine != NULL) | |
| 1217 *pLine = (int)(short)HIWORD(dwRet); | |
| 1218 return (int)(short)LOWORD(dwRet); | |
| 1219 } | |
| 1220 | |
| 1221 // NOTE: first word in lpszBuffer must contain the size of the buffer! | |
| 1222 int GetLine(int nIndex, LPTSTR lpszBuffer) const | |
| 1223 { | |
| 1224 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1225 return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); | |
| 1226 } | |
| 1227 | |
| 1228 int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const | |
| 1229 { | |
| 1230 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1231 *(LPWORD)lpszBuffer = (WORD)nMaxLength; | |
| 1232 return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); | |
| 1233 } | |
| 1234 | |
| 1235 TCHAR GetPasswordChar() const | |
| 1236 { | |
| 1237 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1238 return (TCHAR)::SendMessage(this->m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); | |
| 1239 } | |
| 1240 | |
| 1241 void SetPasswordChar(TCHAR ch) | |
| 1242 { | |
| 1243 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1244 ::SendMessage(this->m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); | |
| 1245 } | |
| 1246 | |
| 1247 EDITWORDBREAKPROC GetWordBreakProc() const | |
| 1248 { | |
| 1249 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1250 return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); | |
| 1251 } | |
| 1252 | |
| 1253 void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) | |
| 1254 { | |
| 1255 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1256 ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); | |
| 1257 } | |
| 1258 | |
| 1259 int GetFirstVisibleLine() const | |
| 1260 { | |
| 1261 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1262 return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); | |
| 1263 } | |
| 1264 | |
| 1265 int GetThumb() const | |
| 1266 { | |
| 1267 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1268 ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); | |
| 1269 return (int)::SendMessage(this->m_hWnd, EM_GETTHUMB, 0, 0L); | |
| 1270 } | |
| 1271 | |
| 1272 BOOL SetReadOnly(BOOL bReadOnly = TRUE) | |
| 1273 { | |
| 1274 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1275 return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); | |
| 1276 } | |
| 1277 | |
| 1278 UINT GetImeStatus(UINT uStatus) const | |
| 1279 { | |
| 1280 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1281 return (UINT)::SendMessage(this->m_hWnd, EM_GETIMESTATUS, uStatus, 0L); | |
| 1282 } | |
| 1283 | |
| 1284 UINT SetImeStatus(UINT uStatus, UINT uData) | |
| 1285 { | |
| 1286 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1287 return (UINT)::SendMessage(this->m_hWnd, EM_SETIMESTATUS, uStatus, uData); | |
| 1288 } | |
| 1289 | |
| 1290 BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const | |
| 1291 { | |
| 1292 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1293 return (BOOL)::SendMessage(this->m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText); | |
| 1294 } | |
| 1295 | |
| 1296 // bKeepWithFocus - Vista only | |
| 1297 BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE) | |
| 1298 { | |
| 1299 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1300 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText)); | |
| 1301 } | |
| 1302 | |
| 1303 // Operations | |
| 1304 void EmptyUndoBuffer() | |
| 1305 { | |
| 1306 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1307 ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); | |
| 1308 } | |
| 1309 | |
| 1310 BOOL FmtLines(BOOL bAddEOL) | |
| 1311 { | |
| 1312 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1313 return (BOOL)::SendMessage(this->m_hWnd, EM_FMTLINES, bAddEOL, 0L); | |
| 1314 } | |
| 1315 | |
| 1316 void LimitText(int nChars = 0) | |
| 1317 { | |
| 1318 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1319 ::SendMessage(this->m_hWnd, EM_LIMITTEXT, nChars, 0L); | |
| 1320 } | |
| 1321 | |
| 1322 int LineFromChar(int nIndex = -1) const | |
| 1323 { | |
| 1324 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1325 return (int)::SendMessage(this->m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); | |
| 1326 } | |
| 1327 | |
| 1328 int LineIndex(int nLine = -1) const | |
| 1329 { | |
| 1330 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1331 return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); | |
| 1332 } | |
| 1333 | |
| 1334 int LineLength(int nLine = -1) const | |
| 1335 { | |
| 1336 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1337 return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); | |
| 1338 } | |
| 1339 | |
| 1340 void LineScroll(int nLines, int nChars = 0) | |
| 1341 { | |
| 1342 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1343 ::SendMessage(this->m_hWnd, EM_LINESCROLL, nChars, nLines); | |
| 1344 } | |
| 1345 | |
| 1346 void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) | |
| 1347 { | |
| 1348 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1349 ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); | |
| 1350 } | |
| 1351 | |
| 1352 void SetRect(LPCRECT lpRect) | |
| 1353 { | |
| 1354 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1355 ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); | |
| 1356 } | |
| 1357 | |
| 1358 void SetRectNP(LPCRECT lpRect) | |
| 1359 { | |
| 1360 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1361 ::SendMessage(this->m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); | |
| 1362 } | |
| 1363 | |
| 1364 void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE) | |
| 1365 { | |
| 1366 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1367 ::SendMessage(this->m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection)); | |
| 1368 if(!bNoScroll) | |
| 1369 ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); | |
| 1370 } | |
| 1371 | |
| 1372 void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE) | |
| 1373 { | |
| 1374 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1375 ::SendMessage(this->m_hWnd, EM_SETSEL, nStartChar, nEndChar); | |
| 1376 if(!bNoScroll) | |
| 1377 ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); | |
| 1378 } | |
| 1379 | |
| 1380 void SetSelAll(BOOL bNoScroll = FALSE) | |
| 1381 { | |
| 1382 SetSel(0, -1, bNoScroll); | |
| 1383 } | |
| 1384 | |
| 1385 void SetSelNone(BOOL bNoScroll = FALSE) | |
| 1386 { | |
| 1387 SetSel(-1, 0, bNoScroll); | |
| 1388 } | |
| 1389 | |
| 1390 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) | |
| 1391 { | |
| 1392 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1393 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); | |
| 1394 } | |
| 1395 | |
| 1396 BOOL SetTabStops() | |
| 1397 { | |
| 1398 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1399 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); | |
| 1400 } | |
| 1401 | |
| 1402 BOOL SetTabStops(const int& cxEachStop) // takes an 'int' | |
| 1403 { | |
| 1404 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1405 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); | |
| 1406 } | |
| 1407 | |
| 1408 void ScrollCaret() | |
| 1409 { | |
| 1410 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1411 ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); | |
| 1412 } | |
| 1413 | |
| 1414 int Scroll(int nScrollAction) | |
| 1415 { | |
| 1416 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1417 ATLASSERT((this->GetStyle() & ES_MULTILINE) != 0); | |
| 1418 LRESULT lRet = ::SendMessage(this->m_hWnd, EM_SCROLL, nScrollAction, 0L); | |
| 1419 if(!(BOOL)HIWORD(lRet)) | |
| 1420 return -1; // failed | |
| 1421 return (int)(short)LOWORD(lRet); | |
| 1422 | |
| 1423 } | |
| 1424 | |
| 1425 void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE) | |
| 1426 { | |
| 1427 SetSel(nInsertAfterChar, nInsertAfterChar, bNoScroll); | |
| 1428 ReplaceSel(lpstrText, bCanUndo); | |
| 1429 } | |
| 1430 | |
| 1431 void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE) | |
| 1432 { | |
| 1433 InsertText(this->GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo); | |
| 1434 } | |
| 1435 | |
| 1436 BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip) | |
| 1437 { | |
| 1438 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1439 return (BOOL)::SendMessage(this->m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip); | |
| 1440 } | |
| 1441 | |
| 1442 BOOL HideBalloonTip() | |
| 1443 { | |
| 1444 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1445 return (BOOL)::SendMessage(this->m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); | |
| 1446 } | |
| 1447 | |
| 1448 #if (_WIN32_WINNT >= 0x0600) | |
| 1449 DWORD GetHilite() const | |
| 1450 { | |
| 1451 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1452 return (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); | |
| 1453 } | |
| 1454 | |
| 1455 void GetHilite(int& nStartChar, int& nEndChar) const | |
| 1456 { | |
| 1457 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1458 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, EM_GETHILITE, 0, 0L); | |
| 1459 nStartChar = (int)(short)LOWORD(dwRet); | |
| 1460 nEndChar = (int)(short)HIWORD(dwRet); | |
| 1461 } | |
| 1462 | |
| 1463 void SetHilite(int nStartChar, int nEndChar) | |
| 1464 { | |
| 1465 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1466 ::SendMessage(this->m_hWnd, EM_SETHILITE, nStartChar, nEndChar); | |
| 1467 } | |
| 1468 #endif // (_WIN32_WINNT >= 0x0600) | |
| 1469 | |
| 1470 // Clipboard operations | |
| 1471 BOOL Undo() | |
| 1472 { | |
| 1473 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1474 return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); | |
| 1475 } | |
| 1476 | |
| 1477 void Clear() | |
| 1478 { | |
| 1479 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1480 ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); | |
| 1481 } | |
| 1482 | |
| 1483 void Copy() | |
| 1484 { | |
| 1485 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1486 ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); | |
| 1487 } | |
| 1488 | |
| 1489 void Cut() | |
| 1490 { | |
| 1491 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1492 ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); | |
| 1493 } | |
| 1494 | |
| 1495 void Paste() | |
| 1496 { | |
| 1497 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1498 ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); | |
| 1499 } | |
| 1500 | |
| 1501 // New messages added in Windows 10.0.17763 | |
| 1502 #if defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) | |
| 1503 DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) | |
| 1504 { | |
| 1505 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1506 return ::SendMessage(this->m_hWnd, EM_SETEXTENDEDSTYLE, dwMask, dwStyle); | |
| 1507 } | |
| 1508 | |
| 1509 DWORD GetExtendedStyle() const | |
| 1510 { | |
| 1511 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1512 return ::SendMessage(this->m_hWnd, EM_GETEXTENDEDSTYLE, 0, 0L); | |
| 1513 } | |
| 1514 | |
| 1515 BOOL SetEndOfLine(EC_ENDOFLINE eolType) | |
| 1516 { | |
| 1517 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1518 return (BOOL)::SendMessage(this->m_hWnd, EM_SETENDOFLINE, eolType, 0L); | |
| 1519 } | |
| 1520 | |
| 1521 EC_ENDOFLINE GetEndOfLine() const | |
| 1522 { | |
| 1523 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1524 return (EC_ENDOFLINE)::SendMessage(this->m_hWnd, EM_GETENDOFLINE, 0, 0L); | |
| 1525 } | |
| 1526 | |
| 1527 BOOL EnableSearchWeb(BOOL bEnable) | |
| 1528 { | |
| 1529 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1530 return (BOOL)::SendMessage(this->m_hWnd, EM_ENABLESEARCHWEB, (WPARAM)bEnable, 0L); | |
| 1531 } | |
| 1532 | |
| 1533 void SearchWeb() | |
| 1534 { | |
| 1535 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1536 ::SendMessage(this->m_hWnd, EM_SEARCHWEB, 0, 0L); | |
| 1537 } | |
| 1538 | |
| 1539 BOOL SetCaretIndex(DWORD dwCaretIndex) | |
| 1540 { | |
| 1541 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1542 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCARETINDEX, dwCaretIndex, 0L); | |
| 1543 } | |
| 1544 | |
| 1545 DWORD GetCaretIndex() const | |
| 1546 { | |
| 1547 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1548 return ::SendMessage(this->m_hWnd, EM_GETCARETINDEX, 0, 0L); | |
| 1549 } | |
| 1550 | |
| 1551 BOOL GetZoom(int& nNum, int& nDen) const | |
| 1552 { | |
| 1553 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1554 return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); | |
| 1555 } | |
| 1556 | |
| 1557 BOOL SetZoom(int nNum, int nDen) | |
| 1558 { | |
| 1559 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1560 ATLASSERT((nNum >= 0) && (nNum <= 64)); | |
| 1561 ATLASSERT((nDen >= 0) && (nDen <= 64)); | |
| 1562 return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); | |
| 1563 } | |
| 1564 | |
| 1565 DWORD GetFileLineFromChar(DWORD dwCharIndex) const | |
| 1566 { | |
| 1567 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1568 return ::SendMessage(this->m_hWnd, EM_FILELINEFROMCHAR, dwCharIndex, 0L); | |
| 1569 } | |
| 1570 | |
| 1571 DWORD GetFileLineIndex(DWORD dwLineNum) const | |
| 1572 { | |
| 1573 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1574 return ::SendMessage(this->m_hWnd, EM_FILELINEINDEX, dwLineNum, 0L); | |
| 1575 } | |
| 1576 | |
| 1577 DWORD GetFileLineLength(DWORD dwCharIndex) const | |
| 1578 { | |
| 1579 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1580 return ::SendMessage(this->m_hWnd, EM_FILELINELENGTH, dwCharIndex, 0L); | |
| 1581 } | |
| 1582 | |
| 1583 DWORD GetFileLine(DWORD dwLineNum, LPTSTR lpstrLine, WORD wLen) const | |
| 1584 { | |
| 1585 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1586 WORD* pw = (WORD*)lpstrLine; | |
| 1587 *pw = wLen; | |
| 1588 return ::SendMessage(this->m_hWnd, EM_GETFILELINE, dwLineNum, (LPARAM)lpstrLine); | |
| 1589 } | |
| 1590 | |
| 1591 #ifdef __ATLSTR_H__ | |
| 1592 ATL::CString GetFileLine(DWORD dwLineNum) const | |
| 1593 { | |
| 1594 ATL::CString strLine; | |
| 1595 DWORD dwCharIndex = GetFileLineIndex(dwLineNum); | |
| 1596 if(dwCharIndex != (DWORD)-1) | |
| 1597 { | |
| 1598 DWORD dwLen = GetFileLineLength(dwCharIndex); | |
| 1599 if(dwLen > 0) | |
| 1600 { | |
| 1601 LPTSTR lpstrLine = strLine.GetBufferSetLength(dwLen); | |
| 1602 ATLVERIFY(GetFileLine(dwLineNum, lpstrLine, (WORD)dwLen) == dwLen); | |
| 1603 strLine.ReleaseBuffer(); | |
| 1604 } | |
| 1605 } | |
| 1606 | |
| 1607 return strLine; | |
| 1608 } | |
| 1609 #endif // __ATLSTR_H__ | |
| 1610 | |
| 1611 DWORD GetFileLineCount() const | |
| 1612 { | |
| 1613 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1614 return ::SendMessage(this->m_hWnd, EM_GETFILELINECOUNT, 0, 0L); | |
| 1615 } | |
| 1616 #endif // defined(NTDDI_VERSION) && defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5) | |
| 1617 }; | |
| 1618 | |
| 1619 typedef CEditT<ATL::CWindow> CEdit; | |
| 1620 | |
| 1621 | |
| 1622 /////////////////////////////////////////////////////////////////////////////// | |
| 1623 // CEditCommands - message handlers for standard EDIT commands | |
| 1624 | |
| 1625 // Chain to CEditCommands message map. Your class must also derive from CEdit. | |
| 1626 // Example: | |
| 1627 // class CMyEdit : public CWindowImpl<CMyEdit, CEdit>, | |
| 1628 // public CEditCommands<CMyEdit> | |
| 1629 // { | |
| 1630 // public: | |
| 1631 // BEGIN_MSG_MAP(CMyEdit) | |
| 1632 // // your handlers... | |
| 1633 // CHAIN_MSG_MAP_ALT(CEditCommands<CMyEdit>, 1) | |
| 1634 // END_MSG_MAP() | |
| 1635 // // other stuff... | |
| 1636 // }; | |
| 1637 | |
| 1638 template <class T> | |
| 1639 class CEditCommands | |
| 1640 { | |
| 1641 public: | |
| 1642 BEGIN_MSG_MAP(CEditCommands< T >) | |
| 1643 ALT_MSG_MAP(1) | |
| 1644 COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear) | |
| 1645 COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll) | |
| 1646 COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy) | |
| 1647 COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut) | |
| 1648 COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste) | |
| 1649 COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll) | |
| 1650 COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo) | |
| 1651 END_MSG_MAP() | |
| 1652 | |
| 1653 LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1654 { | |
| 1655 T* pT = static_cast<T*>(this); | |
| 1656 pT->Clear(); | |
| 1657 return 0; | |
| 1658 } | |
| 1659 | |
| 1660 LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1661 { | |
| 1662 T* pT = static_cast<T*>(this); | |
| 1663 pT->SetSel(0, -1); | |
| 1664 pT->Clear(); | |
| 1665 return 0; | |
| 1666 } | |
| 1667 | |
| 1668 LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1669 { | |
| 1670 T* pT = static_cast<T*>(this); | |
| 1671 pT->Copy(); | |
| 1672 return 0; | |
| 1673 } | |
| 1674 | |
| 1675 LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1676 { | |
| 1677 T* pT = static_cast<T*>(this); | |
| 1678 pT->Cut(); | |
| 1679 return 0; | |
| 1680 } | |
| 1681 | |
| 1682 LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1683 { | |
| 1684 T* pT = static_cast<T*>(this); | |
| 1685 pT->Paste(); | |
| 1686 return 0; | |
| 1687 } | |
| 1688 | |
| 1689 LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1690 { | |
| 1691 T* pT = static_cast<T*>(this); | |
| 1692 pT->SetSel(0, -1); | |
| 1693 return 0; | |
| 1694 } | |
| 1695 | |
| 1696 LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 1697 { | |
| 1698 T* pT = static_cast<T*>(this); | |
| 1699 pT->Undo(); | |
| 1700 return 0; | |
| 1701 } | |
| 1702 | |
| 1703 // State (update UI) helpers | |
| 1704 BOOL CanCut() const | |
| 1705 { return HasSelection(); } | |
| 1706 | |
| 1707 BOOL CanCopy() const | |
| 1708 { return HasSelection(); } | |
| 1709 | |
| 1710 BOOL CanClear() const | |
| 1711 { return HasSelection(); } | |
| 1712 | |
| 1713 BOOL CanSelectAll() const | |
| 1714 { return HasText(); } | |
| 1715 | |
| 1716 BOOL CanFind() const | |
| 1717 { return HasText(); } | |
| 1718 | |
| 1719 BOOL CanRepeat() const | |
| 1720 { return HasText(); } | |
| 1721 | |
| 1722 BOOL CanReplace() const | |
| 1723 { return HasText(); } | |
| 1724 | |
| 1725 BOOL CanClearAll() const | |
| 1726 { return HasText(); } | |
| 1727 | |
| 1728 // Implementation | |
| 1729 BOOL HasSelection() const | |
| 1730 { | |
| 1731 const T* pT = static_cast<const T*>(this); | |
| 1732 int nMin = 0, nMax = 0; | |
| 1733 ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nMin, (LPARAM)&nMax); | |
| 1734 return (nMin != nMax); | |
| 1735 } | |
| 1736 | |
| 1737 BOOL HasText() const | |
| 1738 { | |
| 1739 const T* pT = static_cast<const T*>(this); | |
| 1740 return (pT->GetWindowTextLength() > 0); | |
| 1741 } | |
| 1742 }; | |
| 1743 | |
| 1744 | |
| 1745 /////////////////////////////////////////////////////////////////////////////// | |
| 1746 // CScrollBar - client side for a Windows SCROLLBAR control | |
| 1747 | |
| 1748 template <class TBase> | |
| 1749 class CScrollBarT : public TBase | |
| 1750 { | |
| 1751 public: | |
| 1752 // Constructors | |
| 1753 CScrollBarT(HWND hWnd = NULL) : TBase(hWnd) | |
| 1754 { } | |
| 1755 | |
| 1756 CScrollBarT< TBase >& operator =(HWND hWnd) | |
| 1757 { | |
| 1758 this->m_hWnd = hWnd; | |
| 1759 return *this; | |
| 1760 } | |
| 1761 | |
| 1762 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 1763 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 1764 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 1765 { | |
| 1766 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 1767 } | |
| 1768 | |
| 1769 // Attributes | |
| 1770 static LPCTSTR GetWndClassName() | |
| 1771 { | |
| 1772 return _T("SCROLLBAR"); | |
| 1773 } | |
| 1774 | |
| 1775 int GetScrollPos() const | |
| 1776 { | |
| 1777 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1778 return ::GetScrollPos(this->m_hWnd, SB_CTL); | |
| 1779 } | |
| 1780 | |
| 1781 int SetScrollPos(int nPos, BOOL bRedraw = TRUE) | |
| 1782 { | |
| 1783 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1784 return ::SetScrollPos(this->m_hWnd, SB_CTL, nPos, bRedraw); | |
| 1785 } | |
| 1786 | |
| 1787 void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const | |
| 1788 { | |
| 1789 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1790 ::GetScrollRange(this->m_hWnd, SB_CTL, lpMinPos, lpMaxPos); | |
| 1791 } | |
| 1792 | |
| 1793 void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) | |
| 1794 { | |
| 1795 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1796 ::SetScrollRange(this->m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); | |
| 1797 } | |
| 1798 | |
| 1799 BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const | |
| 1800 { | |
| 1801 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1802 return ::GetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo); | |
| 1803 } | |
| 1804 | |
| 1805 int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) | |
| 1806 { | |
| 1807 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1808 return ::SetScrollInfo(this->m_hWnd, SB_CTL, lpScrollInfo, bRedraw); | |
| 1809 } | |
| 1810 | |
| 1811 int GetScrollLimit() const | |
| 1812 { | |
| 1813 SCROLLINFO info = { sizeof(SCROLLINFO), SIF_RANGE | SIF_PAGE }; | |
| 1814 ::GetScrollInfo(this->m_hWnd, SB_CTL, &info); | |
| 1815 if(info.nPage > 1) | |
| 1816 info.nMax -= info.nPage - 1; | |
| 1817 | |
| 1818 return info.nMax; | |
| 1819 } | |
| 1820 | |
| 1821 BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const | |
| 1822 { | |
| 1823 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1824 return (BOOL)::SendMessage(this->m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo); | |
| 1825 } | |
| 1826 | |
| 1827 // Operations | |
| 1828 void ShowScrollBar(BOOL bShow = TRUE) | |
| 1829 { | |
| 1830 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1831 ::ShowScrollBar(this->m_hWnd, SB_CTL, bShow); | |
| 1832 } | |
| 1833 | |
| 1834 BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH) | |
| 1835 { | |
| 1836 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 1837 return ::EnableScrollBar(this->m_hWnd, SB_CTL, nArrowFlags); | |
| 1838 } | |
| 1839 }; | |
| 1840 | |
| 1841 typedef CScrollBarT<ATL::CWindow> CScrollBar; | |
| 1842 | |
| 1843 | |
| 1844 // --- Windows Common Controls --- | |
| 1845 | |
| 1846 /////////////////////////////////////////////////////////////////////////////// | |
| 1847 // CImageList | |
| 1848 | |
| 1849 // forward declarations | |
| 1850 template <bool t_bManaged> class CImageListT; | |
| 1851 typedef CImageListT<false> CImageList; | |
| 1852 typedef CImageListT<true> CImageListManaged; | |
| 1853 | |
| 1854 | |
| 1855 template <bool t_bManaged> | |
| 1856 class CImageListT | |
| 1857 { | |
| 1858 public: | |
| 1859 // Data members | |
| 1860 HIMAGELIST m_hImageList; | |
| 1861 | |
| 1862 // Constructor/destructor/operators | |
| 1863 CImageListT(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList) | |
| 1864 { } | |
| 1865 | |
| 1866 ~CImageListT() | |
| 1867 { | |
| 1868 if(t_bManaged && (m_hImageList != NULL)) | |
| 1869 Destroy(); | |
| 1870 } | |
| 1871 | |
| 1872 CImageListT<t_bManaged>& operator =(HIMAGELIST hImageList) | |
| 1873 { | |
| 1874 Attach(hImageList); | |
| 1875 return *this; | |
| 1876 } | |
| 1877 | |
| 1878 void Attach(HIMAGELIST hImageList) | |
| 1879 { | |
| 1880 if(t_bManaged && (m_hImageList != NULL) && (m_hImageList != hImageList)) | |
| 1881 ImageList_Destroy(m_hImageList); | |
| 1882 m_hImageList = hImageList; | |
| 1883 } | |
| 1884 | |
| 1885 HIMAGELIST Detach() | |
| 1886 { | |
| 1887 HIMAGELIST hImageList = m_hImageList; | |
| 1888 m_hImageList = NULL; | |
| 1889 return hImageList; | |
| 1890 } | |
| 1891 | |
| 1892 operator HIMAGELIST() const { return m_hImageList; } | |
| 1893 | |
| 1894 bool IsNull() const { return (m_hImageList == NULL); } | |
| 1895 | |
| 1896 // Attributes | |
| 1897 int GetImageCount() const | |
| 1898 { | |
| 1899 ATLASSERT(m_hImageList != NULL); | |
| 1900 return ImageList_GetImageCount(m_hImageList); | |
| 1901 } | |
| 1902 | |
| 1903 COLORREF GetBkColor() const | |
| 1904 { | |
| 1905 ATLASSERT(m_hImageList != NULL); | |
| 1906 return ImageList_GetBkColor(m_hImageList); | |
| 1907 } | |
| 1908 | |
| 1909 COLORREF SetBkColor(COLORREF cr) | |
| 1910 { | |
| 1911 ATLASSERT(m_hImageList != NULL); | |
| 1912 return ImageList_SetBkColor(m_hImageList, cr); | |
| 1913 } | |
| 1914 | |
| 1915 BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const | |
| 1916 { | |
| 1917 ATLASSERT(m_hImageList != NULL); | |
| 1918 return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo); | |
| 1919 } | |
| 1920 | |
| 1921 HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const | |
| 1922 { | |
| 1923 ATLASSERT(m_hImageList != NULL); | |
| 1924 return ImageList_GetIcon(m_hImageList, nIndex, uFlags); | |
| 1925 } | |
| 1926 | |
| 1927 BOOL GetIconSize(int& cx, int& cy) const | |
| 1928 { | |
| 1929 ATLASSERT(m_hImageList != NULL); | |
| 1930 return ImageList_GetIconSize(m_hImageList, &cx, &cy); | |
| 1931 } | |
| 1932 | |
| 1933 BOOL GetIconSize(SIZE& size) const | |
| 1934 { | |
| 1935 ATLASSERT(m_hImageList != NULL); | |
| 1936 return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*)&size.cy); | |
| 1937 } | |
| 1938 | |
| 1939 BOOL SetIconSize(int cx, int cy) | |
| 1940 { | |
| 1941 ATLASSERT(m_hImageList != NULL); | |
| 1942 return ImageList_SetIconSize(m_hImageList, cx, cy); | |
| 1943 } | |
| 1944 | |
| 1945 BOOL SetIconSize(SIZE size) | |
| 1946 { | |
| 1947 ATLASSERT(m_hImageList != NULL); | |
| 1948 return ImageList_SetIconSize(m_hImageList, size.cx, size.cy); | |
| 1949 } | |
| 1950 | |
| 1951 BOOL SetImageCount(UINT uNewCount) | |
| 1952 { | |
| 1953 ATLASSERT(m_hImageList != NULL); | |
| 1954 return ImageList_SetImageCount(m_hImageList, uNewCount); | |
| 1955 } | |
| 1956 | |
| 1957 BOOL SetOverlayImage(int nImage, int nOverlay) | |
| 1958 { | |
| 1959 ATLASSERT(m_hImageList != NULL); | |
| 1960 return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay); | |
| 1961 } | |
| 1962 | |
| 1963 // Operations | |
| 1964 BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow) | |
| 1965 { | |
| 1966 ATLASSERT(m_hImageList == NULL); | |
| 1967 m_hImageList = ImageList_Create(cx, cy, nFlags, nInitial, nGrow); | |
| 1968 return (m_hImageList != NULL) ? TRUE : FALSE; | |
| 1969 } | |
| 1970 | |
| 1971 BOOL Create(ATL::_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMask) | |
| 1972 { | |
| 1973 ATLASSERT(m_hImageList == NULL); | |
| 1974 m_hImageList = ImageList_LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr, cx, nGrow, crMask); | |
| 1975 return (m_hImageList != NULL) ? TRUE : FALSE; | |
| 1976 } | |
| 1977 | |
| 1978 BOOL CreateFromImage(ATL::_U_STRINGorID image, int cx, int nGrow, COLORREF crMask, UINT uType, UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE) | |
| 1979 { | |
| 1980 ATLASSERT(m_hImageList == NULL); | |
| 1981 m_hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInstance(), image.m_lpstr, cx, nGrow, crMask, uType, uFlags); | |
| 1982 return (m_hImageList != NULL) ? TRUE : FALSE; | |
| 1983 } | |
| 1984 | |
| 1985 BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2, int nImage2, int dx, int dy) | |
| 1986 { | |
| 1987 ATLASSERT(m_hImageList == NULL); | |
| 1988 m_hImageList = ImageList_Merge(hImageList1, nImage1, hImageList2, nImage2, dx, dy); | |
| 1989 return (m_hImageList != NULL) ? TRUE : FALSE; | |
| 1990 } | |
| 1991 | |
| 1992 #ifdef __IStream_INTERFACE_DEFINED__ | |
| 1993 BOOL CreateFromStream(LPSTREAM lpStream) | |
| 1994 { | |
| 1995 ATLASSERT(m_hImageList == NULL); | |
| 1996 m_hImageList = ImageList_Read(lpStream); | |
| 1997 return (m_hImageList != NULL) ? TRUE : FALSE; | |
| 1998 } | |
| 1999 #endif // __IStream_INTERFACE_DEFINED__ | |
| 2000 | |
| 2001 BOOL Destroy() | |
| 2002 { | |
| 2003 if (m_hImageList == NULL) | |
| 2004 return FALSE; | |
| 2005 BOOL bRet = ImageList_Destroy(m_hImageList); | |
| 2006 if(bRet) | |
| 2007 m_hImageList = NULL; | |
| 2008 return bRet; | |
| 2009 } | |
| 2010 | |
| 2011 int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL) | |
| 2012 { | |
| 2013 ATLASSERT(m_hImageList != NULL); | |
| 2014 return ImageList_Add(m_hImageList, hBitmap, hBitmapMask); | |
| 2015 } | |
| 2016 | |
| 2017 int Add(HBITMAP hBitmap, COLORREF crMask) | |
| 2018 { | |
| 2019 ATLASSERT(m_hImageList != NULL); | |
| 2020 return ImageList_AddMasked(m_hImageList, hBitmap, crMask); | |
| 2021 } | |
| 2022 | |
| 2023 BOOL Remove(int nImage) | |
| 2024 { | |
| 2025 ATLASSERT(m_hImageList != NULL); | |
| 2026 return ImageList_Remove(m_hImageList, nImage); | |
| 2027 } | |
| 2028 | |
| 2029 BOOL RemoveAll() | |
| 2030 { | |
| 2031 ATLASSERT(m_hImageList != NULL); | |
| 2032 return ImageList_RemoveAll(m_hImageList); | |
| 2033 } | |
| 2034 | |
| 2035 BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask) | |
| 2036 { | |
| 2037 ATLASSERT(m_hImageList != NULL); | |
| 2038 return ImageList_Replace(m_hImageList, nImage, hBitmap, hBitmapMask); | |
| 2039 } | |
| 2040 | |
| 2041 int AddIcon(HICON hIcon) | |
| 2042 { | |
| 2043 ATLASSERT(m_hImageList != NULL); | |
| 2044 return ImageList_AddIcon(m_hImageList, hIcon); | |
| 2045 } | |
| 2046 | |
| 2047 int ReplaceIcon(int nImage, HICON hIcon) | |
| 2048 { | |
| 2049 ATLASSERT(m_hImageList != NULL); | |
| 2050 return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon); | |
| 2051 } | |
| 2052 | |
| 2053 HICON ExtractIcon(int nImage) | |
| 2054 { | |
| 2055 ATLASSERT(m_hImageList != NULL); | |
| 2056 return ImageList_ExtractIcon(NULL, m_hImageList, nImage); | |
| 2057 } | |
| 2058 | |
| 2059 BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle) | |
| 2060 { | |
| 2061 ATLASSERT(m_hImageList != NULL); | |
| 2062 ATLASSERT(hDC != NULL); | |
| 2063 return ImageList_Draw(m_hImageList, nImage, hDC, x, y, nStyle); | |
| 2064 } | |
| 2065 | |
| 2066 BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle) | |
| 2067 { | |
| 2068 ATLASSERT(m_hImageList != NULL); | |
| 2069 ATLASSERT(hDC != NULL); | |
| 2070 return ImageList_Draw(m_hImageList, nImage, hDC, pt.x, pt.y, nStyle); | |
| 2071 } | |
| 2072 | |
| 2073 BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle) | |
| 2074 { | |
| 2075 ATLASSERT(m_hImageList != NULL); | |
| 2076 ATLASSERT(hDC != NULL); | |
| 2077 return ImageList_DrawEx(m_hImageList, nImage, hDC, x, y, dx, dy, rgbBk, rgbFg, fStyle); | |
| 2078 } | |
| 2079 | |
| 2080 BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle) | |
| 2081 { | |
| 2082 ATLASSERT(m_hImageList != NULL); | |
| 2083 ATLASSERT(hDC != NULL); | |
| 2084 return ImageList_DrawEx(m_hImageList, nImage, hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, rgbBk, rgbFg, fStyle); | |
| 2085 } | |
| 2086 | |
| 2087 static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp) | |
| 2088 { | |
| 2089 return ImageList_DrawIndirect(pimldp); | |
| 2090 } | |
| 2091 | |
| 2092 BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE) | |
| 2093 { | |
| 2094 ATLASSERT(m_hImageList != NULL); | |
| 2095 return ImageList_Copy(m_hImageList, nDst, m_hImageList, nSrc, uFlags); | |
| 2096 } | |
| 2097 | |
| 2098 #ifdef __IStream_INTERFACE_DEFINED__ | |
| 2099 static HIMAGELIST Read(LPSTREAM lpStream) | |
| 2100 { | |
| 2101 return ImageList_Read(lpStream); | |
| 2102 } | |
| 2103 | |
| 2104 BOOL Write(LPSTREAM lpStream) | |
| 2105 { | |
| 2106 ATLASSERT(m_hImageList != NULL); | |
| 2107 return ImageList_Write(m_hImageList, lpStream); | |
| 2108 } | |
| 2109 | |
| 2110 static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv) | |
| 2111 { | |
| 2112 return ImageList_ReadEx(dwFlags, lpStream, riid, ppv); | |
| 2113 } | |
| 2114 | |
| 2115 HRESULT WriteEx(DWORD dwFlags, LPSTREAM lpStream) | |
| 2116 { | |
| 2117 ATLASSERT(m_hImageList != NULL); | |
| 2118 return ImageList_WriteEx(m_hImageList, dwFlags, lpStream); | |
| 2119 } | |
| 2120 #endif // __IStream_INTERFACE_DEFINED__ | |
| 2121 | |
| 2122 // Drag operations | |
| 2123 BOOL BeginDrag(int nImage, POINT ptHotSpot) | |
| 2124 { | |
| 2125 ATLASSERT(m_hImageList != NULL); | |
| 2126 return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, ptHotSpot.y); | |
| 2127 } | |
| 2128 | |
| 2129 BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot) | |
| 2130 { | |
| 2131 ATLASSERT(m_hImageList != NULL); | |
| 2132 return ImageList_BeginDrag(m_hImageList, nImage, xHotSpot, yHotSpot); | |
| 2133 } | |
| 2134 | |
| 2135 static void EndDrag() | |
| 2136 { | |
| 2137 ImageList_EndDrag(); | |
| 2138 } | |
| 2139 | |
| 2140 static BOOL DragMove(POINT pt) | |
| 2141 { | |
| 2142 return ImageList_DragMove(pt.x, pt.y); | |
| 2143 } | |
| 2144 | |
| 2145 static BOOL DragMove(int x, int y) | |
| 2146 { | |
| 2147 return ImageList_DragMove(x, y); | |
| 2148 } | |
| 2149 | |
| 2150 BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot) | |
| 2151 { | |
| 2152 ATLASSERT(m_hImageList != NULL); | |
| 2153 return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSpot.x, ptHotSpot.y); | |
| 2154 } | |
| 2155 | |
| 2156 BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot) | |
| 2157 { | |
| 2158 ATLASSERT(m_hImageList != NULL); | |
| 2159 return ImageList_SetDragCursorImage(m_hImageList, nDrag, xHotSpot, yHotSpot); | |
| 2160 } | |
| 2161 | |
| 2162 static BOOL DragShowNolock(BOOL bShow = TRUE) | |
| 2163 { | |
| 2164 return ImageList_DragShowNolock(bShow); | |
| 2165 } | |
| 2166 | |
| 2167 static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot) | |
| 2168 { | |
| 2169 return CImageList(ImageList_GetDragImage(lpPoint, lpPointHotSpot)); | |
| 2170 } | |
| 2171 | |
| 2172 static BOOL DragEnter(HWND hWnd, POINT point) | |
| 2173 { | |
| 2174 return ImageList_DragEnter(hWnd, point.x, point.y); | |
| 2175 } | |
| 2176 | |
| 2177 static BOOL DragEnter(HWND hWnd, int x, int y) | |
| 2178 { | |
| 2179 return ImageList_DragEnter(hWnd, x, y); | |
| 2180 } | |
| 2181 | |
| 2182 static BOOL DragLeave(HWND hWnd) | |
| 2183 { | |
| 2184 return ImageList_DragLeave(hWnd); | |
| 2185 } | |
| 2186 | |
| 2187 CImageList Duplicate() const | |
| 2188 { | |
| 2189 ATLASSERT(m_hImageList != NULL); | |
| 2190 return CImageList(ImageList_Duplicate(m_hImageList)); | |
| 2191 } | |
| 2192 | |
| 2193 static CImageList Duplicate(HIMAGELIST hImageList) | |
| 2194 { | |
| 2195 ATLASSERT(hImageList != NULL); | |
| 2196 return CImageList(ImageList_Duplicate(hImageList)); | |
| 2197 } | |
| 2198 }; | |
| 2199 | |
| 2200 | |
| 2201 /////////////////////////////////////////////////////////////////////////////// | |
| 2202 // CToolTipCtrl | |
| 2203 | |
| 2204 class CToolInfo : public TOOLINFO | |
| 2205 { | |
| 2206 public: | |
| 2207 CToolInfo(UINT nFlags, HWND hWnd, UINT_PTR nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL) | |
| 2208 { | |
| 2209 Init(nFlags, hWnd, nIDTool, lpRect, lpstrText, lUserParam); | |
| 2210 } | |
| 2211 | |
| 2212 operator LPTOOLINFO() { return this; } | |
| 2213 | |
| 2214 operator LPARAM() { return (LPARAM)this; } | |
| 2215 | |
| 2216 void Init(UINT nFlags, HWND hWnd, UINT_PTR nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL) | |
| 2217 { | |
| 2218 ATLASSERT(::IsWindow(hWnd)); | |
| 2219 memset(this, 0, sizeof(TOOLINFO)); | |
| 2220 cbSize = RunTimeHelper::SizeOf_TOOLINFO(); | |
| 2221 uFlags = nFlags; | |
| 2222 if(nIDTool == 0) | |
| 2223 { | |
| 2224 hwnd = ::GetParent(hWnd); | |
| 2225 uFlags |= TTF_IDISHWND; | |
| 2226 uId = (UINT_PTR)hWnd; | |
| 2227 } | |
| 2228 else | |
| 2229 { | |
| 2230 hwnd = hWnd; | |
| 2231 uId = nIDTool; | |
| 2232 } | |
| 2233 if(lpRect != NULL) | |
| 2234 rect = *lpRect; | |
| 2235 hinst = ModuleHelper::GetResourceInstance(); | |
| 2236 lpszText = lpstrText; | |
| 2237 lParam = lUserParam; | |
| 2238 } | |
| 2239 }; | |
| 2240 | |
| 2241 template <class TBase> | |
| 2242 class CToolTipCtrlT : public TBase | |
| 2243 { | |
| 2244 public: | |
| 2245 // Constructors | |
| 2246 CToolTipCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 2247 { } | |
| 2248 | |
| 2249 CToolTipCtrlT< TBase >& operator =(HWND hWnd) | |
| 2250 { | |
| 2251 this->m_hWnd = hWnd; | |
| 2252 return *this; | |
| 2253 } | |
| 2254 | |
| 2255 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 2256 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 2257 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 2258 { | |
| 2259 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 2260 } | |
| 2261 | |
| 2262 // Attributes | |
| 2263 static LPCTSTR GetWndClassName() | |
| 2264 { | |
| 2265 return TOOLTIPS_CLASS; | |
| 2266 } | |
| 2267 | |
| 2268 void GetText(LPTOOLINFO lpToolInfo) const | |
| 2269 { | |
| 2270 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2271 ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); | |
| 2272 } | |
| 2273 | |
| 2274 void GetText(LPTSTR lpstrText, HWND hWnd, UINT_PTR nIDTool = 0) const | |
| 2275 { | |
| 2276 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2277 ATLASSERT(hWnd != NULL); | |
| 2278 CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); | |
| 2279 ::SendMessage(this->m_hWnd, TTM_GETTEXT, 0, ti); | |
| 2280 } | |
| 2281 | |
| 2282 BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const | |
| 2283 { | |
| 2284 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2285 return (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo); | |
| 2286 } | |
| 2287 | |
| 2288 BOOL GetToolInfo(HWND hWnd, UINT_PTR nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const | |
| 2289 { | |
| 2290 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2291 ATLASSERT(hWnd != NULL); | |
| 2292 ATLASSERT(puFlags != NULL); | |
| 2293 ATLASSERT(lpRect != NULL); | |
| 2294 CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); | |
| 2295 BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TTM_GETTOOLINFO, 0, ti); | |
| 2296 if(bRet != FALSE) | |
| 2297 { | |
| 2298 *puFlags = ti.uFlags; | |
| 2299 *lpRect = ti.rect; | |
| 2300 } | |
| 2301 return bRet; | |
| 2302 } | |
| 2303 | |
| 2304 void SetToolInfo(LPTOOLINFO lpToolInfo) | |
| 2305 { | |
| 2306 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2307 ::SendMessage(this->m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); | |
| 2308 } | |
| 2309 | |
| 2310 void SetToolRect(LPTOOLINFO lpToolInfo) | |
| 2311 { | |
| 2312 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2313 ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); | |
| 2314 } | |
| 2315 | |
| 2316 void SetToolRect(HWND hWnd, UINT_PTR nIDTool, LPCRECT lpRect) | |
| 2317 { | |
| 2318 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2319 ATLASSERT(hWnd != NULL); | |
| 2320 ATLASSERT(nIDTool != 0); | |
| 2321 | |
| 2322 CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL); | |
| 2323 ::SendMessage(this->m_hWnd, TTM_NEWTOOLRECT, 0, ti); | |
| 2324 } | |
| 2325 | |
| 2326 int GetToolCount() const | |
| 2327 { | |
| 2328 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2329 return (int)::SendMessage(this->m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); | |
| 2330 } | |
| 2331 | |
| 2332 int GetDelayTime(DWORD dwType) const | |
| 2333 { | |
| 2334 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2335 return (int)::SendMessage(this->m_hWnd, TTM_GETDELAYTIME, dwType, 0L); | |
| 2336 } | |
| 2337 | |
| 2338 void SetDelayTime(DWORD dwType, int nTime) | |
| 2339 { | |
| 2340 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2341 ::SendMessage(this->m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0)); | |
| 2342 } | |
| 2343 | |
| 2344 void GetMargin(LPRECT lpRect) const | |
| 2345 { | |
| 2346 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2347 ::SendMessage(this->m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); | |
| 2348 } | |
| 2349 | |
| 2350 void SetMargin(LPRECT lpRect) | |
| 2351 { | |
| 2352 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2353 ::SendMessage(this->m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); | |
| 2354 } | |
| 2355 | |
| 2356 int GetMaxTipWidth() const | |
| 2357 { | |
| 2358 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2359 return (int)::SendMessage(this->m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); | |
| 2360 } | |
| 2361 | |
| 2362 int SetMaxTipWidth(int nWidth) | |
| 2363 { | |
| 2364 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2365 return (int)::SendMessage(this->m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth); | |
| 2366 } | |
| 2367 | |
| 2368 COLORREF GetTipBkColor() const | |
| 2369 { | |
| 2370 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2371 return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L); | |
| 2372 } | |
| 2373 | |
| 2374 void SetTipBkColor(COLORREF clr) | |
| 2375 { | |
| 2376 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2377 ::SendMessage(this->m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); | |
| 2378 } | |
| 2379 | |
| 2380 COLORREF GetTipTextColor() const | |
| 2381 { | |
| 2382 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2383 return (COLORREF)::SendMessage(this->m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L); | |
| 2384 } | |
| 2385 | |
| 2386 void SetTipTextColor(COLORREF clr) | |
| 2387 { | |
| 2388 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2389 ::SendMessage(this->m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); | |
| 2390 } | |
| 2391 | |
| 2392 BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const | |
| 2393 { | |
| 2394 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2395 return (BOOL)::SendMessage(this->m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo); | |
| 2396 } | |
| 2397 | |
| 2398 SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const | |
| 2399 { | |
| 2400 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2401 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo); | |
| 2402 SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; | |
| 2403 return size; | |
| 2404 } | |
| 2405 | |
| 2406 BOOL SetTitle(UINT_PTR uIcon, LPCTSTR lpstrTitle) | |
| 2407 { | |
| 2408 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2409 return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle); | |
| 2410 } | |
| 2411 | |
| 2412 | |
| 2413 BOOL SetTitle(HICON hIcon, LPCTSTR lpstrTitle) | |
| 2414 { | |
| 2415 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2416 return (BOOL)::SendMessage(this->m_hWnd, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)lpstrTitle); | |
| 2417 } | |
| 2418 | |
| 2419 void GetTitle(PTTGETTITLE pTTGetTitle) const | |
| 2420 { | |
| 2421 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2422 ::SendMessage(this->m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); | |
| 2423 } | |
| 2424 | |
| 2425 void SetWindowTheme(LPCWSTR lpstrTheme) | |
| 2426 { | |
| 2427 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2428 ::SendMessage(this->m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); | |
| 2429 } | |
| 2430 | |
| 2431 // Operations | |
| 2432 void Activate(BOOL bActivate) | |
| 2433 { | |
| 2434 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2435 ::SendMessage(this->m_hWnd, TTM_ACTIVATE, bActivate, 0L); | |
| 2436 } | |
| 2437 | |
| 2438 BOOL AddTool(LPTOOLINFO lpToolInfo) | |
| 2439 { | |
| 2440 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2441 return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo); | |
| 2442 } | |
| 2443 | |
| 2444 BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT_PTR nIDTool = 0) | |
| 2445 { | |
| 2446 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2447 ATLASSERT(hWnd != NULL); | |
| 2448 // the toolrect and toolid must both be zero or both valid | |
| 2449 ATLASSERT(((lpRectTool != NULL) && (nIDTool != 0)) || ((lpRectTool == NULL) && (nIDTool == 0))); | |
| 2450 | |
| 2451 CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr); | |
| 2452 return (BOOL)::SendMessage(this->m_hWnd, TTM_ADDTOOL, 0, ti); | |
| 2453 } | |
| 2454 | |
| 2455 void DelTool(LPTOOLINFO lpToolInfo) | |
| 2456 { | |
| 2457 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2458 ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); | |
| 2459 } | |
| 2460 | |
| 2461 void DelTool(HWND hWnd, UINT_PTR nIDTool = 0) | |
| 2462 { | |
| 2463 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2464 ATLASSERT(hWnd != NULL); | |
| 2465 | |
| 2466 CToolInfo ti(0, hWnd, nIDTool, NULL, NULL); | |
| 2467 ::SendMessage(this->m_hWnd, TTM_DELTOOL, 0, ti); | |
| 2468 } | |
| 2469 | |
| 2470 BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const | |
| 2471 { | |
| 2472 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2473 return (BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo); | |
| 2474 } | |
| 2475 | |
| 2476 BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const | |
| 2477 { | |
| 2478 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2479 ATLASSERT(hWnd != NULL); | |
| 2480 ATLASSERT(lpToolInfo != NULL); | |
| 2481 | |
| 2482 TTHITTESTINFO hti = {}; | |
| 2483 hti.ti.cbSize = RunTimeHelper::SizeOf_TOOLINFO(); | |
| 2484 hti.hwnd = hWnd; | |
| 2485 hti.pt.x = pt.x; | |
| 2486 hti.pt.y = pt.y; | |
| 2487 if((BOOL)::SendMessage(this->m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE) | |
| 2488 { | |
| 2489 *lpToolInfo = hti.ti; | |
| 2490 return TRUE; | |
| 2491 } | |
| 2492 return FALSE; | |
| 2493 } | |
| 2494 | |
| 2495 void RelayEvent(LPMSG lpMsg) | |
| 2496 { | |
| 2497 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2498 ::SendMessage(this->m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); | |
| 2499 } | |
| 2500 | |
| 2501 void UpdateTipText(LPTOOLINFO lpToolInfo) | |
| 2502 { | |
| 2503 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2504 ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); | |
| 2505 } | |
| 2506 | |
| 2507 void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT_PTR nIDTool = 0) | |
| 2508 { | |
| 2509 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2510 ATLASSERT(hWnd != NULL); | |
| 2511 | |
| 2512 CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr); | |
| 2513 ::SendMessage(this->m_hWnd, TTM_UPDATETIPTEXT, 0, ti); | |
| 2514 } | |
| 2515 | |
| 2516 BOOL EnumTools(UINT_PTR nTool, LPTOOLINFO lpToolInfo) const | |
| 2517 { | |
| 2518 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2519 return (BOOL)::SendMessage(this->m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo); | |
| 2520 } | |
| 2521 | |
| 2522 void Pop() | |
| 2523 { | |
| 2524 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2525 ::SendMessage(this->m_hWnd, TTM_POP, 0, 0L); | |
| 2526 } | |
| 2527 | |
| 2528 void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate) | |
| 2529 { | |
| 2530 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2531 ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo); | |
| 2532 } | |
| 2533 | |
| 2534 void TrackActivate(HWND hWnd, UINT_PTR nIDTool, BOOL bActivate) | |
| 2535 { | |
| 2536 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2537 ATLASSERT(hWnd != NULL); | |
| 2538 | |
| 2539 CToolInfo ti(0, hWnd, nIDTool); | |
| 2540 ::SendMessage(this->m_hWnd, TTM_TRACKACTIVATE, bActivate, ti); | |
| 2541 } | |
| 2542 | |
| 2543 void TrackPosition(int xPos, int yPos) | |
| 2544 { | |
| 2545 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2546 ::SendMessage(this->m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos)); | |
| 2547 } | |
| 2548 | |
| 2549 void Update() | |
| 2550 { | |
| 2551 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2552 ::SendMessage(this->m_hWnd, TTM_UPDATE, 0, 0L); | |
| 2553 } | |
| 2554 | |
| 2555 BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/) | |
| 2556 { | |
| 2557 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2558 return (BOOL)::SendMessage(this->m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect); | |
| 2559 } | |
| 2560 | |
| 2561 void Popup() | |
| 2562 { | |
| 2563 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2564 ::SendMessage(this->m_hWnd, TTM_POPUP, 0, 0L); | |
| 2565 } | |
| 2566 }; | |
| 2567 | |
| 2568 typedef CToolTipCtrlT<ATL::CWindow> CToolTipCtrl; | |
| 2569 | |
| 2570 | |
| 2571 /////////////////////////////////////////////////////////////////////////////// | |
| 2572 // CHeaderCtrl | |
| 2573 | |
| 2574 template <class TBase> | |
| 2575 class CHeaderCtrlT : public TBase | |
| 2576 { | |
| 2577 public: | |
| 2578 // Constructors | |
| 2579 CHeaderCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 2580 { } | |
| 2581 | |
| 2582 CHeaderCtrlT< TBase >& operator =(HWND hWnd) | |
| 2583 { | |
| 2584 this->m_hWnd = hWnd; | |
| 2585 return *this; | |
| 2586 } | |
| 2587 | |
| 2588 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 2589 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 2590 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 2591 { | |
| 2592 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 2593 } | |
| 2594 | |
| 2595 // Attributes | |
| 2596 static LPCTSTR GetWndClassName() | |
| 2597 { | |
| 2598 return WC_HEADER; | |
| 2599 } | |
| 2600 | |
| 2601 int GetItemCount() const | |
| 2602 { | |
| 2603 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2604 return (int)::SendMessage(this->m_hWnd, HDM_GETITEMCOUNT, 0, 0L); | |
| 2605 } | |
| 2606 | |
| 2607 BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const | |
| 2608 { | |
| 2609 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2610 return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem); | |
| 2611 } | |
| 2612 | |
| 2613 BOOL SetItem(int nIndex, LPHDITEM pHeaderItem) | |
| 2614 { | |
| 2615 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2616 return (BOOL)::SendMessage(this->m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem); | |
| 2617 } | |
| 2618 | |
| 2619 CImageList GetImageList() const | |
| 2620 { | |
| 2621 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2622 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_GETIMAGELIST, 0, 0L)); | |
| 2623 } | |
| 2624 | |
| 2625 CImageList SetImageList(HIMAGELIST hImageList) | |
| 2626 { | |
| 2627 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2628 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList)); | |
| 2629 } | |
| 2630 | |
| 2631 BOOL GetOrderArray(int nSize, int* lpnArray) const | |
| 2632 { | |
| 2633 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2634 return (BOOL)::SendMessage(this->m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray); | |
| 2635 } | |
| 2636 | |
| 2637 BOOL SetOrderArray(int nSize, int* lpnArray) | |
| 2638 { | |
| 2639 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2640 return (BOOL)::SendMessage(this->m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray); | |
| 2641 } | |
| 2642 | |
| 2643 BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const | |
| 2644 { | |
| 2645 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2646 return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect); | |
| 2647 } | |
| 2648 | |
| 2649 int SetHotDivider(BOOL bPos, DWORD dwInputValue) | |
| 2650 { | |
| 2651 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2652 return (int)::SendMessage(this->m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue); | |
| 2653 } | |
| 2654 | |
| 2655 BOOL GetUnicodeFormat() const | |
| 2656 { | |
| 2657 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2658 return (BOOL)::SendMessage(this->m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); | |
| 2659 } | |
| 2660 | |
| 2661 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 2662 { | |
| 2663 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2664 return (BOOL)::SendMessage(this->m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 2665 } | |
| 2666 | |
| 2667 int GetBitmapMargin() const | |
| 2668 { | |
| 2669 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2670 return (int)::SendMessage(this->m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); | |
| 2671 } | |
| 2672 | |
| 2673 int SetBitmapMargin(int nWidth) | |
| 2674 { | |
| 2675 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2676 return (int)::SendMessage(this->m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L); | |
| 2677 } | |
| 2678 | |
| 2679 int SetFilterChangeTimeout(DWORD dwTimeOut) | |
| 2680 { | |
| 2681 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2682 return (int)::SendMessage(this->m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut); | |
| 2683 } | |
| 2684 | |
| 2685 #if (_WIN32_WINNT >= 0x0600) | |
| 2686 BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const | |
| 2687 { | |
| 2688 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2689 return (BOOL)::SendMessage(this->m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); | |
| 2690 } | |
| 2691 | |
| 2692 BOOL GetOverflowRect(LPRECT lpRect) const | |
| 2693 { | |
| 2694 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2695 return (BOOL)::SendMessage(this->m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect); | |
| 2696 } | |
| 2697 | |
| 2698 int GetFocusedItem() const | |
| 2699 { | |
| 2700 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2701 return (int)::SendMessage(this->m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); | |
| 2702 } | |
| 2703 | |
| 2704 BOOL SetFocusedItem(int nIndex) | |
| 2705 { | |
| 2706 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2707 return (BOOL)::SendMessage(this->m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex); | |
| 2708 } | |
| 2709 #endif // (_WIN32_WINNT >= 0x0600) | |
| 2710 | |
| 2711 // Operations | |
| 2712 int InsertItem(int nIndex, LPHDITEM phdi) | |
| 2713 { | |
| 2714 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2715 return (int)::SendMessage(this->m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi); | |
| 2716 } | |
| 2717 | |
| 2718 int AddItem(LPHDITEM phdi) | |
| 2719 { | |
| 2720 return InsertItem(GetItemCount(), phdi); | |
| 2721 } | |
| 2722 | |
| 2723 BOOL DeleteItem(int nIndex) | |
| 2724 { | |
| 2725 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2726 return (BOOL)::SendMessage(this->m_hWnd, HDM_DELETEITEM, nIndex, 0L); | |
| 2727 } | |
| 2728 | |
| 2729 BOOL Layout(HD_LAYOUT* pHeaderLayout) | |
| 2730 { | |
| 2731 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2732 return (BOOL)::SendMessage(this->m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout); | |
| 2733 } | |
| 2734 | |
| 2735 int HitTest(LPHDHITTESTINFO lpHitTestInfo) const | |
| 2736 { | |
| 2737 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2738 return (int)::SendMessage(this->m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo); | |
| 2739 } | |
| 2740 | |
| 2741 int OrderToIndex(int nOrder) | |
| 2742 { | |
| 2743 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2744 return (int)::SendMessage(this->m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); | |
| 2745 } | |
| 2746 | |
| 2747 CImageList CreateDragImage(int nIndex) | |
| 2748 { | |
| 2749 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2750 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L)); | |
| 2751 } | |
| 2752 | |
| 2753 int EditFilter(int nColumn, BOOL bDiscardChanges) | |
| 2754 { | |
| 2755 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2756 return (int)::SendMessage(this->m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0)); | |
| 2757 } | |
| 2758 | |
| 2759 int ClearFilter(int nColumn) | |
| 2760 { | |
| 2761 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2762 return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, nColumn, 0L); | |
| 2763 } | |
| 2764 | |
| 2765 int ClearAllFilters() | |
| 2766 { | |
| 2767 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2768 return (int)::SendMessage(this->m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L); | |
| 2769 } | |
| 2770 }; | |
| 2771 | |
| 2772 typedef CHeaderCtrlT<ATL::CWindow> CHeaderCtrl; | |
| 2773 | |
| 2774 | |
| 2775 /////////////////////////////////////////////////////////////////////////////// | |
| 2776 // CListViewCtrl | |
| 2777 | |
| 2778 template <class TBase> | |
| 2779 class CListViewCtrlT : public TBase | |
| 2780 { | |
| 2781 public: | |
| 2782 // Constructors | |
| 2783 CListViewCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 2784 { } | |
| 2785 | |
| 2786 CListViewCtrlT< TBase >& operator =(HWND hWnd) | |
| 2787 { | |
| 2788 this->m_hWnd = hWnd; | |
| 2789 return *this; | |
| 2790 } | |
| 2791 | |
| 2792 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 2793 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 2794 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 2795 { | |
| 2796 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 2797 } | |
| 2798 | |
| 2799 // Attributes | |
| 2800 static LPCTSTR GetWndClassName() | |
| 2801 { | |
| 2802 return WC_LISTVIEW; | |
| 2803 } | |
| 2804 | |
| 2805 COLORREF GetBkColor() const | |
| 2806 { | |
| 2807 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2808 return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETBKCOLOR, 0, 0L); | |
| 2809 } | |
| 2810 | |
| 2811 BOOL SetBkColor(COLORREF cr) | |
| 2812 { | |
| 2813 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2814 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKCOLOR, 0, cr); | |
| 2815 } | |
| 2816 | |
| 2817 CImageList GetImageList(int nImageListType) const | |
| 2818 { | |
| 2819 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2820 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); | |
| 2821 } | |
| 2822 | |
| 2823 CImageList SetImageList(HIMAGELIST hImageList, int nImageList) | |
| 2824 { | |
| 2825 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2826 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList)); | |
| 2827 } | |
| 2828 | |
| 2829 int GetItemCount() const | |
| 2830 { | |
| 2831 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2832 return (int)::SendMessage(this->m_hWnd, LVM_GETITEMCOUNT, 0, 0L); | |
| 2833 } | |
| 2834 | |
| 2835 BOOL SetItemCount(int nItems) | |
| 2836 { | |
| 2837 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2838 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, 0L); | |
| 2839 } | |
| 2840 | |
| 2841 BOOL GetItem(LPLVITEM pItem) const | |
| 2842 { | |
| 2843 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2844 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); | |
| 2845 } | |
| 2846 | |
| 2847 BOOL SetItem(const LVITEM* pItem) | |
| 2848 { | |
| 2849 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2850 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); | |
| 2851 } | |
| 2852 | |
| 2853 BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, | |
| 2854 int nImage, UINT nState, UINT nStateMask, LPARAM lParam) | |
| 2855 { | |
| 2856 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2857 LVITEM lvi = {}; | |
| 2858 lvi.mask = nMask; | |
| 2859 lvi.iItem = nItem; | |
| 2860 lvi.iSubItem = nSubItem; | |
| 2861 lvi.stateMask = nStateMask; | |
| 2862 lvi.state = nState; | |
| 2863 lvi.pszText = (LPTSTR) lpszItem; | |
| 2864 lvi.iImage = nImage; | |
| 2865 lvi.lParam = lParam; | |
| 2866 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi); | |
| 2867 } | |
| 2868 | |
| 2869 UINT GetItemState(int nItem, UINT nMask) const | |
| 2870 { | |
| 2871 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2872 return (UINT)::SendMessage(this->m_hWnd, LVM_GETITEMSTATE, nItem, nMask); | |
| 2873 } | |
| 2874 | |
| 2875 BOOL SetItemState(int nItem, UINT nState, UINT nStateMask) | |
| 2876 { | |
| 2877 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2878 LVITEM lvi = {}; | |
| 2879 lvi.state = nState; | |
| 2880 lvi.stateMask = nStateMask; | |
| 2881 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi); | |
| 2882 } | |
| 2883 | |
| 2884 BOOL SetItemState(int nItem, LPLVITEM pItem) | |
| 2885 { | |
| 2886 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2887 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); | |
| 2888 } | |
| 2889 | |
| 2890 BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const | |
| 2891 { | |
| 2892 USES_CONVERSION; | |
| 2893 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2894 ATLASSERT(bstrText == NULL); | |
| 2895 LVITEM lvi = {}; | |
| 2896 lvi.iSubItem = nSubItem; | |
| 2897 | |
| 2898 LPTSTR lpstrText = NULL; | |
| 2899 int nRes = 0; | |
| 2900 for(int nLen = 256; ; nLen *= 2) | |
| 2901 { | |
| 2902 ATLTRY(lpstrText = new TCHAR[nLen]); | |
| 2903 if(lpstrText == NULL) | |
| 2904 break; | |
| 2905 lpstrText[0] = NULL; | |
| 2906 lvi.cchTextMax = nLen; | |
| 2907 lvi.pszText = lpstrText; | |
| 2908 nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); | |
| 2909 if(nRes < nLen - 1) | |
| 2910 break; | |
| 2911 delete [] lpstrText; | |
| 2912 lpstrText = NULL; | |
| 2913 } | |
| 2914 | |
| 2915 if(lpstrText != NULL) | |
| 2916 { | |
| 2917 if(nRes != 0) | |
| 2918 bstrText = ::SysAllocString(T2OLE(lpstrText)); | |
| 2919 delete [] lpstrText; | |
| 2920 } | |
| 2921 | |
| 2922 return (bstrText != NULL) ? TRUE : FALSE; | |
| 2923 } | |
| 2924 | |
| 2925 #ifdef __ATLSTR_H__ | |
| 2926 int GetItemText(int nItem, int nSubItem, ATL::CString& strText) const | |
| 2927 { | |
| 2928 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2929 LVITEM lvi = {}; | |
| 2930 lvi.iSubItem = nSubItem; | |
| 2931 | |
| 2932 strText.Empty(); | |
| 2933 int nRes = 0; | |
| 2934 for(int nLen = 256; ; nLen *= 2) | |
| 2935 { | |
| 2936 lvi.cchTextMax = nLen; | |
| 2937 lvi.pszText = strText.GetBufferSetLength(nLen); | |
| 2938 if(lvi.pszText == NULL) | |
| 2939 { | |
| 2940 nRes = 0; | |
| 2941 break; | |
| 2942 } | |
| 2943 nRes = (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); | |
| 2944 if(nRes < nLen - 1) | |
| 2945 break; | |
| 2946 } | |
| 2947 strText.ReleaseBuffer(); | |
| 2948 return nRes; | |
| 2949 } | |
| 2950 #endif // __ATLSTR_H__ | |
| 2951 | |
| 2952 int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const | |
| 2953 { | |
| 2954 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2955 LVITEM lvi = {}; | |
| 2956 lvi.iSubItem = nSubItem; | |
| 2957 lvi.cchTextMax = nLen; | |
| 2958 lvi.pszText = lpszText; | |
| 2959 return (int)::SendMessage(this->m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi); | |
| 2960 } | |
| 2961 | |
| 2962 BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText) | |
| 2963 { | |
| 2964 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2965 return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0); | |
| 2966 } | |
| 2967 | |
| 2968 DWORD_PTR GetItemData(int nItem) const | |
| 2969 { | |
| 2970 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2971 LVITEM lvi = {}; | |
| 2972 lvi.iItem = nItem; | |
| 2973 lvi.mask = LVIF_PARAM; | |
| 2974 BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi); | |
| 2975 return (DWORD_PTR)(bRet ? lvi.lParam : NULL); | |
| 2976 } | |
| 2977 | |
| 2978 BOOL SetItemData(int nItem, DWORD_PTR dwData) | |
| 2979 { | |
| 2980 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2981 return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData); | |
| 2982 } | |
| 2983 | |
| 2984 UINT GetCallbackMask() const | |
| 2985 { | |
| 2986 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2987 return (UINT)::SendMessage(this->m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); | |
| 2988 } | |
| 2989 | |
| 2990 BOOL SetCallbackMask(UINT nMask) | |
| 2991 { | |
| 2992 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2993 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L); | |
| 2994 } | |
| 2995 | |
| 2996 BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const | |
| 2997 { | |
| 2998 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 2999 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); | |
| 3000 } | |
| 3001 | |
| 3002 BOOL SetItemPosition(int nItem, POINT pt) | |
| 3003 { | |
| 3004 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3005 ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); | |
| 3006 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); | |
| 3007 } | |
| 3008 | |
| 3009 BOOL SetItemPosition(int nItem, int x, int y) | |
| 3010 { | |
| 3011 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3012 ATLASSERT(((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON)); | |
| 3013 POINT pt = { x, y }; | |
| 3014 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); | |
| 3015 } | |
| 3016 | |
| 3017 int GetStringWidth(LPCTSTR lpsz) const | |
| 3018 { | |
| 3019 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3020 return (int)::SendMessage(this->m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); | |
| 3021 } | |
| 3022 | |
| 3023 CEdit GetEditControl() const | |
| 3024 { | |
| 3025 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3026 return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); | |
| 3027 } | |
| 3028 | |
| 3029 BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const | |
| 3030 { | |
| 3031 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3032 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); | |
| 3033 } | |
| 3034 | |
| 3035 BOOL SetColumn(int nCol, const LVCOLUMN* pColumn) | |
| 3036 { | |
| 3037 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3038 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); | |
| 3039 } | |
| 3040 | |
| 3041 int GetColumnWidth(int nCol) const | |
| 3042 { | |
| 3043 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3044 return (int)::SendMessage(this->m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); | |
| 3045 } | |
| 3046 | |
| 3047 BOOL SetColumnWidth(int nCol, int cx) | |
| 3048 { | |
| 3049 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3050 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); | |
| 3051 } | |
| 3052 | |
| 3053 BOOL GetViewRect(LPRECT lpRect) const | |
| 3054 { | |
| 3055 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3056 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); | |
| 3057 } | |
| 3058 | |
| 3059 COLORREF GetTextColor() const | |
| 3060 { | |
| 3061 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3062 return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); | |
| 3063 } | |
| 3064 | |
| 3065 BOOL SetTextColor(COLORREF cr) | |
| 3066 { | |
| 3067 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3068 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTCOLOR, 0, cr); | |
| 3069 } | |
| 3070 | |
| 3071 COLORREF GetTextBkColor() const | |
| 3072 { | |
| 3073 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3074 return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); | |
| 3075 } | |
| 3076 | |
| 3077 BOOL SetTextBkColor(COLORREF cr) | |
| 3078 { | |
| 3079 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3080 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); | |
| 3081 } | |
| 3082 | |
| 3083 int GetTopIndex() const | |
| 3084 { | |
| 3085 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3086 return (int)::SendMessage(this->m_hWnd, LVM_GETTOPINDEX, 0, 0L); | |
| 3087 } | |
| 3088 | |
| 3089 int GetCountPerPage() const | |
| 3090 { | |
| 3091 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3092 return (int)::SendMessage(this->m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); | |
| 3093 } | |
| 3094 | |
| 3095 BOOL GetOrigin(LPPOINT lpPoint) const | |
| 3096 { | |
| 3097 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3098 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); | |
| 3099 } | |
| 3100 | |
| 3101 UINT GetSelectedCount() const | |
| 3102 { | |
| 3103 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3104 return (UINT)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); | |
| 3105 } | |
| 3106 | |
| 3107 BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const | |
| 3108 { | |
| 3109 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3110 lpRect->left = nCode; | |
| 3111 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); | |
| 3112 } | |
| 3113 | |
| 3114 HCURSOR GetHotCursor() const | |
| 3115 { | |
| 3116 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3117 return (HCURSOR)::SendMessage(this->m_hWnd, LVM_GETHOTCURSOR, 0, 0L); | |
| 3118 } | |
| 3119 | |
| 3120 HCURSOR SetHotCursor(HCURSOR hHotCursor) | |
| 3121 { | |
| 3122 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3123 return (HCURSOR)::SendMessage(this->m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor); | |
| 3124 } | |
| 3125 | |
| 3126 int GetHotItem() const | |
| 3127 { | |
| 3128 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3129 return (int)::SendMessage(this->m_hWnd, LVM_GETHOTITEM, 0, 0L); | |
| 3130 } | |
| 3131 | |
| 3132 int SetHotItem(int nIndex) | |
| 3133 { | |
| 3134 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3135 return (int)::SendMessage(this->m_hWnd, LVM_SETHOTITEM, nIndex, 0L); | |
| 3136 } | |
| 3137 | |
| 3138 BOOL GetColumnOrderArray(int nCount, int* lpnArray) const | |
| 3139 { | |
| 3140 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3141 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); | |
| 3142 } | |
| 3143 | |
| 3144 BOOL SetColumnOrderArray(int nCount, int* lpnArray) | |
| 3145 { | |
| 3146 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3147 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray); | |
| 3148 } | |
| 3149 | |
| 3150 CHeaderCtrl GetHeader() const | |
| 3151 { | |
| 3152 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3153 return CHeaderCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETHEADER, 0, 0L)); | |
| 3154 } | |
| 3155 | |
| 3156 BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const | |
| 3157 { | |
| 3158 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3159 ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT); | |
| 3160 ATLASSERT(lpRect != NULL); | |
| 3161 lpRect->top = nSubItem; | |
| 3162 lpRect->left = nFlag; | |
| 3163 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect); | |
| 3164 } | |
| 3165 | |
| 3166 DWORD SetIconSpacing(int cx, int cy) | |
| 3167 { | |
| 3168 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3169 ATLASSERT((this->GetStyle() & LVS_TYPEMASK) == LVS_ICON); | |
| 3170 return (DWORD)::SendMessage(this->m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy)); | |
| 3171 } | |
| 3172 | |
| 3173 int GetISearchString(LPTSTR lpstr) const | |
| 3174 { | |
| 3175 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3176 return (int)::SendMessage(this->m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); | |
| 3177 } | |
| 3178 | |
| 3179 void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const | |
| 3180 { | |
| 3181 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3182 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L); | |
| 3183 sizeSpacing.cx = GET_X_LPARAM(dwRet); | |
| 3184 sizeSpacing.cy = GET_Y_LPARAM(dwRet); | |
| 3185 } | |
| 3186 | |
| 3187 // single-selection only | |
| 3188 int GetSelectedIndex() const | |
| 3189 { | |
| 3190 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3191 ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); | |
| 3192 return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); | |
| 3193 } | |
| 3194 | |
| 3195 BOOL GetSelectedItem(LPLVITEM pItem) const | |
| 3196 { | |
| 3197 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3198 ATLASSERT((this->GetStyle() & LVS_SINGLESEL) != 0); | |
| 3199 ATLASSERT(pItem != NULL); | |
| 3200 pItem->iItem = (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); | |
| 3201 if(pItem->iItem == -1) | |
| 3202 return FALSE; | |
| 3203 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); | |
| 3204 } | |
| 3205 | |
| 3206 // extended list view styles | |
| 3207 DWORD GetExtendedListViewStyle() const | |
| 3208 { | |
| 3209 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3210 return (DWORD)::SendMessage(this->m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L); | |
| 3211 } | |
| 3212 | |
| 3213 // dwExMask = 0 means all styles | |
| 3214 DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0) | |
| 3215 { | |
| 3216 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3217 return (DWORD)::SendMessage(this->m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle); | |
| 3218 } | |
| 3219 | |
| 3220 // checkboxes only | |
| 3221 BOOL GetCheckState(int nIndex) const | |
| 3222 { | |
| 3223 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3224 ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0); | |
| 3225 UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK); | |
| 3226 return (uRet >> 12) - 1; | |
| 3227 } | |
| 3228 | |
| 3229 BOOL SetCheckState(int nItem, BOOL bCheck) | |
| 3230 { | |
| 3231 int nCheck = bCheck ? 2 : 1; // one based index | |
| 3232 return SetItemState(nItem, INDEXTOSTATEIMAGEMASK(nCheck), LVIS_STATEIMAGEMASK); | |
| 3233 } | |
| 3234 | |
| 3235 // view type | |
| 3236 DWORD GetViewType() const | |
| 3237 { | |
| 3238 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3239 return (this->GetStyle() & LVS_TYPEMASK); | |
| 3240 } | |
| 3241 | |
| 3242 DWORD SetViewType(DWORD dwType) | |
| 3243 { | |
| 3244 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3245 ATLASSERT((dwType == LVS_ICON) || (dwType == LVS_SMALLICON) || (dwType == LVS_LIST) || (dwType == LVS_REPORT)); | |
| 3246 DWORD dwOldType = GetViewType(); | |
| 3247 if(dwType != dwOldType) | |
| 3248 this->ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); | |
| 3249 return dwOldType; | |
| 3250 } | |
| 3251 | |
| 3252 BOOL GetBkImage(LPLVBKIMAGE plvbki) const | |
| 3253 { | |
| 3254 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3255 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki); | |
| 3256 } | |
| 3257 | |
| 3258 BOOL SetBkImage(LPLVBKIMAGE plvbki) | |
| 3259 { | |
| 3260 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3261 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki); | |
| 3262 } | |
| 3263 | |
| 3264 int GetSelectionMark() const | |
| 3265 { | |
| 3266 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3267 return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); | |
| 3268 } | |
| 3269 | |
| 3270 int SetSelectionMark(int nIndex) | |
| 3271 { | |
| 3272 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3273 return (int)::SendMessage(this->m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex); | |
| 3274 } | |
| 3275 | |
| 3276 BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const | |
| 3277 { | |
| 3278 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3279 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect); | |
| 3280 } | |
| 3281 | |
| 3282 BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect) | |
| 3283 { | |
| 3284 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3285 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect); | |
| 3286 } | |
| 3287 | |
| 3288 DWORD GetHoverTime() const | |
| 3289 { | |
| 3290 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3291 ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); | |
| 3292 return (DWORD)::SendMessage(this->m_hWnd, LVM_GETHOVERTIME, 0, 0L); | |
| 3293 } | |
| 3294 | |
| 3295 DWORD SetHoverTime(DWORD dwHoverTime) | |
| 3296 { | |
| 3297 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3298 ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); | |
| 3299 return (DWORD)::SendMessage(this->m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime); | |
| 3300 } | |
| 3301 | |
| 3302 BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const | |
| 3303 { | |
| 3304 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3305 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas); | |
| 3306 } | |
| 3307 | |
| 3308 BOOL SetItemCountEx(int nItems, DWORD dwFlags) | |
| 3309 { | |
| 3310 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3311 ATLASSERT(((this->GetStyle() & LVS_OWNERDATA) != 0) && (((this->GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((this->GetStyle() & LVS_TYPEMASK) == LVS_LIST))); | |
| 3312 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags); | |
| 3313 } | |
| 3314 | |
| 3315 CToolTipCtrl GetToolTips() const | |
| 3316 { | |
| 3317 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3318 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_GETTOOLTIPS, 0, 0L)); | |
| 3319 } | |
| 3320 | |
| 3321 CToolTipCtrl SetToolTips(HWND hWndTT) | |
| 3322 { | |
| 3323 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3324 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); | |
| 3325 } | |
| 3326 | |
| 3327 BOOL GetUnicodeFormat() const | |
| 3328 { | |
| 3329 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3330 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); | |
| 3331 } | |
| 3332 | |
| 3333 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 3334 { | |
| 3335 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3336 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 3337 } | |
| 3338 | |
| 3339 int GetSelectedColumn() const | |
| 3340 { | |
| 3341 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3342 return (int)::SendMessage(this->m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); | |
| 3343 } | |
| 3344 | |
| 3345 void SetSelectedColumn(int nColumn) | |
| 3346 { | |
| 3347 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3348 ::SendMessage(this->m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); | |
| 3349 } | |
| 3350 | |
| 3351 DWORD GetView() const | |
| 3352 { | |
| 3353 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3354 return (DWORD)::SendMessage(this->m_hWnd, LVM_GETVIEW, 0, 0L); | |
| 3355 } | |
| 3356 | |
| 3357 int SetView(DWORD dwView) | |
| 3358 { | |
| 3359 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3360 return (int)::SendMessage(this->m_hWnd, LVM_SETVIEW, dwView, 0L); | |
| 3361 } | |
| 3362 | |
| 3363 BOOL IsGroupViewEnabled() const | |
| 3364 { | |
| 3365 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3366 return (BOOL)::SendMessage(this->m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L); | |
| 3367 } | |
| 3368 | |
| 3369 int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const | |
| 3370 { | |
| 3371 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3372 return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup); | |
| 3373 } | |
| 3374 | |
| 3375 int SetGroupInfo(int nGroupID, PLVGROUP pGroup) | |
| 3376 { | |
| 3377 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3378 return (int)::SendMessage(this->m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup); | |
| 3379 } | |
| 3380 | |
| 3381 void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const | |
| 3382 { | |
| 3383 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3384 ::SendMessage(this->m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); | |
| 3385 } | |
| 3386 | |
| 3387 void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) | |
| 3388 { | |
| 3389 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3390 ::SendMessage(this->m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics); | |
| 3391 } | |
| 3392 | |
| 3393 void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const | |
| 3394 { | |
| 3395 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3396 ::SendMessage(this->m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); | |
| 3397 } | |
| 3398 | |
| 3399 BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) | |
| 3400 { | |
| 3401 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3402 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo); | |
| 3403 } | |
| 3404 | |
| 3405 void GetTileInfo(PLVTILEINFO pTileInfo) const | |
| 3406 { | |
| 3407 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3408 ::SendMessage(this->m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); | |
| 3409 } | |
| 3410 | |
| 3411 BOOL SetTileInfo(PLVTILEINFO pTileInfo) | |
| 3412 { | |
| 3413 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3414 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo); | |
| 3415 } | |
| 3416 | |
| 3417 BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const | |
| 3418 { | |
| 3419 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3420 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark); | |
| 3421 } | |
| 3422 | |
| 3423 BOOL SetInsertMark(LPLVINSERTMARK pInsertMark) | |
| 3424 { | |
| 3425 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3426 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark); | |
| 3427 } | |
| 3428 | |
| 3429 int GetInsertMarkRect(LPRECT lpRect) const | |
| 3430 { | |
| 3431 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3432 return (int)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect); | |
| 3433 } | |
| 3434 | |
| 3435 COLORREF GetInsertMarkColor() const | |
| 3436 { | |
| 3437 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3438 return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L); | |
| 3439 } | |
| 3440 | |
| 3441 COLORREF SetInsertMarkColor(COLORREF clr) | |
| 3442 { | |
| 3443 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3444 return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr); | |
| 3445 } | |
| 3446 | |
| 3447 COLORREF GetOutlineColor() const | |
| 3448 { | |
| 3449 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3450 return (COLORREF)::SendMessage(this->m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L); | |
| 3451 } | |
| 3452 | |
| 3453 COLORREF SetOutlineColor(COLORREF clr) | |
| 3454 { | |
| 3455 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3456 return (COLORREF)::SendMessage(this->m_hWnd, LVM_SETOUTLINECOLOR, 0, clr); | |
| 3457 } | |
| 3458 | |
| 3459 #if (_WIN32_WINNT >= 0x0600) | |
| 3460 int GetGroupCount() const | |
| 3461 { | |
| 3462 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3463 return (int)::SendMessage(this->m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); | |
| 3464 } | |
| 3465 | |
| 3466 BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const | |
| 3467 { | |
| 3468 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3469 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup); | |
| 3470 } | |
| 3471 | |
| 3472 BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const | |
| 3473 { | |
| 3474 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3475 ATLASSERT(lpRect != NULL); | |
| 3476 if(lpRect != NULL) | |
| 3477 lpRect->top = nType; | |
| 3478 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect); | |
| 3479 } | |
| 3480 | |
| 3481 UINT GetGroupState(int nGroupID, UINT uMask) const | |
| 3482 { | |
| 3483 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3484 return (UINT)::SendMessage(this->m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask); | |
| 3485 } | |
| 3486 | |
| 3487 int GetFocusedGroup() const | |
| 3488 { | |
| 3489 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3490 return (int)::SendMessage(this->m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); | |
| 3491 } | |
| 3492 | |
| 3493 BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const | |
| 3494 { | |
| 3495 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3496 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText); | |
| 3497 } | |
| 3498 | |
| 3499 BOOL GetFooterRect(LPRECT lpRect) const | |
| 3500 { | |
| 3501 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3502 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect); | |
| 3503 } | |
| 3504 | |
| 3505 BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const | |
| 3506 { | |
| 3507 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3508 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo); | |
| 3509 } | |
| 3510 | |
| 3511 BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const | |
| 3512 { | |
| 3513 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3514 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect); | |
| 3515 } | |
| 3516 | |
| 3517 BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const | |
| 3518 { | |
| 3519 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3520 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem); | |
| 3521 } | |
| 3522 | |
| 3523 BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType, LPRECT lpRect) const | |
| 3524 { | |
| 3525 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3526 ATLASSERT(pItemIndex != NULL); | |
| 3527 ATLASSERT(lpRect != NULL); | |
| 3528 if(lpRect != NULL) | |
| 3529 { | |
| 3530 lpRect->top = nSubItem; | |
| 3531 lpRect->left = nType; | |
| 3532 } | |
| 3533 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect); | |
| 3534 } | |
| 3535 | |
| 3536 BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask) | |
| 3537 { | |
| 3538 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3539 LVITEM lvi = {}; | |
| 3540 lvi.state = uState; | |
| 3541 lvi.stateMask = dwMask; | |
| 3542 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi); | |
| 3543 } | |
| 3544 | |
| 3545 BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const | |
| 3546 { | |
| 3547 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3548 return (BOOL)::SendMessage(this->m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0)); | |
| 3549 } | |
| 3550 #endif // (_WIN32_WINNT >= 0x0600) | |
| 3551 | |
| 3552 // Operations | |
| 3553 int InsertColumn(int nCol, const LVCOLUMN* pColumn) | |
| 3554 { | |
| 3555 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3556 return (int)::SendMessage(this->m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); | |
| 3557 } | |
| 3558 | |
| 3559 int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, | |
| 3560 int nWidth = -1, int nSubItem = -1, int iImage = -1, int iOrder = -1) | |
| 3561 { | |
| 3562 LVCOLUMN column = {}; | |
| 3563 column.mask = LVCF_TEXT | LVCF_FMT; | |
| 3564 column.pszText = (LPTSTR)lpszColumnHeading; | |
| 3565 column.fmt = nFormat; | |
| 3566 if (nWidth != -1) | |
| 3567 { | |
| 3568 column.mask |= LVCF_WIDTH; | |
| 3569 column.cx = nWidth; | |
| 3570 } | |
| 3571 if (nSubItem != -1) | |
| 3572 { | |
| 3573 column.mask |= LVCF_SUBITEM; | |
| 3574 column.iSubItem = nSubItem; | |
| 3575 } | |
| 3576 if (iImage != -1) | |
| 3577 { | |
| 3578 column.mask |= LVCF_IMAGE; | |
| 3579 column.iImage = iImage; | |
| 3580 } | |
| 3581 if (iOrder != -1) | |
| 3582 { | |
| 3583 column.mask |= LVCF_ORDER; | |
| 3584 column.iOrder = iOrder; | |
| 3585 } | |
| 3586 return InsertColumn(nCol, &column); | |
| 3587 } | |
| 3588 | |
| 3589 BOOL DeleteColumn(int nCol) | |
| 3590 { | |
| 3591 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3592 return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETECOLUMN, nCol, 0L); | |
| 3593 } | |
| 3594 | |
| 3595 int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam) | |
| 3596 { | |
| 3597 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3598 LVITEM item = {}; | |
| 3599 item.mask = nMask; | |
| 3600 item.iItem = nItem; | |
| 3601 item.iSubItem = 0; | |
| 3602 item.pszText = (LPTSTR)lpszItem; | |
| 3603 item.state = nState; | |
| 3604 item.stateMask = nStateMask; | |
| 3605 item.iImage = nImage; | |
| 3606 item.lParam = lParam; | |
| 3607 return InsertItem(&item); | |
| 3608 } | |
| 3609 | |
| 3610 int InsertItem(const LVITEM* pItem) | |
| 3611 { | |
| 3612 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3613 return (int)::SendMessage(this->m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); | |
| 3614 } | |
| 3615 | |
| 3616 int InsertItem(int nItem, LPCTSTR lpszItem) | |
| 3617 { | |
| 3618 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3619 return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); | |
| 3620 } | |
| 3621 | |
| 3622 int InsertItem(int nItem, LPCTSTR lpszItem, int nImage) | |
| 3623 { | |
| 3624 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3625 return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0); | |
| 3626 } | |
| 3627 | |
| 3628 int GetNextItem(int nItem, int nFlags) const | |
| 3629 { | |
| 3630 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3631 return (int)::SendMessage(this->m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); | |
| 3632 } | |
| 3633 | |
| 3634 BOOL DeleteItem(int nItem) | |
| 3635 { | |
| 3636 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3637 return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEITEM, nItem, 0L); | |
| 3638 } | |
| 3639 | |
| 3640 BOOL DeleteAllItems() | |
| 3641 { | |
| 3642 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3643 return (BOOL)::SendMessage(this->m_hWnd, LVM_DELETEALLITEMS, 0, 0L); | |
| 3644 } | |
| 3645 | |
| 3646 int FindItem(LVFINDINFO* pFindInfo, int nStart = -1) const | |
| 3647 { | |
| 3648 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3649 return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); | |
| 3650 } | |
| 3651 | |
| 3652 int FindItem(LPCTSTR lpstrFind, bool bPartial = true, bool bWrap = false, int nStart = -1) const | |
| 3653 { | |
| 3654 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3655 LVFINDINFO lvfi = {}; | |
| 3656 lvfi.flags = LVFI_STRING | (bWrap ? LVFI_WRAP : 0) | (bPartial ? LVFI_PARTIAL : 0); | |
| 3657 lvfi.psz = lpstrFind; | |
| 3658 return (int)::SendMessage(this->m_hWnd, LVM_FINDITEM, nStart, (LPARAM)&lvfi); | |
| 3659 } | |
| 3660 | |
| 3661 int HitTest(LVHITTESTINFO* pHitTestInfo) const | |
| 3662 { | |
| 3663 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3664 return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); | |
| 3665 } | |
| 3666 | |
| 3667 int HitTest(POINT pt, UINT* pFlags) const | |
| 3668 { | |
| 3669 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3670 LVHITTESTINFO hti = {}; | |
| 3671 hti.pt = pt; | |
| 3672 int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti); | |
| 3673 if (pFlags != NULL) | |
| 3674 *pFlags = hti.flags; | |
| 3675 return nRes; | |
| 3676 } | |
| 3677 | |
| 3678 BOOL EnsureVisible(int nItem, BOOL bPartialOK) | |
| 3679 { | |
| 3680 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3681 return (BOOL)::SendMessage(this->m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); | |
| 3682 } | |
| 3683 | |
| 3684 BOOL Scroll(int cx, int cy) | |
| 3685 { | |
| 3686 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3687 return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, cx, cy); | |
| 3688 } | |
| 3689 | |
| 3690 BOOL Scroll(SIZE size) | |
| 3691 { | |
| 3692 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3693 return (BOOL)::SendMessage(this->m_hWnd, LVM_SCROLL, size.cx, size.cy); | |
| 3694 } | |
| 3695 | |
| 3696 BOOL RedrawItems(int nFirst, int nLast) | |
| 3697 { | |
| 3698 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3699 return (BOOL)::SendMessage(this->m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); | |
| 3700 } | |
| 3701 | |
| 3702 BOOL Arrange(UINT nCode) | |
| 3703 { | |
| 3704 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3705 return (BOOL)::SendMessage(this->m_hWnd, LVM_ARRANGE, nCode, 0L); | |
| 3706 } | |
| 3707 | |
| 3708 CEdit EditLabel(int nItem) | |
| 3709 { | |
| 3710 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3711 return CEdit((HWND)::SendMessage(this->m_hWnd, LVM_EDITLABEL, nItem, 0L)); | |
| 3712 } | |
| 3713 | |
| 3714 BOOL Update(int nItem) | |
| 3715 { | |
| 3716 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3717 return (BOOL)::SendMessage(this->m_hWnd, LVM_UPDATE, nItem, 0L); | |
| 3718 } | |
| 3719 | |
| 3720 BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) | |
| 3721 { | |
| 3722 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3723 return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare); | |
| 3724 } | |
| 3725 | |
| 3726 CImageList RemoveImageList(int nImageList) | |
| 3727 { | |
| 3728 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3729 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); | |
| 3730 } | |
| 3731 | |
| 3732 CImageList CreateDragImage(int nItem, LPPOINT lpPoint) | |
| 3733 { | |
| 3734 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3735 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint)); | |
| 3736 } | |
| 3737 | |
| 3738 DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1) | |
| 3739 { | |
| 3740 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3741 return (DWORD)::SendMessage(this->m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy)); | |
| 3742 } | |
| 3743 | |
| 3744 int SubItemHitTest(LPLVHITTESTINFO lpInfo) const | |
| 3745 { | |
| 3746 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3747 return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo); | |
| 3748 } | |
| 3749 | |
| 3750 int AddColumn(LPCTSTR strColumn, int nItem, int nSubItem = -1, | |
| 3751 int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, | |
| 3752 int nFmt = LVCFMT_LEFT) | |
| 3753 { | |
| 3754 const int cxOffset = 15; | |
| 3755 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3756 LVCOLUMN lvc = {}; | |
| 3757 lvc.mask = nMask; | |
| 3758 lvc.fmt = nFmt; | |
| 3759 lvc.pszText = (LPTSTR)strColumn; | |
| 3760 lvc.cx = GetStringWidth(lvc.pszText) + cxOffset; | |
| 3761 if(nMask & LVCF_SUBITEM) | |
| 3762 lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem; | |
| 3763 return InsertColumn(nItem, &lvc); | |
| 3764 } | |
| 3765 | |
| 3766 int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -3) | |
| 3767 { | |
| 3768 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3769 LVITEM lvItem = {}; | |
| 3770 lvItem.mask = LVIF_TEXT; | |
| 3771 lvItem.iItem = nItem; | |
| 3772 lvItem.iSubItem = nSubItem; | |
| 3773 lvItem.pszText = (LPTSTR)strItem; | |
| 3774 if(nImageIndex != -3) | |
| 3775 { | |
| 3776 lvItem.mask |= LVIF_IMAGE; | |
| 3777 lvItem.iImage = nImageIndex; | |
| 3778 } | |
| 3779 if(nSubItem == 0) | |
| 3780 return InsertItem(&lvItem); | |
| 3781 return SetItem(&lvItem) ? nItem : -1; | |
| 3782 } | |
| 3783 | |
| 3784 BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) | |
| 3785 { | |
| 3786 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3787 return (BOOL)::SendMessage(this->m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare); | |
| 3788 } | |
| 3789 | |
| 3790 int InsertGroup(int nItem, PLVGROUP pGroup) | |
| 3791 { | |
| 3792 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3793 return (int)::SendMessage(this->m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup); | |
| 3794 } | |
| 3795 | |
| 3796 int AddGroup(PLVGROUP pGroup) | |
| 3797 { | |
| 3798 return InsertGroup(-1, pGroup); | |
| 3799 } | |
| 3800 | |
| 3801 int RemoveGroup(int nGroupID) | |
| 3802 { | |
| 3803 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3804 return (int)::SendMessage(this->m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L); | |
| 3805 } | |
| 3806 | |
| 3807 void MoveGroup(int nGroupID, int nItem) | |
| 3808 { | |
| 3809 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3810 ::SendMessage(this->m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); | |
| 3811 } | |
| 3812 | |
| 3813 void MoveItemToGroup(int nItem, int nGroupID) | |
| 3814 { | |
| 3815 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3816 ::SendMessage(this->m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); | |
| 3817 } | |
| 3818 | |
| 3819 int EnableGroupView(BOOL bEnable) | |
| 3820 { | |
| 3821 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3822 return (int)::SendMessage(this->m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L); | |
| 3823 } | |
| 3824 | |
| 3825 int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL) | |
| 3826 { | |
| 3827 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3828 return (int)::SendMessage(this->m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid); | |
| 3829 } | |
| 3830 | |
| 3831 void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted) | |
| 3832 { | |
| 3833 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3834 ::SendMessage(this->m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L); | |
| 3835 } | |
| 3836 | |
| 3837 void RemoveAllGroups() | |
| 3838 { | |
| 3839 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3840 ::SendMessage(this->m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); | |
| 3841 } | |
| 3842 | |
| 3843 BOOL HasGroup(int nGroupID) | |
| 3844 { | |
| 3845 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3846 return (BOOL)::SendMessage(this->m_hWnd, LVM_HASGROUP, nGroupID, 0L); | |
| 3847 } | |
| 3848 | |
| 3849 BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) const | |
| 3850 { | |
| 3851 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3852 return (BOOL)::SendMessage(this->m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark); | |
| 3853 } | |
| 3854 | |
| 3855 BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip) | |
| 3856 { | |
| 3857 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3858 return (BOOL)::SendMessage(this->m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip); | |
| 3859 } | |
| 3860 | |
| 3861 void CancelEditLabel() | |
| 3862 { | |
| 3863 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3864 ::SendMessage(this->m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); | |
| 3865 } | |
| 3866 | |
| 3867 UINT MapIndexToID(int nIndex) const | |
| 3868 { | |
| 3869 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3870 return (UINT)::SendMessage(this->m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L); | |
| 3871 } | |
| 3872 | |
| 3873 int MapIDToIndex(UINT uID) const | |
| 3874 { | |
| 3875 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3876 return (int)::SendMessage(this->m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); | |
| 3877 } | |
| 3878 | |
| 3879 #if (_WIN32_WINNT >= 0x0600) | |
| 3880 int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const | |
| 3881 { | |
| 3882 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3883 return (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); | |
| 3884 } | |
| 3885 | |
| 3886 int HitTestEx(POINT pt, UINT* pFlags) const | |
| 3887 { | |
| 3888 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3889 LVHITTESTINFO hti = {}; | |
| 3890 hti.pt = pt; | |
| 3891 int nRes = (int)::SendMessage(this->m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti); | |
| 3892 if (pFlags != NULL) | |
| 3893 *pFlags = hti.flags; | |
| 3894 return nRes; | |
| 3895 } | |
| 3896 | |
| 3897 int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const | |
| 3898 { | |
| 3899 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3900 return (int)::SendMessage(this->m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo); | |
| 3901 } | |
| 3902 #endif // (_WIN32_WINNT >= 0x0600) | |
| 3903 | |
| 3904 // Note: selects only one item | |
| 3905 BOOL SelectItem(int nIndex) | |
| 3906 { | |
| 3907 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3908 | |
| 3909 // multi-selection only: de-select all items | |
| 3910 if((this->GetStyle() & LVS_SINGLESEL) == 0) | |
| 3911 SetItemState(-1, 0, LVIS_SELECTED); | |
| 3912 | |
| 3913 BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); | |
| 3914 if(bRet) | |
| 3915 { | |
| 3916 SetSelectionMark(nIndex); | |
| 3917 bRet = EnsureVisible(nIndex, FALSE); | |
| 3918 } | |
| 3919 | |
| 3920 return bRet; | |
| 3921 } | |
| 3922 | |
| 3923 // multi-selection only | |
| 3924 BOOL SelectAllItems(bool bSelect = true) | |
| 3925 { | |
| 3926 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3927 ATLASSERT((this->GetStyle() & LVS_SINGLESEL) == 0); | |
| 3928 | |
| 3929 return SetItemState(-1, bSelect ? LVIS_SELECTED : 0, LVIS_SELECTED); | |
| 3930 } | |
| 3931 }; | |
| 3932 | |
| 3933 typedef CListViewCtrlT<ATL::CWindow> CListViewCtrl; | |
| 3934 | |
| 3935 | |
| 3936 /////////////////////////////////////////////////////////////////////////////// | |
| 3937 // CTreeViewCtrl | |
| 3938 | |
| 3939 template <class TBase> | |
| 3940 class CTreeViewCtrlT : public TBase | |
| 3941 { | |
| 3942 public: | |
| 3943 // Constructors | |
| 3944 CTreeViewCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 3945 { } | |
| 3946 | |
| 3947 CTreeViewCtrlT< TBase >& operator =(HWND hWnd) | |
| 3948 { | |
| 3949 this->m_hWnd = hWnd; | |
| 3950 return *this; | |
| 3951 } | |
| 3952 | |
| 3953 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 3954 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 3955 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 3956 { | |
| 3957 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 3958 } | |
| 3959 | |
| 3960 // Attributes | |
| 3961 static LPCTSTR GetWndClassName() | |
| 3962 { | |
| 3963 return WC_TREEVIEW; | |
| 3964 } | |
| 3965 | |
| 3966 UINT GetCount() const | |
| 3967 { | |
| 3968 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3969 return (UINT)::SendMessage(this->m_hWnd, TVM_GETCOUNT, 0, 0L); | |
| 3970 } | |
| 3971 | |
| 3972 UINT GetIndent() const | |
| 3973 { | |
| 3974 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3975 return (UINT)::SendMessage(this->m_hWnd, TVM_GETINDENT, 0, 0L); | |
| 3976 } | |
| 3977 | |
| 3978 void SetIndent(UINT nIndent) | |
| 3979 { | |
| 3980 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3981 ::SendMessage(this->m_hWnd, TVM_SETINDENT, nIndent, 0L); | |
| 3982 } | |
| 3983 | |
| 3984 CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const | |
| 3985 { | |
| 3986 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3987 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L)); | |
| 3988 } | |
| 3989 | |
| 3990 CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSIL_NORMAL) | |
| 3991 { | |
| 3992 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3993 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList)); | |
| 3994 } | |
| 3995 | |
| 3996 BOOL GetItem(LPTVITEM pItem) const | |
| 3997 { | |
| 3998 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 3999 return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); | |
| 4000 } | |
| 4001 | |
| 4002 BOOL SetItem(LPTVITEM pItem) | |
| 4003 { | |
| 4004 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4005 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); | |
| 4006 } | |
| 4007 | |
| 4008 BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage, | |
| 4009 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) | |
| 4010 { | |
| 4011 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4012 TVITEM item = {}; | |
| 4013 item.hItem = hItem; | |
| 4014 item.mask = nMask; | |
| 4015 item.pszText = (LPTSTR) lpszItem; | |
| 4016 item.iImage = nImage; | |
| 4017 item.iSelectedImage = nSelectedImage; | |
| 4018 item.state = nState; | |
| 4019 item.stateMask = nStateMask; | |
| 4020 item.lParam = lParam; | |
| 4021 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)&item); | |
| 4022 } | |
| 4023 | |
| 4024 BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const | |
| 4025 { | |
| 4026 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4027 ATLASSERT(lpstrText != NULL); | |
| 4028 | |
| 4029 TVITEM item = {}; | |
| 4030 item.hItem = hItem; | |
| 4031 item.mask = TVIF_TEXT; | |
| 4032 item.pszText = lpstrText; | |
| 4033 item.cchTextMax = nLen; | |
| 4034 | |
| 4035 return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); | |
| 4036 } | |
| 4037 | |
| 4038 BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const | |
| 4039 { | |
| 4040 USES_CONVERSION; | |
| 4041 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4042 ATLASSERT(bstrText == NULL); | |
| 4043 TVITEM item = {}; | |
| 4044 item.hItem = hItem; | |
| 4045 item.mask = TVIF_TEXT; | |
| 4046 | |
| 4047 LPTSTR lpstrText = NULL; | |
| 4048 BOOL bRet = FALSE; | |
| 4049 for(int nLen = 256; ; nLen *= 2) | |
| 4050 { | |
| 4051 ATLTRY(lpstrText = new TCHAR[nLen]); | |
| 4052 if(lpstrText == NULL) | |
| 4053 break; | |
| 4054 lpstrText[0] = NULL; | |
| 4055 item.pszText = lpstrText; | |
| 4056 item.cchTextMax = nLen; | |
| 4057 bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); | |
| 4058 if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) | |
| 4059 break; | |
| 4060 delete [] lpstrText; | |
| 4061 lpstrText = NULL; | |
| 4062 } | |
| 4063 | |
| 4064 if(lpstrText != NULL) | |
| 4065 { | |
| 4066 if(bRet) | |
| 4067 bstrText = ::SysAllocString(T2OLE(lpstrText)); | |
| 4068 delete [] lpstrText; | |
| 4069 } | |
| 4070 | |
| 4071 return (bstrText != NULL) ? TRUE : FALSE; | |
| 4072 } | |
| 4073 | |
| 4074 #ifdef __ATLSTR_H__ | |
| 4075 BOOL GetItemText(HTREEITEM hItem, ATL::CString& strText) const | |
| 4076 { | |
| 4077 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4078 TVITEM item = {}; | |
| 4079 item.hItem = hItem; | |
| 4080 item.mask = TVIF_TEXT; | |
| 4081 | |
| 4082 strText.Empty(); | |
| 4083 BOOL bRet = FALSE; | |
| 4084 for(int nLen = 256; ; nLen *= 2) | |
| 4085 { | |
| 4086 item.pszText = strText.GetBufferSetLength(nLen); | |
| 4087 if(item.pszText == NULL) | |
| 4088 { | |
| 4089 bRet = FALSE; | |
| 4090 break; | |
| 4091 } | |
| 4092 item.cchTextMax = nLen; | |
| 4093 bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); | |
| 4094 if(!bRet || (lstrlen(item.pszText) < (nLen - 1))) | |
| 4095 break; | |
| 4096 } | |
| 4097 strText.ReleaseBuffer(); | |
| 4098 return bRet; | |
| 4099 } | |
| 4100 #endif // __ATLSTR_H__ | |
| 4101 | |
| 4102 BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem) | |
| 4103 { | |
| 4104 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4105 return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL); | |
| 4106 } | |
| 4107 | |
| 4108 BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const | |
| 4109 { | |
| 4110 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4111 TVITEM item = {}; | |
| 4112 item.hItem = hItem; | |
| 4113 item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; | |
| 4114 BOOL bRes = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); | |
| 4115 if (bRes) | |
| 4116 { | |
| 4117 nImage = item.iImage; | |
| 4118 nSelectedImage = item.iSelectedImage; | |
| 4119 } | |
| 4120 return bRes; | |
| 4121 } | |
| 4122 | |
| 4123 BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage) | |
| 4124 { | |
| 4125 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4126 return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImage, nSelectedImage, 0, 0, NULL); | |
| 4127 } | |
| 4128 | |
| 4129 UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const | |
| 4130 { | |
| 4131 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4132 return (((UINT)::SendMessage(this->m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask); | |
| 4133 } | |
| 4134 | |
| 4135 BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask) | |
| 4136 { | |
| 4137 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4138 return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask, NULL); | |
| 4139 } | |
| 4140 | |
| 4141 DWORD_PTR GetItemData(HTREEITEM hItem) const | |
| 4142 { | |
| 4143 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4144 TVITEM item = {}; | |
| 4145 item.hItem = hItem; | |
| 4146 item.mask = TVIF_PARAM; | |
| 4147 BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); | |
| 4148 return (DWORD_PTR)(bRet ? item.lParam : NULL); | |
| 4149 } | |
| 4150 | |
| 4151 BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData) | |
| 4152 { | |
| 4153 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4154 return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwData); | |
| 4155 } | |
| 4156 | |
| 4157 CEdit GetEditControl() const | |
| 4158 { | |
| 4159 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4160 return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_GETEDITCONTROL, 0, 0L)); | |
| 4161 } | |
| 4162 | |
| 4163 UINT GetVisibleCount() const | |
| 4164 { | |
| 4165 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4166 return (UINT)::SendMessage(this->m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); | |
| 4167 } | |
| 4168 | |
| 4169 BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const | |
| 4170 { | |
| 4171 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4172 *(HTREEITEM*)lpRect = hItem; | |
| 4173 return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect); | |
| 4174 } | |
| 4175 | |
| 4176 BOOL ItemHasChildren(HTREEITEM hItem) const | |
| 4177 { | |
| 4178 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4179 TVITEM item = {}; | |
| 4180 item.hItem = hItem; | |
| 4181 item.mask = TVIF_CHILDREN; | |
| 4182 ::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); | |
| 4183 return item.cChildren; | |
| 4184 } | |
| 4185 | |
| 4186 CToolTipCtrl GetToolTips() const | |
| 4187 { | |
| 4188 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4189 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_GETTOOLTIPS, 0, 0L)); | |
| 4190 } | |
| 4191 | |
| 4192 CToolTipCtrl SetToolTips(HWND hWndTT) | |
| 4193 { | |
| 4194 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4195 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L)); | |
| 4196 } | |
| 4197 | |
| 4198 int GetISearchString(LPTSTR lpstr) const | |
| 4199 { | |
| 4200 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4201 return (int)::SendMessage(this->m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr); | |
| 4202 } | |
| 4203 | |
| 4204 // checkboxes only | |
| 4205 BOOL GetCheckState(HTREEITEM hItem) const | |
| 4206 { | |
| 4207 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4208 ATLASSERT((this->GetStyle() & TVS_CHECKBOXES) != 0); | |
| 4209 UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); | |
| 4210 return (uRet >> 12) - 1; | |
| 4211 } | |
| 4212 | |
| 4213 BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck) | |
| 4214 { | |
| 4215 int nCheck = bCheck ? 2 : 1; // one based index | |
| 4216 return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK); | |
| 4217 } | |
| 4218 | |
| 4219 COLORREF GetBkColor() const | |
| 4220 { | |
| 4221 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4222 return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETBKCOLOR, 0, 0L); | |
| 4223 } | |
| 4224 | |
| 4225 COLORREF SetBkColor(COLORREF clr) | |
| 4226 { | |
| 4227 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4228 return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr); | |
| 4229 } | |
| 4230 | |
| 4231 COLORREF GetInsertMarkColor() const | |
| 4232 { | |
| 4233 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4234 return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L); | |
| 4235 } | |
| 4236 | |
| 4237 COLORREF SetInsertMarkColor(COLORREF clr) | |
| 4238 { | |
| 4239 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4240 return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr); | |
| 4241 } | |
| 4242 | |
| 4243 int GetItemHeight() const | |
| 4244 { | |
| 4245 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4246 return (int)::SendMessage(this->m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); | |
| 4247 } | |
| 4248 | |
| 4249 int SetItemHeight(int cyHeight) | |
| 4250 { | |
| 4251 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4252 return (int)::SendMessage(this->m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L); | |
| 4253 } | |
| 4254 | |
| 4255 int GetScrollTime() const | |
| 4256 { | |
| 4257 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4258 return (int)::SendMessage(this->m_hWnd, TVM_GETSCROLLTIME, 0, 0L); | |
| 4259 } | |
| 4260 | |
| 4261 int SetScrollTime(int nScrollTime) | |
| 4262 { | |
| 4263 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4264 return (int)::SendMessage(this->m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L); | |
| 4265 } | |
| 4266 | |
| 4267 COLORREF GetTextColor() const | |
| 4268 { | |
| 4269 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4270 return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); | |
| 4271 } | |
| 4272 | |
| 4273 COLORREF SetTextColor(COLORREF clr) | |
| 4274 { | |
| 4275 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4276 return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr); | |
| 4277 } | |
| 4278 | |
| 4279 BOOL GetUnicodeFormat() const | |
| 4280 { | |
| 4281 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4282 return (BOOL)::SendMessage(this->m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); | |
| 4283 } | |
| 4284 | |
| 4285 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 4286 { | |
| 4287 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4288 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 4289 } | |
| 4290 | |
| 4291 COLORREF GetLineColor() const | |
| 4292 { | |
| 4293 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4294 return (COLORREF)::SendMessage(this->m_hWnd, TVM_GETLINECOLOR, 0, 0L); | |
| 4295 } | |
| 4296 | |
| 4297 COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/) | |
| 4298 { | |
| 4299 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4300 return (COLORREF)::SendMessage(this->m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew); | |
| 4301 } | |
| 4302 | |
| 4303 BOOL GetItem(LPTVITEMEX pItem) const | |
| 4304 { | |
| 4305 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4306 return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem); | |
| 4307 } | |
| 4308 | |
| 4309 BOOL SetItem(LPTVITEMEX pItem) | |
| 4310 { | |
| 4311 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4312 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem); | |
| 4313 } | |
| 4314 | |
| 4315 DWORD GetExtendedStyle() const | |
| 4316 { | |
| 4317 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4318 return (DWORD)::SendMessage(this->m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L); | |
| 4319 } | |
| 4320 | |
| 4321 DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) | |
| 4322 { | |
| 4323 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4324 return (DWORD)::SendMessage(this->m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle); | |
| 4325 } | |
| 4326 | |
| 4327 #if (_WIN32_WINNT >= 0x0600) | |
| 4328 BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime) | |
| 4329 { | |
| 4330 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4331 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime); | |
| 4332 } | |
| 4333 | |
| 4334 DWORD GetSelectedCount() const | |
| 4335 { | |
| 4336 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4337 return (DWORD)::SendMessage(this->m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L); | |
| 4338 } | |
| 4339 | |
| 4340 BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect) const | |
| 4341 { | |
| 4342 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4343 TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID }; | |
| 4344 return (BOOL)::SendMessage(this->m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri); | |
| 4345 } | |
| 4346 #endif // (_WIN32_WINNT >= 0x0600) | |
| 4347 | |
| 4348 // Operations | |
| 4349 HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct) | |
| 4350 { | |
| 4351 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4352 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); | |
| 4353 } | |
| 4354 | |
| 4355 HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage, | |
| 4356 int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) | |
| 4357 { | |
| 4358 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4359 return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); | |
| 4360 } | |
| 4361 | |
| 4362 HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) | |
| 4363 { | |
| 4364 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4365 return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); | |
| 4366 } | |
| 4367 | |
| 4368 HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, | |
| 4369 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, | |
| 4370 HTREEITEM hParent, HTREEITEM hInsertAfter) | |
| 4371 { | |
| 4372 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4373 TVINSERTSTRUCT tvis = {}; | |
| 4374 tvis.hParent = hParent; | |
| 4375 tvis.hInsertAfter = hInsertAfter; | |
| 4376 tvis.item.mask = nMask; | |
| 4377 tvis.item.pszText = (LPTSTR) lpszItem; | |
| 4378 tvis.item.iImage = nImage; | |
| 4379 tvis.item.iSelectedImage = nSelectedImage; | |
| 4380 tvis.item.state = nState; | |
| 4381 tvis.item.stateMask = nStateMask; | |
| 4382 tvis.item.lParam = lParam; | |
| 4383 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); | |
| 4384 } | |
| 4385 | |
| 4386 BOOL DeleteItem(HTREEITEM hItem) | |
| 4387 { | |
| 4388 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4389 return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem); | |
| 4390 } | |
| 4391 | |
| 4392 BOOL DeleteAllItems() | |
| 4393 { | |
| 4394 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4395 return (BOOL)::SendMessage(this->m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); | |
| 4396 } | |
| 4397 | |
| 4398 BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND) | |
| 4399 { | |
| 4400 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4401 return (BOOL)::SendMessage(this->m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem); | |
| 4402 } | |
| 4403 | |
| 4404 HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const | |
| 4405 { | |
| 4406 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4407 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); | |
| 4408 } | |
| 4409 | |
| 4410 HTREEITEM GetChildItem(HTREEITEM hItem) const | |
| 4411 { | |
| 4412 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4413 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); | |
| 4414 } | |
| 4415 | |
| 4416 HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const | |
| 4417 { | |
| 4418 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4419 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); | |
| 4420 } | |
| 4421 | |
| 4422 HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const | |
| 4423 { | |
| 4424 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4425 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); | |
| 4426 } | |
| 4427 | |
| 4428 HTREEITEM GetParentItem(HTREEITEM hItem) const | |
| 4429 { | |
| 4430 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4431 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); | |
| 4432 } | |
| 4433 | |
| 4434 HTREEITEM GetFirstVisibleItem() const | |
| 4435 { | |
| 4436 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4437 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); | |
| 4438 } | |
| 4439 | |
| 4440 HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const | |
| 4441 { | |
| 4442 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4443 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); | |
| 4444 } | |
| 4445 | |
| 4446 HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const | |
| 4447 { | |
| 4448 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4449 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); | |
| 4450 } | |
| 4451 | |
| 4452 HTREEITEM GetSelectedItem() const | |
| 4453 { | |
| 4454 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4455 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); | |
| 4456 } | |
| 4457 | |
| 4458 HTREEITEM GetDropHilightItem() const | |
| 4459 { | |
| 4460 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4461 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); | |
| 4462 } | |
| 4463 | |
| 4464 HTREEITEM GetRootItem() const | |
| 4465 { | |
| 4466 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4467 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); | |
| 4468 } | |
| 4469 | |
| 4470 HTREEITEM GetLastVisibleItem() const | |
| 4471 { | |
| 4472 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4473 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); | |
| 4474 } | |
| 4475 | |
| 4476 HTREEITEM GetNextSelectedItem() const | |
| 4477 { | |
| 4478 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4479 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); | |
| 4480 } | |
| 4481 | |
| 4482 BOOL Select(HTREEITEM hItem, UINT nCode) | |
| 4483 { | |
| 4484 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4485 return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem); | |
| 4486 } | |
| 4487 | |
| 4488 BOOL SelectItem(HTREEITEM hItem) | |
| 4489 { | |
| 4490 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4491 return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem); | |
| 4492 } | |
| 4493 | |
| 4494 BOOL SelectDropTarget(HTREEITEM hItem) | |
| 4495 { | |
| 4496 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4497 return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem); | |
| 4498 } | |
| 4499 | |
| 4500 BOOL SelectSetFirstVisible(HTREEITEM hItem) | |
| 4501 { | |
| 4502 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4503 return (BOOL)::SendMessage(this->m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem); | |
| 4504 } | |
| 4505 | |
| 4506 CEdit EditLabel(HTREEITEM hItem) | |
| 4507 { | |
| 4508 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4509 return CEdit((HWND)::SendMessage(this->m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem)); | |
| 4510 } | |
| 4511 | |
| 4512 BOOL EndEditLabelNow(BOOL bCancel) | |
| 4513 { | |
| 4514 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4515 return (BOOL)::SendMessage(this->m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L); | |
| 4516 } | |
| 4517 | |
| 4518 HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const | |
| 4519 { | |
| 4520 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4521 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); | |
| 4522 } | |
| 4523 | |
| 4524 HTREEITEM HitTest(POINT pt, UINT* pFlags) const | |
| 4525 { | |
| 4526 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4527 TVHITTESTINFO hti = {}; | |
| 4528 hti.pt = pt; | |
| 4529 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); | |
| 4530 if (pFlags != NULL) | |
| 4531 *pFlags = hti.flags; | |
| 4532 return hTreeItem; | |
| 4533 } | |
| 4534 | |
| 4535 BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE) | |
| 4536 { | |
| 4537 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4538 return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem); | |
| 4539 } | |
| 4540 | |
| 4541 BOOL EnsureVisible(HTREEITEM hItem) | |
| 4542 { | |
| 4543 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4544 return (BOOL)::SendMessage(this->m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem); | |
| 4545 } | |
| 4546 | |
| 4547 BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE) | |
| 4548 { | |
| 4549 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4550 return (BOOL)::SendMessage(this->m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort); | |
| 4551 } | |
| 4552 | |
| 4553 CImageList RemoveImageList(int nImageList) | |
| 4554 { | |
| 4555 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4556 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL)); | |
| 4557 } | |
| 4558 | |
| 4559 CImageList CreateDragImage(HTREEITEM hItem) | |
| 4560 { | |
| 4561 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4562 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem)); | |
| 4563 } | |
| 4564 | |
| 4565 BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter) | |
| 4566 { | |
| 4567 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4568 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem); | |
| 4569 } | |
| 4570 | |
| 4571 BOOL RemoveInsertMark() | |
| 4572 { | |
| 4573 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4574 return (BOOL)::SendMessage(this->m_hWnd, TVM_SETINSERTMARK, 0, 0L); | |
| 4575 } | |
| 4576 | |
| 4577 HTREEITEM MapAccIDToHTREEITEM(UINT uID) const | |
| 4578 { | |
| 4579 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4580 return (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); | |
| 4581 } | |
| 4582 | |
| 4583 UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const | |
| 4584 { | |
| 4585 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4586 return (UINT)::SendMessage(this->m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L); | |
| 4587 } | |
| 4588 | |
| 4589 #if (_WIN32_WINNT >= 0x0600) | |
| 4590 void ShowInfoTip(HTREEITEM hItem) | |
| 4591 { | |
| 4592 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4593 ::SendMessage(this->m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); | |
| 4594 } | |
| 4595 #endif // (_WIN32_WINNT >= 0x0600) | |
| 4596 }; | |
| 4597 | |
| 4598 typedef CTreeViewCtrlT<ATL::CWindow> CTreeViewCtrl; | |
| 4599 | |
| 4600 | |
| 4601 /////////////////////////////////////////////////////////////////////////////// | |
| 4602 // CTreeViewCtrlEx | |
| 4603 | |
| 4604 // forward declaration | |
| 4605 template <class TBase> class CTreeViewCtrlExT; | |
| 4606 | |
| 4607 // Note: TBase here is for CTreeViewCtrlExT, and not for CTreeItemT itself | |
| 4608 template <class TBase> | |
| 4609 class CTreeItemT | |
| 4610 { | |
| 4611 public: | |
| 4612 HTREEITEM m_hTreeItem; | |
| 4613 CTreeViewCtrlExT<TBase>* m_pTreeView; | |
| 4614 | |
| 4615 // Construction | |
| 4616 CTreeItemT(HTREEITEM hTreeItem = NULL, CTreeViewCtrlExT<TBase>* pTreeView = NULL) : m_hTreeItem(hTreeItem), m_pTreeView(pTreeView) | |
| 4617 { } | |
| 4618 | |
| 4619 CTreeItemT(const CTreeItemT<TBase>& posSrc) | |
| 4620 { | |
| 4621 *this = posSrc; | |
| 4622 } | |
| 4623 | |
| 4624 operator HTREEITEM() { return m_hTreeItem; } | |
| 4625 | |
| 4626 CTreeItemT<TBase>& operator =(const CTreeItemT<TBase>& itemSrc) | |
| 4627 { | |
| 4628 m_hTreeItem = itemSrc.m_hTreeItem; | |
| 4629 m_pTreeView = itemSrc.m_pTreeView; | |
| 4630 return *this; | |
| 4631 } | |
| 4632 | |
| 4633 // Attributes | |
| 4634 CTreeViewCtrlExT<TBase>* GetTreeView() const { return m_pTreeView; } | |
| 4635 | |
| 4636 BOOL operator !() const { return m_hTreeItem == NULL; } | |
| 4637 | |
| 4638 BOOL IsNull() const { return m_hTreeItem == NULL; } | |
| 4639 | |
| 4640 BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const; | |
| 4641 BOOL GetText(LPTSTR lpstrText, int nLen) const; | |
| 4642 BOOL GetText(BSTR& bstrText) const; | |
| 4643 #ifdef __ATLSTR_H__ | |
| 4644 BOOL GetText(ATL::CString& strText) const; | |
| 4645 #endif // __ATLSTR_H__ | |
| 4646 BOOL SetText(LPCTSTR lpszItem); | |
| 4647 BOOL GetImage(int& nImage, int& nSelectedImage) const; | |
| 4648 BOOL SetImage(int nImage, int nSelectedImage); | |
| 4649 UINT GetState(UINT nStateMask) const; | |
| 4650 BOOL SetState(UINT nState, UINT nStateMask); | |
| 4651 DWORD_PTR GetData() const; | |
| 4652 BOOL SetData(DWORD_PTR dwData); | |
| 4653 BOOL SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam); | |
| 4654 | |
| 4655 // Operations | |
| 4656 CTreeItemT<TBase> InsertAfter(LPCTSTR lpstrItem, HTREEITEM hItemAfter, int nImageIndex) | |
| 4657 { | |
| 4658 return _Insert(lpstrItem, nImageIndex, hItemAfter); | |
| 4659 } | |
| 4660 | |
| 4661 CTreeItemT<TBase> AddHead(LPCTSTR lpstrItem, int nImageIndex) | |
| 4662 { | |
| 4663 return _Insert(lpstrItem, nImageIndex, TVI_FIRST); | |
| 4664 } | |
| 4665 | |
| 4666 CTreeItemT<TBase> AddTail(LPCTSTR lpstrItem, int nImageIndex) | |
| 4667 { | |
| 4668 return _Insert(lpstrItem, nImageIndex, TVI_LAST); | |
| 4669 } | |
| 4670 | |
| 4671 CTreeItemT<TBase> GetChild() const; | |
| 4672 CTreeItemT<TBase> GetNext(UINT nCode) const; | |
| 4673 CTreeItemT<TBase> GetNextSibling() const; | |
| 4674 CTreeItemT<TBase> GetPrevSibling() const; | |
| 4675 CTreeItemT<TBase> GetParent() const; | |
| 4676 CTreeItemT<TBase> GetFirstVisible() const; | |
| 4677 CTreeItemT<TBase> GetNextVisible() const; | |
| 4678 CTreeItemT<TBase> GetPrevVisible() const; | |
| 4679 CTreeItemT<TBase> GetSelected() const; | |
| 4680 CTreeItemT<TBase> GetDropHilight() const; | |
| 4681 CTreeItemT<TBase> GetRoot() const; | |
| 4682 CTreeItemT<TBase> GetLastVisible() const; | |
| 4683 CTreeItemT<TBase> GetNextSelected() const; | |
| 4684 BOOL HasChildren() const; | |
| 4685 BOOL Delete(); | |
| 4686 BOOL Expand(UINT nCode = TVE_EXPAND); | |
| 4687 BOOL Select(UINT nCode); | |
| 4688 BOOL Select(); | |
| 4689 BOOL SelectDropTarget(); | |
| 4690 BOOL SelectSetFirstVisible(); | |
| 4691 HWND EditLabel(); | |
| 4692 HIMAGELIST CreateDragImage(); | |
| 4693 BOOL SortChildren(BOOL bRecurse = FALSE); | |
| 4694 BOOL EnsureVisible(); | |
| 4695 CTreeItemT<TBase> _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter); | |
| 4696 int GetImageIndex() const; | |
| 4697 BOOL SetInsertMark(BOOL bAfter); | |
| 4698 UINT MapHTREEITEMToAccID() const; | |
| 4699 #if (_WIN32_WINNT >= 0x0600) | |
| 4700 void ShowInfoTip(); | |
| 4701 BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const; | |
| 4702 #endif // (_WIN32_WINNT >= 0x0600) | |
| 4703 }; | |
| 4704 | |
| 4705 typedef CTreeItemT<ATL::CWindow> CTreeItem; | |
| 4706 | |
| 4707 | |
| 4708 template <class TBase> | |
| 4709 class CTreeViewCtrlExT : public CTreeViewCtrlT< TBase > | |
| 4710 { | |
| 4711 public: | |
| 4712 // Constructors | |
| 4713 CTreeViewCtrlExT(HWND hWnd = NULL) : CTreeViewCtrlT< TBase >(hWnd) | |
| 4714 { } | |
| 4715 | |
| 4716 CTreeViewCtrlExT< TBase >& operator =(HWND hWnd) | |
| 4717 { | |
| 4718 this->m_hWnd = hWnd; | |
| 4719 return *this; | |
| 4720 } | |
| 4721 | |
| 4722 // Operations (overides that return CTreeItem) | |
| 4723 CTreeItemT<TBase> InsertItem(LPTVINSERTSTRUCT lpInsertStruct) | |
| 4724 { | |
| 4725 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4726 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct); | |
| 4727 return CTreeItemT<TBase>(hTreeItem, this); | |
| 4728 } | |
| 4729 | |
| 4730 CTreeItemT<TBase> InsertItem(LPCTSTR lpszItem, int nImage, | |
| 4731 int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) | |
| 4732 { | |
| 4733 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4734 return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); | |
| 4735 } | |
| 4736 | |
| 4737 CTreeItemT<TBase> InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter) | |
| 4738 { | |
| 4739 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4740 return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter); | |
| 4741 } | |
| 4742 | |
| 4743 CTreeItemT<TBase> GetNextItem(HTREEITEM hItem, UINT nCode) const | |
| 4744 { | |
| 4745 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4746 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem); | |
| 4747 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4748 } | |
| 4749 | |
| 4750 CTreeItemT<TBase> GetChildItem(HTREEITEM hItem) const | |
| 4751 { | |
| 4752 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4753 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); | |
| 4754 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4755 } | |
| 4756 | |
| 4757 CTreeItemT<TBase> GetNextSiblingItem(HTREEITEM hItem) const | |
| 4758 { | |
| 4759 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4760 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); | |
| 4761 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4762 } | |
| 4763 | |
| 4764 CTreeItemT<TBase> GetPrevSiblingItem(HTREEITEM hItem) const | |
| 4765 { | |
| 4766 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4767 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem); | |
| 4768 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4769 } | |
| 4770 | |
| 4771 CTreeItemT<TBase> GetParentItem(HTREEITEM hItem) const | |
| 4772 { | |
| 4773 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4774 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem); | |
| 4775 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4776 } | |
| 4777 | |
| 4778 CTreeItemT<TBase> GetFirstVisibleItem() const | |
| 4779 { | |
| 4780 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4781 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L); | |
| 4782 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4783 } | |
| 4784 | |
| 4785 CTreeItemT<TBase> GetNextVisibleItem(HTREEITEM hItem) const | |
| 4786 { | |
| 4787 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4788 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); | |
| 4789 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4790 } | |
| 4791 | |
| 4792 CTreeItemT<TBase> GetPrevVisibleItem(HTREEITEM hItem) const | |
| 4793 { | |
| 4794 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4795 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); | |
| 4796 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4797 } | |
| 4798 | |
| 4799 CTreeItemT<TBase> GetSelectedItem() const | |
| 4800 { | |
| 4801 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4802 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L); | |
| 4803 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4804 } | |
| 4805 | |
| 4806 CTreeItemT<TBase> GetDropHilightItem() const | |
| 4807 { | |
| 4808 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4809 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L); | |
| 4810 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4811 } | |
| 4812 | |
| 4813 CTreeItemT<TBase> GetRootItem() const | |
| 4814 { | |
| 4815 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4816 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L); | |
| 4817 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4818 } | |
| 4819 | |
| 4820 CTreeItemT<TBase> GetLastVisibleItem() const | |
| 4821 { | |
| 4822 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4823 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L); | |
| 4824 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4825 } | |
| 4826 | |
| 4827 CTreeItemT<TBase> GetNextSelectedItem() const | |
| 4828 { | |
| 4829 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4830 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L); | |
| 4831 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4832 } | |
| 4833 | |
| 4834 CTreeItemT<TBase> HitTest(TVHITTESTINFO* pHitTestInfo) const | |
| 4835 { | |
| 4836 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4837 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo); | |
| 4838 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4839 } | |
| 4840 | |
| 4841 CTreeItemT<TBase> InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, | |
| 4842 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, | |
| 4843 HTREEITEM hParent, HTREEITEM hInsertAfter) | |
| 4844 { | |
| 4845 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4846 TVINSERTSTRUCT tvis = {}; | |
| 4847 tvis.hParent = hParent; | |
| 4848 tvis.hInsertAfter = hInsertAfter; | |
| 4849 tvis.item.mask = nMask; | |
| 4850 tvis.item.pszText = (LPTSTR) lpszItem; | |
| 4851 tvis.item.iImage = nImage; | |
| 4852 tvis.item.iSelectedImage = nSelectedImage; | |
| 4853 tvis.item.state = nState; | |
| 4854 tvis.item.stateMask = nStateMask; | |
| 4855 tvis.item.lParam = lParam; | |
| 4856 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis); | |
| 4857 return CTreeItemT<TBase>(hTreeItem, this); | |
| 4858 } | |
| 4859 | |
| 4860 CTreeItemT<TBase> HitTest(POINT pt, UINT* pFlags) const | |
| 4861 { | |
| 4862 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4863 TVHITTESTINFO hti = {}; | |
| 4864 hti.pt = pt; | |
| 4865 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti); | |
| 4866 if (pFlags != NULL) | |
| 4867 *pFlags = hti.flags; | |
| 4868 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4869 } | |
| 4870 | |
| 4871 CTreeItemT<TBase> MapAccIDToHTREEITEM(UINT uID) const | |
| 4872 { | |
| 4873 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 4874 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(this->m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L); | |
| 4875 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this); | |
| 4876 } | |
| 4877 }; | |
| 4878 | |
| 4879 typedef CTreeViewCtrlExT<ATL::CWindow> CTreeViewCtrlEx; | |
| 4880 | |
| 4881 | |
| 4882 // CTreeItem inline methods | |
| 4883 template <class TBase> | |
| 4884 inline BOOL CTreeItemT<TBase>::GetRect(LPRECT lpRect, BOOL bTextOnly) const | |
| 4885 { | |
| 4886 ATLASSERT(m_pTreeView != NULL); | |
| 4887 return m_pTreeView->GetItemRect(m_hTreeItem,lpRect,bTextOnly); | |
| 4888 } | |
| 4889 | |
| 4890 template <class TBase> | |
| 4891 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNext(UINT nCode) const | |
| 4892 { | |
| 4893 ATLASSERT(m_pTreeView != NULL); | |
| 4894 return m_pTreeView->GetNextItem(m_hTreeItem,nCode); | |
| 4895 } | |
| 4896 | |
| 4897 template <class TBase> | |
| 4898 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetChild() const | |
| 4899 { | |
| 4900 ATLASSERT(m_pTreeView != NULL); | |
| 4901 return m_pTreeView->GetChildItem(m_hTreeItem); | |
| 4902 } | |
| 4903 | |
| 4904 template <class TBase> | |
| 4905 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextSibling() const | |
| 4906 { | |
| 4907 ATLASSERT(m_pTreeView != NULL); | |
| 4908 return m_pTreeView->GetNextSiblingItem(m_hTreeItem); | |
| 4909 } | |
| 4910 | |
| 4911 template <class TBase> | |
| 4912 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetPrevSibling() const | |
| 4913 { | |
| 4914 ATLASSERT(m_pTreeView != NULL); | |
| 4915 return m_pTreeView->GetPrevSiblingItem(m_hTreeItem); | |
| 4916 } | |
| 4917 | |
| 4918 template <class TBase> | |
| 4919 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetParent() const | |
| 4920 { | |
| 4921 ATLASSERT(m_pTreeView != NULL); | |
| 4922 return m_pTreeView->GetParentItem(m_hTreeItem); | |
| 4923 } | |
| 4924 | |
| 4925 template <class TBase> | |
| 4926 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetFirstVisible() const | |
| 4927 { | |
| 4928 ATLASSERT(m_pTreeView != NULL); | |
| 4929 return m_pTreeView->GetFirstVisibleItem(); | |
| 4930 } | |
| 4931 | |
| 4932 template <class TBase> | |
| 4933 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextVisible() const | |
| 4934 { | |
| 4935 ATLASSERT(m_pTreeView != NULL); | |
| 4936 return m_pTreeView->GetNextVisibleItem(m_hTreeItem); | |
| 4937 } | |
| 4938 | |
| 4939 template <class TBase> | |
| 4940 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetPrevVisible() const | |
| 4941 { | |
| 4942 ATLASSERT(m_pTreeView != NULL); | |
| 4943 return m_pTreeView->GetPrevVisibleItem(m_hTreeItem); | |
| 4944 } | |
| 4945 | |
| 4946 template <class TBase> | |
| 4947 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetSelected() const | |
| 4948 { | |
| 4949 ATLASSERT(m_pTreeView != NULL); | |
| 4950 return m_pTreeView->GetSelectedItem(); | |
| 4951 } | |
| 4952 | |
| 4953 template <class TBase> | |
| 4954 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetDropHilight() const | |
| 4955 { | |
| 4956 ATLASSERT(m_pTreeView != NULL); | |
| 4957 return m_pTreeView->GetDropHilightItem(); | |
| 4958 } | |
| 4959 | |
| 4960 template <class TBase> | |
| 4961 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetRoot() const | |
| 4962 { | |
| 4963 ATLASSERT(m_pTreeView != NULL); | |
| 4964 return m_pTreeView->GetRootItem(); | |
| 4965 } | |
| 4966 | |
| 4967 template <class TBase> | |
| 4968 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetLastVisible() const | |
| 4969 { | |
| 4970 ATLASSERT(m_pTreeView != NULL); | |
| 4971 return m_pTreeView->GetLastVisibleItem(); | |
| 4972 } | |
| 4973 | |
| 4974 template <class TBase> | |
| 4975 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextSelected() const | |
| 4976 { | |
| 4977 ATLASSERT(m_pTreeView != NULL); | |
| 4978 return m_pTreeView->GetNextSelectedItem(); | |
| 4979 } | |
| 4980 | |
| 4981 template <class TBase> | |
| 4982 inline BOOL CTreeItemT<TBase>::GetText(LPTSTR lpstrText, int nLen) const | |
| 4983 { | |
| 4984 ATLASSERT(m_pTreeView != NULL); | |
| 4985 return m_pTreeView->GetItemText(m_hTreeItem, lpstrText, nLen); | |
| 4986 } | |
| 4987 | |
| 4988 #ifdef _OLEAUTO_H_ | |
| 4989 template <class TBase> | |
| 4990 inline BOOL CTreeItemT<TBase>::GetText(BSTR& bstrText) const | |
| 4991 { | |
| 4992 ATLASSERT(m_pTreeView != NULL); | |
| 4993 return m_pTreeView->GetItemText(m_hTreeItem, bstrText); | |
| 4994 } | |
| 4995 #endif // _OLEAUTO_H_ | |
| 4996 | |
| 4997 #ifdef __ATLSTR_H__ | |
| 4998 template <class TBase> | |
| 4999 inline BOOL CTreeItemT<TBase>::GetText(ATL::CString& strText) const | |
| 5000 { | |
| 5001 ATLASSERT(m_pTreeView != NULL); | |
| 5002 return m_pTreeView->GetItemText(m_hTreeItem, strText); | |
| 5003 } | |
| 5004 #endif // __ATLSTR_H__ | |
| 5005 | |
| 5006 template <class TBase> | |
| 5007 inline BOOL CTreeItemT<TBase>::GetImage(int& nImage, int& nSelectedImage) const | |
| 5008 { | |
| 5009 ATLASSERT(m_pTreeView != NULL); | |
| 5010 return m_pTreeView->GetItemImage(m_hTreeItem,nImage,nSelectedImage); | |
| 5011 } | |
| 5012 | |
| 5013 template <class TBase> | |
| 5014 inline UINT CTreeItemT<TBase>::GetState(UINT nStateMask) const | |
| 5015 { | |
| 5016 ATLASSERT(m_pTreeView != NULL); | |
| 5017 return m_pTreeView->GetItemState(m_hTreeItem,nStateMask); | |
| 5018 } | |
| 5019 | |
| 5020 template <class TBase> | |
| 5021 inline DWORD_PTR CTreeItemT<TBase>::GetData() const | |
| 5022 { | |
| 5023 ATLASSERT(m_pTreeView != NULL); | |
| 5024 return m_pTreeView->GetItemData(m_hTreeItem); | |
| 5025 } | |
| 5026 | |
| 5027 template <class TBase> | |
| 5028 inline BOOL CTreeItemT<TBase>::SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, | |
| 5029 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) | |
| 5030 { | |
| 5031 ATLASSERT(m_pTreeView != NULL); | |
| 5032 return m_pTreeView->SetItem(m_hTreeItem, nMask, lpszItem, nImage, nSelectedImage, nState, nStateMask, lParam); | |
| 5033 } | |
| 5034 | |
| 5035 template <class TBase> | |
| 5036 inline BOOL CTreeItemT<TBase>::SetText(LPCTSTR lpszItem) | |
| 5037 { | |
| 5038 ATLASSERT(m_pTreeView != NULL); | |
| 5039 return m_pTreeView->SetItemText(m_hTreeItem,lpszItem); | |
| 5040 } | |
| 5041 | |
| 5042 template <class TBase> | |
| 5043 inline BOOL CTreeItemT<TBase>::SetImage(int nImage, int nSelectedImage) | |
| 5044 { | |
| 5045 ATLASSERT(m_pTreeView != NULL); | |
| 5046 return m_pTreeView->SetItemImage(m_hTreeItem,nImage,nSelectedImage); | |
| 5047 } | |
| 5048 | |
| 5049 template <class TBase> | |
| 5050 inline BOOL CTreeItemT<TBase>::SetState(UINT nState, UINT nStateMask) | |
| 5051 { | |
| 5052 ATLASSERT(m_pTreeView != NULL); | |
| 5053 return m_pTreeView->SetItemState(m_hTreeItem,nState,nStateMask); | |
| 5054 } | |
| 5055 | |
| 5056 template <class TBase> | |
| 5057 inline BOOL CTreeItemT<TBase>::SetData(DWORD_PTR dwData) | |
| 5058 { | |
| 5059 ATLASSERT(m_pTreeView != NULL); | |
| 5060 return m_pTreeView->SetItemData(m_hTreeItem,dwData); | |
| 5061 } | |
| 5062 | |
| 5063 template <class TBase> | |
| 5064 inline BOOL CTreeItemT<TBase>::HasChildren() const | |
| 5065 { | |
| 5066 ATLASSERT(m_pTreeView != NULL); | |
| 5067 return m_pTreeView->ItemHasChildren(m_hTreeItem); | |
| 5068 } | |
| 5069 | |
| 5070 template <class TBase> | |
| 5071 inline BOOL CTreeItemT<TBase>::Delete() | |
| 5072 { | |
| 5073 ATLASSERT(m_pTreeView != NULL); | |
| 5074 return m_pTreeView->DeleteItem(m_hTreeItem); | |
| 5075 } | |
| 5076 | |
| 5077 template <class TBase> | |
| 5078 inline BOOL CTreeItemT<TBase>::Expand(UINT nCode /*= TVE_EXPAND*/) | |
| 5079 { | |
| 5080 ATLASSERT(m_pTreeView != NULL); | |
| 5081 return m_pTreeView->Expand(m_hTreeItem,nCode); | |
| 5082 } | |
| 5083 | |
| 5084 template <class TBase> | |
| 5085 inline BOOL CTreeItemT<TBase>::Select(UINT nCode) | |
| 5086 { | |
| 5087 ATLASSERT(m_pTreeView != NULL); | |
| 5088 return m_pTreeView->Select(m_hTreeItem,nCode); | |
| 5089 } | |
| 5090 | |
| 5091 template <class TBase> | |
| 5092 inline BOOL CTreeItemT<TBase>::Select() | |
| 5093 { | |
| 5094 ATLASSERT(m_pTreeView != NULL); | |
| 5095 return m_pTreeView->SelectItem(m_hTreeItem); | |
| 5096 } | |
| 5097 | |
| 5098 template <class TBase> | |
| 5099 inline BOOL CTreeItemT<TBase>::SelectDropTarget() | |
| 5100 { | |
| 5101 ATLASSERT(m_pTreeView != NULL); | |
| 5102 return m_pTreeView->SelectDropTarget(m_hTreeItem); | |
| 5103 } | |
| 5104 | |
| 5105 template <class TBase> | |
| 5106 inline BOOL CTreeItemT<TBase>::SelectSetFirstVisible() | |
| 5107 { | |
| 5108 ATLASSERT(m_pTreeView != NULL); | |
| 5109 return m_pTreeView->SelectSetFirstVisible(m_hTreeItem); | |
| 5110 } | |
| 5111 | |
| 5112 template <class TBase> | |
| 5113 inline HWND CTreeItemT<TBase>::EditLabel() | |
| 5114 { | |
| 5115 ATLASSERT(m_pTreeView != NULL); | |
| 5116 return m_pTreeView->EditLabel(m_hTreeItem); | |
| 5117 } | |
| 5118 | |
| 5119 template <class TBase> | |
| 5120 inline HIMAGELIST CTreeItemT<TBase>::CreateDragImage() | |
| 5121 { | |
| 5122 ATLASSERT(m_pTreeView != NULL); | |
| 5123 return m_pTreeView->CreateDragImage(m_hTreeItem); | |
| 5124 } | |
| 5125 | |
| 5126 template <class TBase> | |
| 5127 inline BOOL CTreeItemT<TBase>::SortChildren(BOOL bRecurse /*= FALSE*/) | |
| 5128 { | |
| 5129 ATLASSERT(m_pTreeView != NULL); | |
| 5130 return m_pTreeView->SortChildren(m_hTreeItem, bRecurse); | |
| 5131 } | |
| 5132 | |
| 5133 template <class TBase> | |
| 5134 inline BOOL CTreeItemT<TBase>::EnsureVisible() | |
| 5135 { | |
| 5136 ATLASSERT(m_pTreeView != NULL); | |
| 5137 return m_pTreeView->EnsureVisible(m_hTreeItem); | |
| 5138 } | |
| 5139 | |
| 5140 template <class TBase> | |
| 5141 inline CTreeItemT<TBase> CTreeItemT<TBase>::_Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter) | |
| 5142 { | |
| 5143 ATLASSERT(m_pTreeView != NULL); | |
| 5144 TVINSERTSTRUCT ins = {}; | |
| 5145 ins.hParent = m_hTreeItem; | |
| 5146 ins.hInsertAfter = hItemAfter; | |
| 5147 ins.item.mask = TVIF_TEXT; | |
| 5148 ins.item.pszText = (LPTSTR)lpstrItem; | |
| 5149 if(nImageIndex != -1) | |
| 5150 { | |
| 5151 ins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE; | |
| 5152 ins.item.iImage = nImageIndex; | |
| 5153 ins.item.iSelectedImage = nImageIndex; | |
| 5154 } | |
| 5155 return CTreeItemT<TBase>(m_pTreeView->InsertItem(&ins), m_pTreeView); | |
| 5156 } | |
| 5157 | |
| 5158 template <class TBase> | |
| 5159 inline int CTreeItemT<TBase>::GetImageIndex() const | |
| 5160 { | |
| 5161 ATLASSERT(m_pTreeView != NULL); | |
| 5162 TVITEM item = {}; | |
| 5163 item.mask = TVIF_HANDLE | TVIF_IMAGE; | |
| 5164 item.hItem = m_hTreeItem; | |
| 5165 m_pTreeView->GetItem(&item); | |
| 5166 return item.iImage; | |
| 5167 } | |
| 5168 | |
| 5169 template <class TBase> | |
| 5170 inline BOOL CTreeItemT<TBase>::SetInsertMark(BOOL bAfter) | |
| 5171 { | |
| 5172 ATLASSERT(m_pTreeView != NULL); | |
| 5173 return m_pTreeView->SetInsertMark(m_hTreeItem, bAfter); | |
| 5174 } | |
| 5175 | |
| 5176 template <class TBase> | |
| 5177 inline UINT CTreeItemT<TBase>::MapHTREEITEMToAccID() const | |
| 5178 { | |
| 5179 ATLASSERT(m_pTreeView != NULL); | |
| 5180 return m_pTreeView->MapHTREEITEMToAccID(m_hTreeItem); | |
| 5181 } | |
| 5182 | |
| 5183 #if (_WIN32_WINNT >= 0x0600) | |
| 5184 template <class TBase> | |
| 5185 inline void CTreeItemT<TBase>::ShowInfoTip() | |
| 5186 { | |
| 5187 ATLASSERT(m_pTreeView != NULL); | |
| 5188 m_pTreeView->ShowInfoTip(m_hTreeItem); | |
| 5189 } | |
| 5190 | |
| 5191 template <class TBase> | |
| 5192 inline BOOL CTreeItemT<TBase>::GetPartRect(TVITEMPART partID, LPRECT lpRect) const | |
| 5193 { | |
| 5194 ATLASSERT(m_pTreeView != NULL); | |
| 5195 return m_pTreeView->GetItemPartRect(m_hTreeItem, partID, lpRect); | |
| 5196 } | |
| 5197 #endif // (_WIN32_WINNT >= 0x0600) | |
| 5198 | |
| 5199 | |
| 5200 /////////////////////////////////////////////////////////////////////////////// | |
| 5201 // CToolBarCtrl | |
| 5202 | |
| 5203 template <class TBase> | |
| 5204 class CToolBarCtrlT : public TBase | |
| 5205 { | |
| 5206 public: | |
| 5207 // Construction | |
| 5208 CToolBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 5209 { } | |
| 5210 | |
| 5211 CToolBarCtrlT< TBase >& operator =(HWND hWnd) | |
| 5212 { | |
| 5213 this->m_hWnd = hWnd; | |
| 5214 return *this; | |
| 5215 } | |
| 5216 | |
| 5217 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 5218 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 5219 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 5220 { | |
| 5221 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 5222 } | |
| 5223 | |
| 5224 // Attributes | |
| 5225 static LPCTSTR GetWndClassName() | |
| 5226 { | |
| 5227 return TOOLBARCLASSNAME; | |
| 5228 } | |
| 5229 | |
| 5230 BOOL IsButtonEnabled(int nID) const | |
| 5231 { | |
| 5232 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5233 return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONENABLED, nID, 0L); | |
| 5234 } | |
| 5235 | |
| 5236 BOOL IsButtonChecked(int nID) const | |
| 5237 { | |
| 5238 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5239 return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); | |
| 5240 } | |
| 5241 | |
| 5242 BOOL IsButtonPressed(int nID) const | |
| 5243 { | |
| 5244 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5245 return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); | |
| 5246 } | |
| 5247 | |
| 5248 BOOL IsButtonHidden(int nID) const | |
| 5249 { | |
| 5250 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5251 return(BOOL) ::SendMessage(this->m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); | |
| 5252 } | |
| 5253 | |
| 5254 BOOL IsButtonIndeterminate(int nID) const | |
| 5255 { | |
| 5256 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5257 return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONINDETERMINATE, nID, 0L); | |
| 5258 } | |
| 5259 | |
| 5260 int GetState(int nID) const | |
| 5261 { | |
| 5262 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5263 return (int)::SendMessage(this->m_hWnd, TB_GETSTATE, nID, 0L); | |
| 5264 } | |
| 5265 | |
| 5266 BOOL SetState(int nID, UINT nState) | |
| 5267 { | |
| 5268 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5269 return (BOOL)::SendMessage(this->m_hWnd, TB_SETSTATE, nID, MAKELPARAM(nState, 0)); | |
| 5270 } | |
| 5271 | |
| 5272 BOOL GetButton(int nIndex, LPTBBUTTON lpButton) const | |
| 5273 { | |
| 5274 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5275 return (BOOL)::SendMessage(this->m_hWnd, TB_GETBUTTON, nIndex, (LPARAM)lpButton); | |
| 5276 } | |
| 5277 | |
| 5278 int GetButtonCount() const | |
| 5279 { | |
| 5280 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5281 return (int)::SendMessage(this->m_hWnd, TB_BUTTONCOUNT, 0, 0L); | |
| 5282 } | |
| 5283 | |
| 5284 BOOL GetItemRect(int nIndex, LPRECT lpRect) const | |
| 5285 { | |
| 5286 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5287 return (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMRECT, nIndex, (LPARAM)lpRect); | |
| 5288 } | |
| 5289 | |
| 5290 void SetButtonStructSize(int nSize = sizeof(TBBUTTON)) | |
| 5291 { | |
| 5292 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5293 ::SendMessage(this->m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); | |
| 5294 } | |
| 5295 | |
| 5296 BOOL SetButtonSize(SIZE size) | |
| 5297 { | |
| 5298 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5299 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(size.cx, size.cy)); | |
| 5300 } | |
| 5301 | |
| 5302 BOOL SetButtonSize(int cx, int cy) | |
| 5303 { | |
| 5304 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5305 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cy)); | |
| 5306 } | |
| 5307 | |
| 5308 BOOL SetBitmapSize(SIZE size) | |
| 5309 { | |
| 5310 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5311 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(size.cx, size.cy)); | |
| 5312 } | |
| 5313 | |
| 5314 BOOL SetBitmapSize(int cx, int cy) | |
| 5315 { | |
| 5316 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5317 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPARAM(cx, cy)); | |
| 5318 } | |
| 5319 | |
| 5320 CToolTipCtrl GetToolTips() const | |
| 5321 { | |
| 5322 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5323 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TB_GETTOOLTIPS, 0, 0L)); | |
| 5324 } | |
| 5325 | |
| 5326 void SetToolTips(HWND hWndToolTip) | |
| 5327 { | |
| 5328 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5329 ::SendMessage(this->m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); | |
| 5330 } | |
| 5331 | |
| 5332 void SetNotifyWnd(HWND hWnd) | |
| 5333 { | |
| 5334 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5335 ::SendMessage(this->m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); | |
| 5336 } | |
| 5337 | |
| 5338 int GetRows() const | |
| 5339 { | |
| 5340 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5341 return (int)::SendMessage(this->m_hWnd, TB_GETROWS, 0, 0L); | |
| 5342 } | |
| 5343 | |
| 5344 void SetRows(int nRows, BOOL bLarger, LPRECT lpRect) | |
| 5345 { | |
| 5346 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5347 ::SendMessage(this->m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (LPARAM)lpRect); | |
| 5348 } | |
| 5349 | |
| 5350 BOOL SetCmdID(int nIndex, UINT nID) | |
| 5351 { | |
| 5352 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5353 return (BOOL)::SendMessage(this->m_hWnd, TB_SETCMDID, nIndex, nID); | |
| 5354 } | |
| 5355 | |
| 5356 DWORD GetBitmapFlags() const | |
| 5357 { | |
| 5358 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5359 return (DWORD)::SendMessage(this->m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); | |
| 5360 } | |
| 5361 | |
| 5362 int GetBitmap(int nID) const | |
| 5363 { | |
| 5364 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5365 return (int)::SendMessage(this->m_hWnd, TB_GETBITMAP, nID, 0L); | |
| 5366 } | |
| 5367 | |
| 5368 int GetButtonText(int nID, LPTSTR lpstrText) const | |
| 5369 { | |
| 5370 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5371 return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM)lpstrText); | |
| 5372 } | |
| 5373 | |
| 5374 // nIndex - IE5 or higher only | |
| 5375 CImageList GetImageList(int nIndex = 0) const | |
| 5376 { | |
| 5377 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5378 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETIMAGELIST, nIndex, 0L)); | |
| 5379 } | |
| 5380 | |
| 5381 // nIndex - IE5 or higher only | |
| 5382 CImageList SetImageList(HIMAGELIST hImageList, int nIndex = 0) | |
| 5383 { | |
| 5384 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5385 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETIMAGELIST, nIndex, (LPARAM)hImageList)); | |
| 5386 } | |
| 5387 | |
| 5388 // nIndex - IE5 or higher only | |
| 5389 CImageList GetDisabledImageList(int nIndex = 0) const | |
| 5390 { | |
| 5391 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5392 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETDISABLEDIMAGELIST, nIndex, 0L)); | |
| 5393 } | |
| 5394 | |
| 5395 // nIndex - IE5 or higher only | |
| 5396 CImageList SetDisabledImageList(HIMAGELIST hImageList, int nIndex = 0) | |
| 5397 { | |
| 5398 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5399 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETDISABLEDIMAGELIST, nIndex, (LPARAM)hImageList)); | |
| 5400 } | |
| 5401 | |
| 5402 // nIndex - IE5 or higher only | |
| 5403 CImageList GetHotImageList(int nIndex = 0) const | |
| 5404 { | |
| 5405 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5406 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETHOTIMAGELIST, nIndex, 0L)); | |
| 5407 } | |
| 5408 | |
| 5409 // nIndex - IE5 or higher only | |
| 5410 CImageList SetHotImageList(HIMAGELIST hImageList, int nIndex = 0) | |
| 5411 { | |
| 5412 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5413 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETHOTIMAGELIST, nIndex, (LPARAM)hImageList)); | |
| 5414 } | |
| 5415 | |
| 5416 DWORD GetStyle() const | |
| 5417 { | |
| 5418 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5419 return (DWORD)::SendMessage(this->m_hWnd, TB_GETSTYLE, 0, 0L); | |
| 5420 } | |
| 5421 | |
| 5422 void SetStyle(DWORD dwStyle) | |
| 5423 { | |
| 5424 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5425 ::SendMessage(this->m_hWnd, TB_SETSTYLE, 0, dwStyle); | |
| 5426 } | |
| 5427 | |
| 5428 DWORD GetButtonSize() const | |
| 5429 { | |
| 5430 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5431 return (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); | |
| 5432 } | |
| 5433 | |
| 5434 void GetButtonSize(SIZE& size) const | |
| 5435 { | |
| 5436 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5437 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETBUTTONSIZE, 0, 0L); | |
| 5438 size.cx = LOWORD(dwRet); | |
| 5439 size.cy = HIWORD(dwRet); | |
| 5440 } | |
| 5441 | |
| 5442 BOOL GetRect(int nID, LPRECT lpRect) const | |
| 5443 { | |
| 5444 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5445 return (BOOL)::SendMessage(this->m_hWnd, TB_GETRECT, nID, (LPARAM)lpRect); | |
| 5446 } | |
| 5447 | |
| 5448 int GetTextRows() const | |
| 5449 { | |
| 5450 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5451 return (int)::SendMessage(this->m_hWnd, TB_GETTEXTROWS, 0, 0L); | |
| 5452 } | |
| 5453 | |
| 5454 BOOL SetButtonWidth(int cxMin, int cxMax) | |
| 5455 { | |
| 5456 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5457 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cxMin, cxMax)); | |
| 5458 } | |
| 5459 | |
| 5460 BOOL SetIndent(int nIndent) | |
| 5461 { | |
| 5462 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5463 return (BOOL)::SendMessage(this->m_hWnd, TB_SETINDENT, nIndent, 0L); | |
| 5464 } | |
| 5465 | |
| 5466 BOOL SetMaxTextRows(int nMaxTextRows) | |
| 5467 { | |
| 5468 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5469 return (BOOL)::SendMessage(this->m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRows, 0L); | |
| 5470 } | |
| 5471 | |
| 5472 BOOL GetAnchorHighlight() const | |
| 5473 { | |
| 5474 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5475 return (BOOL)::SendMessage(this->m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L); | |
| 5476 } | |
| 5477 | |
| 5478 BOOL SetAnchorHighlight(BOOL bEnable = TRUE) | |
| 5479 { | |
| 5480 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5481 return (BOOL)::SendMessage(this->m_hWnd, TB_SETANCHORHIGHLIGHT, bEnable, 0L); | |
| 5482 } | |
| 5483 | |
| 5484 int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const | |
| 5485 { | |
| 5486 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5487 return (int)::SendMessage(this->m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM)lptbbi); | |
| 5488 } | |
| 5489 | |
| 5490 BOOL SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) | |
| 5491 { | |
| 5492 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5493 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)lptbbi); | |
| 5494 } | |
| 5495 | |
| 5496 BOOL SetButtonInfo(int nID, DWORD dwMask, BYTE Style, BYTE State, LPCTSTR lpszItem, | |
| 5497 int iImage, WORD cx, int iCommand, DWORD_PTR lParam) | |
| 5498 { | |
| 5499 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5500 TBBUTTONINFO tbbi = {}; | |
| 5501 tbbi.cbSize = sizeof(TBBUTTONINFO); | |
| 5502 tbbi.dwMask = dwMask; | |
| 5503 tbbi.idCommand = iCommand; | |
| 5504 tbbi.iImage = iImage; | |
| 5505 tbbi.fsState = State; | |
| 5506 tbbi.fsStyle = Style; | |
| 5507 tbbi.cx = cx; | |
| 5508 tbbi.pszText = (LPTSTR) lpszItem; | |
| 5509 tbbi.lParam = lParam; | |
| 5510 return (BOOL)::SendMessage(this->m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)&tbbi); | |
| 5511 } | |
| 5512 | |
| 5513 int GetHotItem() const | |
| 5514 { | |
| 5515 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5516 return (int)::SendMessage(this->m_hWnd, TB_GETHOTITEM, 0, 0L); | |
| 5517 } | |
| 5518 | |
| 5519 int SetHotItem(int nItem) | |
| 5520 { | |
| 5521 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5522 return (int)::SendMessage(this->m_hWnd, TB_SETHOTITEM, nItem, 0L); | |
| 5523 } | |
| 5524 | |
| 5525 BOOL IsButtonHighlighted(int nButtonID) const | |
| 5526 { | |
| 5527 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5528 return (BOOL)::SendMessage(this->m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButtonID, 0L); | |
| 5529 } | |
| 5530 | |
| 5531 DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags) | |
| 5532 { | |
| 5533 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5534 return (DWORD)::SendMessage(this->m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask, dwFlags); | |
| 5535 } | |
| 5536 | |
| 5537 BOOL GetColorScheme(LPCOLORSCHEME lpcs) const | |
| 5538 { | |
| 5539 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5540 return (BOOL)::SendMessage(this->m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM)lpcs); | |
| 5541 } | |
| 5542 | |
| 5543 void SetColorScheme(LPCOLORSCHEME lpcs) | |
| 5544 { | |
| 5545 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5546 ::SendMessage(this->m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); | |
| 5547 } | |
| 5548 | |
| 5549 DWORD GetExtendedStyle() const | |
| 5550 { | |
| 5551 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5552 return (DWORD)::SendMessage(this->m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); | |
| 5553 } | |
| 5554 | |
| 5555 DWORD SetExtendedStyle(DWORD dwStyle) | |
| 5556 { | |
| 5557 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5558 return (DWORD)::SendMessage(this->m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwStyle); | |
| 5559 } | |
| 5560 | |
| 5561 void GetInsertMark(LPTBINSERTMARK lptbim) const | |
| 5562 { | |
| 5563 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5564 ::SendMessage(this->m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); | |
| 5565 } | |
| 5566 | |
| 5567 void SetInsertMark(LPTBINSERTMARK lptbim) | |
| 5568 { | |
| 5569 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5570 ::SendMessage(this->m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); | |
| 5571 } | |
| 5572 | |
| 5573 COLORREF GetInsertMarkColor() const | |
| 5574 { | |
| 5575 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5576 return (COLORREF)::SendMessage(this->m_hWnd, TB_GETINSERTMARKCOLOR, 0, 0L); | |
| 5577 } | |
| 5578 | |
| 5579 COLORREF SetInsertMarkColor(COLORREF clr) | |
| 5580 { | |
| 5581 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5582 return (COLORREF)::SendMessage(this->m_hWnd, TB_SETINSERTMARKCOLOR, 0, (LPARAM)clr); | |
| 5583 } | |
| 5584 | |
| 5585 BOOL GetMaxSize(LPSIZE lpSize) const | |
| 5586 { | |
| 5587 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5588 return (BOOL)::SendMessage(this->m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpSize); | |
| 5589 } | |
| 5590 | |
| 5591 void GetPadding(LPSIZE lpSizePadding) const | |
| 5592 { | |
| 5593 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5594 ATLASSERT(lpSizePadding != NULL); | |
| 5595 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_GETPADDING, 0, 0L); | |
| 5596 lpSizePadding->cx = GET_X_LPARAM(dwRet); | |
| 5597 lpSizePadding->cy = GET_Y_LPARAM(dwRet); | |
| 5598 } | |
| 5599 | |
| 5600 void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL) | |
| 5601 { | |
| 5602 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5603 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, TB_SETPADDING, 0, MAKELPARAM(cx, cy)); | |
| 5604 if(lpSizePadding != NULL) | |
| 5605 { | |
| 5606 lpSizePadding->cx = GET_X_LPARAM(dwRet); | |
| 5607 lpSizePadding->cy = GET_Y_LPARAM(dwRet); | |
| 5608 } | |
| 5609 } | |
| 5610 | |
| 5611 BOOL GetUnicodeFormat() const | |
| 5612 { | |
| 5613 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5614 return (BOOL)::SendMessage(this->m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); | |
| 5615 } | |
| 5616 | |
| 5617 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 5618 { | |
| 5619 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5620 return (BOOL)::SendMessage(this->m_hWnd, TB_SETUNICODEFORMAT, bUnicode, 0L); | |
| 5621 } | |
| 5622 | |
| 5623 int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const | |
| 5624 { | |
| 5625 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5626 return (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMaxLen, nString), (LPARAM)lpstrString); | |
| 5627 } | |
| 5628 | |
| 5629 int GetStringBSTR(int nString, BSTR& bstrString) const | |
| 5630 { | |
| 5631 USES_CONVERSION; | |
| 5632 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5633 ATLASSERT(bstrString == NULL); | |
| 5634 int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); | |
| 5635 if(nLength != -1) | |
| 5636 { | |
| 5637 ATL::CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; | |
| 5638 LPTSTR lpstrText = buff.Allocate(nLength + 1); | |
| 5639 if(lpstrText != NULL) | |
| 5640 { | |
| 5641 nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); | |
| 5642 if(nLength != -1) | |
| 5643 bstrString = ::SysAllocString(T2OLE(lpstrText)); | |
| 5644 } | |
| 5645 else | |
| 5646 { | |
| 5647 nLength = -1; | |
| 5648 } | |
| 5649 } | |
| 5650 | |
| 5651 return nLength; | |
| 5652 } | |
| 5653 | |
| 5654 #ifdef __ATLSTR_H__ | |
| 5655 int GetString(int nString, ATL::CString& str) const | |
| 5656 { | |
| 5657 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5658 int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(0, nString), NULL)); | |
| 5659 if(nLength != -1) | |
| 5660 { | |
| 5661 LPTSTR lpstr = str.GetBufferSetLength(nLength + 1); | |
| 5662 if(lpstr != NULL) | |
| 5663 nLength = (int)::SendMessage(this->m_hWnd, TB_GETSTRING, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); | |
| 5664 else | |
| 5665 nLength = -1; | |
| 5666 str.ReleaseBuffer(); | |
| 5667 } | |
| 5668 return nLength; | |
| 5669 } | |
| 5670 #endif // __ATLSTR_H__ | |
| 5671 | |
| 5672 void GetMetrics(LPTBMETRICS lptbm) const | |
| 5673 { | |
| 5674 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5675 ::SendMessage(this->m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); | |
| 5676 } | |
| 5677 | |
| 5678 void SetMetrics(LPTBMETRICS lptbm) | |
| 5679 { | |
| 5680 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5681 ::SendMessage(this->m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); | |
| 5682 } | |
| 5683 | |
| 5684 void SetWindowTheme(LPCWSTR lpstrTheme) | |
| 5685 { | |
| 5686 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5687 ::SendMessage(this->m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); | |
| 5688 } | |
| 5689 | |
| 5690 #if (_WIN32_WINNT >= 0x0600) | |
| 5691 CImageList GetPressedImageList(int nIndex = 0) const | |
| 5692 { | |
| 5693 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5694 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_GETPRESSEDIMAGELIST, nIndex, 0L)); | |
| 5695 } | |
| 5696 | |
| 5697 CImageList SetPressedImageList(HIMAGELIST hImageList, int nIndex = 0) | |
| 5698 { | |
| 5699 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5700 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TB_SETPRESSEDIMAGELIST, nIndex, (LPARAM)hImageList)); | |
| 5701 } | |
| 5702 | |
| 5703 void GetItemDropDownRect(int nIndex, LPRECT lpRect) const | |
| 5704 { | |
| 5705 #ifndef TB_GETITEMDROPDOWNRECT | |
| 5706 const int TB_GETITEMDROPDOWNRECT = WM_USER + 103; | |
| 5707 #endif | |
| 5708 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5709 BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, TB_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect); | |
| 5710 (void)bRet; // avoid level 4 warning | |
| 5711 ATLASSERT(bRet != FALSE); | |
| 5712 } | |
| 5713 #endif // (_WIN32_WINNT >= 0x0600) | |
| 5714 | |
| 5715 // Operations | |
| 5716 BOOL EnableButton(int nID, BOOL bEnable = TRUE) | |
| 5717 { | |
| 5718 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5719 return (BOOL)::SendMessage(this->m_hWnd, TB_ENABLEBUTTON, nID, MAKELPARAM(bEnable, 0)); | |
| 5720 } | |
| 5721 | |
| 5722 BOOL CheckButton(int nID, BOOL bCheck = TRUE) | |
| 5723 { | |
| 5724 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5725 return (BOOL)::SendMessage(this->m_hWnd, TB_CHECKBUTTON, nID, MAKELPARAM(bCheck, 0)); | |
| 5726 } | |
| 5727 | |
| 5728 BOOL PressButton(int nID, BOOL bPress = TRUE) | |
| 5729 { | |
| 5730 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5731 return (BOOL)::SendMessage(this->m_hWnd, TB_PRESSBUTTON, nID, MAKELPARAM(bPress, 0)); | |
| 5732 } | |
| 5733 | |
| 5734 BOOL HideButton(int nID, BOOL bHide = TRUE) | |
| 5735 { | |
| 5736 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5737 return (BOOL)::SendMessage(this->m_hWnd, TB_HIDEBUTTON, nID, MAKELPARAM(bHide, 0)); | |
| 5738 } | |
| 5739 | |
| 5740 BOOL Indeterminate(int nID, BOOL bIndeterminate = TRUE) | |
| 5741 { | |
| 5742 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5743 return (BOOL)::SendMessage(this->m_hWnd, TB_INDETERMINATE, nID, MAKELPARAM(bIndeterminate, 0)); | |
| 5744 } | |
| 5745 | |
| 5746 int AddBitmap(int nNumButtons, UINT nBitmapID) | |
| 5747 { | |
| 5748 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5749 TBADDBITMAP tbab = {}; | |
| 5750 tbab.hInst = ModuleHelper::GetResourceInstance(); | |
| 5751 ATLASSERT(tbab.hInst != NULL); | |
| 5752 tbab.nID = nBitmapID; | |
| 5753 return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); | |
| 5754 } | |
| 5755 | |
| 5756 int AddBitmap(int nNumButtons, HBITMAP hBitmap) | |
| 5757 { | |
| 5758 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5759 TBADDBITMAP tbab = {}; | |
| 5760 tbab.hInst = NULL; | |
| 5761 tbab.nID = (UINT_PTR)hBitmap; | |
| 5762 return (int)::SendMessage(this->m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); | |
| 5763 } | |
| 5764 | |
| 5765 BOOL AddButtons(int nNumButtons, LPCTBBUTTON lpButtons) | |
| 5766 { | |
| 5767 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5768 return (BOOL)::SendMessage(this->m_hWnd, TB_ADDBUTTONS, nNumButtons, (LPARAM)lpButtons); | |
| 5769 } | |
| 5770 | |
| 5771 BOOL InsertButton(int nIndex, LPCTBBUTTON lpButton) | |
| 5772 { | |
| 5773 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5774 return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)lpButton); | |
| 5775 } | |
| 5776 | |
| 5777 BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, | |
| 5778 INT_PTR iString, DWORD_PTR lParam) | |
| 5779 { | |
| 5780 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5781 TBBUTTON tbb = {}; | |
| 5782 tbb.fsStyle = Style; | |
| 5783 tbb.fsState = State; | |
| 5784 tbb.idCommand = iCommand; | |
| 5785 tbb.iBitmap = iBitmap; | |
| 5786 tbb.iString = iString; | |
| 5787 tbb.dwData = lParam; | |
| 5788 return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTBUTTON, nIndex, (LPARAM)&tbb); | |
| 5789 } | |
| 5790 | |
| 5791 BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int iBitmap, | |
| 5792 LPCTSTR lpszItem, DWORD_PTR lParam) | |
| 5793 { | |
| 5794 return InsertButton(nIndex, iCommand, Style, State, iBitmap, (INT_PTR)lpszItem, lParam); | |
| 5795 } | |
| 5796 | |
| 5797 BOOL AddButton(LPTBBUTTON lpButton) | |
| 5798 { | |
| 5799 return InsertButton(-1, lpButton); | |
| 5800 } | |
| 5801 | |
| 5802 BOOL AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, INT_PTR iString, DWORD_PTR lParam) | |
| 5803 { | |
| 5804 return InsertButton(-1, iCommand, Style, State, iBitmap, iString, lParam); | |
| 5805 } | |
| 5806 | |
| 5807 BOOL AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, LPCTSTR lpszItem, DWORD_PTR lParam) | |
| 5808 { | |
| 5809 return InsertButton(-1, iCommand, Style, State, iBitmap, lpszItem, lParam); | |
| 5810 } | |
| 5811 | |
| 5812 BOOL DeleteButton(int nIndex) | |
| 5813 { | |
| 5814 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5815 return (BOOL)::SendMessage(this->m_hWnd, TB_DELETEBUTTON, nIndex, 0L); | |
| 5816 } | |
| 5817 | |
| 5818 BOOL InsertSeparator(int nIndex, int cxWidth = 8) | |
| 5819 { | |
| 5820 return InsertButton(nIndex, 0, BTNS_SEP, 0, cxWidth, (INT_PTR)0, 0); | |
| 5821 } | |
| 5822 | |
| 5823 BOOL AddSeparator(int cxWidth = 8) | |
| 5824 { | |
| 5825 return AddButton(0, BTNS_SEP, 0, cxWidth, (INT_PTR)0, 0); | |
| 5826 } | |
| 5827 | |
| 5828 int CommandToIndex(UINT nID) const | |
| 5829 { | |
| 5830 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5831 return (int)::SendMessage(this->m_hWnd, TB_COMMANDTOINDEX, nID, 0L); | |
| 5832 } | |
| 5833 | |
| 5834 void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) | |
| 5835 { | |
| 5836 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5837 TBSAVEPARAMS tbs = {}; | |
| 5838 tbs.hkr = hKeyRoot; | |
| 5839 tbs.pszSubKey = lpszSubKey; | |
| 5840 tbs.pszValueName = lpszValueName; | |
| 5841 ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs); | |
| 5842 } | |
| 5843 | |
| 5844 void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) | |
| 5845 { | |
| 5846 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5847 TBSAVEPARAMS tbs = {}; | |
| 5848 tbs.hkr = hKeyRoot; | |
| 5849 tbs.pszSubKey = lpszSubKey; | |
| 5850 tbs.pszValueName = lpszValueName; | |
| 5851 ::SendMessage(this->m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tbs); | |
| 5852 } | |
| 5853 | |
| 5854 void Customize() | |
| 5855 { | |
| 5856 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5857 ::SendMessage(this->m_hWnd, TB_CUSTOMIZE, 0, 0L); | |
| 5858 } | |
| 5859 | |
| 5860 int AddString(UINT nStringID) | |
| 5861 { | |
| 5862 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5863 return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHelper::GetResourceInstance(), (LPARAM)nStringID); | |
| 5864 } | |
| 5865 | |
| 5866 int AddStrings(LPCTSTR lpszStrings) | |
| 5867 { | |
| 5868 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5869 return (int)::SendMessage(this->m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszStrings); | |
| 5870 } | |
| 5871 | |
| 5872 void AutoSize() | |
| 5873 { | |
| 5874 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5875 ::SendMessage(this->m_hWnd, TB_AUTOSIZE, 0, 0L); | |
| 5876 } | |
| 5877 | |
| 5878 BOOL ChangeBitmap(int nID, int nBitmap) | |
| 5879 { | |
| 5880 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5881 return (BOOL)::SendMessage(this->m_hWnd, TB_CHANGEBITMAP, nID, MAKELPARAM(nBitmap, 0)); | |
| 5882 } | |
| 5883 | |
| 5884 int LoadImages(int nBitmapID) | |
| 5885 { | |
| 5886 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5887 return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)ModuleHelper::GetResourceInstance()); | |
| 5888 } | |
| 5889 | |
| 5890 int LoadStdImages(int nBitmapID) | |
| 5891 { | |
| 5892 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5893 return (int)::SendMessage(this->m_hWnd, TB_LOADIMAGES, nBitmapID, (LPARAM)HINST_COMMCTRL); | |
| 5894 } | |
| 5895 | |
| 5896 BOOL ReplaceBitmap(LPTBREPLACEBITMAP ptbrb) | |
| 5897 { | |
| 5898 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5899 return (BOOL)::SendMessage(this->m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)ptbrb); | |
| 5900 } | |
| 5901 | |
| 5902 int HitTest(LPPOINT lpPoint) const | |
| 5903 { | |
| 5904 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5905 return (int)::SendMessage(this->m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint); | |
| 5906 } | |
| 5907 | |
| 5908 BOOL InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim) const | |
| 5909 { | |
| 5910 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5911 return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)lptbim); | |
| 5912 } | |
| 5913 | |
| 5914 BOOL InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim) const | |
| 5915 { | |
| 5916 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5917 POINT pt = { x, y }; | |
| 5918 return (BOOL)::SendMessage(this->m_hWnd, TB_INSERTMARKHITTEST, (WPARAM)&pt, (LPARAM)lptbim); | |
| 5919 } | |
| 5920 | |
| 5921 BOOL MapAccelerator(TCHAR chAccel, int& nID) const | |
| 5922 { | |
| 5923 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5924 return (BOOL)::SendMessage(this->m_hWnd, TB_MAPACCELERATOR, (WPARAM)chAccel, (LPARAM)&nID); | |
| 5925 } | |
| 5926 | |
| 5927 BOOL MarkButton(int nID, BOOL bHighlight = TRUE) | |
| 5928 { | |
| 5929 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5930 return (BOOL)::SendMessage(this->m_hWnd, TB_MARKBUTTON, nID, MAKELPARAM(bHighlight, 0)); | |
| 5931 } | |
| 5932 | |
| 5933 BOOL MoveButton(int nOldPos, int nNewPos) | |
| 5934 { | |
| 5935 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5936 return (BOOL)::SendMessage(this->m_hWnd, TB_MOVEBUTTON, nOldPos, nNewPos); | |
| 5937 } | |
| 5938 | |
| 5939 HRESULT GetObject(REFIID iid, LPVOID* ppvObject) | |
| 5940 { | |
| 5941 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5942 return (HRESULT)::SendMessage(this->m_hWnd, TB_GETOBJECT, (WPARAM)&iid, (LPARAM)ppvObject); | |
| 5943 } | |
| 5944 }; | |
| 5945 | |
| 5946 typedef CToolBarCtrlT<ATL::CWindow> CToolBarCtrl; | |
| 5947 | |
| 5948 | |
| 5949 /////////////////////////////////////////////////////////////////////////////// | |
| 5950 // CStatusBarCtrl | |
| 5951 | |
| 5952 template <class TBase> | |
| 5953 class CStatusBarCtrlT : public TBase | |
| 5954 { | |
| 5955 public: | |
| 5956 // Constructors | |
| 5957 CStatusBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 5958 { } | |
| 5959 | |
| 5960 CStatusBarCtrlT< TBase >& operator =(HWND hWnd) | |
| 5961 { | |
| 5962 this->m_hWnd = hWnd; | |
| 5963 return *this; | |
| 5964 } | |
| 5965 | |
| 5966 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 5967 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 5968 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 5969 { | |
| 5970 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 5971 } | |
| 5972 | |
| 5973 // Methods | |
| 5974 static LPCTSTR GetWndClassName() | |
| 5975 { | |
| 5976 return STATUSCLASSNAME; | |
| 5977 } | |
| 5978 | |
| 5979 int GetParts(int nParts, int* pParts) const | |
| 5980 { | |
| 5981 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5982 return (int)::SendMessage(this->m_hWnd, SB_GETPARTS, nParts, (LPARAM)pParts); | |
| 5983 } | |
| 5984 | |
| 5985 BOOL SetParts(int nParts, int* pWidths) | |
| 5986 { | |
| 5987 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5988 return (BOOL)::SendMessage(this->m_hWnd, SB_SETPARTS, nParts, (LPARAM)pWidths); | |
| 5989 } | |
| 5990 | |
| 5991 int GetTextLength(int nPane, int* pType = NULL) const | |
| 5992 { | |
| 5993 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 5994 ATLASSERT(nPane < 256); | |
| 5995 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L); | |
| 5996 if (pType != NULL) | |
| 5997 *pType = (int)(short)HIWORD(dwRet); | |
| 5998 return (int)(short)LOWORD(dwRet); | |
| 5999 } | |
| 6000 | |
| 6001 int GetText(int nPane, LPTSTR lpszText, int* pType = NULL) const | |
| 6002 { | |
| 6003 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6004 ATLASSERT(nPane < 256); | |
| 6005 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, SB_GETTEXT, (WPARAM)nPane, (LPARAM)lpszText); | |
| 6006 if(pType != NULL) | |
| 6007 *pType = (int)(short)HIWORD(dwRet); | |
| 6008 return (int)(short)LOWORD(dwRet); | |
| 6009 } | |
| 6010 | |
| 6011 BOOL GetTextBSTR(int nPane, BSTR& bstrText, int* pType = NULL) const | |
| 6012 { | |
| 6013 USES_CONVERSION; | |
| 6014 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6015 ATLASSERT(nPane < 256); | |
| 6016 ATLASSERT(bstrText == NULL); | |
| 6017 int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); | |
| 6018 if(nLength == 0) | |
| 6019 return FALSE; | |
| 6020 | |
| 6021 ATL::CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; | |
| 6022 LPTSTR lpstrText = buff.Allocate(nLength + 1); | |
| 6023 if(lpstrText == NULL) | |
| 6024 return FALSE; | |
| 6025 | |
| 6026 if(!GetText(nPane, lpstrText, pType)) | |
| 6027 return FALSE; | |
| 6028 | |
| 6029 bstrText = ::SysAllocString(T2OLE(lpstrText)); | |
| 6030 return (bstrText != NULL) ? TRUE : FALSE; | |
| 6031 } | |
| 6032 | |
| 6033 #ifdef __ATLSTR_H__ | |
| 6034 int GetText(int nPane, ATL::CString& strText, int* pType = NULL) const | |
| 6035 { | |
| 6036 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6037 ATLASSERT(nPane < 256); | |
| 6038 int nLength = (int)(short)LOWORD(::SendMessage(this->m_hWnd, SB_GETTEXTLENGTH, (WPARAM)nPane, 0L)); | |
| 6039 if(nLength == 0) | |
| 6040 return 0; | |
| 6041 | |
| 6042 LPTSTR lpstr = strText.GetBufferSetLength(nLength); | |
| 6043 if(lpstr == NULL) | |
| 6044 return 0; | |
| 6045 return GetText(nPane, lpstr, pType); | |
| 6046 } | |
| 6047 #endif // __ATLSTR_H__ | |
| 6048 | |
| 6049 BOOL SetText(int nPane, LPCTSTR lpszText, int nType = 0) | |
| 6050 { | |
| 6051 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6052 ATLASSERT(nPane < 256); | |
| 6053 return (BOOL)::SendMessage(this->m_hWnd, SB_SETTEXT, (nPane | nType), (LPARAM)lpszText); | |
| 6054 } | |
| 6055 | |
| 6056 BOOL GetRect(int nPane, LPRECT lpRect) const | |
| 6057 { | |
| 6058 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6059 ATLASSERT(nPane < 256); | |
| 6060 return (BOOL)::SendMessage(this->m_hWnd, SB_GETRECT, nPane, (LPARAM)lpRect); | |
| 6061 } | |
| 6062 | |
| 6063 BOOL GetBorders(int* pBorders) const | |
| 6064 { | |
| 6065 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6066 return (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBorders); | |
| 6067 } | |
| 6068 | |
| 6069 BOOL GetBorders(int& nHorz, int& nVert, int& nSpacing) const | |
| 6070 { | |
| 6071 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6072 int borders[3] = {}; | |
| 6073 BOOL bResult = (BOOL)::SendMessage(this->m_hWnd, SB_GETBORDERS, 0, (LPARAM)&borders); | |
| 6074 if(bResult) | |
| 6075 { | |
| 6076 nHorz = borders[0]; | |
| 6077 nVert = borders[1]; | |
| 6078 nSpacing = borders[2]; | |
| 6079 } | |
| 6080 return bResult; | |
| 6081 } | |
| 6082 | |
| 6083 void SetMinHeight(int nMin) | |
| 6084 { | |
| 6085 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6086 ::SendMessage(this->m_hWnd, SB_SETMINHEIGHT, nMin, 0L); | |
| 6087 } | |
| 6088 | |
| 6089 BOOL SetSimple(BOOL bSimple = TRUE) | |
| 6090 { | |
| 6091 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6092 return (BOOL)::SendMessage(this->m_hWnd, SB_SIMPLE, bSimple, 0L); | |
| 6093 } | |
| 6094 | |
| 6095 BOOL IsSimple() const | |
| 6096 { | |
| 6097 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6098 return (BOOL)::SendMessage(this->m_hWnd, SB_ISSIMPLE, 0, 0L); | |
| 6099 } | |
| 6100 | |
| 6101 BOOL GetUnicodeFormat() const | |
| 6102 { | |
| 6103 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6104 return (BOOL)::SendMessage(this->m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); | |
| 6105 } | |
| 6106 | |
| 6107 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 6108 { | |
| 6109 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6110 return (BOOL)::SendMessage(this->m_hWnd, SB_SETUNICODEFORMAT, bUnicode, 0L); | |
| 6111 } | |
| 6112 | |
| 6113 void GetTipText(int nPane, LPTSTR lpstrText, int nSize) const | |
| 6114 { | |
| 6115 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6116 ATLASSERT(nPane < 256); | |
| 6117 ::SendMessage(this->m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (LPARAM)lpstrText); | |
| 6118 } | |
| 6119 | |
| 6120 void SetTipText(int nPane, LPCTSTR lpstrText) | |
| 6121 { | |
| 6122 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6123 ATLASSERT(nPane < 256); | |
| 6124 ::SendMessage(this->m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); | |
| 6125 } | |
| 6126 | |
| 6127 COLORREF SetBkColor(COLORREF clrBk) | |
| 6128 { | |
| 6129 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6130 return (COLORREF)::SendMessage(this->m_hWnd, SB_SETBKCOLOR, 0, (LPARAM)clrBk); | |
| 6131 } | |
| 6132 | |
| 6133 HICON GetIcon(int nPane) const | |
| 6134 { | |
| 6135 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6136 ATLASSERT(nPane < 256); | |
| 6137 return (HICON)::SendMessage(this->m_hWnd, SB_GETICON, nPane, 0L); | |
| 6138 } | |
| 6139 | |
| 6140 BOOL SetIcon(int nPane, HICON hIcon) | |
| 6141 { | |
| 6142 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6143 ATLASSERT(nPane < 256); | |
| 6144 return (BOOL)::SendMessage(this->m_hWnd, SB_SETICON, nPane, (LPARAM)hIcon); | |
| 6145 } | |
| 6146 }; | |
| 6147 | |
| 6148 typedef CStatusBarCtrlT<ATL::CWindow> CStatusBarCtrl; | |
| 6149 | |
| 6150 | |
| 6151 /////////////////////////////////////////////////////////////////////////////// | |
| 6152 // CTabCtrl | |
| 6153 | |
| 6154 template <class TBase> | |
| 6155 class CTabCtrlT : public TBase | |
| 6156 { | |
| 6157 public: | |
| 6158 // Constructors | |
| 6159 CTabCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 6160 { } | |
| 6161 | |
| 6162 CTabCtrlT< TBase >& operator =(HWND hWnd) | |
| 6163 { | |
| 6164 this->m_hWnd = hWnd; | |
| 6165 return *this; | |
| 6166 } | |
| 6167 | |
| 6168 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 6169 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 6170 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 6171 { | |
| 6172 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 6173 } | |
| 6174 | |
| 6175 // Attributes | |
| 6176 static LPCTSTR GetWndClassName() | |
| 6177 { | |
| 6178 return WC_TABCONTROL; | |
| 6179 } | |
| 6180 | |
| 6181 CImageList GetImageList() const | |
| 6182 { | |
| 6183 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6184 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_GETIMAGELIST, 0, 0L)); | |
| 6185 } | |
| 6186 | |
| 6187 CImageList SetImageList(HIMAGELIST hImageList) | |
| 6188 { | |
| 6189 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6190 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList)); | |
| 6191 } | |
| 6192 | |
| 6193 int GetItemCount() const | |
| 6194 { | |
| 6195 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6196 return (int)::SendMessage(this->m_hWnd, TCM_GETITEMCOUNT, 0, 0L); | |
| 6197 } | |
| 6198 | |
| 6199 BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const | |
| 6200 { | |
| 6201 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6202 return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); | |
| 6203 } | |
| 6204 | |
| 6205 BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem) | |
| 6206 { | |
| 6207 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6208 return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); | |
| 6209 } | |
| 6210 | |
| 6211 int SetItem(int nItem, UINT mask, LPCTSTR lpszItem, DWORD dwState, DWORD dwStateMask, int iImage, LPARAM lParam) | |
| 6212 { | |
| 6213 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6214 TCITEM tci = {}; | |
| 6215 tci.mask = mask; | |
| 6216 tci.pszText = (LPTSTR) lpszItem; | |
| 6217 tci.dwState = dwState; | |
| 6218 tci.dwStateMask = dwStateMask; | |
| 6219 tci.iImage = iImage; | |
| 6220 tci.lParam = lParam; | |
| 6221 return (int)::SendMessage(this->m_hWnd, TCM_SETITEM, nItem, (LPARAM)&tci); | |
| 6222 } | |
| 6223 | |
| 6224 BOOL GetItemRect(int nItem, LPRECT lpRect) const | |
| 6225 { | |
| 6226 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6227 return (BOOL)::SendMessage(this->m_hWnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect); | |
| 6228 } | |
| 6229 | |
| 6230 int GetCurSel() const | |
| 6231 { | |
| 6232 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6233 return (int)::SendMessage(this->m_hWnd, TCM_GETCURSEL, 0, 0L); | |
| 6234 } | |
| 6235 | |
| 6236 int SetCurSel(int nItem) | |
| 6237 { | |
| 6238 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6239 return (int)::SendMessage(this->m_hWnd, TCM_SETCURSEL, nItem, 0L); | |
| 6240 } | |
| 6241 | |
| 6242 SIZE SetItemSize(SIZE size) | |
| 6243 { | |
| 6244 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6245 DWORD dwSize = (DWORD)::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy)); | |
| 6246 SIZE sizeRet = { GET_X_LPARAM(dwSize), GET_Y_LPARAM(dwSize) }; | |
| 6247 return sizeRet; | |
| 6248 } | |
| 6249 | |
| 6250 void SetItemSize(int cx, int cy) | |
| 6251 { | |
| 6252 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6253 ::SendMessage(this->m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); | |
| 6254 } | |
| 6255 | |
| 6256 void SetPadding(SIZE size) | |
| 6257 { | |
| 6258 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6259 ::SendMessage(this->m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy)); | |
| 6260 } | |
| 6261 | |
| 6262 int GetRowCount() const | |
| 6263 { | |
| 6264 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6265 return (int)::SendMessage(this->m_hWnd, TCM_GETROWCOUNT, 0, 0L); | |
| 6266 } | |
| 6267 | |
| 6268 CToolTipCtrl GetToolTips() const | |
| 6269 { | |
| 6270 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6271 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TCM_GETTOOLTIPS, 0, 0L)); | |
| 6272 } | |
| 6273 | |
| 6274 // this method is deprecated, please use GetToolTips | |
| 6275 CToolTipCtrl GetTooltips() const { return GetToolTips(); } | |
| 6276 | |
| 6277 void SetToolTips(HWND hWndToolTip) | |
| 6278 { | |
| 6279 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6280 ::SendMessage(this->m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); | |
| 6281 } | |
| 6282 | |
| 6283 // this method is deprecated, please use SetToolTips | |
| 6284 void SetTooltips(HWND hWndToolTip) { SetToolTips(hWndToolTip); } | |
| 6285 | |
| 6286 int GetCurFocus() const | |
| 6287 { | |
| 6288 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6289 return (int)::SendMessage(this->m_hWnd, TCM_GETCURFOCUS, 0, 0L); | |
| 6290 } | |
| 6291 | |
| 6292 void SetCurFocus(int nItem) | |
| 6293 { | |
| 6294 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6295 ::SendMessage(this->m_hWnd, TCM_SETCURFOCUS, nItem, 0L); | |
| 6296 } | |
| 6297 | |
| 6298 BOOL SetItemExtra(int cbExtra) | |
| 6299 { | |
| 6300 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6301 ATLASSERT(GetItemCount() == 0); // must be empty | |
| 6302 return (BOOL)::SendMessage(this->m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L); | |
| 6303 } | |
| 6304 | |
| 6305 int SetMinTabWidth(int nWidth = -1) | |
| 6306 { | |
| 6307 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6308 return (int)::SendMessage(this->m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth); | |
| 6309 } | |
| 6310 | |
| 6311 DWORD GetExtendedStyle() const | |
| 6312 { | |
| 6313 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6314 return (DWORD)::SendMessage(this->m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L); | |
| 6315 } | |
| 6316 | |
| 6317 DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) | |
| 6318 { | |
| 6319 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6320 return (DWORD)::SendMessage(this->m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); | |
| 6321 } | |
| 6322 | |
| 6323 BOOL GetUnicodeFormat() const | |
| 6324 { | |
| 6325 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6326 return (BOOL)::SendMessage(this->m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); | |
| 6327 } | |
| 6328 | |
| 6329 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 6330 { | |
| 6331 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6332 return (BOOL)::SendMessage(this->m_hWnd, TCM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 6333 } | |
| 6334 | |
| 6335 // Operations | |
| 6336 int InsertItem(int nItem, LPTCITEM pTabCtrlItem) | |
| 6337 { | |
| 6338 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6339 return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); | |
| 6340 } | |
| 6341 | |
| 6342 int InsertItem(int nItem, UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) | |
| 6343 { | |
| 6344 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6345 TCITEM tci = {}; | |
| 6346 tci.mask = mask; | |
| 6347 tci.pszText = (LPTSTR) lpszItem; | |
| 6348 tci.iImage = iImage; | |
| 6349 tci.lParam = lParam; | |
| 6350 return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); | |
| 6351 } | |
| 6352 | |
| 6353 int InsertItem(int nItem, LPCTSTR lpszItem) | |
| 6354 { | |
| 6355 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6356 TCITEM tci = {}; | |
| 6357 tci.mask = TCIF_TEXT; | |
| 6358 tci.pszText = (LPTSTR) lpszItem; | |
| 6359 return (int)::SendMessage(this->m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)&tci); | |
| 6360 } | |
| 6361 | |
| 6362 int AddItem(LPTCITEM pTabCtrlItem) | |
| 6363 { | |
| 6364 return InsertItem(GetItemCount(), pTabCtrlItem); | |
| 6365 } | |
| 6366 | |
| 6367 int AddItem(UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) | |
| 6368 { | |
| 6369 return InsertItem(GetItemCount(), mask, lpszItem, iImage, lParam); | |
| 6370 } | |
| 6371 | |
| 6372 int AddItem(LPCTSTR lpszItem) | |
| 6373 { | |
| 6374 return InsertItem(GetItemCount(), lpszItem); | |
| 6375 } | |
| 6376 | |
| 6377 BOOL DeleteItem(int nItem) | |
| 6378 { | |
| 6379 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6380 return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEITEM, nItem, 0L); | |
| 6381 } | |
| 6382 | |
| 6383 BOOL DeleteAllItems() | |
| 6384 { | |
| 6385 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6386 return (BOOL)::SendMessage(this->m_hWnd, TCM_DELETEALLITEMS, 0, 0L); | |
| 6387 } | |
| 6388 | |
| 6389 void AdjustRect(BOOL bLarger, LPRECT lpRect) | |
| 6390 { | |
| 6391 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6392 ::SendMessage(this->m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); | |
| 6393 } | |
| 6394 | |
| 6395 void RemoveImage(int nImage) | |
| 6396 { | |
| 6397 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6398 ::SendMessage(this->m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); | |
| 6399 } | |
| 6400 | |
| 6401 int HitTest(TC_HITTESTINFO* pHitTestInfo) const | |
| 6402 { | |
| 6403 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6404 return (int)::SendMessage(this->m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo); | |
| 6405 } | |
| 6406 | |
| 6407 void DeselectAll(BOOL bExcludeFocus = TRUE) | |
| 6408 { | |
| 6409 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6410 ::SendMessage(this->m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); | |
| 6411 } | |
| 6412 | |
| 6413 BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE) | |
| 6414 { | |
| 6415 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6416 return (BOOL)::SendMessage(this->m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0)); | |
| 6417 } | |
| 6418 }; | |
| 6419 | |
| 6420 typedef CTabCtrlT<ATL::CWindow> CTabCtrl; | |
| 6421 | |
| 6422 | |
| 6423 /////////////////////////////////////////////////////////////////////////////// | |
| 6424 // CTrackBarCtrl | |
| 6425 | |
| 6426 template <class TBase> | |
| 6427 class CTrackBarCtrlT : public TBase | |
| 6428 { | |
| 6429 public: | |
| 6430 // Constructors | |
| 6431 CTrackBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 6432 { } | |
| 6433 | |
| 6434 CTrackBarCtrlT< TBase >& operator =(HWND hWnd) | |
| 6435 { | |
| 6436 this->m_hWnd = hWnd; | |
| 6437 return *this; | |
| 6438 } | |
| 6439 | |
| 6440 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 6441 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 6442 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 6443 { | |
| 6444 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 6445 } | |
| 6446 | |
| 6447 // Attributes | |
| 6448 static LPCTSTR GetWndClassName() | |
| 6449 { | |
| 6450 return TRACKBAR_CLASS; | |
| 6451 } | |
| 6452 | |
| 6453 int GetLineSize() const | |
| 6454 { | |
| 6455 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6456 return (int)::SendMessage(this->m_hWnd, TBM_GETLINESIZE, 0, 0L); | |
| 6457 } | |
| 6458 | |
| 6459 int SetLineSize(int nSize) | |
| 6460 { | |
| 6461 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6462 return (int)::SendMessage(this->m_hWnd, TBM_SETLINESIZE, 0, nSize); | |
| 6463 } | |
| 6464 | |
| 6465 int GetPageSize() const | |
| 6466 { | |
| 6467 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6468 return (int)::SendMessage(this->m_hWnd, TBM_GETPAGESIZE, 0, 0L); | |
| 6469 } | |
| 6470 | |
| 6471 int SetPageSize(int nSize) | |
| 6472 { | |
| 6473 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6474 return (int)::SendMessage(this->m_hWnd, TBM_SETPAGESIZE, 0, nSize); | |
| 6475 } | |
| 6476 | |
| 6477 int GetRangeMin() const | |
| 6478 { | |
| 6479 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6480 return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMIN, 0, 0L); | |
| 6481 } | |
| 6482 | |
| 6483 void SetRangeMin(int nMin, BOOL bRedraw = FALSE) | |
| 6484 { | |
| 6485 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6486 ::SendMessage(this->m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); | |
| 6487 } | |
| 6488 | |
| 6489 int GetRangeMax() const | |
| 6490 { | |
| 6491 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6492 return (int)::SendMessage(this->m_hWnd, TBM_GETRANGEMAX, 0, 0L); | |
| 6493 } | |
| 6494 | |
| 6495 void SetRangeMax(int nMax, BOOL bRedraw = FALSE) | |
| 6496 { | |
| 6497 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6498 ::SendMessage(this->m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); | |
| 6499 } | |
| 6500 | |
| 6501 void GetRange(int& nMin, int& nMax) const | |
| 6502 { | |
| 6503 nMin = GetRangeMin(); | |
| 6504 nMax = GetRangeMax(); | |
| 6505 } | |
| 6506 | |
| 6507 void SetRange(int nMin, int nMax, BOOL bRedraw = TRUE) | |
| 6508 { | |
| 6509 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6510 ::SendMessage(this->m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nMax)); | |
| 6511 } | |
| 6512 | |
| 6513 int GetSelStart() const | |
| 6514 { | |
| 6515 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6516 return (int)::SendMessage(this->m_hWnd, TBM_GETSELSTART, 0, 0L); | |
| 6517 } | |
| 6518 | |
| 6519 void SetSelStart(int nMin, BOOL bRedraw = FALSE) | |
| 6520 { | |
| 6521 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6522 ::SendMessage(this->m_hWnd, TBM_SETSELSTART, bRedraw, (LPARAM)nMin); | |
| 6523 } | |
| 6524 | |
| 6525 int GetSelEnd() const | |
| 6526 { | |
| 6527 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6528 return (int)::SendMessage(this->m_hWnd, TBM_GETSELEND, 0, 0L); | |
| 6529 } | |
| 6530 | |
| 6531 void SetSelEnd(int nMax, BOOL bRedraw = FALSE) | |
| 6532 { | |
| 6533 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6534 ::SendMessage(this->m_hWnd, TBM_SETSELEND, bRedraw, (LPARAM)nMax); | |
| 6535 } | |
| 6536 | |
| 6537 void GetSelection(int& nMin, int& nMax) const | |
| 6538 { | |
| 6539 nMin = GetSelStart(); | |
| 6540 nMax = GetSelEnd(); | |
| 6541 } | |
| 6542 | |
| 6543 void SetSelection(int nMin, int nMax, BOOL bRedraw = TRUE) | |
| 6544 { | |
| 6545 SetSelStart(nMin, FALSE); | |
| 6546 SetSelEnd(nMax, bRedraw); | |
| 6547 } | |
| 6548 | |
| 6549 void GetChannelRect(LPRECT lprc) const | |
| 6550 { | |
| 6551 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6552 ::SendMessage(this->m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); | |
| 6553 } | |
| 6554 | |
| 6555 void GetThumbRect(LPRECT lprc) const | |
| 6556 { | |
| 6557 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6558 ::SendMessage(this->m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); | |
| 6559 } | |
| 6560 | |
| 6561 int GetPos() const | |
| 6562 { | |
| 6563 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6564 return (int)::SendMessage(this->m_hWnd, TBM_GETPOS, 0, 0L); | |
| 6565 } | |
| 6566 | |
| 6567 void SetPos(int nPos) | |
| 6568 { | |
| 6569 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6570 ::SendMessage(this->m_hWnd, TBM_SETPOS, TRUE, nPos); | |
| 6571 } | |
| 6572 | |
| 6573 UINT GetNumTics() const | |
| 6574 { | |
| 6575 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6576 return (UINT)::SendMessage(this->m_hWnd, TBM_GETNUMTICS, 0, 0L); | |
| 6577 } | |
| 6578 | |
| 6579 DWORD* GetTicArray() const | |
| 6580 { | |
| 6581 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6582 return (DWORD*)::SendMessage(this->m_hWnd, TBM_GETPTICS, 0, 0L); | |
| 6583 } | |
| 6584 | |
| 6585 int GetTic(int nTic) const | |
| 6586 { | |
| 6587 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6588 return (int)::SendMessage(this->m_hWnd, TBM_GETTIC, nTic, 0L); | |
| 6589 } | |
| 6590 | |
| 6591 BOOL SetTic(int nTic) | |
| 6592 { | |
| 6593 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6594 return (BOOL)::SendMessage(this->m_hWnd, TBM_SETTIC, 0, nTic); | |
| 6595 } | |
| 6596 | |
| 6597 int GetTicPos(int nTic) const | |
| 6598 { | |
| 6599 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6600 return (int)::SendMessage(this->m_hWnd, TBM_GETTICPOS, nTic, 0L); | |
| 6601 } | |
| 6602 | |
| 6603 void SetTicFreq(int nFreq) | |
| 6604 { | |
| 6605 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6606 ::SendMessage(this->m_hWnd, TBM_SETTICFREQ, nFreq, 0L); | |
| 6607 } | |
| 6608 | |
| 6609 int GetThumbLength() const | |
| 6610 { | |
| 6611 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6612 return (int)::SendMessage(this->m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); | |
| 6613 } | |
| 6614 | |
| 6615 void SetThumbLength(int nLength) | |
| 6616 { | |
| 6617 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6618 ::SendMessage(this->m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); | |
| 6619 } | |
| 6620 | |
| 6621 void SetSel(int nStart, int nEnd, BOOL bRedraw = TRUE) | |
| 6622 { | |
| 6623 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6624 ATLASSERT((this->GetStyle() & TBS_ENABLESELRANGE) != 0); | |
| 6625 ::SendMessage(this->m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nEnd)); | |
| 6626 } | |
| 6627 | |
| 6628 ATL::CWindow GetBuddy(BOOL bLeft = TRUE) const | |
| 6629 { | |
| 6630 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6631 return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_GETBUDDY, bLeft, 0L)); | |
| 6632 } | |
| 6633 | |
| 6634 ATL::CWindow SetBuddy(HWND hWndBuddy, BOOL bLeft = TRUE) | |
| 6635 { | |
| 6636 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6637 return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, TBM_SETBUDDY, bLeft, (LPARAM)hWndBuddy)); | |
| 6638 } | |
| 6639 | |
| 6640 CToolTipCtrl GetToolTips() const | |
| 6641 { | |
| 6642 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6643 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, TBM_GETTOOLTIPS, 0, 0L)); | |
| 6644 } | |
| 6645 | |
| 6646 void SetToolTips(HWND hWndTT) | |
| 6647 { | |
| 6648 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6649 ::SendMessage(this->m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); | |
| 6650 } | |
| 6651 | |
| 6652 int SetTipSide(int nSide) | |
| 6653 { | |
| 6654 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6655 return (int)::SendMessage(this->m_hWnd, TBM_SETTIPSIDE, nSide, 0L); | |
| 6656 } | |
| 6657 | |
| 6658 BOOL GetUnicodeFormat() const | |
| 6659 { | |
| 6660 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6661 return (BOOL)::SendMessage(this->m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); | |
| 6662 } | |
| 6663 | |
| 6664 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 6665 { | |
| 6666 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6667 return (BOOL)::SendMessage(this->m_hWnd, TBM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 6668 } | |
| 6669 | |
| 6670 // Operations | |
| 6671 void ClearSel(BOOL bRedraw = FALSE) | |
| 6672 { | |
| 6673 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6674 ::SendMessage(this->m_hWnd, TBM_CLEARSEL, bRedraw, 0L); | |
| 6675 } | |
| 6676 | |
| 6677 void VerifyPos() | |
| 6678 { | |
| 6679 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6680 ::SendMessage(this->m_hWnd, TBM_SETPOS, FALSE, 0L); | |
| 6681 } | |
| 6682 | |
| 6683 void ClearTics(BOOL bRedraw = FALSE) | |
| 6684 { | |
| 6685 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6686 ::SendMessage(this->m_hWnd, TBM_CLEARTICS, bRedraw, 0L); | |
| 6687 } | |
| 6688 }; | |
| 6689 | |
| 6690 typedef CTrackBarCtrlT<ATL::CWindow> CTrackBarCtrl; | |
| 6691 | |
| 6692 | |
| 6693 /////////////////////////////////////////////////////////////////////////////// | |
| 6694 // CUpDownCtrl | |
| 6695 | |
| 6696 template <class TBase> | |
| 6697 class CUpDownCtrlT : public TBase | |
| 6698 { | |
| 6699 public: | |
| 6700 // Constructors | |
| 6701 CUpDownCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 6702 { } | |
| 6703 | |
| 6704 CUpDownCtrlT< TBase >& operator =(HWND hWnd) | |
| 6705 { | |
| 6706 this->m_hWnd = hWnd; | |
| 6707 return *this; | |
| 6708 } | |
| 6709 | |
| 6710 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 6711 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 6712 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 6713 { | |
| 6714 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 6715 } | |
| 6716 | |
| 6717 // Attributes | |
| 6718 static LPCTSTR GetWndClassName() | |
| 6719 { | |
| 6720 return UPDOWN_CLASS; | |
| 6721 } | |
| 6722 | |
| 6723 UINT GetAccel(int nAccel, UDACCEL* pAccel) const | |
| 6724 { | |
| 6725 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6726 return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETACCEL, nAccel, (LPARAM)pAccel)); | |
| 6727 } | |
| 6728 | |
| 6729 BOOL SetAccel(int nAccel, UDACCEL* pAccel) | |
| 6730 { | |
| 6731 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6732 return (BOOL)LOWORD(::SendMessage(this->m_hWnd, UDM_SETACCEL, nAccel, (LPARAM)pAccel)); | |
| 6733 } | |
| 6734 | |
| 6735 UINT GetBase() const | |
| 6736 { | |
| 6737 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6738 return (UINT)LOWORD(::SendMessage(this->m_hWnd, UDM_GETBASE, 0, 0L)); | |
| 6739 } | |
| 6740 | |
| 6741 int SetBase(int nBase) | |
| 6742 { | |
| 6743 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6744 return (int)::SendMessage(this->m_hWnd, UDM_SETBASE, nBase, 0L); | |
| 6745 } | |
| 6746 | |
| 6747 ATL::CWindow GetBuddy() const | |
| 6748 { | |
| 6749 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6750 return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_GETBUDDY, 0, 0L)); | |
| 6751 } | |
| 6752 | |
| 6753 ATL::CWindow SetBuddy(HWND hWndBuddy) | |
| 6754 { | |
| 6755 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6756 return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, UDM_SETBUDDY, (WPARAM)hWndBuddy, 0L)); | |
| 6757 } | |
| 6758 | |
| 6759 int GetPos(LPBOOL lpbError = NULL) const | |
| 6760 { | |
| 6761 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6762 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETPOS, 0, 0L); | |
| 6763 // Note: Seems that Windows always sets error to TRUE if | |
| 6764 // UDS_SETBUDDYINT style is not used | |
| 6765 if(lpbError != NULL) | |
| 6766 *lpbError = (HIWORD(dwRet) != 0) ? TRUE : FALSE; | |
| 6767 return (int)(short)LOWORD(dwRet); | |
| 6768 } | |
| 6769 | |
| 6770 int SetPos(int nPos) | |
| 6771 { | |
| 6772 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6773 return (int)(short)LOWORD(::SendMessage(this->m_hWnd, UDM_SETPOS, 0, MAKELPARAM(nPos, 0))); | |
| 6774 } | |
| 6775 | |
| 6776 DWORD GetRange() const | |
| 6777 { | |
| 6778 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6779 return (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); | |
| 6780 } | |
| 6781 | |
| 6782 void GetRange(int& nLower, int& nUpper) const | |
| 6783 { | |
| 6784 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6785 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, UDM_GETRANGE, 0, 0L); | |
| 6786 nLower = (int)(short)HIWORD(dwRet); | |
| 6787 nUpper = (int)(short)LOWORD(dwRet); | |
| 6788 } | |
| 6789 | |
| 6790 void SetRange(int nLower, int nUpper) | |
| 6791 { | |
| 6792 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6793 ::SendMessage(this->m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower)); | |
| 6794 } | |
| 6795 | |
| 6796 void SetRange32(int nLower, int nUpper) | |
| 6797 { | |
| 6798 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6799 ::SendMessage(this->m_hWnd, UDM_SETRANGE32, nLower, nUpper); | |
| 6800 } | |
| 6801 | |
| 6802 void GetRange32(int& nLower, int& nUpper) const | |
| 6803 { | |
| 6804 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6805 ::SendMessage(this->m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&nUpper); | |
| 6806 } | |
| 6807 | |
| 6808 BOOL GetUnicodeFormat() const | |
| 6809 { | |
| 6810 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6811 return (BOOL)::SendMessage(this->m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); | |
| 6812 } | |
| 6813 | |
| 6814 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 6815 { | |
| 6816 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6817 return (BOOL)::SendMessage(this->m_hWnd, UDM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 6818 } | |
| 6819 | |
| 6820 int GetPos32(LPBOOL lpbError = NULL) const | |
| 6821 { | |
| 6822 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6823 // Note: Seems that Windows always sets error to TRUE if | |
| 6824 // UDS_SETBUDDYINT style is not used | |
| 6825 return (int)::SendMessage(this->m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbError); | |
| 6826 } | |
| 6827 | |
| 6828 int SetPos32(int nPos) | |
| 6829 { | |
| 6830 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6831 return (int)::SendMessage(this->m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos); | |
| 6832 } | |
| 6833 }; | |
| 6834 | |
| 6835 typedef CUpDownCtrlT<ATL::CWindow> CUpDownCtrl; | |
| 6836 | |
| 6837 | |
| 6838 /////////////////////////////////////////////////////////////////////////////// | |
| 6839 // CProgressBarCtrl | |
| 6840 | |
| 6841 template <class TBase> | |
| 6842 class CProgressBarCtrlT : public TBase | |
| 6843 { | |
| 6844 public: | |
| 6845 // Constructors | |
| 6846 CProgressBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 6847 { } | |
| 6848 | |
| 6849 CProgressBarCtrlT< TBase >& operator =(HWND hWnd) | |
| 6850 { | |
| 6851 this->m_hWnd = hWnd; | |
| 6852 return *this; | |
| 6853 } | |
| 6854 | |
| 6855 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 6856 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 6857 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 6858 { | |
| 6859 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 6860 } | |
| 6861 | |
| 6862 // Attributes | |
| 6863 static LPCTSTR GetWndClassName() | |
| 6864 { | |
| 6865 return PROGRESS_CLASS; | |
| 6866 } | |
| 6867 | |
| 6868 DWORD SetRange(int nLower, int nUpper) | |
| 6869 { | |
| 6870 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6871 return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); | |
| 6872 } | |
| 6873 | |
| 6874 int SetPos(int nPos) | |
| 6875 { | |
| 6876 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6877 return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETPOS, nPos, 0L)); | |
| 6878 } | |
| 6879 | |
| 6880 int OffsetPos(int nPos) | |
| 6881 { | |
| 6882 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6883 return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_DELTAPOS, nPos, 0L)); | |
| 6884 } | |
| 6885 | |
| 6886 int SetStep(int nStep) | |
| 6887 { | |
| 6888 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6889 return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_SETSTEP, nStep, 0L)); | |
| 6890 } | |
| 6891 | |
| 6892 UINT GetPos() const | |
| 6893 { | |
| 6894 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6895 return (UINT)::SendMessage(this->m_hWnd, PBM_GETPOS, 0, 0L); | |
| 6896 } | |
| 6897 | |
| 6898 void GetRange(PPBRANGE pPBRange) const | |
| 6899 { | |
| 6900 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6901 ATLASSERT(pPBRange != NULL); | |
| 6902 ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); | |
| 6903 } | |
| 6904 | |
| 6905 void GetRange(int& nLower, int& nUpper) const | |
| 6906 { | |
| 6907 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6908 PBRANGE range = {}; | |
| 6909 ::SendMessage(this->m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); | |
| 6910 nLower = range.iLow; | |
| 6911 nUpper = range.iHigh; | |
| 6912 } | |
| 6913 | |
| 6914 int GetRangeLimit(BOOL bLowLimit) const | |
| 6915 { | |
| 6916 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6917 return (int)::SendMessage(this->m_hWnd, PBM_GETRANGE, bLowLimit, (LPARAM)NULL); | |
| 6918 } | |
| 6919 | |
| 6920 DWORD SetRange32(int nMin, int nMax) | |
| 6921 { | |
| 6922 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6923 return (DWORD)::SendMessage(this->m_hWnd, PBM_SETRANGE32, nMin, nMax); | |
| 6924 } | |
| 6925 | |
| 6926 COLORREF SetBarColor(COLORREF clr) | |
| 6927 { | |
| 6928 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6929 return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)clr); | |
| 6930 } | |
| 6931 | |
| 6932 COLORREF SetBkColor(COLORREF clr) | |
| 6933 { | |
| 6934 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6935 return (COLORREF)::SendMessage(this->m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)clr); | |
| 6936 } | |
| 6937 | |
| 6938 #ifdef PBM_SETMARQUEE | |
| 6939 BOOL SetMarquee(BOOL bMarquee, UINT uUpdateTime = 0U) | |
| 6940 { | |
| 6941 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6942 return (BOOL)::SendMessage(this->m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarquee, (LPARAM)uUpdateTime); | |
| 6943 } | |
| 6944 #endif | |
| 6945 | |
| 6946 #if (_WIN32_WINNT >= 0x0600) | |
| 6947 int GetStep() const | |
| 6948 { | |
| 6949 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6950 return (int)::SendMessage(this->m_hWnd, PBM_GETSTEP, 0, 0L); | |
| 6951 } | |
| 6952 | |
| 6953 COLORREF GetBkColor() const | |
| 6954 { | |
| 6955 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6956 return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBKCOLOR, 0, 0L); | |
| 6957 } | |
| 6958 | |
| 6959 COLORREF GetBarColor() const | |
| 6960 { | |
| 6961 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6962 return (COLORREF)::SendMessage(this->m_hWnd, PBM_GETBARCOLOR, 0, 0L); | |
| 6963 } | |
| 6964 | |
| 6965 int GetState() const | |
| 6966 { | |
| 6967 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6968 return (int)::SendMessage(this->m_hWnd, PBM_GETSTATE, 0, 0L); | |
| 6969 } | |
| 6970 | |
| 6971 int SetState(int nState) | |
| 6972 { | |
| 6973 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6974 return (int)::SendMessage(this->m_hWnd, PBM_SETSTATE, nState, 0L); | |
| 6975 } | |
| 6976 #endif // (_WIN32_WINNT >= 0x0600) | |
| 6977 | |
| 6978 // Operations | |
| 6979 int StepIt() | |
| 6980 { | |
| 6981 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 6982 return (int)(short)LOWORD(::SendMessage(this->m_hWnd, PBM_STEPIT, 0, 0L)); | |
| 6983 } | |
| 6984 }; | |
| 6985 | |
| 6986 typedef CProgressBarCtrlT<ATL::CWindow> CProgressBarCtrl; | |
| 6987 | |
| 6988 | |
| 6989 /////////////////////////////////////////////////////////////////////////////// | |
| 6990 // CHotKeyCtrl | |
| 6991 | |
| 6992 template <class TBase> | |
| 6993 class CHotKeyCtrlT : public TBase | |
| 6994 { | |
| 6995 public: | |
| 6996 // Constructors | |
| 6997 CHotKeyCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 6998 { } | |
| 6999 | |
| 7000 CHotKeyCtrlT< TBase >& operator =(HWND hWnd) | |
| 7001 { | |
| 7002 this->m_hWnd = hWnd; | |
| 7003 return *this; | |
| 7004 } | |
| 7005 | |
| 7006 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 7007 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 7008 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 7009 { | |
| 7010 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 7011 } | |
| 7012 | |
| 7013 // Attributes | |
| 7014 static LPCTSTR GetWndClassName() | |
| 7015 { | |
| 7016 return HOTKEY_CLASS; | |
| 7017 } | |
| 7018 | |
| 7019 DWORD GetHotKey() const | |
| 7020 { | |
| 7021 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7022 return (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); | |
| 7023 } | |
| 7024 | |
| 7025 void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const | |
| 7026 { | |
| 7027 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7028 DWORD dw = (DWORD)::SendMessage(this->m_hWnd, HKM_GETHOTKEY, 0, 0L); | |
| 7029 wVirtualKeyCode = LOBYTE(LOWORD(dw)); | |
| 7030 wModifiers = HIBYTE(LOWORD(dw)); | |
| 7031 } | |
| 7032 | |
| 7033 void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers) | |
| 7034 { | |
| 7035 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7036 ::SendMessage(this->m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0L); | |
| 7037 } | |
| 7038 | |
| 7039 void SetRules(WORD wInvalidComb, WORD wModifiers) | |
| 7040 { | |
| 7041 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7042 ::SendMessage(this->m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wModifiers, 0)); | |
| 7043 } | |
| 7044 }; | |
| 7045 | |
| 7046 typedef CHotKeyCtrlT<ATL::CWindow> CHotKeyCtrl; | |
| 7047 | |
| 7048 | |
| 7049 /////////////////////////////////////////////////////////////////////////////// | |
| 7050 // CAnimateCtrl | |
| 7051 | |
| 7052 template <class TBase> | |
| 7053 class CAnimateCtrlT : public TBase | |
| 7054 { | |
| 7055 public: | |
| 7056 // Constructors | |
| 7057 CAnimateCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 7058 { } | |
| 7059 | |
| 7060 CAnimateCtrlT< TBase >& operator =(HWND hWnd) | |
| 7061 { | |
| 7062 this->m_hWnd = hWnd; | |
| 7063 return *this; | |
| 7064 } | |
| 7065 | |
| 7066 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 7067 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 7068 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 7069 { | |
| 7070 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 7071 } | |
| 7072 | |
| 7073 // Attributes | |
| 7074 static LPCTSTR GetWndClassName() | |
| 7075 { | |
| 7076 return ANIMATE_CLASS; | |
| 7077 } | |
| 7078 | |
| 7079 // Operations | |
| 7080 BOOL Open(ATL::_U_STRINGorID FileName) | |
| 7081 { | |
| 7082 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7083 return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, (LPARAM)FileName.m_lpstr); | |
| 7084 } | |
| 7085 | |
| 7086 BOOL Play(UINT nFrom, UINT nTo, UINT nRep) | |
| 7087 { | |
| 7088 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7089 return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nFrom, nTo)); | |
| 7090 } | |
| 7091 | |
| 7092 BOOL Stop() | |
| 7093 { | |
| 7094 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7095 return (BOOL)::SendMessage(this->m_hWnd, ACM_STOP, 0, 0L); | |
| 7096 } | |
| 7097 | |
| 7098 BOOL Close() | |
| 7099 { | |
| 7100 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7101 return (BOOL)::SendMessage(this->m_hWnd, ACM_OPEN, 0, 0L); | |
| 7102 } | |
| 7103 | |
| 7104 BOOL Seek(UINT nTo) | |
| 7105 { | |
| 7106 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7107 return (BOOL)::SendMessage(this->m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo, nTo)); | |
| 7108 } | |
| 7109 | |
| 7110 // Vista only | |
| 7111 BOOL IsPlaying() const | |
| 7112 { | |
| 7113 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7114 return (BOOL)::SendMessage(this->m_hWnd, ACM_ISPLAYING, 0, 0L); | |
| 7115 } | |
| 7116 }; | |
| 7117 | |
| 7118 typedef CAnimateCtrlT<ATL::CWindow> CAnimateCtrl; | |
| 7119 | |
| 7120 | |
| 7121 /////////////////////////////////////////////////////////////////////////////// | |
| 7122 // CRichEditCtrl | |
| 7123 | |
| 7124 #if !defined(_UNICODE) && (_RICHEDIT_VER >= 0x0500) | |
| 7125 #undef MSFTEDIT_CLASS | |
| 7126 #define MSFTEDIT_CLASS "RICHEDIT50W" | |
| 7127 #endif | |
| 7128 | |
| 7129 template <class TBase> | |
| 7130 class CRichEditCtrlT : public TBase | |
| 7131 { | |
| 7132 public: | |
| 7133 // Constructors | |
| 7134 CRichEditCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 7135 { } | |
| 7136 | |
| 7137 CRichEditCtrlT< TBase >& operator =(HWND hWnd) | |
| 7138 { | |
| 7139 this->m_hWnd = hWnd; | |
| 7140 return *this; | |
| 7141 } | |
| 7142 | |
| 7143 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 7144 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 7145 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 7146 { | |
| 7147 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 7148 } | |
| 7149 | |
| 7150 // Attributes | |
| 7151 static LPCTSTR GetWndClassName() | |
| 7152 { | |
| 7153 #if (_RICHEDIT_VER >= 0x0500) | |
| 7154 return MSFTEDIT_CLASS; | |
| 7155 #else | |
| 7156 return RICHEDIT_CLASS; | |
| 7157 #endif | |
| 7158 } | |
| 7159 | |
| 7160 static LPCTSTR GetLibraryName() | |
| 7161 { | |
| 7162 #if (_RICHEDIT_VER >= 0x0500) | |
| 7163 return _T("MSFTEDIT.DLL"); | |
| 7164 #else | |
| 7165 return _T("RICHED20.DLL"); | |
| 7166 #endif | |
| 7167 } | |
| 7168 | |
| 7169 int GetLineCount() const | |
| 7170 { | |
| 7171 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7172 return (int)::SendMessage(this->m_hWnd, EM_GETLINECOUNT, 0, 0L); | |
| 7173 } | |
| 7174 | |
| 7175 BOOL GetModify() const | |
| 7176 { | |
| 7177 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7178 return (BOOL)::SendMessage(this->m_hWnd, EM_GETMODIFY, 0, 0L); | |
| 7179 } | |
| 7180 | |
| 7181 void SetModify(BOOL bModified = TRUE) | |
| 7182 { | |
| 7183 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7184 ::SendMessage(this->m_hWnd, EM_SETMODIFY, bModified, 0L); | |
| 7185 } | |
| 7186 | |
| 7187 void GetRect(LPRECT lpRect) const | |
| 7188 { | |
| 7189 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7190 ::SendMessage(this->m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); | |
| 7191 } | |
| 7192 | |
| 7193 DWORD GetOptions() const | |
| 7194 { | |
| 7195 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7196 return (DWORD)::SendMessage(this->m_hWnd, EM_GETOPTIONS, 0, 0L); | |
| 7197 } | |
| 7198 | |
| 7199 DWORD SetOptions(WORD wOperation, DWORD dwOptions) | |
| 7200 { | |
| 7201 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7202 return (DWORD)::SendMessage(this->m_hWnd, EM_SETOPTIONS, wOperation, dwOptions); | |
| 7203 } | |
| 7204 | |
| 7205 // NOTE: first word in lpszBuffer must contain the size of the buffer! | |
| 7206 int GetLine(int nIndex, LPTSTR lpszBuffer) const | |
| 7207 { | |
| 7208 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7209 return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); | |
| 7210 } | |
| 7211 | |
| 7212 int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const | |
| 7213 { | |
| 7214 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7215 *(LPWORD)lpszBuffer = (WORD)nMaxLength; | |
| 7216 return (int)::SendMessage(this->m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); | |
| 7217 } | |
| 7218 | |
| 7219 BOOL CanUndo() const | |
| 7220 { | |
| 7221 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7222 return (BOOL)::SendMessage(this->m_hWnd, EM_CANUNDO, 0, 0L); | |
| 7223 } | |
| 7224 | |
| 7225 BOOL CanPaste(UINT nFormat = 0) const | |
| 7226 { | |
| 7227 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7228 return (BOOL)::SendMessage(this->m_hWnd, EM_CANPASTE, nFormat, 0L); | |
| 7229 } | |
| 7230 | |
| 7231 void GetSel(LONG& nStartChar, LONG& nEndChar) const | |
| 7232 { | |
| 7233 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7234 CHARRANGE cr = {}; | |
| 7235 ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); | |
| 7236 nStartChar = cr.cpMin; | |
| 7237 nEndChar = cr.cpMax; | |
| 7238 } | |
| 7239 | |
| 7240 void GetSel(CHARRANGE &cr) const | |
| 7241 { | |
| 7242 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7243 ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); | |
| 7244 } | |
| 7245 | |
| 7246 int SetSel(LONG nStartChar, LONG nEndChar) | |
| 7247 { | |
| 7248 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7249 CHARRANGE cr = { nStartChar, nEndChar }; | |
| 7250 return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); | |
| 7251 } | |
| 7252 | |
| 7253 int SetSel(CHARRANGE &cr) | |
| 7254 { | |
| 7255 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7256 return (int)::SendMessage(this->m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); | |
| 7257 } | |
| 7258 | |
| 7259 int SetSelAll() | |
| 7260 { | |
| 7261 return SetSel(0, -1); | |
| 7262 } | |
| 7263 | |
| 7264 int SetSelNone() | |
| 7265 { | |
| 7266 return SetSel(-1, 0); | |
| 7267 } | |
| 7268 | |
| 7269 DWORD GetDefaultCharFormat(CHARFORMAT& cf) const | |
| 7270 { | |
| 7271 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7272 cf.cbSize = sizeof(CHARFORMAT); | |
| 7273 return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); | |
| 7274 } | |
| 7275 | |
| 7276 DWORD GetSelectionCharFormat(CHARFORMAT& cf) const | |
| 7277 { | |
| 7278 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7279 cf.cbSize = sizeof(CHARFORMAT); | |
| 7280 return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); | |
| 7281 } | |
| 7282 | |
| 7283 DWORD GetEventMask() const | |
| 7284 { | |
| 7285 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7286 return (DWORD)::SendMessage(this->m_hWnd, EM_GETEVENTMASK, 0, 0L); | |
| 7287 } | |
| 7288 | |
| 7289 LONG GetLimitText() const | |
| 7290 { | |
| 7291 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7292 return (LONG)::SendMessage(this->m_hWnd, EM_GETLIMITTEXT, 0, 0L); | |
| 7293 } | |
| 7294 | |
| 7295 DWORD GetParaFormat(PARAFORMAT& pf) const | |
| 7296 { | |
| 7297 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7298 pf.cbSize = sizeof(PARAFORMAT); | |
| 7299 return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); | |
| 7300 } | |
| 7301 | |
| 7302 LONG GetSelText(LPTSTR lpstrBuff) const | |
| 7303 { | |
| 7304 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7305 return (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrBuff); | |
| 7306 } | |
| 7307 | |
| 7308 BOOL GetSelTextBSTR(BSTR& bstrText) const | |
| 7309 { | |
| 7310 USES_CONVERSION; | |
| 7311 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7312 ATLASSERT(bstrText == NULL); | |
| 7313 | |
| 7314 CHARRANGE cr = {}; | |
| 7315 ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); | |
| 7316 | |
| 7317 ATL::CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; | |
| 7318 LPTSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); | |
| 7319 if(lpstrText == NULL) | |
| 7320 return FALSE; | |
| 7321 if(::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) == 0) | |
| 7322 return FALSE; | |
| 7323 | |
| 7324 bstrText = ::SysAllocString(T2W(lpstrText)); | |
| 7325 | |
| 7326 return (bstrText != NULL) ? TRUE : FALSE; | |
| 7327 } | |
| 7328 | |
| 7329 #ifdef __ATLSTR_H__ | |
| 7330 LONG GetSelText(ATL::CString& strText) const | |
| 7331 { | |
| 7332 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7333 | |
| 7334 CHARRANGE cr = {}; | |
| 7335 ::SendMessage(this->m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); | |
| 7336 | |
| 7337 LONG lLen = 0; | |
| 7338 LPTSTR lpstrText = strText.GetBufferSetLength(cr.cpMax - cr.cpMin); | |
| 7339 if(lpstrText != NULL) | |
| 7340 { | |
| 7341 lLen = (LONG)::SendMessage(this->m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText); | |
| 7342 strText.ReleaseBuffer(); | |
| 7343 } | |
| 7344 | |
| 7345 return lLen; | |
| 7346 } | |
| 7347 #endif // __ATLSTR_H__ | |
| 7348 | |
| 7349 WORD GetSelectionType() const | |
| 7350 { | |
| 7351 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7352 return (WORD)::SendMessage(this->m_hWnd, EM_SELECTIONTYPE, 0, 0L); | |
| 7353 } | |
| 7354 | |
| 7355 COLORREF SetBackgroundColor(COLORREF cr) | |
| 7356 { | |
| 7357 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7358 return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 0, cr); | |
| 7359 } | |
| 7360 | |
| 7361 COLORREF SetBackgroundColor() // sets to system background | |
| 7362 { | |
| 7363 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7364 return (COLORREF)::SendMessage(this->m_hWnd, EM_SETBKGNDCOLOR, 1, 0); | |
| 7365 } | |
| 7366 | |
| 7367 BOOL SetCharFormat(CHARFORMAT& cf, WORD wFlags) | |
| 7368 { | |
| 7369 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7370 cf.cbSize = sizeof(CHARFORMAT); | |
| 7371 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); | |
| 7372 } | |
| 7373 | |
| 7374 BOOL SetDefaultCharFormat(CHARFORMAT& cf) | |
| 7375 { | |
| 7376 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7377 cf.cbSize = sizeof(CHARFORMAT); | |
| 7378 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); | |
| 7379 } | |
| 7380 | |
| 7381 BOOL SetSelectionCharFormat(CHARFORMAT& cf) | |
| 7382 { | |
| 7383 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7384 cf.cbSize = sizeof(CHARFORMAT); | |
| 7385 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); | |
| 7386 } | |
| 7387 | |
| 7388 BOOL SetWordCharFormat(CHARFORMAT& cf) | |
| 7389 { | |
| 7390 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7391 cf.cbSize = sizeof(CHARFORMAT); | |
| 7392 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); | |
| 7393 } | |
| 7394 | |
| 7395 DWORD SetEventMask(DWORD dwEventMask) | |
| 7396 { | |
| 7397 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7398 return (DWORD)::SendMessage(this->m_hWnd, EM_SETEVENTMASK, 0, dwEventMask); | |
| 7399 } | |
| 7400 | |
| 7401 BOOL SetParaFormat(PARAFORMAT& pf) | |
| 7402 { | |
| 7403 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7404 pf.cbSize = sizeof(PARAFORMAT); | |
| 7405 return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); | |
| 7406 } | |
| 7407 | |
| 7408 BOOL SetTargetDevice(HDC hDC, int cxLineWidth) | |
| 7409 { | |
| 7410 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7411 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTARGETDEVICE, (WPARAM)hDC, cxLineWidth); | |
| 7412 } | |
| 7413 | |
| 7414 int GetTextLength() const | |
| 7415 { | |
| 7416 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7417 return (int)::SendMessage(this->m_hWnd, WM_GETTEXTLENGTH, 0, 0L); | |
| 7418 } | |
| 7419 | |
| 7420 BOOL SetReadOnly(BOOL bReadOnly = TRUE) | |
| 7421 { | |
| 7422 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7423 return (BOOL)::SendMessage(this->m_hWnd, EM_SETREADONLY, bReadOnly, 0L); | |
| 7424 } | |
| 7425 | |
| 7426 int GetFirstVisibleLine() const | |
| 7427 { | |
| 7428 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7429 return (int)::SendMessage(this->m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L); | |
| 7430 } | |
| 7431 | |
| 7432 int GetTextRange(TEXTRANGE* pTextRange) const | |
| 7433 { | |
| 7434 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7435 return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pTextRange); | |
| 7436 } | |
| 7437 | |
| 7438 int GetTextRange(LONG nStartChar, LONG nEndChar, LPTSTR lpstrText) const | |
| 7439 { | |
| 7440 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7441 TEXTRANGE tr = {}; | |
| 7442 tr.chrg.cpMin = nStartChar; | |
| 7443 tr.chrg.cpMax = nEndChar; | |
| 7444 tr.lpstrText = lpstrText; | |
| 7445 return (int)::SendMessage(this->m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); | |
| 7446 } | |
| 7447 | |
| 7448 DWORD GetDefaultCharFormat(CHARFORMAT2& cf) const | |
| 7449 { | |
| 7450 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7451 cf.cbSize = sizeof(CHARFORMAT2); | |
| 7452 return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM)&cf); | |
| 7453 } | |
| 7454 | |
| 7455 BOOL SetCharFormat(CHARFORMAT2& cf, WORD wFlags) | |
| 7456 { | |
| 7457 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7458 cf.cbSize = sizeof(CHARFORMAT2); | |
| 7459 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFlags, (LPARAM)&cf); | |
| 7460 } | |
| 7461 | |
| 7462 BOOL SetDefaultCharFormat(CHARFORMAT2& cf) | |
| 7463 { | |
| 7464 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7465 cf.cbSize = sizeof(CHARFORMAT2); | |
| 7466 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf); | |
| 7467 } | |
| 7468 | |
| 7469 DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const | |
| 7470 { | |
| 7471 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7472 cf.cbSize = sizeof(CHARFORMAT2); | |
| 7473 return (DWORD)::SendMessage(this->m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM)&cf); | |
| 7474 } | |
| 7475 | |
| 7476 BOOL SetSelectionCharFormat(CHARFORMAT2& cf) | |
| 7477 { | |
| 7478 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7479 cf.cbSize = sizeof(CHARFORMAT2); | |
| 7480 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); | |
| 7481 } | |
| 7482 | |
| 7483 BOOL SetWordCharFormat(CHARFORMAT2& cf) | |
| 7484 { | |
| 7485 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7486 cf.cbSize = sizeof(CHARFORMAT2); | |
| 7487 return (BOOL)::SendMessage(this->m_hWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); | |
| 7488 } | |
| 7489 | |
| 7490 DWORD GetParaFormat(PARAFORMAT2& pf) const | |
| 7491 { | |
| 7492 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7493 pf.cbSize = sizeof(PARAFORMAT2); | |
| 7494 return (DWORD)::SendMessage(this->m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM)&pf); | |
| 7495 } | |
| 7496 | |
| 7497 BOOL SetParaFormat(PARAFORMAT2& pf) | |
| 7498 { | |
| 7499 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7500 pf.cbSize = sizeof(PARAFORMAT2); | |
| 7501 return (BOOL)::SendMessage(this->m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf); | |
| 7502 } | |
| 7503 | |
| 7504 TEXTMODE GetTextMode() const | |
| 7505 { | |
| 7506 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7507 return (TEXTMODE)::SendMessage(this->m_hWnd, EM_GETTEXTMODE, 0, 0L); | |
| 7508 } | |
| 7509 | |
| 7510 BOOL SetTextMode(TEXTMODE enumTextMode) | |
| 7511 { | |
| 7512 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7513 return !(BOOL)::SendMessage(this->m_hWnd, EM_SETTEXTMODE, enumTextMode, 0L); | |
| 7514 } | |
| 7515 | |
| 7516 UNDONAMEID GetUndoName() const | |
| 7517 { | |
| 7518 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7519 return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETUNDONAME, 0, 0L); | |
| 7520 } | |
| 7521 | |
| 7522 UNDONAMEID GetRedoName() const | |
| 7523 { | |
| 7524 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7525 return (UNDONAMEID)::SendMessage(this->m_hWnd, EM_GETREDONAME, 0, 0L); | |
| 7526 } | |
| 7527 | |
| 7528 BOOL CanRedo() const | |
| 7529 { | |
| 7530 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7531 return (BOOL)::SendMessage(this->m_hWnd, EM_CANREDO, 0, 0L); | |
| 7532 } | |
| 7533 | |
| 7534 BOOL GetAutoURLDetect() const | |
| 7535 { | |
| 7536 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7537 return (BOOL)::SendMessage(this->m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); | |
| 7538 } | |
| 7539 | |
| 7540 BOOL SetAutoURLDetect(BOOL bAutoDetect = TRUE) | |
| 7541 { | |
| 7542 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7543 return !(BOOL)::SendMessage(this->m_hWnd, EM_AUTOURLDETECT, bAutoDetect, 0L); | |
| 7544 } | |
| 7545 | |
| 7546 // this method is deprecated, please use SetAutoURLDetect | |
| 7547 BOOL EnableAutoURLDetect(BOOL bEnable = TRUE) { return SetAutoURLDetect(bEnable); } | |
| 7548 | |
| 7549 UINT SetUndoLimit(UINT uUndoLimit) | |
| 7550 { | |
| 7551 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7552 return (UINT)::SendMessage(this->m_hWnd, EM_SETUNDOLIMIT, uUndoLimit, 0L); | |
| 7553 } | |
| 7554 | |
| 7555 void SetPalette(HPALETTE hPalette) | |
| 7556 { | |
| 7557 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7558 ::SendMessage(this->m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); | |
| 7559 } | |
| 7560 | |
| 7561 int GetTextEx(GETTEXTEX* pGetTextEx, LPTSTR lpstrText) const | |
| 7562 { | |
| 7563 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7564 return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)pGetTextEx, (LPARAM)lpstrText); | |
| 7565 } | |
| 7566 | |
| 7567 int GetTextEx(LPTSTR lpstrText, int nTextLen, DWORD dwFlags = GT_DEFAULT, UINT uCodePage = CP_ACP, LPCSTR lpDefaultChar = NULL, LPBOOL lpUsedDefChar = NULL) const | |
| 7568 { | |
| 7569 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7570 GETTEXTEX gte = {}; | |
| 7571 gte.cb = nTextLen * sizeof(TCHAR); | |
| 7572 gte.codepage = uCodePage; | |
| 7573 gte.flags = dwFlags; | |
| 7574 gte.lpDefaultChar = lpDefaultChar; | |
| 7575 gte.lpUsedDefChar = lpUsedDefChar; | |
| 7576 return (int)::SendMessage(this->m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (LPARAM)lpstrText); | |
| 7577 } | |
| 7578 | |
| 7579 int GetTextLengthEx(GETTEXTLENGTHEX* pGetTextLengthEx) const | |
| 7580 { | |
| 7581 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7582 return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pGetTextLengthEx, 0L); | |
| 7583 } | |
| 7584 | |
| 7585 int GetTextLengthEx(DWORD dwFlags = GTL_DEFAULT, UINT uCodePage = CP_ACP) const | |
| 7586 { | |
| 7587 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7588 GETTEXTLENGTHEX gtle = {}; | |
| 7589 gtle.codepage = uCodePage; | |
| 7590 gtle.flags = dwFlags; | |
| 7591 return (int)::SendMessage(this->m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)>le, 0L); | |
| 7592 } | |
| 7593 | |
| 7594 EDITWORDBREAKPROC GetWordBreakProc() const | |
| 7595 { | |
| 7596 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7597 return (EDITWORDBREAKPROC)::SendMessage(this->m_hWnd, EM_GETWORDBREAKPROC, 0, 0L); | |
| 7598 } | |
| 7599 | |
| 7600 void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) | |
| 7601 { | |
| 7602 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7603 ::SendMessage(this->m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); | |
| 7604 } | |
| 7605 | |
| 7606 int SetTextEx(SETTEXTEX* pSetTextEx, LPCTSTR lpstrText) | |
| 7607 { | |
| 7608 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7609 return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)pSetTextEx, (LPARAM)lpstrText); | |
| 7610 } | |
| 7611 | |
| 7612 int SetTextEx(LPCTSTR lpstrText, DWORD dwFlags = ST_DEFAULT, UINT uCodePage = CP_ACP) | |
| 7613 { | |
| 7614 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7615 SETTEXTEX ste = {}; | |
| 7616 ste.flags = dwFlags; | |
| 7617 ste.codepage = uCodePage; | |
| 7618 return (int)::SendMessage(this->m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpstrText); | |
| 7619 } | |
| 7620 | |
| 7621 int GetEditStyle() const | |
| 7622 { | |
| 7623 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7624 return (int)::SendMessage(this->m_hWnd, EM_GETEDITSTYLE, 0, 0L); | |
| 7625 } | |
| 7626 | |
| 7627 int SetEditStyle(int nStyle, int nMask = -1) | |
| 7628 { | |
| 7629 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7630 if(nMask == -1) | |
| 7631 nMask = nStyle; // set everything specified | |
| 7632 return (int)::SendMessage(this->m_hWnd, EM_SETEDITSTYLE, nStyle, nMask); | |
| 7633 } | |
| 7634 | |
| 7635 BOOL SetFontSize(int nFontSizeDelta) | |
| 7636 { | |
| 7637 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7638 ATLASSERT((nFontSizeDelta >= -1637) && (nFontSizeDelta <= 1638)); | |
| 7639 return (BOOL)::SendMessage(this->m_hWnd, EM_SETFONTSIZE, nFontSizeDelta, 0L); | |
| 7640 } | |
| 7641 | |
| 7642 void GetScrollPos(LPPOINT lpPoint) const | |
| 7643 { | |
| 7644 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7645 ATLASSERT(lpPoint != NULL); | |
| 7646 ::SendMessage(this->m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); | |
| 7647 } | |
| 7648 | |
| 7649 void SetScrollPos(LPPOINT lpPoint) | |
| 7650 { | |
| 7651 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7652 ATLASSERT(lpPoint != NULL); | |
| 7653 ::SendMessage(this->m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); | |
| 7654 } | |
| 7655 | |
| 7656 BOOL GetZoom(int& nNum, int& nDen) const | |
| 7657 { | |
| 7658 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7659 return (BOOL)::SendMessage(this->m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (LPARAM)&nDen); | |
| 7660 } | |
| 7661 | |
| 7662 BOOL SetZoom(int nNum, int nDen) | |
| 7663 { | |
| 7664 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7665 ATLASSERT((nNum >= 0) && (nNum <= 64)); | |
| 7666 ATLASSERT((nDen >= 0) && (nDen <= 64)); | |
| 7667 return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, nNum, nDen); | |
| 7668 } | |
| 7669 | |
| 7670 BOOL SetZoomOff() | |
| 7671 { | |
| 7672 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7673 return (BOOL)::SendMessage(this->m_hWnd, EM_SETZOOM, 0, 0L); | |
| 7674 } | |
| 7675 | |
| 7676 void SetMargins(UINT nLeft, UINT nRight, WORD wFlags = EC_LEFTMARGIN | EC_RIGHTMARGIN) | |
| 7677 { | |
| 7678 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7679 ::SendMessage(this->m_hWnd, EM_SETMARGINS, wFlags, MAKELONG(nLeft, nRight)); | |
| 7680 } | |
| 7681 | |
| 7682 WORD GetTypographyOptions() const | |
| 7683 { | |
| 7684 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7685 return (WORD)::SendMessage(this->m_hWnd, EM_GETTYPOGRAPHYOPTIONS, 0, 0L); | |
| 7686 } | |
| 7687 | |
| 7688 BOOL SetTypographyOptions(WORD wOptions, WORD wMask) const | |
| 7689 { | |
| 7690 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7691 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTYPOGRAPHYOPTIONS, wOptions, wMask); | |
| 7692 } | |
| 7693 | |
| 7694 // Operations | |
| 7695 void LimitText(LONG nChars = 0) | |
| 7696 { | |
| 7697 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7698 ::SendMessage(this->m_hWnd, EM_EXLIMITTEXT, 0, nChars); | |
| 7699 } | |
| 7700 | |
| 7701 int LineFromChar(LONG nIndex) const | |
| 7702 { | |
| 7703 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7704 return (int)::SendMessage(this->m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); | |
| 7705 } | |
| 7706 | |
| 7707 POINT PosFromChar(LONG nChar) const | |
| 7708 { | |
| 7709 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7710 POINT point = {}; | |
| 7711 ::SendMessage(this->m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); | |
| 7712 return point; | |
| 7713 } | |
| 7714 | |
| 7715 int CharFromPos(POINT pt) const | |
| 7716 { | |
| 7717 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7718 POINTL ptl = { pt.x, pt.y }; | |
| 7719 return (int)::SendMessage(this->m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&ptl); | |
| 7720 } | |
| 7721 | |
| 7722 void EmptyUndoBuffer() | |
| 7723 { | |
| 7724 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7725 ::SendMessage(this->m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); | |
| 7726 } | |
| 7727 | |
| 7728 int LineIndex(int nLine = -1) const | |
| 7729 { | |
| 7730 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7731 return (int)::SendMessage(this->m_hWnd, EM_LINEINDEX, nLine, 0L); | |
| 7732 } | |
| 7733 | |
| 7734 int LineLength(int nLine = -1) const | |
| 7735 { | |
| 7736 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7737 return (int)::SendMessage(this->m_hWnd, EM_LINELENGTH, nLine, 0L); | |
| 7738 } | |
| 7739 | |
| 7740 BOOL LineScroll(int nLines) | |
| 7741 { | |
| 7742 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7743 return (BOOL)::SendMessage(this->m_hWnd, EM_LINESCROLL, 0, nLines); | |
| 7744 } | |
| 7745 | |
| 7746 void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) | |
| 7747 { | |
| 7748 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7749 ::SendMessage(this->m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText); | |
| 7750 } | |
| 7751 | |
| 7752 void SetRect(LPCRECT lpRect) | |
| 7753 { | |
| 7754 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7755 ::SendMessage(this->m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); | |
| 7756 } | |
| 7757 | |
| 7758 BOOL DisplayBand(LPRECT pDisplayRect) | |
| 7759 { | |
| 7760 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7761 return (BOOL)::SendMessage(this->m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pDisplayRect); | |
| 7762 } | |
| 7763 | |
| 7764 LONG FindText(DWORD dwFlags, FINDTEXT& ft) const | |
| 7765 { | |
| 7766 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7767 #ifdef _UNICODE | |
| 7768 return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTW, dwFlags, (LPARAM)&ft); | |
| 7769 #else | |
| 7770 return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM)&ft); | |
| 7771 #endif | |
| 7772 } | |
| 7773 | |
| 7774 LONG FindText(DWORD dwFlags, FINDTEXTEX& ft) const | |
| 7775 { | |
| 7776 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7777 #ifdef _UNICODE | |
| 7778 return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPARAM)&ft); | |
| 7779 #else | |
| 7780 return (LONG)::SendMessage(this->m_hWnd, EM_FINDTEXTEX, dwFlags, (LPARAM)&ft); | |
| 7781 #endif | |
| 7782 } | |
| 7783 | |
| 7784 LONG FormatRange(FORMATRANGE& fr, BOOL bDisplay = TRUE) | |
| 7785 { | |
| 7786 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7787 return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)&fr); | |
| 7788 } | |
| 7789 | |
| 7790 LONG FormatRange(FORMATRANGE* pFormatRange, BOOL bDisplay = TRUE) | |
| 7791 { | |
| 7792 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7793 return (LONG)::SendMessage(this->m_hWnd, EM_FORMATRANGE, bDisplay, (LPARAM)pFormatRange); | |
| 7794 } | |
| 7795 | |
| 7796 void HideSelection(BOOL bHide = TRUE, BOOL bChangeStyle = FALSE) | |
| 7797 { | |
| 7798 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7799 ::SendMessage(this->m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); | |
| 7800 } | |
| 7801 | |
| 7802 void PasteSpecial(UINT uClipFormat, DWORD dwAspect = 0, HMETAFILE hMF = 0) | |
| 7803 { | |
| 7804 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7805 REPASTESPECIAL reps = { dwAspect, (DWORD_PTR)hMF }; | |
| 7806 ::SendMessage(this->m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&reps); | |
| 7807 } | |
| 7808 | |
| 7809 void RequestResize() | |
| 7810 { | |
| 7811 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7812 ::SendMessage(this->m_hWnd, EM_REQUESTRESIZE, 0, 0L); | |
| 7813 } | |
| 7814 | |
| 7815 LONG StreamIn(UINT uFormat, EDITSTREAM& es) | |
| 7816 { | |
| 7817 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7818 return (LONG)::SendMessage(this->m_hWnd, EM_STREAMIN, uFormat, (LPARAM)&es); | |
| 7819 } | |
| 7820 | |
| 7821 LONG StreamOut(UINT uFormat, EDITSTREAM& es) | |
| 7822 { | |
| 7823 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7824 return (LONG)::SendMessage(this->m_hWnd, EM_STREAMOUT, uFormat, (LPARAM)&es); | |
| 7825 } | |
| 7826 | |
| 7827 DWORD FindWordBreak(int nCode, LONG nStartChar) | |
| 7828 { | |
| 7829 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7830 return (DWORD)::SendMessage(this->m_hWnd, EM_FINDWORDBREAK, nCode, nStartChar); | |
| 7831 } | |
| 7832 | |
| 7833 // Additional operations | |
| 7834 void ScrollCaret() | |
| 7835 { | |
| 7836 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7837 ::SendMessage(this->m_hWnd, EM_SCROLLCARET, 0, 0L); | |
| 7838 } | |
| 7839 | |
| 7840 int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo = FALSE) | |
| 7841 { | |
| 7842 int nRet = SetSel(nInsertAfterChar, nInsertAfterChar); | |
| 7843 ReplaceSel(lpstrText, bCanUndo); | |
| 7844 return nRet; | |
| 7845 } | |
| 7846 | |
| 7847 int AppendText(LPCTSTR lpstrText, BOOL bCanUndo = FALSE) | |
| 7848 { | |
| 7849 return InsertText(this->GetWindowTextLength(), lpstrText, bCanUndo); | |
| 7850 } | |
| 7851 | |
| 7852 // Clipboard operations | |
| 7853 BOOL Undo() | |
| 7854 { | |
| 7855 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7856 return (BOOL)::SendMessage(this->m_hWnd, EM_UNDO, 0, 0L); | |
| 7857 } | |
| 7858 | |
| 7859 void Clear() | |
| 7860 { | |
| 7861 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7862 ::SendMessage(this->m_hWnd, WM_CLEAR, 0, 0L); | |
| 7863 } | |
| 7864 | |
| 7865 void Copy() | |
| 7866 { | |
| 7867 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7868 ::SendMessage(this->m_hWnd, WM_COPY, 0, 0L); | |
| 7869 } | |
| 7870 | |
| 7871 void Cut() | |
| 7872 { | |
| 7873 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7874 ::SendMessage(this->m_hWnd, WM_CUT, 0, 0L); | |
| 7875 } | |
| 7876 | |
| 7877 void Paste() | |
| 7878 { | |
| 7879 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7880 ::SendMessage(this->m_hWnd, WM_PASTE, 0, 0L); | |
| 7881 } | |
| 7882 | |
| 7883 // OLE support | |
| 7884 IRichEditOle* GetOleInterface() const | |
| 7885 { | |
| 7886 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7887 IRichEditOle *pRichEditOle = NULL; | |
| 7888 ::SendMessage(this->m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle); | |
| 7889 return pRichEditOle; | |
| 7890 } | |
| 7891 | |
| 7892 BOOL SetOleCallback(IRichEditOleCallback* pCallback) | |
| 7893 { | |
| 7894 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7895 return (BOOL)::SendMessage(this->m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM)pCallback); | |
| 7896 } | |
| 7897 | |
| 7898 BOOL Redo() | |
| 7899 { | |
| 7900 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7901 return (BOOL)::SendMessage(this->m_hWnd, EM_REDO, 0, 0L); | |
| 7902 } | |
| 7903 | |
| 7904 void StopGroupTyping() | |
| 7905 { | |
| 7906 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7907 ::SendMessage(this->m_hWnd, EM_STOPGROUPTYPING, 0, 0L); | |
| 7908 } | |
| 7909 | |
| 7910 void ShowScrollBar(int nBarType, BOOL bVisible = TRUE) | |
| 7911 { | |
| 7912 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7913 ::SendMessage(this->m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); | |
| 7914 } | |
| 7915 | |
| 7916 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) | |
| 7917 { | |
| 7918 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7919 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops); | |
| 7920 } | |
| 7921 | |
| 7922 BOOL SetTabStops() | |
| 7923 { | |
| 7924 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7925 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 0, 0L); | |
| 7926 } | |
| 7927 | |
| 7928 BOOL SetTabStops(const int& cxEachStop) // takes an 'int' | |
| 7929 { | |
| 7930 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7931 return (BOOL)::SendMessage(this->m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop); | |
| 7932 } | |
| 7933 | |
| 7934 #if (_RICHEDIT_VER >= 0x0800) | |
| 7935 AutoCorrectProc GetAutoCorrectProc() const | |
| 7936 { | |
| 7937 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7938 return (AutoCorrectProc)::SendMessage(this->m_hWnd, EM_GETAUTOCORRECTPROC, 0, 0L); | |
| 7939 } | |
| 7940 | |
| 7941 BOOL SetAutoCorrectProc(AutoCorrectProc pfn) | |
| 7942 { | |
| 7943 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7944 return (BOOL)::SendMessage(this->m_hWnd, EM_SETAUTOCORRECTPROC, (WPARAM)pfn, 0L); | |
| 7945 } | |
| 7946 | |
| 7947 BOOL CallAutoCorrectProc(WCHAR ch) | |
| 7948 { | |
| 7949 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7950 return (BOOL)::SendMessage(this->m_hWnd, EM_CALLAUTOCORRECTPROC, (WPARAM)ch, 0L); | |
| 7951 } | |
| 7952 | |
| 7953 DWORD GetEditStyleEx() const | |
| 7954 { | |
| 7955 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7956 return (DWORD)::SendMessage(this->m_hWnd, EM_GETEDITSTYLEEX, 0, 0L); | |
| 7957 } | |
| 7958 | |
| 7959 DWORD SetEditStyleEx(DWORD dwStyleEx, DWORD dwMask) | |
| 7960 { | |
| 7961 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7962 return (DWORD)::SendMessage(this->m_hWnd, EM_SETEDITSTYLEEX, dwStyleEx, dwMask); | |
| 7963 } | |
| 7964 | |
| 7965 DWORD GetStoryType(int nStoryIndex) const | |
| 7966 { | |
| 7967 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7968 return (DWORD)::SendMessage(this->m_hWnd, EM_GETSTORYTYPE, nStoryIndex, 0L); | |
| 7969 } | |
| 7970 | |
| 7971 DWORD SetStoryType(int nStoryIndex, DWORD dwStoryType) | |
| 7972 { | |
| 7973 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7974 return (DWORD)::SendMessage(this->m_hWnd, EM_SETSTORYTYPE, nStoryIndex, dwStoryType); | |
| 7975 } | |
| 7976 | |
| 7977 DWORD GetEllipsisMode() const | |
| 7978 { | |
| 7979 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7980 | |
| 7981 DWORD dwMode = 0; | |
| 7982 BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISMODE, 0, (LPARAM)&dwMode); | |
| 7983 (void)bRet; // avoid level 4 warning | |
| 7984 ATLASSERT(bRet != FALSE); | |
| 7985 | |
| 7986 return dwMode; | |
| 7987 } | |
| 7988 | |
| 7989 BOOL SetEllipsisMode(DWORD dwEllipsisMode) | |
| 7990 { | |
| 7991 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7992 return (BOOL)::SendMessage(this->m_hWnd, EM_SETELLIPSISMODE, 0, dwEllipsisMode); | |
| 7993 } | |
| 7994 | |
| 7995 BOOL GetEllipsisState() const | |
| 7996 { | |
| 7997 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 7998 return (BOOL)::SendMessage(this->m_hWnd, EM_GETELLIPSISSTATE, 0, 0L); | |
| 7999 } | |
| 8000 | |
| 8001 BOOL GetTouchOptions(int nTouchOptions) const | |
| 8002 { | |
| 8003 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8004 return (BOOL)::SendMessage(this->m_hWnd, EM_GETTOUCHOPTIONS, nTouchOptions, 0L); | |
| 8005 } | |
| 8006 | |
| 8007 void SetTouchOptions(int nTouchOptions, BOOL bEnable) | |
| 8008 { | |
| 8009 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8010 ::SendMessage(this->m_hWnd, EM_SETTOUCHOPTIONS, nTouchOptions, bEnable); | |
| 8011 } | |
| 8012 | |
| 8013 HRESULT InsertTable(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) | |
| 8014 { | |
| 8015 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8016 return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTTABLE, (WPARAM)pRowParams, (LPARAM)pCellParams); | |
| 8017 } | |
| 8018 | |
| 8019 HRESULT GetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) const | |
| 8020 { | |
| 8021 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8022 return (HRESULT)::SendMessage(this->m_hWnd, EM_GETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); | |
| 8023 } | |
| 8024 | |
| 8025 HRESULT SetTableParams(TABLEROWPARMS* pRowParams, TABLECELLPARMS* pCellParams) | |
| 8026 { | |
| 8027 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8028 return (HRESULT)::SendMessage(this->m_hWnd, EM_SETTABLEPARMS, (WPARAM)pRowParams, (LPARAM)pCellParams); | |
| 8029 } | |
| 8030 | |
| 8031 HRESULT InsertImage(RICHEDIT_IMAGE_PARAMETERS* pParams) | |
| 8032 { | |
| 8033 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8034 return (HRESULT)::SendMessage(this->m_hWnd, EM_INSERTIMAGE, 0, (LPARAM)pParams); | |
| 8035 } | |
| 8036 | |
| 8037 BOOL SetUiaName(LPCTSTR lpstrName) | |
| 8038 { | |
| 8039 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8040 return (BOOL)::SendMessage(this->m_hWnd, EM_SETUIANAME, 0, (LPARAM)lpstrName); | |
| 8041 } | |
| 8042 #endif // (_RICHEDIT_VER >= 0x0800) | |
| 8043 }; | |
| 8044 | |
| 8045 typedef CRichEditCtrlT<ATL::CWindow> CRichEditCtrl; | |
| 8046 | |
| 8047 | |
| 8048 /////////////////////////////////////////////////////////////////////////////// | |
| 8049 // CRichEditCommands - message handlers for standard EDIT commands | |
| 8050 | |
| 8051 // Chain to CRichEditCommands message map. Your class must also derive from CRichEditCtrl. | |
| 8052 // Example: | |
| 8053 // class CMyRichEdit : public CWindowImpl<CMyRichEdit, CRichEditCtrl>, | |
| 8054 // public CRichEditCommands<CMyRichEdit> | |
| 8055 // { | |
| 8056 // public: | |
| 8057 // BEGIN_MSG_MAP(CMyRichEdit) | |
| 8058 // // your handlers... | |
| 8059 // CHAIN_MSG_MAP_ALT(CRichEditCommands<CMyRichEdit>, 1) | |
| 8060 // END_MSG_MAP() | |
| 8061 // // other stuff... | |
| 8062 // }; | |
| 8063 | |
| 8064 template <class T> | |
| 8065 class CRichEditCommands : public CEditCommands< T > | |
| 8066 { | |
| 8067 public: | |
| 8068 BEGIN_MSG_MAP(CRichEditCommands< T >) | |
| 8069 ALT_MSG_MAP(1) | |
| 8070 COMMAND_ID_HANDLER(ID_EDIT_CLEAR, CEditCommands< T >::OnEditClear) | |
| 8071 COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, CEditCommands< T >::OnEditClearAll) | |
| 8072 COMMAND_ID_HANDLER(ID_EDIT_COPY, CEditCommands< T >::OnEditCopy) | |
| 8073 COMMAND_ID_HANDLER(ID_EDIT_CUT, CEditCommands< T >::OnEditCut) | |
| 8074 COMMAND_ID_HANDLER(ID_EDIT_PASTE, CEditCommands< T >::OnEditPaste) | |
| 8075 COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, CEditCommands< T >::OnEditSelectAll) | |
| 8076 COMMAND_ID_HANDLER(ID_EDIT_UNDO, CEditCommands< T >::OnEditUndo) | |
| 8077 COMMAND_ID_HANDLER(ID_EDIT_REDO, OnEditRedo) | |
| 8078 END_MSG_MAP() | |
| 8079 | |
| 8080 LRESULT OnEditRedo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | |
| 8081 { | |
| 8082 T* pT = static_cast<T*>(this); | |
| 8083 pT->Redo(); | |
| 8084 return 0; | |
| 8085 } | |
| 8086 | |
| 8087 // State (update UI) helpers | |
| 8088 BOOL CanCut() const | |
| 8089 { return HasSelection(); } | |
| 8090 | |
| 8091 BOOL CanCopy() const | |
| 8092 { return HasSelection(); } | |
| 8093 | |
| 8094 BOOL CanClear() const | |
| 8095 { return HasSelection(); } | |
| 8096 | |
| 8097 // Implementation | |
| 8098 BOOL HasSelection() const | |
| 8099 { | |
| 8100 const T* pT = static_cast<const T*>(this); | |
| 8101 return (pT->GetSelectionType() != SEL_EMPTY); | |
| 8102 } | |
| 8103 }; | |
| 8104 | |
| 8105 | |
| 8106 /////////////////////////////////////////////////////////////////////////////// | |
| 8107 // CDragListBox | |
| 8108 | |
| 8109 template <class TBase> | |
| 8110 class CDragListBoxT : public CListBoxT< TBase > | |
| 8111 { | |
| 8112 public: | |
| 8113 // Constructors | |
| 8114 CDragListBoxT(HWND hWnd = NULL) : CListBoxT< TBase >(hWnd) | |
| 8115 { } | |
| 8116 | |
| 8117 CDragListBoxT< TBase >& operator =(HWND hWnd) | |
| 8118 { | |
| 8119 this->m_hWnd = hWnd; | |
| 8120 return *this; | |
| 8121 } | |
| 8122 | |
| 8123 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 8124 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 8125 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 8126 { | |
| 8127 HWND hWnd = TBase::Create(TBase::GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 8128 if(hWnd != NULL) | |
| 8129 MakeDragList(); | |
| 8130 return hWnd; | |
| 8131 } | |
| 8132 | |
| 8133 // Operations | |
| 8134 BOOL MakeDragList() | |
| 8135 { | |
| 8136 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8137 ATLASSERT((this->GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0); | |
| 8138 return ::MakeDragList(this->m_hWnd); | |
| 8139 } | |
| 8140 | |
| 8141 int LBItemFromPt(POINT pt, BOOL bAutoScroll = TRUE) | |
| 8142 { | |
| 8143 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8144 return ::LBItemFromPt(this->m_hWnd, pt, bAutoScroll); | |
| 8145 } | |
| 8146 | |
| 8147 void DrawInsert(int nItem) | |
| 8148 { | |
| 8149 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8150 ::DrawInsert(this->GetParent(), this->m_hWnd, nItem); | |
| 8151 } | |
| 8152 | |
| 8153 static UINT GetDragListMessage() | |
| 8154 { | |
| 8155 static UINT uDragListMessage = 0; | |
| 8156 if(uDragListMessage == 0) | |
| 8157 { | |
| 8158 CStaticDataInitCriticalSectionLock lock; | |
| 8159 if(FAILED(lock.Lock())) | |
| 8160 { | |
| 8161 ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CDragListBox::GetDragListMessage.\n")); | |
| 8162 ATLASSERT(FALSE); | |
| 8163 return 0; | |
| 8164 } | |
| 8165 | |
| 8166 if(uDragListMessage == 0) | |
| 8167 uDragListMessage = ::RegisterWindowMessage(DRAGLISTMSGSTRING); | |
| 8168 | |
| 8169 lock.Unlock(); | |
| 8170 } | |
| 8171 ATLASSERT(uDragListMessage != 0); | |
| 8172 return uDragListMessage; | |
| 8173 } | |
| 8174 }; | |
| 8175 | |
| 8176 typedef CDragListBoxT<ATL::CWindow> CDragListBox; | |
| 8177 | |
| 8178 template <class T> | |
| 8179 class CDragListNotifyImpl | |
| 8180 { | |
| 8181 public: | |
| 8182 BEGIN_MSG_MAP(CDragListNotifyImpl< T >) | |
| 8183 MESSAGE_HANDLER(CDragListBox::GetDragListMessage(), OnDragListNotify) | |
| 8184 END_MSG_MAP() | |
| 8185 | |
| 8186 LRESULT OnDragListNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) | |
| 8187 { | |
| 8188 (void)uMsg; // avoid level 4 warning | |
| 8189 ATLASSERT(uMsg == CDragListBox::GetDragListMessage()); | |
| 8190 T* pT = static_cast<T*>(this); | |
| 8191 LPDRAGLISTINFO lpDragListInfo = (LPDRAGLISTINFO)lParam; | |
| 8192 LRESULT lRet = 0; | |
| 8193 switch(lpDragListInfo->uNotification) | |
| 8194 { | |
| 8195 case DL_BEGINDRAG: | |
| 8196 lRet = (LPARAM)pT->OnBeginDrag((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); | |
| 8197 break; | |
| 8198 case DL_CANCELDRAG: | |
| 8199 pT->OnCancelDrag((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); | |
| 8200 break; | |
| 8201 case DL_DRAGGING: | |
| 8202 lRet = (LPARAM)pT->OnDragging((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); | |
| 8203 break; | |
| 8204 case DL_DROPPED: | |
| 8205 pT->OnDropped((int)wParam, lpDragListInfo->hWnd, lpDragListInfo->ptCursor); | |
| 8206 break; | |
| 8207 default: | |
| 8208 ATLTRACE2(atlTraceUI, 0, _T("Unknown DragListBox notification\n")); | |
| 8209 bHandled = FALSE; // don't handle it | |
| 8210 break; | |
| 8211 } | |
| 8212 return lRet; | |
| 8213 } | |
| 8214 | |
| 8215 // Overrideables | |
| 8216 BOOL OnBeginDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) | |
| 8217 { | |
| 8218 return TRUE; // allow dragging | |
| 8219 } | |
| 8220 | |
| 8221 void OnCancelDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) | |
| 8222 { | |
| 8223 // nothing to do | |
| 8224 } | |
| 8225 | |
| 8226 int OnDragging(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) | |
| 8227 { | |
| 8228 return 0; // don't change cursor | |
| 8229 } | |
| 8230 | |
| 8231 void OnDropped(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/) | |
| 8232 { | |
| 8233 // nothing to do | |
| 8234 } | |
| 8235 }; | |
| 8236 | |
| 8237 | |
| 8238 /////////////////////////////////////////////////////////////////////////////// | |
| 8239 // CReBarCtrl | |
| 8240 | |
| 8241 template <class TBase> | |
| 8242 class CReBarCtrlT : public TBase | |
| 8243 { | |
| 8244 public: | |
| 8245 // Constructors | |
| 8246 CReBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 8247 { } | |
| 8248 | |
| 8249 CReBarCtrlT< TBase >& operator =(HWND hWnd) | |
| 8250 { | |
| 8251 this->m_hWnd = hWnd; | |
| 8252 return *this; | |
| 8253 } | |
| 8254 | |
| 8255 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 8256 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 8257 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 8258 { | |
| 8259 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 8260 } | |
| 8261 | |
| 8262 // Attributes | |
| 8263 static LPCTSTR GetWndClassName() | |
| 8264 { | |
| 8265 return REBARCLASSNAME; | |
| 8266 } | |
| 8267 | |
| 8268 UINT GetBandCount() const | |
| 8269 { | |
| 8270 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8271 return (UINT)::SendMessage(this->m_hWnd, RB_GETBANDCOUNT, 0, 0L); | |
| 8272 } | |
| 8273 | |
| 8274 BOOL GetBandInfo(int nBand, LPREBARBANDINFO lprbbi) const | |
| 8275 { | |
| 8276 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8277 return (BOOL)::SendMessage(this->m_hWnd, RB_GETBANDINFO, nBand, (LPARAM)lprbbi); | |
| 8278 } | |
| 8279 | |
| 8280 BOOL SetBandInfo(int nBand, LPREBARBANDINFO lprbbi) | |
| 8281 { | |
| 8282 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8283 return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDINFO, nBand, (LPARAM)lprbbi); | |
| 8284 } | |
| 8285 | |
| 8286 BOOL GetBarInfo(LPREBARINFO lprbi) const | |
| 8287 { | |
| 8288 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8289 return (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)lprbi); | |
| 8290 } | |
| 8291 | |
| 8292 BOOL SetBarInfo(LPREBARINFO lprbi) | |
| 8293 { | |
| 8294 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8295 return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)lprbi); | |
| 8296 } | |
| 8297 | |
| 8298 CImageList GetImageList() const | |
| 8299 { | |
| 8300 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8301 REBARINFO rbi = {}; | |
| 8302 rbi.cbSize = sizeof(REBARINFO); | |
| 8303 rbi.fMask = RBIM_IMAGELIST; | |
| 8304 BOOL bRet = (BOOL)::SendMessage(this->m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi); | |
| 8305 return CImageList((bRet != FALSE) ? rbi.himl : NULL); | |
| 8306 } | |
| 8307 | |
| 8308 BOOL SetImageList(HIMAGELIST hImageList) | |
| 8309 { | |
| 8310 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8311 REBARINFO rbi = {}; | |
| 8312 rbi.cbSize = sizeof(REBARINFO); | |
| 8313 rbi.fMask = RBIM_IMAGELIST; | |
| 8314 rbi.himl = hImageList; | |
| 8315 return (BOOL)::SendMessage(this->m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rbi); | |
| 8316 } | |
| 8317 | |
| 8318 UINT GetRowCount() const | |
| 8319 { | |
| 8320 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8321 return (UINT)::SendMessage(this->m_hWnd, RB_GETROWCOUNT, 0, 0L); | |
| 8322 } | |
| 8323 | |
| 8324 UINT GetRowHeight(int nBand) const | |
| 8325 { | |
| 8326 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8327 return (UINT)::SendMessage(this->m_hWnd, RB_GETROWHEIGHT, nBand, 0L); | |
| 8328 } | |
| 8329 | |
| 8330 COLORREF GetTextColor() const | |
| 8331 { | |
| 8332 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8333 return (COLORREF)::SendMessage(this->m_hWnd, RB_GETTEXTCOLOR, 0, 0L); | |
| 8334 } | |
| 8335 | |
| 8336 COLORREF SetTextColor(COLORREF clr) | |
| 8337 { | |
| 8338 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8339 return (COLORREF)::SendMessage(this->m_hWnd, RB_SETTEXTCOLOR, 0, (LPARAM)clr); | |
| 8340 } | |
| 8341 | |
| 8342 COLORREF GetBkColor() const | |
| 8343 { | |
| 8344 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8345 return (COLORREF)::SendMessage(this->m_hWnd, RB_GETBKCOLOR, 0, 0L); | |
| 8346 } | |
| 8347 | |
| 8348 COLORREF SetBkColor(COLORREF clr) | |
| 8349 { | |
| 8350 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8351 return (COLORREF)::SendMessage(this->m_hWnd, RB_SETBKCOLOR, 0, (LPARAM)clr); | |
| 8352 } | |
| 8353 | |
| 8354 UINT GetBarHeight() const | |
| 8355 { | |
| 8356 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8357 return (UINT)::SendMessage(this->m_hWnd, RB_GETBARHEIGHT, 0, 0L); | |
| 8358 } | |
| 8359 | |
| 8360 BOOL GetRect(int nBand, LPRECT lpRect) const | |
| 8361 { | |
| 8362 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8363 return (BOOL)::SendMessage(this->m_hWnd, RB_GETRECT, nBand, (LPARAM)lpRect); | |
| 8364 } | |
| 8365 | |
| 8366 CToolTipCtrl GetToolTips() const | |
| 8367 { | |
| 8368 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8369 return CToolTipCtrl((HWND)::SendMessage(this->m_hWnd, RB_GETTOOLTIPS, 0, 0L)); | |
| 8370 } | |
| 8371 | |
| 8372 void SetToolTips(HWND hwndToolTip) | |
| 8373 { | |
| 8374 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8375 ::SendMessage(this->m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); | |
| 8376 } | |
| 8377 | |
| 8378 void GetBandBorders(int nBand, LPRECT lpRect) const | |
| 8379 { | |
| 8380 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8381 ATLASSERT(lpRect != NULL); | |
| 8382 ::SendMessage(this->m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); | |
| 8383 } | |
| 8384 | |
| 8385 BOOL GetColorScheme(LPCOLORSCHEME lpColorScheme) const | |
| 8386 { | |
| 8387 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8388 ATLASSERT(lpColorScheme != NULL); | |
| 8389 return (BOOL)::SendMessage(this->m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM)lpColorScheme); | |
| 8390 } | |
| 8391 | |
| 8392 void SetColorScheme(LPCOLORSCHEME lpColorScheme) | |
| 8393 { | |
| 8394 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8395 ATLASSERT(lpColorScheme != NULL); | |
| 8396 ::SendMessage(this->m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorScheme); | |
| 8397 } | |
| 8398 | |
| 8399 HPALETTE GetPalette() const | |
| 8400 { | |
| 8401 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8402 return (HPALETTE)::SendMessage(this->m_hWnd, RB_GETPALETTE, 0, 0L); | |
| 8403 } | |
| 8404 | |
| 8405 HPALETTE SetPalette(HPALETTE hPalette) | |
| 8406 { | |
| 8407 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8408 return (HPALETTE)::SendMessage(this->m_hWnd, RB_SETPALETTE, 0, (LPARAM)hPalette); | |
| 8409 } | |
| 8410 | |
| 8411 BOOL GetUnicodeFormat() const | |
| 8412 { | |
| 8413 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8414 return (BOOL)::SendMessage(this->m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); | |
| 8415 } | |
| 8416 | |
| 8417 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 8418 { | |
| 8419 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8420 return (BOOL)::SendMessage(this->m_hWnd, RB_SETUNICODEFORMAT, bUnicode, 0L); | |
| 8421 } | |
| 8422 | |
| 8423 // requires uxtheme.h to be included to use MARGINS struct | |
| 8424 #ifndef _UXTHEME_H_ | |
| 8425 typedef struct _MARGINS* PMARGINS; | |
| 8426 #endif // !_UXTHEME_H_ | |
| 8427 void GetBandMargins(PMARGINS pMargins) const | |
| 8428 { | |
| 8429 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8430 ::SendMessage(this->m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); | |
| 8431 } | |
| 8432 | |
| 8433 void SetWindowTheme(LPCWSTR lpstrTheme) | |
| 8434 { | |
| 8435 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8436 ::SendMessage(this->m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); | |
| 8437 } | |
| 8438 | |
| 8439 DWORD GetExtendedStyle() const | |
| 8440 { | |
| 8441 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8442 return (DWORD)::SendMessage(this->m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); | |
| 8443 } | |
| 8444 | |
| 8445 DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) | |
| 8446 { | |
| 8447 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8448 return (DWORD)::SendMessage(this->m_hWnd, RB_SETEXTENDEDSTYLE, dwMask, dwStyle); | |
| 8449 } | |
| 8450 | |
| 8451 // Operations | |
| 8452 BOOL InsertBand(int nBand, LPREBARBANDINFO lprbbi) | |
| 8453 { | |
| 8454 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8455 return (BOOL)::SendMessage(this->m_hWnd, RB_INSERTBAND, nBand, (LPARAM)lprbbi); | |
| 8456 } | |
| 8457 | |
| 8458 BOOL AddBand(LPREBARBANDINFO lprbbi) | |
| 8459 { | |
| 8460 return InsertBand(-1, lprbbi); | |
| 8461 } | |
| 8462 | |
| 8463 BOOL DeleteBand(int nBand) | |
| 8464 { | |
| 8465 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8466 return (BOOL)::SendMessage(this->m_hWnd, RB_DELETEBAND, nBand, 0L); | |
| 8467 } | |
| 8468 | |
| 8469 ATL::CWindow SetNotifyWnd(HWND hWnd) | |
| 8470 { | |
| 8471 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8472 return ATL::CWindow((HWND)::SendMessage(this->m_hWnd, RB_SETPARENT, (WPARAM)hWnd, 0L)); | |
| 8473 } | |
| 8474 | |
| 8475 void BeginDrag(int nBand, DWORD dwPos) | |
| 8476 { | |
| 8477 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8478 ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, dwPos); | |
| 8479 } | |
| 8480 | |
| 8481 void BeginDrag(int nBand, int xPos, int yPos) | |
| 8482 { | |
| 8483 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8484 ::SendMessage(this->m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos)); | |
| 8485 } | |
| 8486 | |
| 8487 void EndDrag() | |
| 8488 { | |
| 8489 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8490 ::SendMessage(this->m_hWnd, RB_ENDDRAG, 0, 0L); | |
| 8491 } | |
| 8492 | |
| 8493 void DragMove(DWORD dwPos) | |
| 8494 { | |
| 8495 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8496 ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, dwPos); | |
| 8497 } | |
| 8498 | |
| 8499 void DragMove(int xPos, int yPos) | |
| 8500 { | |
| 8501 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8502 ::SendMessage(this->m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); | |
| 8503 } | |
| 8504 | |
| 8505 void GetDropTarget(IDropTarget** ppDropTarget) const | |
| 8506 { | |
| 8507 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8508 ::SendMessage(this->m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget); | |
| 8509 } | |
| 8510 | |
| 8511 void MaximizeBand(int nBand, BOOL bIdeal = FALSE) | |
| 8512 { | |
| 8513 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8514 ::SendMessage(this->m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); | |
| 8515 } | |
| 8516 | |
| 8517 void MinimizeBand(int nBand) | |
| 8518 { | |
| 8519 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8520 ::SendMessage(this->m_hWnd, RB_MINIMIZEBAND, nBand, 0L); | |
| 8521 } | |
| 8522 | |
| 8523 BOOL SizeToRect(LPRECT lpRect) | |
| 8524 { | |
| 8525 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8526 return (BOOL)::SendMessage(this->m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpRect); | |
| 8527 } | |
| 8528 | |
| 8529 int IdToIndex(UINT uBandID) const | |
| 8530 { | |
| 8531 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8532 return (int)::SendMessage(this->m_hWnd, RB_IDTOINDEX, uBandID, 0L); | |
| 8533 } | |
| 8534 | |
| 8535 int HitTest(LPRBHITTESTINFO lprbht) const | |
| 8536 { | |
| 8537 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8538 return (int)::SendMessage(this->m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht); | |
| 8539 } | |
| 8540 | |
| 8541 BOOL ShowBand(int nBand, BOOL bShow) | |
| 8542 { | |
| 8543 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8544 return (BOOL)::SendMessage(this->m_hWnd, RB_SHOWBAND, nBand, bShow); | |
| 8545 } | |
| 8546 | |
| 8547 BOOL MoveBand(int nBand, int nNewPos) | |
| 8548 { | |
| 8549 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8550 ATLASSERT((nNewPos >= 0) && (nNewPos <= ((int)GetBandCount() - 1))); | |
| 8551 return (BOOL)::SendMessage(this->m_hWnd, RB_MOVEBAND, nBand, nNewPos); | |
| 8552 } | |
| 8553 | |
| 8554 void PushChevron(int nBand, LPARAM lAppValue) | |
| 8555 { | |
| 8556 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8557 ::SendMessage(this->m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); | |
| 8558 } | |
| 8559 | |
| 8560 // Extra operations | |
| 8561 void LockBands(bool bLock) | |
| 8562 { | |
| 8563 int nBandCount = GetBandCount(); | |
| 8564 for(int i =0; i < nBandCount; i++) | |
| 8565 { | |
| 8566 REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO() }; | |
| 8567 rbbi.fMask = RBBIM_STYLE; | |
| 8568 BOOL bRet = GetBandInfo(i, &rbbi); | |
| 8569 ATLASSERT(bRet); | |
| 8570 | |
| 8571 if((rbbi.fStyle & RBBS_GRIPPERALWAYS) == 0) | |
| 8572 { | |
| 8573 rbbi.fStyle |= RBBS_GRIPPERALWAYS; | |
| 8574 bRet = SetBandInfo(i, &rbbi); | |
| 8575 ATLASSERT(bRet); | |
| 8576 rbbi.fStyle &= ~RBBS_GRIPPERALWAYS; | |
| 8577 } | |
| 8578 | |
| 8579 if(bLock) | |
| 8580 rbbi.fStyle |= RBBS_NOGRIPPER; | |
| 8581 else | |
| 8582 rbbi.fStyle &= ~RBBS_NOGRIPPER; | |
| 8583 | |
| 8584 bRet = SetBandInfo(i, &rbbi); | |
| 8585 ATLASSERT(bRet); | |
| 8586 } | |
| 8587 } | |
| 8588 | |
| 8589 #if (_WIN32_WINNT >= 0x0600) | |
| 8590 BOOL SetBandWidth(int nBand, int cxWidth) | |
| 8591 { | |
| 8592 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8593 return (BOOL)::SendMessage(this->m_hWnd, RB_SETBANDWIDTH, nBand, cxWidth); | |
| 8594 } | |
| 8595 #endif // (_WIN32_WINNT >= 0x0600) | |
| 8596 }; | |
| 8597 | |
| 8598 typedef CReBarCtrlT<ATL::CWindow> CReBarCtrl; | |
| 8599 | |
| 8600 | |
| 8601 /////////////////////////////////////////////////////////////////////////////// | |
| 8602 // CComboBoxEx | |
| 8603 | |
| 8604 template <class TBase> | |
| 8605 class CComboBoxExT : public CComboBoxT< TBase > | |
| 8606 { | |
| 8607 public: | |
| 8608 // Constructors | |
| 8609 CComboBoxExT(HWND hWnd = NULL) : CComboBoxT< TBase >(hWnd) | |
| 8610 { } | |
| 8611 | |
| 8612 CComboBoxExT< TBase >& operator =(HWND hWnd) | |
| 8613 { | |
| 8614 this->m_hWnd = hWnd; | |
| 8615 return *this; | |
| 8616 } | |
| 8617 | |
| 8618 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 8619 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 8620 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 8621 { | |
| 8622 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 8623 } | |
| 8624 | |
| 8625 // Attributes | |
| 8626 static LPCTSTR GetWndClassName() | |
| 8627 { | |
| 8628 return WC_COMBOBOXEX; | |
| 8629 } | |
| 8630 | |
| 8631 CImageList GetImageList() const | |
| 8632 { | |
| 8633 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8634 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_GETIMAGELIST, 0, 0L)); | |
| 8635 } | |
| 8636 | |
| 8637 CImageList SetImageList(HIMAGELIST hImageList) | |
| 8638 { | |
| 8639 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8640 return CImageList((HIMAGELIST)::SendMessage(this->m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)hImageList)); | |
| 8641 } | |
| 8642 | |
| 8643 DWORD GetExtendedStyle() const | |
| 8644 { | |
| 8645 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8646 return (DWORD)::SendMessage(this->m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L); | |
| 8647 } | |
| 8648 | |
| 8649 DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) | |
| 8650 { | |
| 8651 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8652 return (DWORD)::SendMessage(this->m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExMask, dwExStyle); | |
| 8653 } | |
| 8654 | |
| 8655 BOOL GetUnicodeFormat() const | |
| 8656 { | |
| 8657 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8658 return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L); | |
| 8659 } | |
| 8660 | |
| 8661 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 8662 { | |
| 8663 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8664 return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 8665 } | |
| 8666 | |
| 8667 void SetWindowTheme(LPCWSTR lpstrTheme) | |
| 8668 { | |
| 8669 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8670 ::SendMessage(this->m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); | |
| 8671 } | |
| 8672 | |
| 8673 // Operations | |
| 8674 int InsertItem(const COMBOBOXEXITEM* lpcCBItem) | |
| 8675 { | |
| 8676 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8677 return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lpcCBItem); | |
| 8678 } | |
| 8679 | |
| 8680 int InsertItem(UINT nMask, int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, | |
| 8681 int iIndent, int iOverlay, LPARAM lParam) | |
| 8682 { | |
| 8683 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8684 COMBOBOXEXITEM cbex = {}; | |
| 8685 cbex.mask = nMask; | |
| 8686 cbex.iItem = nIndex; | |
| 8687 cbex.pszText = (LPTSTR) lpszItem; | |
| 8688 cbex.iImage = nImage; | |
| 8689 cbex.iSelectedImage = nSelImage; | |
| 8690 cbex.iIndent = iIndent; | |
| 8691 cbex.iOverlay = iOverlay; | |
| 8692 cbex.lParam = lParam; | |
| 8693 return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); | |
| 8694 } | |
| 8695 | |
| 8696 int InsertItem(int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LPARAM lParam = 0) | |
| 8697 { | |
| 8698 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8699 COMBOBOXEXITEM cbex = {}; | |
| 8700 cbex.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_INDENT | CBEIF_LPARAM; | |
| 8701 cbex.iItem = nIndex; | |
| 8702 cbex.pszText = (LPTSTR) lpszItem; | |
| 8703 cbex.iImage = nImage; | |
| 8704 cbex.iSelectedImage = nSelImage; | |
| 8705 cbex.iIndent = iIndent; | |
| 8706 cbex.lParam = lParam; | |
| 8707 return (int)::SendMessage(this->m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&cbex); | |
| 8708 } | |
| 8709 | |
| 8710 int AddItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, int iOverlay, LPARAM lParam) | |
| 8711 { | |
| 8712 return InsertItem(nMask, -1, lpszItem, nImage, nSelImage, iIndent, iOverlay, lParam); | |
| 8713 } | |
| 8714 | |
| 8715 int AddItem(LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LPARAM lParam = 0) | |
| 8716 { | |
| 8717 return InsertItem(-1, lpszItem, nImage, nSelImage, iIndent, lParam); | |
| 8718 } | |
| 8719 | |
| 8720 int DeleteItem(int nIndex) | |
| 8721 { | |
| 8722 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8723 return (int)::SendMessage(this->m_hWnd, CBEM_DELETEITEM, nIndex, 0L); | |
| 8724 } | |
| 8725 | |
| 8726 BOOL GetItem(PCOMBOBOXEXITEM pCBItem) const | |
| 8727 { | |
| 8728 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8729 return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBItem); | |
| 8730 } | |
| 8731 | |
| 8732 BOOL SetItem(const COMBOBOXEXITEM* lpcCBItem) | |
| 8733 { | |
| 8734 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8735 return (BOOL)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcCBItem); | |
| 8736 } | |
| 8737 | |
| 8738 int SetItem(int nIndex, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, | |
| 8739 int iIndent, int iOverlay, LPARAM lParam) | |
| 8740 { | |
| 8741 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8742 COMBOBOXEXITEM cbex = {}; | |
| 8743 cbex.mask = nMask; | |
| 8744 cbex.iItem = nIndex; | |
| 8745 cbex.pszText = (LPTSTR) lpszItem; | |
| 8746 cbex.iImage = nImage; | |
| 8747 cbex.iSelectedImage = nSelImage; | |
| 8748 cbex.iIndent = iIndent; | |
| 8749 cbex.iOverlay = iOverlay; | |
| 8750 cbex.lParam = lParam; | |
| 8751 return (int)::SendMessage(this->m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex); | |
| 8752 } | |
| 8753 | |
| 8754 BOOL GetItemText(int nIndex, LPTSTR lpszItem, int nLen) const | |
| 8755 { | |
| 8756 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8757 ATLASSERT(lpszItem != NULL); | |
| 8758 | |
| 8759 COMBOBOXEXITEM cbex = {}; | |
| 8760 cbex.mask = CBEIF_TEXT; | |
| 8761 cbex.iItem = nIndex; | |
| 8762 cbex.pszText = lpszItem; | |
| 8763 cbex.cchTextMax = nLen; | |
| 8764 | |
| 8765 return (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); | |
| 8766 } | |
| 8767 | |
| 8768 BOOL GetItemText(int nIndex, BSTR& bstrText) const | |
| 8769 { | |
| 8770 USES_CONVERSION; | |
| 8771 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8772 ATLASSERT(bstrText == NULL); | |
| 8773 | |
| 8774 COMBOBOXEXITEM cbex = {}; | |
| 8775 cbex.mask = CBEIF_TEXT; | |
| 8776 cbex.iItem = nIndex; | |
| 8777 | |
| 8778 LPTSTR lpstrText = NULL; | |
| 8779 BOOL bRet = FALSE; | |
| 8780 for(int nLen = 256; ; nLen *= 2) | |
| 8781 { | |
| 8782 ATLTRY(lpstrText = new TCHAR[nLen]); | |
| 8783 if(lpstrText == NULL) | |
| 8784 break; | |
| 8785 lpstrText[0] = NULL; | |
| 8786 cbex.pszText = lpstrText; | |
| 8787 cbex.cchTextMax = nLen; | |
| 8788 bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); | |
| 8789 if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) | |
| 8790 break; | |
| 8791 delete [] lpstrText; | |
| 8792 lpstrText = NULL; | |
| 8793 } | |
| 8794 | |
| 8795 if(lpstrText != NULL) | |
| 8796 { | |
| 8797 if(bRet) | |
| 8798 bstrText = ::SysAllocString(T2OLE(lpstrText)); | |
| 8799 delete [] lpstrText; | |
| 8800 } | |
| 8801 | |
| 8802 return (bstrText != NULL) ? TRUE : FALSE; | |
| 8803 } | |
| 8804 | |
| 8805 #ifdef __ATLSTR_H__ | |
| 8806 BOOL GetItemText(int nIndex, ATL::CString& strText) const | |
| 8807 { | |
| 8808 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8809 | |
| 8810 COMBOBOXEXITEM cbex = {}; | |
| 8811 cbex.mask = CBEIF_TEXT; | |
| 8812 cbex.iItem = nIndex; | |
| 8813 | |
| 8814 strText.Empty(); | |
| 8815 BOOL bRet = FALSE; | |
| 8816 for(int nLen = 256; ; nLen *= 2) | |
| 8817 { | |
| 8818 cbex.pszText = strText.GetBufferSetLength(nLen); | |
| 8819 if(cbex.pszText == NULL) | |
| 8820 { | |
| 8821 bRet = FALSE; | |
| 8822 break; | |
| 8823 } | |
| 8824 cbex.cchTextMax = nLen; | |
| 8825 bRet = (BOOL)::SendMessage(this->m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbex); | |
| 8826 if(!bRet || (lstrlen(cbex.pszText) < (nLen - 1))) | |
| 8827 break; | |
| 8828 } | |
| 8829 strText.ReleaseBuffer(); | |
| 8830 return bRet; | |
| 8831 } | |
| 8832 #endif // __ATLSTR_H__ | |
| 8833 | |
| 8834 BOOL SetItemText(int nIndex, LPCTSTR lpszItem) | |
| 8835 { | |
| 8836 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8837 return SetItem(nIndex, CBEIF_TEXT, lpszItem, 0, 0, 0, 0, 0); | |
| 8838 } | |
| 8839 | |
| 8840 CComboBox GetComboCtrl() const | |
| 8841 { | |
| 8842 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8843 return CComboBox((HWND)::SendMessage(this->m_hWnd, CBEM_GETCOMBOCONTROL, 0, 0L)); | |
| 8844 } | |
| 8845 | |
| 8846 CEdit GetEditCtrl() const | |
| 8847 { | |
| 8848 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8849 return CEdit((HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0L)); | |
| 8850 } | |
| 8851 | |
| 8852 BOOL HasEditChanged() const | |
| 8853 { | |
| 8854 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8855 return (BOOL)::SendMessage(this->m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); | |
| 8856 } | |
| 8857 | |
| 8858 // Non-functional | |
| 8859 int AddString(LPCTSTR /*lpszItem*/) | |
| 8860 { | |
| 8861 ATLASSERT(FALSE); // Not available in CComboBoxEx; use InsertItem | |
| 8862 return 0; | |
| 8863 } | |
| 8864 | |
| 8865 int InsertString(int /*nIndex*/, LPCTSTR /*lpszString*/) | |
| 8866 { | |
| 8867 ATLASSERT(FALSE); // Not available in CComboBoxEx; use InsertItem | |
| 8868 return 0; | |
| 8869 } | |
| 8870 | |
| 8871 int Dir(UINT /*attr*/, LPCTSTR /*lpszWildCard*/) | |
| 8872 { | |
| 8873 ATLASSERT(FALSE); // Not available in CComboBoxEx | |
| 8874 return 0; | |
| 8875 } | |
| 8876 | |
| 8877 int FindString(int /*nStartAfter*/, LPCTSTR /*lpszString*/) const | |
| 8878 { | |
| 8879 ATLASSERT(FALSE); // Not available in CComboBoxEx; try FindStringExact | |
| 8880 return 0; | |
| 8881 } | |
| 8882 }; | |
| 8883 | |
| 8884 typedef CComboBoxExT<ATL::CWindow> CComboBoxEx; | |
| 8885 | |
| 8886 | |
| 8887 /////////////////////////////////////////////////////////////////////////////// | |
| 8888 // CMonthCalendarCtrl | |
| 8889 | |
| 8890 template <class TBase> | |
| 8891 class CMonthCalendarCtrlT : public TBase | |
| 8892 { | |
| 8893 public: | |
| 8894 // Constructors | |
| 8895 CMonthCalendarCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 8896 { } | |
| 8897 | |
| 8898 CMonthCalendarCtrlT< TBase >& operator =(HWND hWnd) | |
| 8899 { | |
| 8900 this->m_hWnd = hWnd; | |
| 8901 return *this; | |
| 8902 } | |
| 8903 | |
| 8904 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 8905 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 8906 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 8907 { | |
| 8908 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 8909 } | |
| 8910 | |
| 8911 // Attributes | |
| 8912 static LPCTSTR GetWndClassName() | |
| 8913 { | |
| 8914 return MONTHCAL_CLASS; | |
| 8915 } | |
| 8916 | |
| 8917 COLORREF GetColor(int nColorType) const | |
| 8918 { | |
| 8919 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8920 return (COLORREF)::SendMessage(this->m_hWnd, MCM_GETCOLOR, nColorType, 0L); | |
| 8921 } | |
| 8922 | |
| 8923 COLORREF SetColor(int nColorType, COLORREF clr) | |
| 8924 { | |
| 8925 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8926 return (COLORREF)::SendMessage(this->m_hWnd, MCM_SETCOLOR, nColorType, clr); | |
| 8927 } | |
| 8928 | |
| 8929 BOOL GetCurSel(LPSYSTEMTIME lpSysTime) const | |
| 8930 { | |
| 8931 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8932 return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpSysTime); | |
| 8933 } | |
| 8934 | |
| 8935 BOOL SetCurSel(LPSYSTEMTIME lpSysTime) | |
| 8936 { | |
| 8937 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8938 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpSysTime); | |
| 8939 } | |
| 8940 | |
| 8941 int GetFirstDayOfWeek(BOOL* pbLocaleVal = NULL) const | |
| 8942 { | |
| 8943 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8944 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_GETFIRSTDAYOFWEEK, 0, 0L); | |
| 8945 if(pbLocaleVal != NULL) | |
| 8946 *pbLocaleVal = (BOOL)HIWORD(dwRet); | |
| 8947 return (int)(short)LOWORD(dwRet); | |
| 8948 } | |
| 8949 | |
| 8950 int SetFirstDayOfWeek(int nDay, BOOL* pbLocaleVal = NULL) | |
| 8951 { | |
| 8952 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8953 DWORD dwRet = (DWORD)::SendMessage(this->m_hWnd, MCM_SETFIRSTDAYOFWEEK, 0, nDay); | |
| 8954 if(pbLocaleVal != NULL) | |
| 8955 *pbLocaleVal = (BOOL)HIWORD(dwRet); | |
| 8956 return (int)(short)LOWORD(dwRet); | |
| 8957 } | |
| 8958 | |
| 8959 int GetMaxSelCount() const | |
| 8960 { | |
| 8961 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8962 return (int)::SendMessage(this->m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); | |
| 8963 } | |
| 8964 | |
| 8965 BOOL SetMaxSelCount(int nMax) | |
| 8966 { | |
| 8967 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8968 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L); | |
| 8969 } | |
| 8970 | |
| 8971 int GetMonthDelta() const | |
| 8972 { | |
| 8973 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8974 return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHDELTA, 0, 0L); | |
| 8975 } | |
| 8976 | |
| 8977 int SetMonthDelta(int nDelta) | |
| 8978 { | |
| 8979 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8980 return (int)::SendMessage(this->m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L); | |
| 8981 } | |
| 8982 | |
| 8983 DWORD GetRange(LPSYSTEMTIME lprgSysTimeArray) const | |
| 8984 { | |
| 8985 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8986 return (DWORD)::SendMessage(this->m_hWnd, MCM_GETRANGE, 0, (LPARAM)lprgSysTimeArray); | |
| 8987 } | |
| 8988 | |
| 8989 BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) | |
| 8990 { | |
| 8991 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8992 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETRANGE, dwFlags, (LPARAM)lprgSysTimeArray); | |
| 8993 } | |
| 8994 | |
| 8995 BOOL GetSelRange(LPSYSTEMTIME lprgSysTimeArray) const | |
| 8996 { | |
| 8997 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 8998 return (BOOL)::SendMessage(this->m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)lprgSysTimeArray); | |
| 8999 } | |
| 9000 | |
| 9001 BOOL SetSelRange(LPSYSTEMTIME lprgSysTimeArray) | |
| 9002 { | |
| 9003 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9004 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)lprgSysTimeArray); | |
| 9005 } | |
| 9006 | |
| 9007 BOOL GetToday(LPSYSTEMTIME lpSysTime) const | |
| 9008 { | |
| 9009 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9010 return (BOOL)::SendMessage(this->m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSysTime); | |
| 9011 } | |
| 9012 | |
| 9013 void SetToday(LPSYSTEMTIME lpSysTime) | |
| 9014 { | |
| 9015 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9016 ::SendMessage(this->m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); | |
| 9017 } | |
| 9018 | |
| 9019 BOOL GetMinReqRect(LPRECT lpRectInfo) const | |
| 9020 { | |
| 9021 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9022 return (BOOL)::SendMessage(this->m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)lpRectInfo); | |
| 9023 } | |
| 9024 | |
| 9025 int GetMaxTodayWidth() const | |
| 9026 { | |
| 9027 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9028 return (int)::SendMessage(this->m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); | |
| 9029 } | |
| 9030 | |
| 9031 BOOL GetUnicodeFormat() const | |
| 9032 { | |
| 9033 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9034 return (BOOL)::SendMessage(this->m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); | |
| 9035 } | |
| 9036 | |
| 9037 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) | |
| 9038 { | |
| 9039 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9040 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETUNICODEFORMAT, bUnicode, 0L); | |
| 9041 } | |
| 9042 | |
| 9043 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) | |
| 9044 DWORD GetCurrentView() const | |
| 9045 { | |
| 9046 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9047 return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); | |
| 9048 } | |
| 9049 | |
| 9050 BOOL SetCurrentView(DWORD dwView) | |
| 9051 { | |
| 9052 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9053 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETCURRENTVIEW, 0, dwView); | |
| 9054 } | |
| 9055 | |
| 9056 DWORD GetCalendarCount() const | |
| 9057 { | |
| 9058 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9059 return (DWORD)::SendMessage(this->m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L); | |
| 9060 } | |
| 9061 | |
| 9062 BOOL GetCalendarGridInfo(PMCGRIDINFO pGridInfo) const | |
| 9063 { | |
| 9064 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9065 return (BOOL)::SendMessage(this->m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)pGridInfo); | |
| 9066 } | |
| 9067 | |
| 9068 CALID GetCALID() const | |
| 9069 { | |
| 9070 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9071 return (CALID)::SendMessage(this->m_hWnd, MCM_GETCALID, 0, 0L); | |
| 9072 } | |
| 9073 | |
| 9074 void SetCALID(CALID calid) | |
| 9075 { | |
| 9076 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9077 ::SendMessage(this->m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); | |
| 9078 } | |
| 9079 | |
| 9080 int GetCalendarBorder() const | |
| 9081 { | |
| 9082 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9083 return (int)::SendMessage(this->m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); | |
| 9084 } | |
| 9085 | |
| 9086 void SetCalendarBorder(int cxyBorder, BOOL bSet = TRUE) | |
| 9087 { | |
| 9088 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9089 ::SendMessage(this->m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPARAM)cxyBorder); | |
| 9090 } | |
| 9091 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) | |
| 9092 | |
| 9093 // Operations | |
| 9094 int GetMonthRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) const | |
| 9095 { | |
| 9096 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9097 return (int)::SendMessage(this->m_hWnd, MCM_GETMONTHRANGE, dwFlags, (LPARAM)lprgSysTimeArray); | |
| 9098 } | |
| 9099 | |
| 9100 BOOL SetDayState(int nMonths, LPMONTHDAYSTATE lpDayStateArray) | |
| 9101 { | |
| 9102 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9103 return (BOOL)::SendMessage(this->m_hWnd, MCM_SETDAYSTATE, nMonths, (LPARAM)lpDayStateArray); | |
| 9104 } | |
| 9105 | |
| 9106 DWORD HitTest(PMCHITTESTINFO pMCHitTest) const | |
| 9107 { | |
| 9108 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9109 return (DWORD)::SendMessage(this->m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCHitTest); | |
| 9110 } | |
| 9111 | |
| 9112 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) | |
| 9113 void SizeRectToMin(LPRECT lpRect) | |
| 9114 { | |
| 9115 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9116 ::SendMessage(this->m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); | |
| 9117 } | |
| 9118 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) | |
| 9119 }; | |
| 9120 | |
| 9121 typedef CMonthCalendarCtrlT<ATL::CWindow> CMonthCalendarCtrl; | |
| 9122 | |
| 9123 | |
| 9124 /////////////////////////////////////////////////////////////////////////////// | |
| 9125 // CDateTimePickerCtrl | |
| 9126 | |
| 9127 template <class TBase> | |
| 9128 class CDateTimePickerCtrlT : public TBase | |
| 9129 { | |
| 9130 public: | |
| 9131 // Constructors | |
| 9132 CDateTimePickerCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 9133 { } | |
| 9134 | |
| 9135 CDateTimePickerCtrlT< TBase >& operator =(HWND hWnd) | |
| 9136 { | |
| 9137 this->m_hWnd = hWnd; | |
| 9138 return *this; | |
| 9139 } | |
| 9140 | |
| 9141 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 9142 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 9143 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 9144 { | |
| 9145 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 9146 } | |
| 9147 | |
| 9148 // Operations | |
| 9149 static LPCTSTR GetWndClassName() | |
| 9150 { | |
| 9151 return DATETIMEPICK_CLASS; | |
| 9152 } | |
| 9153 | |
| 9154 BOOL SetFormat(LPCTSTR lpszFormat) | |
| 9155 { | |
| 9156 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9157 return (BOOL)::SendMessage(this->m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lpszFormat); | |
| 9158 } | |
| 9159 | |
| 9160 COLORREF GetMonthCalColor(int nColorType) const | |
| 9161 { | |
| 9162 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9163 return (COLORREF)::SendMessage(this->m_hWnd, DTM_GETMCCOLOR, nColorType, 0L); | |
| 9164 } | |
| 9165 | |
| 9166 COLORREF SetMonthCalColor(int nColorType, COLORREF clr) | |
| 9167 { | |
| 9168 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9169 return (COLORREF)::SendMessage(this->m_hWnd, DTM_SETMCCOLOR, nColorType, clr); | |
| 9170 } | |
| 9171 | |
| 9172 DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const | |
| 9173 { | |
| 9174 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9175 return (DWORD)::SendMessage(this->m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpSysTimeArray); | |
| 9176 } | |
| 9177 | |
| 9178 BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lpSysTimeArray) | |
| 9179 { | |
| 9180 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9181 return (BOOL)::SendMessage(this->m_hWnd, DTM_SETRANGE, dwFlags, (LPARAM)lpSysTimeArray); | |
| 9182 } | |
| 9183 | |
| 9184 DWORD GetSystemTime(LPSYSTEMTIME lpSysTime) const | |
| 9185 { | |
| 9186 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9187 return (DWORD)::SendMessage(this->m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)lpSysTime); | |
| 9188 } | |
| 9189 | |
| 9190 BOOL SetSystemTime(DWORD dwFlags, LPSYSTEMTIME lpSysTime) | |
| 9191 { | |
| 9192 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9193 return (BOOL)::SendMessage(this->m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (LPARAM)lpSysTime); | |
| 9194 } | |
| 9195 | |
| 9196 CMonthCalendarCtrl GetMonthCal() const | |
| 9197 { | |
| 9198 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9199 return CMonthCalendarCtrl((HWND)::SendMessage(this->m_hWnd, DTM_GETMONTHCAL, 0, 0L)); | |
| 9200 } | |
| 9201 | |
| 9202 CFontHandle GetMonthCalFont() const | |
| 9203 { | |
| 9204 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9205 return CFontHandle((HFONT)::SendMessage(this->m_hWnd, DTM_GETMCFONT, 0, 0L)); | |
| 9206 } | |
| 9207 | |
| 9208 void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE) | |
| 9209 { | |
| 9210 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9211 ::SendMessage(this->m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(bRedraw, 0)); | |
| 9212 } | |
| 9213 | |
| 9214 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) | |
| 9215 DWORD GetMonthCalStyle() const | |
| 9216 { | |
| 9217 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9218 return (DWORD)::SendMessage(this->m_hWnd, DTM_GETMCSTYLE, 0, 0L); | |
| 9219 } | |
| 9220 | |
| 9221 DWORD SetMonthCalStyle(DWORD dwStyle) | |
| 9222 { | |
| 9223 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9224 return (DWORD)::SendMessage(this->m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle); | |
| 9225 } | |
| 9226 | |
| 9227 void GetDateTimePickerInfo(LPDATETIMEPICKERINFO lpPickerInfo) const | |
| 9228 { | |
| 9229 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9230 ::SendMessage(this->m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPickerInfo); | |
| 9231 } | |
| 9232 | |
| 9233 BOOL GetIdealSize(LPSIZE lpSize) const | |
| 9234 { | |
| 9235 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9236 return (BOOL)::SendMessage(this->m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)lpSize); | |
| 9237 } | |
| 9238 | |
| 9239 void CloseMonthCal() | |
| 9240 { | |
| 9241 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9242 ::SendMessage(this->m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); | |
| 9243 } | |
| 9244 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) | |
| 9245 }; | |
| 9246 | |
| 9247 typedef CDateTimePickerCtrlT<ATL::CWindow> CDateTimePickerCtrl; | |
| 9248 | |
| 9249 | |
| 9250 /////////////////////////////////////////////////////////////////////////////// | |
| 9251 // CFlatScrollBarImpl - support for flat scroll bars | |
| 9252 | |
| 9253 template <class T> | |
| 9254 class CFlatScrollBarImpl | |
| 9255 { | |
| 9256 public: | |
| 9257 // Initialization | |
| 9258 BOOL FlatSB_Initialize() | |
| 9259 { | |
| 9260 T* pT = static_cast<T*>(this); | |
| 9261 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9262 return ::InitializeFlatSB(pT->m_hWnd); | |
| 9263 } | |
| 9264 | |
| 9265 HRESULT FlatSB_Uninitialize() | |
| 9266 { | |
| 9267 T* pT = static_cast<T*>(this); | |
| 9268 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9269 return ::UninitializeFlatSB(pT->m_hWnd); | |
| 9270 } | |
| 9271 | |
| 9272 // Flat scroll bar properties | |
| 9273 BOOL FlatSB_GetScrollProp(UINT uIndex, LPINT lpnValue) const | |
| 9274 { | |
| 9275 const T* pT = static_cast<const T*>(this); | |
| 9276 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9277 return ::FlatSB_GetScrollProp(pT->m_hWnd, uIndex, lpnValue); | |
| 9278 } | |
| 9279 | |
| 9280 BOOL FlatSB_SetScrollProp(UINT uIndex, int nValue, BOOL bRedraw = TRUE) | |
| 9281 { | |
| 9282 T* pT = static_cast<T*>(this); | |
| 9283 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9284 return ::FlatSB_SetScrollProp(pT->m_hWnd, uIndex, nValue, bRedraw); | |
| 9285 } | |
| 9286 | |
| 9287 // Attributes | |
| 9288 int FlatSB_GetScrollPos(int nBar) const | |
| 9289 { | |
| 9290 const T* pT = static_cast<const T*>(this); | |
| 9291 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9292 return ::FlatSB_GetScrollPos(pT->m_hWnd, nBar); | |
| 9293 } | |
| 9294 | |
| 9295 int FlatSB_SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE) | |
| 9296 { | |
| 9297 T* pT = static_cast<T*>(this); | |
| 9298 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9299 return ::FlatSB_SetScrollPos(pT->m_hWnd, nBar, nPos, bRedraw); | |
| 9300 } | |
| 9301 | |
| 9302 BOOL FlatSB_GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const | |
| 9303 { | |
| 9304 const T* pT = static_cast<const T*>(this); | |
| 9305 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9306 return ::FlatSB_GetScrollRange(pT->m_hWnd, nBar, lpMinPos, lpMaxPos); | |
| 9307 } | |
| 9308 | |
| 9309 BOOL FlatSB_SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) | |
| 9310 { | |
| 9311 T* pT = static_cast<T*>(this); | |
| 9312 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9313 return ::FlatSB_SetScrollRange(pT->m_hWnd, nBar, nMinPos, nMaxPos, bRedraw); | |
| 9314 } | |
| 9315 | |
| 9316 BOOL FlatSB_GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) const | |
| 9317 { | |
| 9318 const T* pT = static_cast<const T*>(this); | |
| 9319 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9320 return ::FlatSB_GetScrollInfo(pT->m_hWnd, nBar, lpScrollInfo); | |
| 9321 } | |
| 9322 | |
| 9323 int FlatSB_SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) | |
| 9324 { | |
| 9325 T* pT = static_cast<T*>(this); | |
| 9326 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9327 return ::FlatSB_SetScrollInfo(pT->m_hWnd, nBar, lpScrollInfo, bRedraw); | |
| 9328 } | |
| 9329 | |
| 9330 // Operations | |
| 9331 BOOL FlatSB_ShowScrollBar(UINT nBar, BOOL bShow = TRUE) | |
| 9332 { | |
| 9333 T* pT = static_cast<T*>(this); | |
| 9334 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9335 return ::FlatSB_ShowScrollBar(pT->m_hWnd, nBar, bShow); | |
| 9336 } | |
| 9337 | |
| 9338 BOOL FlatSB_EnableScrollBar(UINT uSBFlags, UINT uArrowFlags = ESB_ENABLE_BOTH) | |
| 9339 { | |
| 9340 T* pT = static_cast<T*>(this); | |
| 9341 ATLASSERT(::IsWindow(pT->m_hWnd)); | |
| 9342 return ::FlatSB_EnableScrollBar(pT->m_hWnd, uSBFlags, uArrowFlags); | |
| 9343 } | |
| 9344 }; | |
| 9345 | |
| 9346 template <class TBase> | |
| 9347 class CFlatScrollBarT : public TBase, public CFlatScrollBarImpl<CFlatScrollBarT< TBase > > | |
| 9348 { | |
| 9349 public: | |
| 9350 CFlatScrollBarT(HWND hWnd = NULL) : TBase(hWnd) | |
| 9351 { } | |
| 9352 | |
| 9353 CFlatScrollBarT< TBase >& operator =(HWND hWnd) | |
| 9354 { | |
| 9355 this->m_hWnd = hWnd; | |
| 9356 return *this; | |
| 9357 } | |
| 9358 }; | |
| 9359 | |
| 9360 typedef CFlatScrollBarT<ATL::CWindow> CFlatScrollBar; | |
| 9361 | |
| 9362 | |
| 9363 /////////////////////////////////////////////////////////////////////////////// | |
| 9364 // CIPAddressCtrl | |
| 9365 | |
| 9366 template <class TBase> | |
| 9367 class CIPAddressCtrlT : public TBase | |
| 9368 { | |
| 9369 public: | |
| 9370 // Constructors | |
| 9371 CIPAddressCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 9372 { } | |
| 9373 | |
| 9374 CIPAddressCtrlT< TBase >& operator =(HWND hWnd) | |
| 9375 { | |
| 9376 this->m_hWnd = hWnd; | |
| 9377 return *this; | |
| 9378 } | |
| 9379 | |
| 9380 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 9381 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 9382 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 9383 { | |
| 9384 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 9385 } | |
| 9386 | |
| 9387 // Atteributes | |
| 9388 static LPCTSTR GetWndClassName() | |
| 9389 { | |
| 9390 return WC_IPADDRESS; | |
| 9391 } | |
| 9392 | |
| 9393 BOOL IsBlank() const | |
| 9394 { | |
| 9395 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9396 return (BOOL)::SendMessage(this->m_hWnd, IPM_ISBLANK, 0, 0L); | |
| 9397 } | |
| 9398 | |
| 9399 int GetAddress(LPDWORD lpdwAddress) const | |
| 9400 { | |
| 9401 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9402 return (int)::SendMessage(this->m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwAddress); | |
| 9403 } | |
| 9404 | |
| 9405 void SetAddress(DWORD dwAddress) | |
| 9406 { | |
| 9407 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9408 ::SendMessage(this->m_hWnd, IPM_SETADDRESS, 0, dwAddress); | |
| 9409 } | |
| 9410 | |
| 9411 void ClearAddress() | |
| 9412 { | |
| 9413 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9414 ::SendMessage(this->m_hWnd, IPM_CLEARADDRESS, 0, 0L); | |
| 9415 } | |
| 9416 | |
| 9417 void SetRange(int nField, WORD wRange) | |
| 9418 { | |
| 9419 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9420 ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, wRange); | |
| 9421 } | |
| 9422 | |
| 9423 void SetRange(int nField, BYTE nMin, BYTE nMax) | |
| 9424 { | |
| 9425 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9426 ::SendMessage(this->m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nMax)); | |
| 9427 } | |
| 9428 | |
| 9429 void SetFocus(int nField) | |
| 9430 { | |
| 9431 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9432 ::SendMessage(this->m_hWnd, IPM_SETFOCUS, nField, 0L); | |
| 9433 } | |
| 9434 }; | |
| 9435 | |
| 9436 typedef CIPAddressCtrlT<ATL::CWindow> CIPAddressCtrl; | |
| 9437 | |
| 9438 | |
| 9439 /////////////////////////////////////////////////////////////////////////////// | |
| 9440 // CPagerCtrl | |
| 9441 | |
| 9442 template <class TBase> | |
| 9443 class CPagerCtrlT : public TBase | |
| 9444 { | |
| 9445 public: | |
| 9446 // Constructors | |
| 9447 CPagerCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 9448 { } | |
| 9449 | |
| 9450 CPagerCtrlT< TBase >& operator =(HWND hWnd) | |
| 9451 { | |
| 9452 this->m_hWnd = hWnd; | |
| 9453 return *this; | |
| 9454 } | |
| 9455 | |
| 9456 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 9457 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 9458 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 9459 { | |
| 9460 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 9461 } | |
| 9462 | |
| 9463 // Attributes | |
| 9464 static LPCTSTR GetWndClassName() | |
| 9465 { | |
| 9466 return WC_PAGESCROLLER; | |
| 9467 } | |
| 9468 | |
| 9469 int GetButtonSize() const | |
| 9470 { | |
| 9471 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9472 return (int)::SendMessage(this->m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); | |
| 9473 } | |
| 9474 | |
| 9475 int SetButtonSize(int nButtonSize) | |
| 9476 { | |
| 9477 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9478 return (int)::SendMessage(this->m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonSize); | |
| 9479 } | |
| 9480 | |
| 9481 DWORD GetButtonState(int nButton) const | |
| 9482 { | |
| 9483 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9484 ATLASSERT((nButton == PGB_TOPORLEFT) || (nButton == PGB_BOTTOMORRIGHT)); | |
| 9485 return (DWORD)::SendMessage(this->m_hWnd, PGM_GETBUTTONSTATE, 0, nButton); | |
| 9486 } | |
| 9487 | |
| 9488 COLORREF GetBkColor() const | |
| 9489 { | |
| 9490 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9491 return (COLORREF)::SendMessage(this->m_hWnd, PGM_GETBKCOLOR, 0, 0L); | |
| 9492 } | |
| 9493 | |
| 9494 COLORREF SetBkColor(COLORREF clrBk) | |
| 9495 { | |
| 9496 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9497 return (COLORREF)::SendMessage(this->m_hWnd, PGM_SETBKCOLOR, 0, (LPARAM)clrBk); | |
| 9498 } | |
| 9499 | |
| 9500 int GetBorder() const | |
| 9501 { | |
| 9502 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9503 return (int)::SendMessage(this->m_hWnd, PGM_GETBORDER, 0, 0L); | |
| 9504 } | |
| 9505 | |
| 9506 int SetBorder(int nBorderSize) | |
| 9507 { | |
| 9508 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9509 return (int)::SendMessage(this->m_hWnd, PGM_SETBORDER, 0, nBorderSize); | |
| 9510 } | |
| 9511 | |
| 9512 int GetPos() const | |
| 9513 { | |
| 9514 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9515 return (int)::SendMessage(this->m_hWnd, PGM_GETPOS, 0, 0L); | |
| 9516 } | |
| 9517 | |
| 9518 int SetPos(int nPos) | |
| 9519 { | |
| 9520 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9521 return (int)::SendMessage(this->m_hWnd, PGM_SETPOS, 0, nPos); | |
| 9522 } | |
| 9523 | |
| 9524 // Operations | |
| 9525 void SetChild(HWND hWndChild) | |
| 9526 { | |
| 9527 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9528 ::SendMessage(this->m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); | |
| 9529 } | |
| 9530 | |
| 9531 void ForwardMouse(BOOL bForward = TRUE) | |
| 9532 { | |
| 9533 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9534 ::SendMessage(this->m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); | |
| 9535 } | |
| 9536 | |
| 9537 void RecalcSize() | |
| 9538 { | |
| 9539 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9540 ::SendMessage(this->m_hWnd, PGM_RECALCSIZE, 0, 0L); | |
| 9541 } | |
| 9542 | |
| 9543 void GetDropTarget(IDropTarget** ppDropTarget) | |
| 9544 { | |
| 9545 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9546 ATLASSERT(ppDropTarget != NULL); | |
| 9547 ::SendMessage(this->m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget); | |
| 9548 } | |
| 9549 }; | |
| 9550 | |
| 9551 typedef CPagerCtrlT<ATL::CWindow> CPagerCtrl; | |
| 9552 | |
| 9553 | |
| 9554 /////////////////////////////////////////////////////////////////////////////// | |
| 9555 // CLinkCtrl - Windows SYSLINK control | |
| 9556 | |
| 9557 template <class TBase> | |
| 9558 class CLinkCtrlT : public TBase | |
| 9559 { | |
| 9560 public: | |
| 9561 // Constructors | |
| 9562 CLinkCtrlT(HWND hWnd = NULL) : TBase(hWnd) | |
| 9563 { } | |
| 9564 | |
| 9565 CLinkCtrlT< TBase >& operator =(HWND hWnd) | |
| 9566 { | |
| 9567 this->m_hWnd = hWnd; | |
| 9568 return *this; | |
| 9569 } | |
| 9570 | |
| 9571 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL, | |
| 9572 DWORD dwStyle = 0, DWORD dwExStyle = 0, | |
| 9573 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) | |
| 9574 { | |
| 9575 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); | |
| 9576 } | |
| 9577 | |
| 9578 // Attributes | |
| 9579 static LPCTSTR GetWndClassName() | |
| 9580 { | |
| 9581 #ifdef _UNICODE | |
| 9582 return WC_LINK; | |
| 9583 #else // !_UNICODE | |
| 9584 return "SysLink"; | |
| 9585 #endif // !_UNICODE | |
| 9586 } | |
| 9587 | |
| 9588 int GetIdealHeight(int cxMaxWidth = 0) const | |
| 9589 { | |
| 9590 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9591 return (int)::SendMessage(this->m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth, 0L); | |
| 9592 } | |
| 9593 | |
| 9594 BOOL GetItem(PLITEM pLItem) const | |
| 9595 { | |
| 9596 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9597 return (BOOL)::SendMessage(this->m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem); | |
| 9598 } | |
| 9599 | |
| 9600 BOOL SetItem(PLITEM pLItem) | |
| 9601 { | |
| 9602 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9603 return (BOOL)::SendMessage(this->m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem); | |
| 9604 } | |
| 9605 | |
| 9606 // Vista only | |
| 9607 int GetIdealSize(SIZE& size, int cxMaxWidth = 0) const | |
| 9608 { | |
| 9609 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9610 return (int)::SendMessage(this->m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (LPARAM)&size); | |
| 9611 } | |
| 9612 | |
| 9613 // Operations | |
| 9614 BOOL HitTest(PLHITTESTINFO pLHitTestInfo) const | |
| 9615 { | |
| 9616 ATLASSERT(::IsWindow(this->m_hWnd)); | |
| 9617 return (BOOL)::SendMessage(this->m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitTestInfo); | |
| 9618 } | |
| 9619 }; | |
| 9620 | |
| 9621 typedef CLinkCtrlT<ATL::CWindow> CLinkCtrl; | |
| 9622 | |
| 9623 | |
| 9624 /////////////////////////////////////////////////////////////////////////////// | |
| 9625 // CCustomDraw - MI class for custom-draw support | |
| 9626 | |
| 9627 template <class T> | |
| 9628 class CCustomDraw | |
| 9629 { | |
| 9630 public: | |
| 9631 // Message map and handlers | |
| 9632 BEGIN_MSG_MAP(CCustomDraw< T >) | |
| 9633 NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) | |
| 9634 ALT_MSG_MAP(1) | |
| 9635 REFLECTED_NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) | |
| 9636 END_MSG_MAP() | |
| 9637 | |
| 9638 // message handler | |
| 9639 LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) | |
| 9640 { | |
| 9641 T* pT = static_cast<T*>(this); | |
| 9642 pT->SetMsgHandled(TRUE); | |
| 9643 LPNMCUSTOMDRAW lpNMCustomDraw = (LPNMCUSTOMDRAW)pnmh; | |
| 9644 DWORD dwRet = 0; | |
| 9645 switch(lpNMCustomDraw->dwDrawStage) | |
| 9646 { | |
| 9647 case CDDS_PREPAINT: | |
| 9648 dwRet = pT->OnPrePaint(idCtrl, lpNMCustomDraw); | |
| 9649 break; | |
| 9650 case CDDS_POSTPAINT: | |
| 9651 dwRet = pT->OnPostPaint(idCtrl, lpNMCustomDraw); | |
| 9652 break; | |
| 9653 case CDDS_PREERASE: | |
| 9654 dwRet = pT->OnPreErase(idCtrl, lpNMCustomDraw); | |
| 9655 break; | |
| 9656 case CDDS_POSTERASE: | |
| 9657 dwRet = pT->OnPostErase(idCtrl, lpNMCustomDraw); | |
| 9658 break; | |
| 9659 case CDDS_ITEMPREPAINT: | |
| 9660 dwRet = pT->OnItemPrePaint(idCtrl, lpNMCustomDraw); | |
| 9661 break; | |
| 9662 case CDDS_ITEMPOSTPAINT: | |
| 9663 dwRet = pT->OnItemPostPaint(idCtrl, lpNMCustomDraw); | |
| 9664 break; | |
| 9665 case CDDS_ITEMPREERASE: | |
| 9666 dwRet = pT->OnItemPreErase(idCtrl, lpNMCustomDraw); | |
| 9667 break; | |
| 9668 case CDDS_ITEMPOSTERASE: | |
| 9669 dwRet = pT->OnItemPostErase(idCtrl, lpNMCustomDraw); | |
| 9670 break; | |
| 9671 case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): | |
| 9672 dwRet = pT->OnSubItemPrePaint(idCtrl, lpNMCustomDraw); | |
| 9673 break; | |
| 9674 default: | |
| 9675 pT->SetMsgHandled(FALSE); | |
| 9676 break; | |
| 9677 } | |
| 9678 bHandled = pT->IsMsgHandled(); | |
| 9679 return dwRet; | |
| 9680 } | |
| 9681 | |
| 9682 // Overrideables | |
| 9683 DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9684 { | |
| 9685 return CDRF_DODEFAULT; | |
| 9686 } | |
| 9687 | |
| 9688 DWORD OnPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9689 { | |
| 9690 return CDRF_DODEFAULT; | |
| 9691 } | |
| 9692 | |
| 9693 DWORD OnPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9694 { | |
| 9695 return CDRF_DODEFAULT; | |
| 9696 } | |
| 9697 | |
| 9698 DWORD OnPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9699 { | |
| 9700 return CDRF_DODEFAULT; | |
| 9701 } | |
| 9702 | |
| 9703 DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9704 { | |
| 9705 return CDRF_DODEFAULT; | |
| 9706 } | |
| 9707 | |
| 9708 DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9709 { | |
| 9710 return CDRF_DODEFAULT; | |
| 9711 } | |
| 9712 | |
| 9713 DWORD OnItemPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9714 { | |
| 9715 return CDRF_DODEFAULT; | |
| 9716 } | |
| 9717 | |
| 9718 DWORD OnItemPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9719 { | |
| 9720 return CDRF_DODEFAULT; | |
| 9721 } | |
| 9722 | |
| 9723 DWORD OnSubItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) | |
| 9724 { | |
| 9725 return CDRF_DODEFAULT; | |
| 9726 } | |
| 9727 }; | |
| 9728 | |
| 9729 } // namespace WTL | |
| 9730 | |
| 9731 #endif // __ATLCTRLS_H__ |
