OLD | NEW |
(Empty) | |
| 1 // Windows Template Library - WTL version 8.0 |
| 2 // Copyright (C) Microsoft Corporation. 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 Permissive License (Ms-PL) which can be found in the file |
| 7 // Ms-PL.txt at the root of this distribution. |
| 8 |
| 9 #ifndef __ATLCTRLS_H__ |
| 10 #define __ATLCTRLS_H__ |
| 11 |
| 12 #pragma once |
| 13 |
| 14 #ifndef __cplusplus |
| 15 #error ATL requires C++ compilation (use a .cpp suffix) |
| 16 #endif |
| 17 |
| 18 #ifndef __ATLAPP_H__ |
| 19 #error atlctrls.h requires atlapp.h to be included first |
| 20 #endif |
| 21 |
| 22 #ifndef __ATLWIN_H__ |
| 23 #error atlctrls.h requires atlwin.h to be included first |
| 24 #endif |
| 25 |
| 26 #if (_WIN32_IE < 0x0300) |
| 27 #error atlctrls.h requires IE Version 3.0 or higher |
| 28 #endif |
| 29 |
| 30 #ifndef _WIN32_WCE |
| 31 #include <richedit.h> |
| 32 #include <richole.h> |
| 33 #elif defined(WIN32_PLATFORM_WFSP) && !defined(_WINUSERM_H_) |
| 34 #include <winuserm.h> |
| 35 #endif // !_WIN32_WCE |
| 36 |
| 37 // protect template members from windowsx.h macros |
| 38 #ifdef _INC_WINDOWSX |
| 39 #undef GetNextSibling |
| 40 #undef GetPrevSibling |
| 41 #endif // _INC_WINDOWSX |
| 42 |
| 43 |
| 44 /////////////////////////////////////////////////////////////////////////////// |
| 45 // Classes in this file: |
| 46 // |
| 47 // CStaticT<TBase> - CStatic |
| 48 // CButtonT<TBase> - CButton |
| 49 // CListBoxT<TBase> - CListBox |
| 50 // CComboBoxT<TBase> - CComboBox |
| 51 // CEditT<TBase> - CEdit |
| 52 // CEditCommands<T> |
| 53 // CScrollBarT<TBase> - CScrollBar |
| 54 // |
| 55 // CImageList |
| 56 // CListViewCtrlT<TBase> - CListViewCtrl |
| 57 // CTreeViewCtrlT<TBase> - CTreeViewCtrl |
| 58 // CTreeItemT<TBase> - CTreeItem |
| 59 // CTreeViewCtrlExT<TBase> - CTreeViewCtrlEx |
| 60 // CHeaderCtrlT<TBase> - CHeaderCtrl |
| 61 // CToolBarCtrlT<TBase> - CToolBarCtrl |
| 62 // CStatusBarCtrlT<TBase> - CStatusBarCtrl |
| 63 // CTabCtrlT<TBase> - CTabCtrl |
| 64 // CToolInfo |
| 65 // CToolTipCtrlT<TBase> - CToolTipCtrl |
| 66 // CTrackBarCtrlT<TBase> - CTrackBarCtrl |
| 67 // CUpDownCtrlT<TBase> - CUpDownCtrl |
| 68 // CProgressBarCtrlT<TBase> - CProgressBarCtrl |
| 69 // CHotKeyCtrlT<TBase> - CHotKeyCtrl |
| 70 // CAnimateCtrlT<TBase> - CAnimateCtrl |
| 71 // CRichEditCtrlT<TBase> - CRichEditCtrl |
| 72 // CRichEditCommands<T> |
| 73 // CDragListBoxT<TBase> - CDragListBox |
| 74 // CDragListNotifyImpl<T> |
| 75 // CReBarCtrlT<TBase> - CReBarCtrl |
| 76 // CComboBoxExT<TBase> - CComboBoxEx |
| 77 // CDateTimePickerCtrlT<TBase> - CDateTimePickerCtrl |
| 78 // CMonthCalendarCtrlT<TBase> - CMonthCalendarCtrl |
| 79 // CFlatScrollBarImpl<T> |
| 80 // CFlatScrollBarT<TBase> - CFlatScrollBar |
| 81 // CIPAddressCtrlT<TBase> - CIPAddressCtrl |
| 82 // CPagerCtrlT<TBase> - CPagerCtrl |
| 83 // CLinkCtrlT<TBase> - CLinkCtrl |
| 84 // |
| 85 // CCustomDraw<T> |
| 86 // |
| 87 // CCECommandBarCtrlT<TBase> - CCECommandBarCtrl |
| 88 // CCECommandBandsCtrlT<TBase> - CCECommandBandsCtrl |
| 89 |
| 90 |
| 91 namespace WTL |
| 92 { |
| 93 |
| 94 // These are wrapper classes for Windows standard and common controls. |
| 95 // To implement a window based on a control, use following: |
| 96 // Example: Implementing a window based on a list box |
| 97 // |
| 98 // class CMyListBox : CWindowImpl<CMyListBox, CListBox> |
| 99 // { |
| 100 // public: |
| 101 // BEGIN_MSG_MAP(CMyListBox) |
| 102 // // put your message handler entries here |
| 103 // END_MSG_MAP() |
| 104 // }; |
| 105 |
| 106 |
| 107 |
| 108 // --- Standard Windows controls --- |
| 109 |
| 110 /////////////////////////////////////////////////////////////////////////////// |
| 111 // CStatic - client side for a Windows STATIC control |
| 112 |
| 113 template <class TBase> |
| 114 class CStaticT : public TBase |
| 115 { |
| 116 public: |
| 117 // Constructors |
| 118 CStaticT(HWND hWnd = NULL) : TBase(hWnd) |
| 119 { } |
| 120 |
| 121 CStaticT< TBase >& operator =(HWND hWnd) |
| 122 { |
| 123 m_hWnd = hWnd; |
| 124 return *this; |
| 125 } |
| 126 |
| 127 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 128 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 129 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 130 { |
| 131 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 132 } |
| 133 |
| 134 // Attributes |
| 135 static LPCTSTR GetWndClassName() |
| 136 { |
| 137 return _T("STATIC"); |
| 138 } |
| 139 |
| 140 #ifndef _WIN32_WCE |
| 141 HICON GetIcon() const |
| 142 { |
| 143 ATLASSERT(::IsWindow(m_hWnd)); |
| 144 return (HICON)::SendMessage(m_hWnd, STM_GETICON, 0, 0L); |
| 145 } |
| 146 |
| 147 HICON SetIcon(HICON hIcon) |
| 148 { |
| 149 ATLASSERT(::IsWindow(m_hWnd)); |
| 150 return (HICON)::SendMessage(m_hWnd, STM_SETICON, (WPARAM)hIcon,
0L); |
| 151 } |
| 152 |
| 153 HENHMETAFILE GetEnhMetaFile() const |
| 154 { |
| 155 ATLASSERT(::IsWindow(m_hWnd)); |
| 156 return (HENHMETAFILE)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_E
NHMETAFILE, 0L); |
| 157 } |
| 158 |
| 159 HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) |
| 160 { |
| 161 ATLASSERT(::IsWindow(m_hWnd)); |
| 162 return (HENHMETAFILE)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_E
NHMETAFILE, (LPARAM)hMetaFile); |
| 163 } |
| 164 #else // CE specific |
| 165 HICON GetIcon() const |
| 166 { |
| 167 ATLASSERT(::IsWindow(m_hWnd)); |
| 168 return (HICON)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ICON, 0L
); |
| 169 } |
| 170 |
| 171 HICON SetIcon(HICON hIcon) |
| 172 { |
| 173 ATLASSERT(::IsWindow(m_hWnd)); |
| 174 return (HICON)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ICON, (L
PARAM)hIcon); |
| 175 } |
| 176 #endif // _WIN32_WCE |
| 177 |
| 178 CBitmapHandle GetBitmap() const |
| 179 { |
| 180 ATLASSERT(::IsWindow(m_hWnd)); |
| 181 return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_GETIMAGE
, IMAGE_BITMAP, 0L)); |
| 182 } |
| 183 |
| 184 CBitmapHandle SetBitmap(HBITMAP hBitmap) |
| 185 { |
| 186 ATLASSERT(::IsWindow(m_hWnd)); |
| 187 return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE
, IMAGE_BITMAP, (LPARAM)hBitmap)); |
| 188 } |
| 189 |
| 190 HCURSOR GetCursor() const |
| 191 { |
| 192 ATLASSERT(::IsWindow(m_hWnd)); |
| 193 return (HCURSOR)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_CURSOR
, 0L); |
| 194 } |
| 195 |
| 196 HCURSOR SetCursor(HCURSOR hCursor) |
| 197 { |
| 198 ATLASSERT(::IsWindow(m_hWnd)); |
| 199 return (HCURSOR)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_CURSOR
, (LPARAM)hCursor); |
| 200 } |
| 201 }; |
| 202 |
| 203 typedef CStaticT<ATL::CWindow> CStatic; |
| 204 |
| 205 |
| 206 /////////////////////////////////////////////////////////////////////////////// |
| 207 // CButton - client side for a Windows BUTTON control |
| 208 |
| 209 template <class TBase> |
| 210 class CButtonT : public TBase |
| 211 { |
| 212 public: |
| 213 // Constructors |
| 214 CButtonT(HWND hWnd = NULL) : TBase(hWnd) |
| 215 { } |
| 216 |
| 217 CButtonT< TBase >& operator =(HWND hWnd) |
| 218 { |
| 219 m_hWnd = hWnd; |
| 220 return *this; |
| 221 } |
| 222 |
| 223 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 224 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 225 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 226 { |
| 227 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 228 } |
| 229 |
| 230 // Attributes |
| 231 static LPCTSTR GetWndClassName() |
| 232 { |
| 233 return _T("BUTTON"); |
| 234 } |
| 235 |
| 236 UINT GetState() const |
| 237 { |
| 238 ATLASSERT(::IsWindow(m_hWnd)); |
| 239 return (UINT)::SendMessage(m_hWnd, BM_GETSTATE, 0, 0L); |
| 240 } |
| 241 |
| 242 void SetState(BOOL bHighlight) |
| 243 { |
| 244 ATLASSERT(::IsWindow(m_hWnd)); |
| 245 ::SendMessage(m_hWnd, BM_SETSTATE, bHighlight, 0L); |
| 246 } |
| 247 |
| 248 int GetCheck() const |
| 249 { |
| 250 ATLASSERT(::IsWindow(m_hWnd)); |
| 251 return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0L); |
| 252 } |
| 253 |
| 254 void SetCheck(int nCheck) |
| 255 { |
| 256 ATLASSERT(::IsWindow(m_hWnd)); |
| 257 ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0L); |
| 258 } |
| 259 |
| 260 UINT GetButtonStyle() const |
| 261 { |
| 262 ATLASSERT(::IsWindow(m_hWnd)); |
| 263 return (UINT)::GetWindowLong(m_hWnd, GWL_STYLE) & 0xFFFF; |
| 264 } |
| 265 |
| 266 void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE) |
| 267 { |
| 268 ATLASSERT(::IsWindow(m_hWnd)); |
| 269 ::SendMessage(m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); |
| 270 } |
| 271 |
| 272 #ifndef _WIN32_WCE |
| 273 HICON GetIcon() const |
| 274 { |
| 275 ATLASSERT(::IsWindow(m_hWnd)); |
| 276 return (HICON)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L)
; |
| 277 } |
| 278 |
| 279 HICON SetIcon(HICON hIcon) |
| 280 { |
| 281 ATLASSERT(::IsWindow(m_hWnd)); |
| 282 return (HICON)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LP
ARAM)hIcon); |
| 283 } |
| 284 |
| 285 CBitmapHandle GetBitmap() const |
| 286 { |
| 287 ATLASSERT(::IsWindow(m_hWnd)); |
| 288 return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_GETIMAGE,
IMAGE_BITMAP, 0L)); |
| 289 } |
| 290 |
| 291 CBitmapHandle SetBitmap(HBITMAP hBitmap) |
| 292 { |
| 293 ATLASSERT(::IsWindow(m_hWnd)); |
| 294 return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_SETIMAGE,
IMAGE_BITMAP, (LPARAM)hBitmap)); |
| 295 } |
| 296 #endif // !_WIN32_WCE |
| 297 |
| 298 #if (_WIN32_WINNT >= 0x0501) |
| 299 BOOL GetIdealSize(LPSIZE lpSize) const |
| 300 { |
| 301 ATLASSERT(::IsWindow(m_hWnd)); |
| 302 return (BOOL)::SendMessage(m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)
lpSize); |
| 303 } |
| 304 |
| 305 BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const |
| 306 { |
| 307 ATLASSERT(::IsWindow(m_hWnd)); |
| 308 return (BOOL)::SendMessage(m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)
pButtonImagelist); |
| 309 } |
| 310 |
| 311 BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist) |
| 312 { |
| 313 ATLASSERT(::IsWindow(m_hWnd)); |
| 314 return (BOOL)::SendMessage(m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)
pButtonImagelist); |
| 315 } |
| 316 |
| 317 BOOL GetTextMargin(LPRECT lpRect) const |
| 318 { |
| 319 ATLASSERT(::IsWindow(m_hWnd)); |
| 320 return (BOOL)::SendMessage(m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM
)lpRect); |
| 321 } |
| 322 |
| 323 BOOL SetTextMargin(LPRECT lpRect) |
| 324 { |
| 325 ATLASSERT(::IsWindow(m_hWnd)); |
| 326 return (BOOL)::SendMessage(m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM
)lpRect); |
| 327 } |
| 328 #endif // (_WIN32_WINNT >= 0x0501) |
| 329 |
| 330 #if (WINVER >= 0x0600) |
| 331 void SetDontClick(BOOL bDontClick) |
| 332 { |
| 333 ATLASSERT(::IsWindow(m_hWnd)); |
| 334 ::SendMessage(m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); |
| 335 } |
| 336 #endif // (WINVER >= 0x0600) |
| 337 |
| 338 #if (_WIN32_WINNT >= 0x0600) |
| 339 BOOL SetDropDownState(BOOL bDropDown) |
| 340 { |
| 341 ATLASSERT(::IsWindow(m_hWnd)); |
| 342 ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) !=
0); |
| 343 return (BOOL)::SendMessage(m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM
)bDropDown, 0L); |
| 344 } |
| 345 |
| 346 BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const |
| 347 { |
| 348 ATLASSERT(::IsWindow(m_hWnd)); |
| 349 ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) !=
0); |
| 350 return (BOOL)::SendMessage(m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)
pSplitInfo); |
| 351 } |
| 352 |
| 353 BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) |
| 354 { |
| 355 ATLASSERT(::IsWindow(m_hWnd)); |
| 356 ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) !=
0); |
| 357 return (BOOL)::SendMessage(m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)
pSplitInfo); |
| 358 } |
| 359 |
| 360 int GetNoteLength() const |
| 361 { |
| 362 ATLASSERT(::IsWindow(m_hWnd)); |
| 363 ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) !=
0); |
| 364 return (int)::SendMessage(m_hWnd, BCM_GETNOTELENGTH, 0, 0L); |
| 365 } |
| 366 |
| 367 BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const |
| 368 { |
| 369 ATLASSERT(::IsWindow(m_hWnd)); |
| 370 ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) !=
0); |
| 371 return (BOOL)::SendMessage(m_hWnd, BCM_GETNOTE, cchNoteText, (LP
ARAM)lpstrNoteText); |
| 372 } |
| 373 |
| 374 BOOL SetNote(LPCWSTR lpstrNoteText) |
| 375 { |
| 376 ATLASSERT(::IsWindow(m_hWnd)); |
| 377 ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) !=
0); |
| 378 return (BOOL)::SendMessage(m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstr
NoteText); |
| 379 } |
| 380 |
| 381 LRESULT SetElevationRequiredState(BOOL bSet) |
| 382 { |
| 383 ATLASSERT(::IsWindow(m_hWnd)); |
| 384 return ::SendMessage(m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet); |
| 385 } |
| 386 #endif // (_WIN32_WINNT >= 0x0600) |
| 387 |
| 388 // Operations |
| 389 void Click() |
| 390 { |
| 391 ATLASSERT(::IsWindow(m_hWnd)); |
| 392 ::SendMessage(m_hWnd, BM_CLICK, 0, 0L); |
| 393 } |
| 394 }; |
| 395 |
| 396 typedef CButtonT<ATL::CWindow> CButton; |
| 397 |
| 398 |
| 399 /////////////////////////////////////////////////////////////////////////////// |
| 400 // CListBox - client side for a Windows LISTBOX control |
| 401 |
| 402 template <class TBase> |
| 403 class CListBoxT : public TBase |
| 404 { |
| 405 public: |
| 406 // Constructors |
| 407 CListBoxT(HWND hWnd = NULL) : TBase(hWnd) |
| 408 { } |
| 409 |
| 410 CListBoxT< TBase >& operator =(HWND hWnd) |
| 411 { |
| 412 m_hWnd = hWnd; |
| 413 return *this; |
| 414 } |
| 415 |
| 416 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 417 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 418 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 419 { |
| 420 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 421 } |
| 422 |
| 423 // Attributes |
| 424 static LPCTSTR GetWndClassName() |
| 425 { |
| 426 return _T("LISTBOX"); |
| 427 } |
| 428 |
| 429 // for entire listbox |
| 430 int GetCount() const |
| 431 { |
| 432 ATLASSERT(::IsWindow(m_hWnd)); |
| 433 return (int)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0L); |
| 434 } |
| 435 |
| 436 #ifndef _WIN32_WCE |
| 437 int SetCount(int cItems) |
| 438 { |
| 439 ATLASSERT(::IsWindow(m_hWnd)); |
| 440 ATLASSERT(((GetStyle() & LBS_NODATA) != 0) && ((GetStyle() & LBS
_HASSTRINGS) == 0)); |
| 441 return (int)::SendMessage(m_hWnd, LB_SETCOUNT, cItems, 0L); |
| 442 } |
| 443 #endif // !_WIN32_WCE |
| 444 |
| 445 int GetHorizontalExtent() const |
| 446 { |
| 447 ATLASSERT(::IsWindow(m_hWnd)); |
| 448 return (int)::SendMessage(m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L)
; |
| 449 } |
| 450 |
| 451 void SetHorizontalExtent(int cxExtent) |
| 452 { |
| 453 ATLASSERT(::IsWindow(m_hWnd)); |
| 454 ::SendMessage(m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L); |
| 455 } |
| 456 |
| 457 int GetTopIndex() const |
| 458 { |
| 459 ATLASSERT(::IsWindow(m_hWnd)); |
| 460 return (int)::SendMessage(m_hWnd, LB_GETTOPINDEX, 0, 0L); |
| 461 } |
| 462 |
| 463 int SetTopIndex(int nIndex) |
| 464 { |
| 465 ATLASSERT(::IsWindow(m_hWnd)); |
| 466 return (int)::SendMessage(m_hWnd, LB_SETTOPINDEX, nIndex, 0L); |
| 467 } |
| 468 |
| 469 LCID GetLocale() const |
| 470 { |
| 471 ATLASSERT(::IsWindow(m_hWnd)); |
| 472 return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0L); |
| 473 } |
| 474 |
| 475 LCID SetLocale(LCID nNewLocale) |
| 476 { |
| 477 ATLASSERT(::IsWindow(m_hWnd)); |
| 478 return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLoc
ale, 0L); |
| 479 } |
| 480 |
| 481 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE) |
| 482 DWORD GetListBoxInfo() const |
| 483 { |
| 484 ATLASSERT(::IsWindow(m_hWnd)); |
| 485 #if (_WIN32_WINNT >= 0x0501) |
| 486 return (DWORD)::SendMessage(m_hWnd, LB_GETLISTBOXINFO, 0, 0L); |
| 487 #else // !(_WIN32_WINNT >= 0x0501) |
| 488 return ::GetListBoxInfo(m_hWnd); |
| 489 #endif // !(_WIN32_WINNT >= 0x0501) |
| 490 } |
| 491 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) |
| 492 |
| 493 // for single-selection listboxes |
| 494 int GetCurSel() const |
| 495 { |
| 496 ATLASSERT(::IsWindow(m_hWnd)); |
| 497 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) ==
0); |
| 498 return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0L); |
| 499 } |
| 500 |
| 501 int SetCurSel(int nSelect) |
| 502 { |
| 503 ATLASSERT(::IsWindow(m_hWnd)); |
| 504 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) ==
0); |
| 505 return (int)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0L); |
| 506 } |
| 507 |
| 508 // for multiple-selection listboxes |
| 509 int GetSel(int nIndex) const // also works for single-selectio
n |
| 510 { |
| 511 ATLASSERT(::IsWindow(m_hWnd)); |
| 512 return (int)::SendMessage(m_hWnd, LB_GETSEL, nIndex, 0L); |
| 513 } |
| 514 |
| 515 int SetSel(int nIndex, BOOL bSelect = TRUE) |
| 516 { |
| 517 ATLASSERT(::IsWindow(m_hWnd)); |
| 518 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) !=
0); |
| 519 return (int)::SendMessage(m_hWnd, LB_SETSEL, bSelect, nIndex); |
| 520 } |
| 521 |
| 522 int GetSelCount() const |
| 523 { |
| 524 ATLASSERT(::IsWindow(m_hWnd)); |
| 525 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) !=
0); |
| 526 return (int)::SendMessage(m_hWnd, LB_GETSELCOUNT, 0, 0L); |
| 527 } |
| 528 |
| 529 int GetSelItems(int nMaxItems, LPINT rgIndex) const |
| 530 { |
| 531 ATLASSERT(::IsWindow(m_hWnd)); |
| 532 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) !=
0); |
| 533 return (int)::SendMessage(m_hWnd, LB_GETSELITEMS, nMaxItems, (LP
ARAM)rgIndex); |
| 534 } |
| 535 |
| 536 int GetAnchorIndex() const |
| 537 { |
| 538 ATLASSERT(::IsWindow(m_hWnd)); |
| 539 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) !=
0); |
| 540 return (int)::SendMessage(m_hWnd, LB_GETANCHORINDEX, 0, 0L); |
| 541 } |
| 542 |
| 543 void SetAnchorIndex(int nIndex) |
| 544 { |
| 545 ATLASSERT(::IsWindow(m_hWnd)); |
| 546 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) !=
0); |
| 547 ::SendMessage(m_hWnd, LB_SETANCHORINDEX, nIndex, 0L); |
| 548 } |
| 549 |
| 550 int GetCaretIndex() const |
| 551 { |
| 552 ATLASSERT(::IsWindow(m_hWnd)); |
| 553 return (int)::SendMessage(m_hWnd, LB_GETCARETINDEX, 0, 0); |
| 554 } |
| 555 |
| 556 int SetCaretIndex(int nIndex, BOOL bScroll = TRUE) |
| 557 { |
| 558 ATLASSERT(::IsWindow(m_hWnd)); |
| 559 return (int)::SendMessage(m_hWnd, LB_SETCARETINDEX, nIndex, MAKE
LONG(bScroll, 0)); |
| 560 } |
| 561 |
| 562 // for listbox items |
| 563 DWORD_PTR GetItemData(int nIndex) const |
| 564 { |
| 565 ATLASSERT(::IsWindow(m_hWnd)); |
| 566 return (DWORD_PTR)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex,
0L); |
| 567 } |
| 568 |
| 569 int SetItemData(int nIndex, DWORD_PTR dwItemData) |
| 570 { |
| 571 ATLASSERT(::IsWindow(m_hWnd)); |
| 572 return (int)::SendMessage(m_hWnd, LB_SETITEMDATA, nIndex, (LPARA
M)dwItemData); |
| 573 } |
| 574 |
| 575 void* GetItemDataPtr(int nIndex) const |
| 576 { |
| 577 ATLASSERT(::IsWindow(m_hWnd)); |
| 578 return (void*)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L); |
| 579 } |
| 580 |
| 581 int SetItemDataPtr(int nIndex, void* pData) |
| 582 { |
| 583 ATLASSERT(::IsWindow(m_hWnd)); |
| 584 return SetItemData(nIndex, (DWORD_PTR)pData); |
| 585 } |
| 586 |
| 587 int GetItemRect(int nIndex, LPRECT lpRect) const |
| 588 { |
| 589 ATLASSERT(::IsWindow(m_hWnd)); |
| 590 return (int)::SendMessage(m_hWnd, LB_GETITEMRECT, nIndex, (LPARA
M)lpRect); |
| 591 } |
| 592 |
| 593 int GetText(int nIndex, LPTSTR lpszBuffer) const |
| 594 { |
| 595 ATLASSERT(::IsWindow(m_hWnd)); |
| 596 return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lp
szBuffer); |
| 597 } |
| 598 |
| 599 #ifndef _ATL_NO_COM |
| 600 #ifdef _OLEAUTO_H_ |
| 601 BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const |
| 602 { |
| 603 USES_CONVERSION; |
| 604 ATLASSERT(::IsWindow(m_hWnd)); |
| 605 ATLASSERT(bstrText == NULL); |
| 606 |
| 607 int nLen = GetTextLen(nIndex); |
| 608 if(nLen == LB_ERR) |
| 609 return FALSE; |
| 610 |
| 611 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 612 LPTSTR lpstrText = buff.Allocate(nLen + 1); |
| 613 if(lpstrText == NULL) |
| 614 return FALSE; |
| 615 |
| 616 if(GetText(nIndex, lpstrText) == LB_ERR) |
| 617 return FALSE; |
| 618 |
| 619 bstrText = ::SysAllocString(T2OLE(lpstrText)); |
| 620 return (bstrText != NULL) ? TRUE : FALSE; |
| 621 } |
| 622 #endif // _OLEAUTO_H_ |
| 623 #endif // !_ATL_NO_COM |
| 624 |
| 625 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 626 int GetText(int nIndex, _CSTRING_NS::CString& strText) const |
| 627 { |
| 628 ATLASSERT(::IsWindow(m_hWnd)); |
| 629 int cchLen = GetTextLen(nIndex); |
| 630 if(cchLen == LB_ERR) |
| 631 return LB_ERR; |
| 632 int nRet = LB_ERR; |
| 633 LPTSTR lpstr = strText.GetBufferSetLength(cchLen); |
| 634 if(lpstr != NULL) |
| 635 { |
| 636 nRet = GetText(nIndex, lpstr); |
| 637 strText.ReleaseBuffer(); |
| 638 } |
| 639 return nRet; |
| 640 } |
| 641 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 642 |
| 643 int GetTextLen(int nIndex) const |
| 644 { |
| 645 ATLASSERT(::IsWindow(m_hWnd)); |
| 646 return (int)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0L); |
| 647 } |
| 648 |
| 649 int GetItemHeight(int nIndex) const |
| 650 { |
| 651 ATLASSERT(::IsWindow(m_hWnd)); |
| 652 return (int)::SendMessage(m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L); |
| 653 } |
| 654 |
| 655 int SetItemHeight(int nIndex, UINT cyItemHeight) |
| 656 { |
| 657 ATLASSERT(::IsWindow(m_hWnd)); |
| 658 return (int)::SendMessage(m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKE
LONG(cyItemHeight, 0)); |
| 659 } |
| 660 |
| 661 // Settable only attributes |
| 662 void SetColumnWidth(int cxWidth) |
| 663 { |
| 664 ATLASSERT(::IsWindow(m_hWnd)); |
| 665 ::SendMessage(m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L); |
| 666 } |
| 667 |
| 668 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) |
| 669 { |
| 670 ATLASSERT(::IsWindow(m_hWnd)); |
| 671 ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); |
| 672 return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, nTabStops, (L
PARAM)rgTabStops); |
| 673 } |
| 674 |
| 675 BOOL SetTabStops() |
| 676 { |
| 677 ATLASSERT(::IsWindow(m_hWnd)); |
| 678 ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); |
| 679 return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 0, 0L); |
| 680 } |
| 681 |
| 682 BOOL SetTabStops(const int& cxEachStop) // takes an 'int' |
| 683 { |
| 684 ATLASSERT(::IsWindow(m_hWnd)); |
| 685 ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0); |
| 686 return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(L
PINT)&cxEachStop); |
| 687 } |
| 688 |
| 689 // Operations |
| 690 int InitStorage(int nItems, UINT nBytes) |
| 691 { |
| 692 ATLASSERT(::IsWindow(m_hWnd)); |
| 693 return (int)::SendMessage(m_hWnd, LB_INITSTORAGE, (WPARAM)nItems
, nBytes); |
| 694 } |
| 695 |
| 696 void ResetContent() |
| 697 { |
| 698 ATLASSERT(::IsWindow(m_hWnd)); |
| 699 ::SendMessage(m_hWnd, LB_RESETCONTENT, 0, 0L); |
| 700 } |
| 701 |
| 702 UINT ItemFromPoint(POINT pt, BOOL& bOutside) const |
| 703 { |
| 704 ATLASSERT(::IsWindow(m_hWnd)); |
| 705 DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAK
ELPARAM(pt.x, pt.y)); |
| 706 bOutside = (BOOL)HIWORD(dw); |
| 707 return (UINT)LOWORD(dw); |
| 708 } |
| 709 |
| 710 // manipulating listbox items |
| 711 int AddString(LPCTSTR lpszItem) |
| 712 { |
| 713 ATLASSERT(::IsWindow(m_hWnd)); |
| 714 return (int)::SendMessage(m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszI
tem); |
| 715 } |
| 716 |
| 717 int DeleteString(UINT nIndex) |
| 718 { |
| 719 ATLASSERT(::IsWindow(m_hWnd)); |
| 720 return (int)::SendMessage(m_hWnd, LB_DELETESTRING, nIndex, 0L); |
| 721 } |
| 722 |
| 723 int InsertString(int nIndex, LPCTSTR lpszItem) |
| 724 { |
| 725 ATLASSERT(::IsWindow(m_hWnd)); |
| 726 return (int)::SendMessage(m_hWnd, LB_INSERTSTRING, nIndex, (LPAR
AM)lpszItem); |
| 727 } |
| 728 |
| 729 #ifndef _WIN32_WCE |
| 730 int Dir(UINT attr, LPCTSTR lpszWildCard) |
| 731 { |
| 732 ATLASSERT(::IsWindow(m_hWnd)); |
| 733 return (int)::SendMessage(m_hWnd, LB_DIR, attr, (LPARAM)lpszWild
Card); |
| 734 } |
| 735 |
| 736 int AddFile(LPCTSTR lpstrFileName) |
| 737 { |
| 738 ATLASSERT(::IsWindow(m_hWnd)); |
| 739 return (int)::SendMessage(m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFi
leName); |
| 740 } |
| 741 #endif // !_WIN32_WCE |
| 742 |
| 743 // selection helpers |
| 744 int FindString(int nStartAfter, LPCTSTR lpszItem) const |
| 745 { |
| 746 ATLASSERT(::IsWindow(m_hWnd)); |
| 747 return (int)::SendMessage(m_hWnd, LB_FINDSTRING, nStartAfter, (L
PARAM)lpszItem); |
| 748 } |
| 749 |
| 750 int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const |
| 751 { |
| 752 ATLASSERT(::IsWindow(m_hWnd)); |
| 753 return (int)::SendMessage(m_hWnd, LB_FINDSTRINGEXACT, nIndexStar
t, (LPARAM)lpszFind); |
| 754 } |
| 755 |
| 756 int SelectString(int nStartAfter, LPCTSTR lpszItem) |
| 757 { |
| 758 ATLASSERT(::IsWindow(m_hWnd)); |
| 759 return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter,
(LPARAM)lpszItem); |
| 760 } |
| 761 |
| 762 int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) |
| 763 { |
| 764 ATLASSERT(::IsWindow(m_hWnd)); |
| 765 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) !=
0); |
| 766 ATLASSERT(nFirstItem <= nLastItem); |
| 767 return bSelect ? (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, n
FirstItem, nLastItem) : (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nLastItem,
nFirstItem); |
| 768 } |
| 769 |
| 770 #ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages |
| 771 DWORD GetInputMode(BOOL bCurrentMode = TRUE) |
| 772 { |
| 773 return SendMessage(LB_GETINPUTMODE, 0, (LPARAM)bCurrentMode); |
| 774 } |
| 775 |
| 776 BOOL SetInputMode(DWORD dwMode) |
| 777 { |
| 778 return SendMessage(LB_SETINPUTMODE, 0, (LPARAM)dwMode); |
| 779 } |
| 780 #endif // WIN32_PLATFORM_WFSP |
| 781 }; |
| 782 |
| 783 typedef CListBoxT<ATL::CWindow> CListBox; |
| 784 |
| 785 |
| 786 /////////////////////////////////////////////////////////////////////////////// |
| 787 // CComboBox - client side for a Windows COMBOBOX control |
| 788 |
| 789 #ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones |
| 790 |
| 791 template <class TBase> |
| 792 class CComboBoxT : public TBase |
| 793 { |
| 794 public: |
| 795 // Constructors |
| 796 CComboBoxT(HWND hWnd = NULL) : TBase(hWnd) |
| 797 { } |
| 798 |
| 799 CComboBoxT< TBase >& operator =(HWND hWnd) |
| 800 { |
| 801 m_hWnd = hWnd; |
| 802 return *this; |
| 803 } |
| 804 |
| 805 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 806 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 807 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 808 { |
| 809 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 810 } |
| 811 |
| 812 // Attributes |
| 813 static LPCTSTR GetWndClassName() |
| 814 { |
| 815 return _T("COMBOBOX"); |
| 816 } |
| 817 |
| 818 // for entire combo box |
| 819 int GetCount() const |
| 820 { |
| 821 ATLASSERT(::IsWindow(m_hWnd)); |
| 822 return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0L); |
| 823 } |
| 824 |
| 825 int GetCurSel() const |
| 826 { |
| 827 ATLASSERT(::IsWindow(m_hWnd)); |
| 828 return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0L); |
| 829 } |
| 830 |
| 831 int SetCurSel(int nSelect) |
| 832 { |
| 833 ATLASSERT(::IsWindow(m_hWnd)); |
| 834 return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0L); |
| 835 } |
| 836 |
| 837 LCID GetLocale() const |
| 838 { |
| 839 ATLASSERT(::IsWindow(m_hWnd)); |
| 840 return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0L); |
| 841 } |
| 842 |
| 843 LCID SetLocale(LCID nNewLocale) |
| 844 { |
| 845 ATLASSERT(::IsWindow(m_hWnd)); |
| 846 return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLoc
ale, 0L); |
| 847 } |
| 848 |
| 849 int GetTopIndex() const |
| 850 { |
| 851 ATLASSERT(::IsWindow(m_hWnd)); |
| 852 return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0L); |
| 853 } |
| 854 |
| 855 int SetTopIndex(int nIndex) |
| 856 { |
| 857 ATLASSERT(::IsWindow(m_hWnd)); |
| 858 return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0L); |
| 859 } |
| 860 |
| 861 UINT GetHorizontalExtent() const |
| 862 { |
| 863 ATLASSERT(::IsWindow(m_hWnd)); |
| 864 return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L
); |
| 865 } |
| 866 |
| 867 void SetHorizontalExtent(UINT nExtent) |
| 868 { |
| 869 ATLASSERT(::IsWindow(m_hWnd)); |
| 870 ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L); |
| 871 } |
| 872 |
| 873 int GetDroppedWidth() const |
| 874 { |
| 875 ATLASSERT(::IsWindow(m_hWnd)); |
| 876 return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L); |
| 877 } |
| 878 |
| 879 int SetDroppedWidth(UINT nWidth) |
| 880 { |
| 881 ATLASSERT(::IsWindow(m_hWnd)); |
| 882 return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L
); |
| 883 } |
| 884 |
| 885 #if ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WI
N32_WCE >= 420)) |
| 886 BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const |
| 887 { |
| 888 ATLASSERT(::IsWindow(m_hWnd)); |
| 889 #if ((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) &
& (_WIN32_WCE >= 420)) |
| 890 return (BOOL)::SendMessage(m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARA
M)pComboBoxInfo); |
| 891 #else // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_
WCE) && (_WIN32_WCE >= 420)) |
| 892 return ::GetComboBoxInfo(m_hWnd, pComboBoxInfo); |
| 893 #endif // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32
_WCE) && (_WIN32_WCE >= 420)) |
| 894 } |
| 895 #endif // ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) &
& (_WIN32_WCE >= 420)) |
| 896 |
| 897 // for edit control |
| 898 DWORD GetEditSel() const |
| 899 { |
| 900 ATLASSERT(::IsWindow(m_hWnd)); |
| 901 return (DWORD)::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0L); |
| 902 } |
| 903 |
| 904 BOOL SetEditSel(int nStartChar, int nEndChar) |
| 905 { |
| 906 ATLASSERT(::IsWindow(m_hWnd)); |
| 907 return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nS
tartChar, nEndChar)); |
| 908 } |
| 909 |
| 910 // for combobox item |
| 911 DWORD_PTR GetItemData(int nIndex) const |
| 912 { |
| 913 ATLASSERT(::IsWindow(m_hWnd)); |
| 914 return (DWORD_PTR)::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex,
0L); |
| 915 } |
| 916 |
| 917 int SetItemData(int nIndex, DWORD_PTR dwItemData) |
| 918 { |
| 919 ATLASSERT(::IsWindow(m_hWnd)); |
| 920 return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARA
M)dwItemData); |
| 921 } |
| 922 |
| 923 void* GetItemDataPtr(int nIndex) const |
| 924 { |
| 925 ATLASSERT(::IsWindow(m_hWnd)); |
| 926 return (void*)GetItemData(nIndex); |
| 927 } |
| 928 |
| 929 int SetItemDataPtr(int nIndex, void* pData) |
| 930 { |
| 931 ATLASSERT(::IsWindow(m_hWnd)); |
| 932 return SetItemData(nIndex, (DWORD_PTR)pData); |
| 933 } |
| 934 |
| 935 int GetLBText(int nIndex, LPTSTR lpszText) const |
| 936 { |
| 937 ATLASSERT(::IsWindow(m_hWnd)); |
| 938 return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)
lpszText); |
| 939 } |
| 940 |
| 941 #ifndef _ATL_NO_COM |
| 942 BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const |
| 943 { |
| 944 USES_CONVERSION; |
| 945 ATLASSERT(::IsWindow(m_hWnd)); |
| 946 ATLASSERT(bstrText == NULL); |
| 947 |
| 948 int nLen = GetLBTextLen(nIndex); |
| 949 if(nLen == CB_ERR) |
| 950 return FALSE; |
| 951 |
| 952 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 953 LPTSTR lpstrText = buff.Allocate(nLen + 1); |
| 954 if(lpstrText == NULL) |
| 955 return FALSE; |
| 956 |
| 957 if(GetLBText(nIndex, lpstrText) == CB_ERR) |
| 958 return FALSE; |
| 959 |
| 960 bstrText = ::SysAllocString(T2OLE(lpstrText)); |
| 961 return (bstrText != NULL) ? TRUE : FALSE; |
| 962 } |
| 963 #endif // !_ATL_NO_COM |
| 964 |
| 965 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 966 int GetLBText(int nIndex, _CSTRING_NS::CString& strText) const |
| 967 { |
| 968 ATLASSERT(::IsWindow(m_hWnd)); |
| 969 int cchLen = GetLBTextLen(nIndex); |
| 970 if(cchLen == CB_ERR) |
| 971 return CB_ERR; |
| 972 int nRet = CB_ERR; |
| 973 LPTSTR lpstr = strText.GetBufferSetLength(cchLen); |
| 974 if(lpstr != NULL) |
| 975 { |
| 976 nRet = GetLBText(nIndex, lpstr); |
| 977 strText.ReleaseBuffer(); |
| 978 } |
| 979 return nRet; |
| 980 } |
| 981 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 982 |
| 983 int GetLBTextLen(int nIndex) const |
| 984 { |
| 985 ATLASSERT(::IsWindow(m_hWnd)); |
| 986 return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L); |
| 987 } |
| 988 |
| 989 int GetItemHeight(int nIndex) const |
| 990 { |
| 991 ATLASSERT(::IsWindow(m_hWnd)); |
| 992 return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L); |
| 993 } |
| 994 |
| 995 int SetItemHeight(int nIndex, UINT cyItemHeight) |
| 996 { |
| 997 ATLASSERT(::IsWindow(m_hWnd)); |
| 998 return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKE
LONG(cyItemHeight, 0)); |
| 999 } |
| 1000 |
| 1001 BOOL GetExtendedUI() const |
| 1002 { |
| 1003 ATLASSERT(::IsWindow(m_hWnd)); |
| 1004 return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L); |
| 1005 } |
| 1006 |
| 1007 int SetExtendedUI(BOOL bExtended = TRUE) |
| 1008 { |
| 1009 ATLASSERT(::IsWindow(m_hWnd)); |
| 1010 return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0
L); |
| 1011 } |
| 1012 |
| 1013 void GetDroppedControlRect(LPRECT lprect) const |
| 1014 { |
| 1015 ATLASSERT(::IsWindow(m_hWnd)); |
| 1016 ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprec
t); |
| 1017 } |
| 1018 |
| 1019 BOOL GetDroppedState() const |
| 1020 { |
| 1021 ATLASSERT(::IsWindow(m_hWnd)); |
| 1022 return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L); |
| 1023 } |
| 1024 |
| 1025 #if (_WIN32_WINNT >= 0x0501) |
| 1026 int GetMinVisible() const |
| 1027 { |
| 1028 ATLASSERT(::IsWindow(m_hWnd)); |
| 1029 return (int)::SendMessage(m_hWnd, CB_GETMINVISIBLE, 0, 0L); |
| 1030 } |
| 1031 |
| 1032 BOOL SetMinVisible(int nMinVisible) |
| 1033 { |
| 1034 ATLASSERT(::IsWindow(m_hWnd)); |
| 1035 return (BOOL)::SendMessage(m_hWnd, CB_SETMINVISIBLE, nMinVisible
, 0L); |
| 1036 } |
| 1037 |
| 1038 // Vista only |
| 1039 BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const |
| 1040 { |
| 1041 #ifndef CB_GETCUEBANNER |
| 1042 const UINT CB_GETCUEBANNER = (CBM_FIRST + 4); |
| 1043 #endif |
| 1044 ATLASSERT(::IsWindow(m_hWnd)); |
| 1045 return (BOOL)::SendMessage(m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwT
ext, cchText); |
| 1046 } |
| 1047 |
| 1048 // Vista only |
| 1049 BOOL SetCueBannerText(LPCWSTR lpcwText) |
| 1050 { |
| 1051 #ifndef CB_SETCUEBANNER |
| 1052 const UINT CB_SETCUEBANNER = (CBM_FIRST + 3); |
| 1053 #endif |
| 1054 ATLASSERT(::IsWindow(m_hWnd)); |
| 1055 return (BOOL)::SendMessage(m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)l
pcwText); |
| 1056 } |
| 1057 #endif // (_WIN32_WINNT >= 0x0501) |
| 1058 |
| 1059 // Operations |
| 1060 int InitStorage(int nItems, UINT nBytes) |
| 1061 { |
| 1062 ATLASSERT(::IsWindow(m_hWnd)); |
| 1063 return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems
, nBytes); |
| 1064 } |
| 1065 |
| 1066 void ResetContent() |
| 1067 { |
| 1068 ATLASSERT(::IsWindow(m_hWnd)); |
| 1069 ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0L); |
| 1070 } |
| 1071 |
| 1072 // for edit control |
| 1073 BOOL LimitText(int nMaxChars) |
| 1074 { |
| 1075 ATLASSERT(::IsWindow(m_hWnd)); |
| 1076 return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0L); |
| 1077 } |
| 1078 |
| 1079 // for drop-down combo boxes |
| 1080 void ShowDropDown(BOOL bShowIt = TRUE) |
| 1081 { |
| 1082 ATLASSERT(::IsWindow(m_hWnd)); |
| 1083 ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L); |
| 1084 } |
| 1085 |
| 1086 // manipulating listbox items |
| 1087 int AddString(LPCTSTR lpszString) |
| 1088 { |
| 1089 ATLASSERT(::IsWindow(m_hWnd)); |
| 1090 return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszS
tring); |
| 1091 } |
| 1092 |
| 1093 int DeleteString(UINT nIndex) |
| 1094 { |
| 1095 ATLASSERT(::IsWindow(m_hWnd)); |
| 1096 return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0L); |
| 1097 } |
| 1098 |
| 1099 int InsertString(int nIndex, LPCTSTR lpszString) |
| 1100 { |
| 1101 ATLASSERT(::IsWindow(m_hWnd)); |
| 1102 return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPAR
AM)lpszString); |
| 1103 } |
| 1104 |
| 1105 #ifndef _WIN32_WCE |
| 1106 int Dir(UINT attr, LPCTSTR lpszWildCard) |
| 1107 { |
| 1108 ATLASSERT(::IsWindow(m_hWnd)); |
| 1109 return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWild
Card); |
| 1110 } |
| 1111 #endif // !_WIN32_WCE |
| 1112 |
| 1113 // selection helpers |
| 1114 int FindString(int nStartAfter, LPCTSTR lpszString) const |
| 1115 { |
| 1116 ATLASSERT(::IsWindow(m_hWnd)); |
| 1117 return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter, (L
PARAM)lpszString); |
| 1118 } |
| 1119 |
| 1120 int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const |
| 1121 { |
| 1122 ATLASSERT(::IsWindow(m_hWnd)); |
| 1123 return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStar
t, (LPARAM)lpszFind); |
| 1124 } |
| 1125 |
| 1126 int SelectString(int nStartAfter, LPCTSTR lpszString) |
| 1127 { |
| 1128 ATLASSERT(::IsWindow(m_hWnd)); |
| 1129 return (int)::SendMessage(m_hWnd, CB_SELECTSTRING, nStartAfter,
(LPARAM)lpszString); |
| 1130 } |
| 1131 |
| 1132 // Clipboard operations |
| 1133 void Clear() |
| 1134 { |
| 1135 ATLASSERT(::IsWindow(m_hWnd)); |
| 1136 ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); |
| 1137 } |
| 1138 |
| 1139 void Copy() |
| 1140 { |
| 1141 ATLASSERT(::IsWindow(m_hWnd)); |
| 1142 ::SendMessage(m_hWnd, WM_COPY, 0, 0L); |
| 1143 } |
| 1144 |
| 1145 void Cut() |
| 1146 { |
| 1147 ATLASSERT(::IsWindow(m_hWnd)); |
| 1148 ::SendMessage(m_hWnd, WM_CUT, 0, 0L); |
| 1149 } |
| 1150 |
| 1151 void Paste() |
| 1152 { |
| 1153 ATLASSERT(::IsWindow(m_hWnd)); |
| 1154 ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); |
| 1155 } |
| 1156 }; |
| 1157 |
| 1158 typedef CComboBoxT<ATL::CWindow> CComboBox; |
| 1159 |
| 1160 #endif // !WIN32_PLATFORM_WFSP |
| 1161 |
| 1162 /////////////////////////////////////////////////////////////////////////////// |
| 1163 // CEdit - client side for a Windows EDIT control |
| 1164 |
| 1165 template <class TBase> |
| 1166 class CEditT : public TBase |
| 1167 { |
| 1168 public: |
| 1169 // Constructors |
| 1170 CEditT(HWND hWnd = NULL) : TBase(hWnd) |
| 1171 { } |
| 1172 |
| 1173 CEditT< TBase >& operator =(HWND hWnd) |
| 1174 { |
| 1175 m_hWnd = hWnd; |
| 1176 return *this; |
| 1177 } |
| 1178 |
| 1179 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 1180 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 1181 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 1182 { |
| 1183 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 1184 } |
| 1185 |
| 1186 // Attributes |
| 1187 static LPCTSTR GetWndClassName() |
| 1188 { |
| 1189 return _T("EDIT"); |
| 1190 } |
| 1191 |
| 1192 BOOL CanUndo() const |
| 1193 { |
| 1194 ATLASSERT(::IsWindow(m_hWnd)); |
| 1195 return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L); |
| 1196 } |
| 1197 |
| 1198 int GetLineCount() const |
| 1199 { |
| 1200 ATLASSERT(::IsWindow(m_hWnd)); |
| 1201 return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L); |
| 1202 } |
| 1203 |
| 1204 BOOL GetModify() const |
| 1205 { |
| 1206 ATLASSERT(::IsWindow(m_hWnd)); |
| 1207 return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L); |
| 1208 } |
| 1209 |
| 1210 void SetModify(BOOL bModified = TRUE) |
| 1211 { |
| 1212 ATLASSERT(::IsWindow(m_hWnd)); |
| 1213 ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L); |
| 1214 } |
| 1215 |
| 1216 void GetRect(LPRECT lpRect) const |
| 1217 { |
| 1218 ATLASSERT(::IsWindow(m_hWnd)); |
| 1219 ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); |
| 1220 } |
| 1221 |
| 1222 DWORD GetSel() const |
| 1223 { |
| 1224 ATLASSERT(::IsWindow(m_hWnd)); |
| 1225 return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L); |
| 1226 } |
| 1227 |
| 1228 void GetSel(int& nStartChar, int& nEndChar) const |
| 1229 { |
| 1230 ATLASSERT(::IsWindow(m_hWnd)); |
| 1231 ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&n
EndChar); |
| 1232 } |
| 1233 |
| 1234 #ifndef _WIN32_WCE |
| 1235 HLOCAL GetHandle() const |
| 1236 { |
| 1237 ATLASSERT(::IsWindow(m_hWnd)); |
| 1238 return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0L); |
| 1239 } |
| 1240 |
| 1241 void SetHandle(HLOCAL hBuffer) |
| 1242 { |
| 1243 ATLASSERT(::IsWindow(m_hWnd)); |
| 1244 ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L); |
| 1245 } |
| 1246 #endif // !_WIN32_WCE |
| 1247 |
| 1248 DWORD GetMargins() const |
| 1249 { |
| 1250 ATLASSERT(::IsWindow(m_hWnd)); |
| 1251 return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L); |
| 1252 } |
| 1253 |
| 1254 void SetMargins(UINT nLeft, UINT nRight) |
| 1255 { |
| 1256 ATLASSERT(::IsWindow(m_hWnd)); |
| 1257 ::SendMessage(m_hWnd, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGI
N, MAKELONG(nLeft, nRight)); |
| 1258 } |
| 1259 |
| 1260 UINT GetLimitText() const |
| 1261 { |
| 1262 ATLASSERT(::IsWindow(m_hWnd)); |
| 1263 return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L); |
| 1264 } |
| 1265 |
| 1266 void SetLimitText(UINT nMax) |
| 1267 { |
| 1268 ATLASSERT(::IsWindow(m_hWnd)); |
| 1269 ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0L); |
| 1270 } |
| 1271 |
| 1272 POINT PosFromChar(UINT nChar) const |
| 1273 { |
| 1274 ATLASSERT(::IsWindow(m_hWnd)); |
| 1275 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_POSFROMCHAR, nChar
, 0); |
| 1276 POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; |
| 1277 return point; |
| 1278 } |
| 1279 |
| 1280 int CharFromPos(POINT pt, int* pLine = NULL) const |
| 1281 { |
| 1282 ATLASSERT(::IsWindow(m_hWnd)); |
| 1283 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, MA
KELPARAM(pt.x, pt.y)); |
| 1284 if(pLine != NULL) |
| 1285 *pLine = (int)(short)HIWORD(dwRet); |
| 1286 return (int)(short)LOWORD(dwRet); |
| 1287 } |
| 1288 |
| 1289 // NOTE: first word in lpszBuffer must contain the size of the buffer! |
| 1290 int GetLine(int nIndex, LPTSTR lpszBuffer) const |
| 1291 { |
| 1292 ATLASSERT(::IsWindow(m_hWnd)); |
| 1293 return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lp
szBuffer); |
| 1294 } |
| 1295 |
| 1296 int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const |
| 1297 { |
| 1298 ATLASSERT(::IsWindow(m_hWnd)); |
| 1299 *(LPWORD)lpszBuffer = (WORD)nMaxLength; |
| 1300 return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lp
szBuffer); |
| 1301 } |
| 1302 |
| 1303 TCHAR GetPasswordChar() const |
| 1304 { |
| 1305 ATLASSERT(::IsWindow(m_hWnd)); |
| 1306 return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L); |
| 1307 } |
| 1308 |
| 1309 void SetPasswordChar(TCHAR ch) |
| 1310 { |
| 1311 ATLASSERT(::IsWindow(m_hWnd)); |
| 1312 ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0L); |
| 1313 } |
| 1314 |
| 1315 #ifndef _WIN32_WCE |
| 1316 EDITWORDBREAKPROC GetWordBreakProc() const |
| 1317 { |
| 1318 ATLASSERT(::IsWindow(m_hWnd)); |
| 1319 return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKP
ROC, 0, 0L); |
| 1320 } |
| 1321 |
| 1322 void SetWordBreakProc(EDITWORDBREAKPROC ewbprc) |
| 1323 { |
| 1324 ATLASSERT(::IsWindow(m_hWnd)); |
| 1325 ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc); |
| 1326 } |
| 1327 #endif // !_WIN32_WCE |
| 1328 |
| 1329 int GetFirstVisibleLine() const |
| 1330 { |
| 1331 ATLASSERT(::IsWindow(m_hWnd)); |
| 1332 return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L)
; |
| 1333 } |
| 1334 |
| 1335 #ifndef _WIN32_WCE |
| 1336 int GetThumb() const |
| 1337 { |
| 1338 ATLASSERT(::IsWindow(m_hWnd)); |
| 1339 ATLASSERT((GetStyle() & ES_MULTILINE) != 0); |
| 1340 return (int)::SendMessage(m_hWnd, EM_GETTHUMB, 0, 0L); |
| 1341 } |
| 1342 #endif // !_WIN32_WCE |
| 1343 |
| 1344 BOOL SetReadOnly(BOOL bReadOnly = TRUE) |
| 1345 { |
| 1346 ATLASSERT(::IsWindow(m_hWnd)); |
| 1347 return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L
); |
| 1348 } |
| 1349 |
| 1350 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE) |
| 1351 UINT GetImeStatus(UINT uStatus) const |
| 1352 { |
| 1353 ATLASSERT(::IsWindow(m_hWnd)); |
| 1354 return (UINT)::SendMessage(m_hWnd, EM_GETIMESTATUS, uStatus, 0L)
; |
| 1355 } |
| 1356 |
| 1357 UINT SetImeStatus(UINT uStatus, UINT uData) |
| 1358 { |
| 1359 ATLASSERT(::IsWindow(m_hWnd)); |
| 1360 return (UINT)::SendMessage(m_hWnd, EM_SETIMESTATUS, uStatus, uDa
ta); |
| 1361 } |
| 1362 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) |
| 1363 |
| 1364 #if (_WIN32_WINNT >= 0x0501) |
| 1365 BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const |
| 1366 { |
| 1367 ATLASSERT(::IsWindow(m_hWnd)); |
| 1368 return (BOOL)::SendMessage(m_hWnd, EM_GETCUEBANNER, (WPARAM)lpst
rText, cchText); |
| 1369 } |
| 1370 |
| 1371 // bKeepWithFocus - Vista only |
| 1372 BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE) |
| 1373 { |
| 1374 ATLASSERT(::IsWindow(m_hWnd)); |
| 1375 return (BOOL)::SendMessage(m_hWnd, EM_SETCUEBANNER, (WPARAM)bKee
pWithFocus, (LPARAM)(lpstrText)); |
| 1376 } |
| 1377 #endif // (_WIN32_WINNT >= 0x0501) |
| 1378 |
| 1379 // Operations |
| 1380 void EmptyUndoBuffer() |
| 1381 { |
| 1382 ATLASSERT(::IsWindow(m_hWnd)); |
| 1383 ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); |
| 1384 } |
| 1385 |
| 1386 BOOL FmtLines(BOOL bAddEOL) |
| 1387 { |
| 1388 ATLASSERT(::IsWindow(m_hWnd)); |
| 1389 return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0L); |
| 1390 } |
| 1391 |
| 1392 void LimitText(int nChars = 0) |
| 1393 { |
| 1394 ATLASSERT(::IsWindow(m_hWnd)); |
| 1395 ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0L); |
| 1396 } |
| 1397 |
| 1398 int LineFromChar(int nIndex = -1) const |
| 1399 { |
| 1400 ATLASSERT(::IsWindow(m_hWnd)); |
| 1401 return (int)::SendMessage(m_hWnd, EM_LINEFROMCHAR, nIndex, 0L); |
| 1402 } |
| 1403 |
| 1404 int LineIndex(int nLine = -1) const |
| 1405 { |
| 1406 ATLASSERT(::IsWindow(m_hWnd)); |
| 1407 return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L); |
| 1408 } |
| 1409 |
| 1410 int LineLength(int nLine = -1) const |
| 1411 { |
| 1412 ATLASSERT(::IsWindow(m_hWnd)); |
| 1413 return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L); |
| 1414 } |
| 1415 |
| 1416 void LineScroll(int nLines, int nChars = 0) |
| 1417 { |
| 1418 ATLASSERT(::IsWindow(m_hWnd)); |
| 1419 ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines); |
| 1420 } |
| 1421 |
| 1422 void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) |
| 1423 { |
| 1424 ATLASSERT(::IsWindow(m_hWnd)); |
| 1425 ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)
lpszNewText); |
| 1426 } |
| 1427 |
| 1428 void SetRect(LPCRECT lpRect) |
| 1429 { |
| 1430 ATLASSERT(::IsWindow(m_hWnd)); |
| 1431 ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); |
| 1432 } |
| 1433 |
| 1434 void SetRectNP(LPCRECT lpRect) |
| 1435 { |
| 1436 ATLASSERT(::IsWindow(m_hWnd)); |
| 1437 ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect); |
| 1438 } |
| 1439 |
| 1440 void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE) |
| 1441 { |
| 1442 ATLASSERT(::IsWindow(m_hWnd)); |
| 1443 ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwS
election)); |
| 1444 if(!bNoScroll) |
| 1445 ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); |
| 1446 } |
| 1447 |
| 1448 void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE) |
| 1449 { |
| 1450 ATLASSERT(::IsWindow(m_hWnd)); |
| 1451 ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar); |
| 1452 if(!bNoScroll) |
| 1453 ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); |
| 1454 } |
| 1455 |
| 1456 void SetSelAll(BOOL bNoScroll = FALSE) |
| 1457 { |
| 1458 SetSel(0, -1, bNoScroll); |
| 1459 } |
| 1460 |
| 1461 void SetSelNone(BOOL bNoScroll = FALSE) |
| 1462 { |
| 1463 SetSel(-1, 0, bNoScroll); |
| 1464 } |
| 1465 |
| 1466 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) |
| 1467 { |
| 1468 ATLASSERT(::IsWindow(m_hWnd)); |
| 1469 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (L
PARAM)rgTabStops); |
| 1470 } |
| 1471 |
| 1472 BOOL SetTabStops() |
| 1473 { |
| 1474 ATLASSERT(::IsWindow(m_hWnd)); |
| 1475 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L); |
| 1476 } |
| 1477 |
| 1478 BOOL SetTabStops(const int& cxEachStop) // takes an 'int' |
| 1479 { |
| 1480 ATLASSERT(::IsWindow(m_hWnd)); |
| 1481 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(L
PINT)&cxEachStop); |
| 1482 } |
| 1483 |
| 1484 void ScrollCaret() |
| 1485 { |
| 1486 ATLASSERT(::IsWindow(m_hWnd)); |
| 1487 ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); |
| 1488 } |
| 1489 |
| 1490 int Scroll(int nScrollAction) |
| 1491 { |
| 1492 ATLASSERT(::IsWindow(m_hWnd)); |
| 1493 ATLASSERT((GetStyle() & ES_MULTILINE) != 0); |
| 1494 LRESULT lRet = ::SendMessage(m_hWnd, EM_SCROLL, nScrollAction, 0
L); |
| 1495 if(!(BOOL)HIWORD(lRet)) |
| 1496 return -1; // failed |
| 1497 return (int)(short)LOWORD(lRet); |
| 1498 |
| 1499 } |
| 1500 |
| 1501 void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll
= FALSE, BOOL bCanUndo = FALSE) |
| 1502 { |
| 1503 SetSel(nInsertAfterChar, nInsertAfterChar, bNoScroll); |
| 1504 ReplaceSel(lpstrText, bCanUndo); |
| 1505 } |
| 1506 |
| 1507 void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo
= FALSE) |
| 1508 { |
| 1509 InsertText(GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo
); |
| 1510 } |
| 1511 |
| 1512 #if (_WIN32_WINNT >= 0x0501) |
| 1513 BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip) |
| 1514 { |
| 1515 ATLASSERT(::IsWindow(m_hWnd)); |
| 1516 return (BOOL)::SendMessage(m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM
)pEditBaloonTip); |
| 1517 } |
| 1518 |
| 1519 BOOL HideBalloonTip() |
| 1520 { |
| 1521 ATLASSERT(::IsWindow(m_hWnd)); |
| 1522 return (BOOL)::SendMessage(m_hWnd, EM_HIDEBALLOONTIP, 0, 0L); |
| 1523 } |
| 1524 #endif // (_WIN32_WINNT >= 0x0501) |
| 1525 |
| 1526 #if (_WIN32_WINNT >= 0x0600) |
| 1527 DWORD GetHilite() const |
| 1528 { |
| 1529 ATLASSERT(::IsWindow(m_hWnd)); |
| 1530 return (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L); |
| 1531 } |
| 1532 |
| 1533 void GetHilite(int& nStartChar, int& nEndChar) const |
| 1534 { |
| 1535 ATLASSERT(::IsWindow(m_hWnd)); |
| 1536 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L); |
| 1537 nStartChar = (int)(short)LOWORD(dwRet); |
| 1538 nEndChar = (int)(short)HIWORD(dwRet); |
| 1539 } |
| 1540 |
| 1541 void SetHilite(int nStartChar, int nEndChar) |
| 1542 { |
| 1543 ATLASSERT(::IsWindow(m_hWnd)); |
| 1544 ::SendMessage(m_hWnd, EM_SETHILITE, nStartChar, nEndChar); |
| 1545 } |
| 1546 #endif // (_WIN32_WINNT >= 0x0600) |
| 1547 |
| 1548 // Clipboard operations |
| 1549 BOOL Undo() |
| 1550 { |
| 1551 ATLASSERT(::IsWindow(m_hWnd)); |
| 1552 return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L); |
| 1553 } |
| 1554 |
| 1555 void Clear() |
| 1556 { |
| 1557 ATLASSERT(::IsWindow(m_hWnd)); |
| 1558 ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); |
| 1559 } |
| 1560 |
| 1561 void Copy() |
| 1562 { |
| 1563 ATLASSERT(::IsWindow(m_hWnd)); |
| 1564 ::SendMessage(m_hWnd, WM_COPY, 0, 0L); |
| 1565 } |
| 1566 |
| 1567 void Cut() |
| 1568 { |
| 1569 ATLASSERT(::IsWindow(m_hWnd)); |
| 1570 ::SendMessage(m_hWnd, WM_CUT, 0, 0L); |
| 1571 } |
| 1572 |
| 1573 void Paste() |
| 1574 { |
| 1575 ATLASSERT(::IsWindow(m_hWnd)); |
| 1576 ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); |
| 1577 } |
| 1578 |
| 1579 #ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages |
| 1580 DWORD GetExtendedStyle() |
| 1581 { |
| 1582 return SendMessage(EM_GETEXTENDEDSTYLE); |
| 1583 } |
| 1584 |
| 1585 DWORD SetExtendedStyle(DWORD dwMask, DWORD dwExStyle) |
| 1586 { |
| 1587 return SendMessage(EM_SETEXTENDEDSTYLE, (WPARAM)dwMask, (LPARAM)
dwExStyle); |
| 1588 } |
| 1589 |
| 1590 DWORD GetInputMode(BOOL bCurrentMode = TRUE) |
| 1591 { |
| 1592 return SendMessage(EM_GETINPUTMODE, 0, (LPARAM)bCurrentMode); |
| 1593 } |
| 1594 |
| 1595 BOOL SetInputMode(DWORD dwMode) |
| 1596 { |
| 1597 return SendMessage(EM_SETINPUTMODE, 0, (LPARAM)dwMode); |
| 1598 } |
| 1599 |
| 1600 BOOL SetSymbols(LPCTSTR szSymbols) |
| 1601 { |
| 1602 return SendMessage(EM_SETSYMBOLS, 0, (LPARAM)szSymbols); |
| 1603 } |
| 1604 |
| 1605 BOOL ResetSymbols() |
| 1606 { |
| 1607 return SendMessage(EM_SETSYMBOLS); |
| 1608 } |
| 1609 #endif // WIN32_PLATFORM_WFSP |
| 1610 }; |
| 1611 |
| 1612 typedef CEditT<ATL::CWindow> CEdit; |
| 1613 |
| 1614 |
| 1615 /////////////////////////////////////////////////////////////////////////////// |
| 1616 // CEditCommands - message handlers for standard EDIT commands |
| 1617 |
| 1618 // Chain to CEditCommands message map. Your class must also derive from CEdit. |
| 1619 // Example: |
| 1620 // class CMyEdit : public CWindowImpl<CMyEdit, CEdit>, |
| 1621 // public CEditCommands<CMyEdit> |
| 1622 // { |
| 1623 // public: |
| 1624 // BEGIN_MSG_MAP(CMyEdit) |
| 1625 // // your handlers... |
| 1626 // CHAIN_MSG_MAP_ALT(CEditCommands<CMyEdit>, 1) |
| 1627 // END_MSG_MAP() |
| 1628 // // other stuff... |
| 1629 // }; |
| 1630 |
| 1631 template <class T> |
| 1632 class CEditCommands |
| 1633 { |
| 1634 public: |
| 1635 BEGIN_MSG_MAP(CEditCommands< T >) |
| 1636 ALT_MSG_MAP(1) |
| 1637 COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear) |
| 1638 COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll) |
| 1639 COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy) |
| 1640 COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut) |
| 1641 COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste) |
| 1642 COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll) |
| 1643 COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo) |
| 1644 END_MSG_MAP() |
| 1645 |
| 1646 LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/
, BOOL& /*bHandled*/) |
| 1647 { |
| 1648 T* pT = static_cast<T*>(this); |
| 1649 pT->Clear(); |
| 1650 return 0; |
| 1651 } |
| 1652 |
| 1653 LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt
l*/, BOOL& /*bHandled*/) |
| 1654 { |
| 1655 T* pT = static_cast<T*>(this); |
| 1656 pT->SetSel(0, -1); |
| 1657 pT->Clear(); |
| 1658 return 0; |
| 1659 } |
| 1660 |
| 1661 LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
BOOL& /*bHandled*/) |
| 1662 { |
| 1663 T* pT = static_cast<T*>(this); |
| 1664 pT->Copy(); |
| 1665 return 0; |
| 1666 } |
| 1667 |
| 1668 LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
BOOL& /*bHandled*/) |
| 1669 { |
| 1670 T* pT = static_cast<T*>(this); |
| 1671 pT->Cut(); |
| 1672 return 0; |
| 1673 } |
| 1674 |
| 1675 LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/
, BOOL& /*bHandled*/) |
| 1676 { |
| 1677 T* pT = static_cast<T*>(this); |
| 1678 pT->Paste(); |
| 1679 return 0; |
| 1680 } |
| 1681 |
| 1682 LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndC
tl*/, BOOL& /*bHandled*/) |
| 1683 { |
| 1684 T* pT = static_cast<T*>(this); |
| 1685 pT->SetSel(0, -1); |
| 1686 return 0; |
| 1687 } |
| 1688 |
| 1689 LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
BOOL& /*bHandled*/) |
| 1690 { |
| 1691 T* pT = static_cast<T*>(this); |
| 1692 pT->Undo(); |
| 1693 return 0; |
| 1694 } |
| 1695 |
| 1696 // State (update UI) helpers |
| 1697 BOOL CanCut() const |
| 1698 { return HasSelection(); } |
| 1699 |
| 1700 BOOL CanCopy() const |
| 1701 { return HasSelection(); } |
| 1702 |
| 1703 BOOL CanClear() const |
| 1704 { return HasSelection(); } |
| 1705 |
| 1706 BOOL CanSelectAll() const |
| 1707 { return HasText(); } |
| 1708 |
| 1709 BOOL CanFind() const |
| 1710 { return HasText(); } |
| 1711 |
| 1712 BOOL CanRepeat() const |
| 1713 { return HasText(); } |
| 1714 |
| 1715 BOOL CanReplace() const |
| 1716 { return HasText(); } |
| 1717 |
| 1718 BOOL CanClearAll() const |
| 1719 { return HasText(); } |
| 1720 |
| 1721 // Implementation |
| 1722 BOOL HasSelection() const |
| 1723 { |
| 1724 const T* pT = static_cast<const T*>(this); |
| 1725 int nMin, nMax; |
| 1726 ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nMin, (LPARAM)&nMa
x); |
| 1727 return (nMin != nMax); |
| 1728 } |
| 1729 |
| 1730 BOOL HasText() const |
| 1731 { |
| 1732 const T* pT = static_cast<const T*>(this); |
| 1733 return (pT->GetWindowTextLength() > 0); |
| 1734 } |
| 1735 }; |
| 1736 |
| 1737 |
| 1738 /////////////////////////////////////////////////////////////////////////////// |
| 1739 // CScrollBar - client side for a Windows SCROLLBAR control |
| 1740 |
| 1741 template <class TBase> |
| 1742 class CScrollBarT : public TBase |
| 1743 { |
| 1744 public: |
| 1745 // Constructors |
| 1746 CScrollBarT(HWND hWnd = NULL) : TBase(hWnd) |
| 1747 { } |
| 1748 |
| 1749 CScrollBarT< TBase >& operator =(HWND hWnd) |
| 1750 { |
| 1751 m_hWnd = hWnd; |
| 1752 return *this; |
| 1753 } |
| 1754 |
| 1755 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 1756 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 1757 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 1758 { |
| 1759 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 1760 } |
| 1761 |
| 1762 // Attributes |
| 1763 static LPCTSTR GetWndClassName() |
| 1764 { |
| 1765 return _T("SCROLLBAR"); |
| 1766 } |
| 1767 |
| 1768 #ifndef _WIN32_WCE |
| 1769 int GetScrollPos() const |
| 1770 { |
| 1771 ATLASSERT(::IsWindow(m_hWnd)); |
| 1772 return ::GetScrollPos(m_hWnd, SB_CTL); |
| 1773 } |
| 1774 #endif // !_WIN32_WCE |
| 1775 |
| 1776 int SetScrollPos(int nPos, BOOL bRedraw = TRUE) |
| 1777 { |
| 1778 ATLASSERT(::IsWindow(m_hWnd)); |
| 1779 return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw); |
| 1780 } |
| 1781 |
| 1782 #ifndef _WIN32_WCE |
| 1783 void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const |
| 1784 { |
| 1785 ATLASSERT(::IsWindow(m_hWnd)); |
| 1786 ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos); |
| 1787 } |
| 1788 #endif // !_WIN32_WCE |
| 1789 |
| 1790 void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE) |
| 1791 { |
| 1792 ATLASSERT(::IsWindow(m_hWnd)); |
| 1793 ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw); |
| 1794 } |
| 1795 |
| 1796 BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const |
| 1797 { |
| 1798 ATLASSERT(::IsWindow(m_hWnd)); |
| 1799 return ::GetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo); |
| 1800 } |
| 1801 |
| 1802 int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE) |
| 1803 { |
| 1804 ATLASSERT(::IsWindow(m_hWnd)); |
| 1805 return ::SetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo, bRedraw); |
| 1806 } |
| 1807 |
| 1808 #ifndef _WIN32_WCE |
| 1809 int GetScrollLimit() const |
| 1810 { |
| 1811 int nMin = 0, nMax = 0; |
| 1812 ::GetScrollRange(m_hWnd, SB_CTL, &nMin, &nMax); |
| 1813 SCROLLINFO info = { 0 }; |
| 1814 info.cbSize = sizeof(SCROLLINFO); |
| 1815 info.fMask = SIF_PAGE; |
| 1816 if(::GetScrollInfo(m_hWnd, SB_CTL, &info)) |
| 1817 nMax -= ((info.nPage - 1) > 0) ? (info.nPage - 1) : 0; |
| 1818 |
| 1819 return nMax; |
| 1820 } |
| 1821 |
| 1822 #if (WINVER >= 0x0500) |
| 1823 BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const |
| 1824 { |
| 1825 ATLASSERT(::IsWindow(m_hWnd)); |
| 1826 #if (_WIN32_WINNT >= 0x0501) |
| 1827 return (BOOL)::SendMessage(m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPA
RAM)pScrollBarInfo); |
| 1828 #else // !(_WIN32_WINNT >= 0x0501) |
| 1829 return ::GetScrollBarInfo(m_hWnd, OBJID_CLIENT, pScrollBarInfo); |
| 1830 #endif // !(_WIN32_WINNT >= 0x0501) |
| 1831 } |
| 1832 #endif // (WINVER >= 0x0500) |
| 1833 |
| 1834 // Operations |
| 1835 void ShowScrollBar(BOOL bShow = TRUE) |
| 1836 { |
| 1837 ATLASSERT(::IsWindow(m_hWnd)); |
| 1838 ::ShowScrollBar(m_hWnd, SB_CTL, bShow); |
| 1839 } |
| 1840 |
| 1841 BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH) |
| 1842 { |
| 1843 ATLASSERT(::IsWindow(m_hWnd)); |
| 1844 return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags); |
| 1845 } |
| 1846 #endif // !_WIN32_WCE |
| 1847 }; |
| 1848 |
| 1849 typedef CScrollBarT<ATL::CWindow> CScrollBar; |
| 1850 |
| 1851 |
| 1852 // --- Windows Common Controls --- |
| 1853 |
| 1854 /////////////////////////////////////////////////////////////////////////////// |
| 1855 // CImageList |
| 1856 |
| 1857 class CImageList |
| 1858 { |
| 1859 public: |
| 1860 HIMAGELIST m_hImageList; |
| 1861 |
| 1862 // Constructor |
| 1863 CImageList(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList) |
| 1864 { } |
| 1865 |
| 1866 // Operators, etc. |
| 1867 CImageList& operator =(HIMAGELIST hImageList) |
| 1868 { |
| 1869 m_hImageList = hImageList; |
| 1870 return *this; |
| 1871 } |
| 1872 |
| 1873 operator HIMAGELIST() const { return m_hImageList; } |
| 1874 |
| 1875 void Attach(HIMAGELIST hImageList) |
| 1876 { |
| 1877 ATLASSERT(m_hImageList == NULL); |
| 1878 ATLASSERT(hImageList != NULL); |
| 1879 m_hImageList = hImageList; |
| 1880 } |
| 1881 |
| 1882 HIMAGELIST Detach() |
| 1883 { |
| 1884 HIMAGELIST hImageList = m_hImageList; |
| 1885 m_hImageList = NULL; |
| 1886 return hImageList; |
| 1887 } |
| 1888 |
| 1889 bool IsNull() const { return (m_hImageList == NULL); } |
| 1890 |
| 1891 // Attributes |
| 1892 int GetImageCount() const |
| 1893 { |
| 1894 ATLASSERT(m_hImageList != NULL); |
| 1895 return ImageList_GetImageCount(m_hImageList); |
| 1896 } |
| 1897 |
| 1898 COLORREF GetBkColor() const |
| 1899 { |
| 1900 ATLASSERT(m_hImageList != NULL); |
| 1901 return ImageList_GetBkColor(m_hImageList); |
| 1902 } |
| 1903 |
| 1904 COLORREF SetBkColor(COLORREF cr) |
| 1905 { |
| 1906 ATLASSERT(m_hImageList != NULL); |
| 1907 return ImageList_SetBkColor(m_hImageList, cr); |
| 1908 } |
| 1909 |
| 1910 BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const |
| 1911 { |
| 1912 ATLASSERT(m_hImageList != NULL); |
| 1913 return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo); |
| 1914 } |
| 1915 |
| 1916 HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const |
| 1917 { |
| 1918 ATLASSERT(m_hImageList != NULL); |
| 1919 return ImageList_GetIcon(m_hImageList, nIndex, uFlags); |
| 1920 } |
| 1921 |
| 1922 BOOL GetIconSize(int& cx, int& cy) const |
| 1923 { |
| 1924 ATLASSERT(m_hImageList != NULL); |
| 1925 return ImageList_GetIconSize(m_hImageList, &cx, &cy); |
| 1926 } |
| 1927 |
| 1928 BOOL GetIconSize(SIZE& size) const |
| 1929 { |
| 1930 ATLASSERT(m_hImageList != NULL); |
| 1931 return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*
)&size.cy); |
| 1932 } |
| 1933 |
| 1934 BOOL SetIconSize(int cx, int cy) |
| 1935 { |
| 1936 ATLASSERT(m_hImageList != NULL); |
| 1937 return ImageList_SetIconSize(m_hImageList, cx, cy); |
| 1938 } |
| 1939 |
| 1940 BOOL SetIconSize(SIZE size) |
| 1941 { |
| 1942 ATLASSERT(m_hImageList != NULL); |
| 1943 return ImageList_SetIconSize(m_hImageList, size.cx, size.cy); |
| 1944 } |
| 1945 |
| 1946 BOOL SetImageCount(UINT uNewCount) |
| 1947 { |
| 1948 ATLASSERT(m_hImageList != NULL); |
| 1949 return ImageList_SetImageCount(m_hImageList, uNewCount); |
| 1950 } |
| 1951 |
| 1952 BOOL SetOverlayImage(int nImage, int nOverlay) |
| 1953 { |
| 1954 ATLASSERT(m_hImageList != NULL); |
| 1955 return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay)
; |
| 1956 } |
| 1957 |
| 1958 // Operations |
| 1959 BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow) |
| 1960 { |
| 1961 ATLASSERT(m_hImageList == NULL); |
| 1962 m_hImageList = ImageList_Create(cx, cy, nFlags, nInitial, nGrow)
; |
| 1963 return (m_hImageList != NULL) ? TRUE : FALSE; |
| 1964 } |
| 1965 |
| 1966 BOOL Create(ATL::_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMas
k) |
| 1967 { |
| 1968 ATLASSERT(m_hImageList == NULL); |
| 1969 m_hImageList = ImageList_LoadBitmap(ModuleHelper::GetResourceIns
tance(), bitmap.m_lpstr, cx, nGrow, crMask); |
| 1970 return (m_hImageList != NULL) ? TRUE : FALSE; |
| 1971 } |
| 1972 |
| 1973 BOOL CreateFromImage(ATL::_U_STRINGorID image, int cx, int nGrow, COLORR
EF crMask, UINT uType, UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE) |
| 1974 { |
| 1975 ATLASSERT(m_hImageList == NULL); |
| 1976 m_hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInst
ance(), image.m_lpstr, cx, nGrow, crMask, uType, uFlags); |
| 1977 return (m_hImageList != NULL) ? TRUE : FALSE; |
| 1978 } |
| 1979 |
| 1980 BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2,
int nImage2, int dx, int dy) |
| 1981 { |
| 1982 ATLASSERT(m_hImageList == NULL); |
| 1983 m_hImageList = ImageList_Merge(hImageList1, nImage1, hImageList2
, nImage2, dx, dy); |
| 1984 return (m_hImageList != NULL) ? TRUE : FALSE; |
| 1985 } |
| 1986 |
| 1987 #ifndef _WIN32_WCE |
| 1988 #ifdef __IStream_INTERFACE_DEFINED__ |
| 1989 BOOL CreateFromStream(LPSTREAM lpStream) |
| 1990 { |
| 1991 ATLASSERT(m_hImageList == NULL); |
| 1992 m_hImageList = ImageList_Read(lpStream); |
| 1993 return (m_hImageList != NULL) ? TRUE : FALSE; |
| 1994 } |
| 1995 #endif // __IStream_INTERFACE_DEFINED__ |
| 1996 #endif // !_WIN32_WCE |
| 1997 |
| 1998 BOOL Destroy() |
| 1999 { |
| 2000 if (m_hImageList == NULL) |
| 2001 return FALSE; |
| 2002 BOOL bRet = ImageList_Destroy(m_hImageList); |
| 2003 if(bRet) |
| 2004 m_hImageList = NULL; |
| 2005 return bRet; |
| 2006 } |
| 2007 |
| 2008 int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL) |
| 2009 { |
| 2010 ATLASSERT(m_hImageList != NULL); |
| 2011 return ImageList_Add(m_hImageList, hBitmap, hBitmapMask); |
| 2012 } |
| 2013 |
| 2014 int Add(HBITMAP hBitmap, COLORREF crMask) |
| 2015 { |
| 2016 ATLASSERT(m_hImageList != NULL); |
| 2017 return ImageList_AddMasked(m_hImageList, hBitmap, crMask); |
| 2018 } |
| 2019 |
| 2020 BOOL Remove(int nImage) |
| 2021 { |
| 2022 ATLASSERT(m_hImageList != NULL); |
| 2023 return ImageList_Remove(m_hImageList, nImage); |
| 2024 } |
| 2025 |
| 2026 BOOL RemoveAll() |
| 2027 { |
| 2028 ATLASSERT(m_hImageList != NULL); |
| 2029 return ImageList_RemoveAll(m_hImageList); |
| 2030 } |
| 2031 |
| 2032 BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask) |
| 2033 { |
| 2034 ATLASSERT(m_hImageList != NULL); |
| 2035 return ImageList_Replace(m_hImageList, nImage, hBitmap, hBitmapM
ask); |
| 2036 } |
| 2037 |
| 2038 int AddIcon(HICON hIcon) |
| 2039 { |
| 2040 ATLASSERT(m_hImageList != NULL); |
| 2041 return ImageList_AddIcon(m_hImageList, hIcon); |
| 2042 } |
| 2043 |
| 2044 int ReplaceIcon(int nImage, HICON hIcon) |
| 2045 { |
| 2046 ATLASSERT(m_hImageList != NULL); |
| 2047 return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon); |
| 2048 } |
| 2049 |
| 2050 HICON ExtractIcon(int nImage) |
| 2051 { |
| 2052 ATLASSERT(m_hImageList != NULL); |
| 2053 return ImageList_ExtractIcon(NULL, m_hImageList, nImage); |
| 2054 } |
| 2055 |
| 2056 BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle) |
| 2057 { |
| 2058 ATLASSERT(m_hImageList != NULL); |
| 2059 ATLASSERT(hDC != NULL); |
| 2060 return ImageList_Draw(m_hImageList, nImage, hDC, x, y, nStyle); |
| 2061 } |
| 2062 |
| 2063 BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle) |
| 2064 { |
| 2065 ATLASSERT(m_hImageList != NULL); |
| 2066 ATLASSERT(hDC != NULL); |
| 2067 return ImageList_Draw(m_hImageList, nImage, hDC, pt.x, pt.y, nSt
yle); |
| 2068 } |
| 2069 |
| 2070 BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF
rgbBk, COLORREF rgbFg, UINT fStyle) |
| 2071 { |
| 2072 ATLASSERT(m_hImageList != NULL); |
| 2073 ATLASSERT(hDC != NULL); |
| 2074 return ImageList_DrawEx(m_hImageList, nImage, hDC, x, y, dx, dy,
rgbBk, rgbFg, fStyle); |
| 2075 } |
| 2076 |
| 2077 BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rg
bFg, UINT fStyle) |
| 2078 { |
| 2079 ATLASSERT(m_hImageList != NULL); |
| 2080 ATLASSERT(hDC != NULL); |
| 2081 return ImageList_DrawEx(m_hImageList, nImage, hDC, rect.left, re
ct.top, rect.right - rect.left, rect.bottom - rect.top, rgbBk, rgbFg, fStyle); |
| 2082 } |
| 2083 |
| 2084 static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp) |
| 2085 { |
| 2086 return ImageList_DrawIndirect(pimldp); |
| 2087 } |
| 2088 |
| 2089 BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE) |
| 2090 { |
| 2091 ATLASSERT(m_hImageList != NULL); |
| 2092 return ImageList_Copy(m_hImageList, nDst, m_hImageList, nSrc, uF
lags); |
| 2093 } |
| 2094 |
| 2095 #ifdef __IStream_INTERFACE_DEFINED__ |
| 2096 #ifndef _WIN32_WCE |
| 2097 static HIMAGELIST Read(LPSTREAM lpStream) |
| 2098 { |
| 2099 return ImageList_Read(lpStream); |
| 2100 } |
| 2101 |
| 2102 BOOL Write(LPSTREAM lpStream) |
| 2103 { |
| 2104 ATLASSERT(m_hImageList != NULL); |
| 2105 return ImageList_Write(m_hImageList, lpStream); |
| 2106 } |
| 2107 #endif // !_WIN32_WCE |
| 2108 |
| 2109 #if (_WIN32_WINNT >= 0x0501) |
| 2110 static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVO
ID* 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 // (_WIN32_WINNT >= 0x0501) |
| 2121 #endif // __IStream_INTERFACE_DEFINED__ |
| 2122 |
| 2123 // Drag operations |
| 2124 BOOL BeginDrag(int nImage, POINT ptHotSpot) |
| 2125 { |
| 2126 ATLASSERT(m_hImageList != NULL); |
| 2127 return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, pt
HotSpot.y); |
| 2128 } |
| 2129 |
| 2130 BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot) |
| 2131 { |
| 2132 ATLASSERT(m_hImageList != NULL); |
| 2133 return ImageList_BeginDrag(m_hImageList, nImage, xHotSpot, yHotS
pot); |
| 2134 } |
| 2135 |
| 2136 static void EndDrag() |
| 2137 { |
| 2138 ImageList_EndDrag(); |
| 2139 } |
| 2140 |
| 2141 static BOOL DragMove(POINT pt) |
| 2142 { |
| 2143 return ImageList_DragMove(pt.x, pt.y); |
| 2144 } |
| 2145 |
| 2146 static BOOL DragMove(int x, int y) |
| 2147 { |
| 2148 return ImageList_DragMove(x, y); |
| 2149 } |
| 2150 |
| 2151 BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot) |
| 2152 { |
| 2153 ATLASSERT(m_hImageList != NULL); |
| 2154 return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSp
ot.x, ptHotSpot.y); |
| 2155 } |
| 2156 |
| 2157 BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot) |
| 2158 { |
| 2159 ATLASSERT(m_hImageList != NULL); |
| 2160 return ImageList_SetDragCursorImage(m_hImageList, nDrag, xHotSpo
t, yHotSpot); |
| 2161 } |
| 2162 |
| 2163 static BOOL DragShowNolock(BOOL bShow = TRUE) |
| 2164 { |
| 2165 return ImageList_DragShowNolock(bShow); |
| 2166 } |
| 2167 |
| 2168 static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot) |
| 2169 { |
| 2170 return CImageList(ImageList_GetDragImage(lpPoint, lpPointHotSpot
)); |
| 2171 } |
| 2172 |
| 2173 static BOOL DragEnter(HWND hWnd, POINT point) |
| 2174 { |
| 2175 return ImageList_DragEnter(hWnd, point.x, point.y); |
| 2176 } |
| 2177 |
| 2178 static BOOL DragEnter(HWND hWnd, int x, int y) |
| 2179 { |
| 2180 return ImageList_DragEnter(hWnd, x, y); |
| 2181 } |
| 2182 |
| 2183 static BOOL DragLeave(HWND hWnd) |
| 2184 { |
| 2185 return ImageList_DragLeave(hWnd); |
| 2186 } |
| 2187 |
| 2188 #if (_WIN32_IE >= 0x0400) |
| 2189 CImageList Duplicate() const |
| 2190 { |
| 2191 ATLASSERT(m_hImageList != NULL); |
| 2192 return CImageList(ImageList_Duplicate(m_hImageList)); |
| 2193 } |
| 2194 |
| 2195 static CImageList Duplicate(HIMAGELIST hImageList) |
| 2196 { |
| 2197 ATLASSERT(hImageList != NULL); |
| 2198 return CImageList(ImageList_Duplicate(hImageList)); |
| 2199 } |
| 2200 #endif // (_WIN32_IE >= 0x0400) |
| 2201 }; |
| 2202 |
| 2203 |
| 2204 /////////////////////////////////////////////////////////////////////////////// |
| 2205 // CToolTipCtrl |
| 2206 |
| 2207 #ifndef _WIN32_WCE |
| 2208 |
| 2209 class CToolInfo : public TOOLINFO |
| 2210 { |
| 2211 public: |
| 2212 CToolInfo(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL
, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL) |
| 2213 { |
| 2214 Init(nFlags, hWnd, nIDTool, lpRect, lpstrText, lUserParam); |
| 2215 } |
| 2216 |
| 2217 operator LPTOOLINFO() { return this; } |
| 2218 |
| 2219 operator LPARAM() { return (LPARAM)this; } |
| 2220 |
| 2221 void Init(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL
, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL) |
| 2222 { |
| 2223 ATLASSERT(::IsWindow(hWnd)); |
| 2224 memset(this, 0, sizeof(TOOLINFO)); |
| 2225 cbSize = sizeof(TOOLINFO); |
| 2226 uFlags = nFlags; |
| 2227 if(nIDTool == 0) |
| 2228 { |
| 2229 hwnd = ::GetParent(hWnd); |
| 2230 uFlags |= TTF_IDISHWND; |
| 2231 uId = (UINT_PTR)hWnd; |
| 2232 } |
| 2233 else |
| 2234 { |
| 2235 hwnd = hWnd; |
| 2236 uId = nIDTool; |
| 2237 } |
| 2238 if(lpRect != NULL) |
| 2239 rect = *lpRect; |
| 2240 hinst = ModuleHelper::GetResourceInstance(); |
| 2241 lpszText = lpstrText; |
| 2242 lParam = lUserParam; |
| 2243 } |
| 2244 }; |
| 2245 |
| 2246 template <class TBase> |
| 2247 class CToolTipCtrlT : public TBase |
| 2248 { |
| 2249 public: |
| 2250 // Constructors |
| 2251 CToolTipCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 2252 { } |
| 2253 |
| 2254 CToolTipCtrlT< TBase >& operator =(HWND hWnd) |
| 2255 { |
| 2256 m_hWnd = hWnd; |
| 2257 return *this; |
| 2258 } |
| 2259 |
| 2260 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 2261 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 2262 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 2263 { |
| 2264 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 2265 } |
| 2266 |
| 2267 // Attributes |
| 2268 static LPCTSTR GetWndClassName() |
| 2269 { |
| 2270 return TOOLTIPS_CLASS; |
| 2271 } |
| 2272 |
| 2273 void GetText(LPTOOLINFO lpToolInfo) const |
| 2274 { |
| 2275 ATLASSERT(::IsWindow(m_hWnd)); |
| 2276 ::SendMessage(m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo); |
| 2277 } |
| 2278 |
| 2279 void GetText(LPTSTR lpstrText, HWND hWnd, UINT nIDTool = 0) const |
| 2280 { |
| 2281 ATLASSERT(::IsWindow(m_hWnd)); |
| 2282 ATLASSERT(hWnd != NULL); |
| 2283 CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); |
| 2284 ::SendMessage(m_hWnd, TTM_GETTEXT, 0, ti); |
| 2285 } |
| 2286 |
| 2287 BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const |
| 2288 { |
| 2289 ATLASSERT(::IsWindow(m_hWnd)); |
| 2290 return (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)l
pToolInfo); |
| 2291 } |
| 2292 |
| 2293 BOOL GetToolInfo(HWND hWnd, UINT nIDTool, UINT* puFlags, LPRECT lpRect,
LPTSTR lpstrText) const |
| 2294 { |
| 2295 ATLASSERT(::IsWindow(m_hWnd)); |
| 2296 ATLASSERT(hWnd != NULL); |
| 2297 ATLASSERT(puFlags != NULL); |
| 2298 ATLASSERT(lpRect != NULL); |
| 2299 CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText); |
| 2300 BOOL bRet = (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, ti); |
| 2301 if(bRet != FALSE) |
| 2302 { |
| 2303 *puFlags = ti.uFlags; |
| 2304 *lpRect = ti.rect; |
| 2305 } |
| 2306 return bRet; |
| 2307 } |
| 2308 |
| 2309 void SetToolInfo(LPTOOLINFO lpToolInfo) |
| 2310 { |
| 2311 ATLASSERT(::IsWindow(m_hWnd)); |
| 2312 ::SendMessage(m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo); |
| 2313 } |
| 2314 |
| 2315 void SetToolRect(LPTOOLINFO lpToolInfo) |
| 2316 { |
| 2317 ATLASSERT(::IsWindow(m_hWnd)); |
| 2318 ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo); |
| 2319 } |
| 2320 |
| 2321 void SetToolRect(HWND hWnd, UINT nIDTool, LPCRECT lpRect) |
| 2322 { |
| 2323 ATLASSERT(::IsWindow(m_hWnd)); |
| 2324 ATLASSERT(hWnd != NULL); |
| 2325 ATLASSERT(nIDTool != 0); |
| 2326 |
| 2327 CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL); |
| 2328 ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, ti); |
| 2329 } |
| 2330 |
| 2331 int GetToolCount() const |
| 2332 { |
| 2333 ATLASSERT(::IsWindow(m_hWnd)); |
| 2334 return (int)::SendMessage(m_hWnd, TTM_GETTOOLCOUNT, 0, 0L); |
| 2335 } |
| 2336 |
| 2337 int GetDelayTime(DWORD dwType) const |
| 2338 { |
| 2339 ATLASSERT(::IsWindow(m_hWnd)); |
| 2340 return (int)::SendMessage(m_hWnd, TTM_GETDELAYTIME, dwType, 0L); |
| 2341 } |
| 2342 |
| 2343 void SetDelayTime(DWORD dwType, int nTime) |
| 2344 { |
| 2345 ATLASSERT(::IsWindow(m_hWnd)); |
| 2346 ::SendMessage(m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime
, 0)); |
| 2347 } |
| 2348 |
| 2349 void GetMargin(LPRECT lpRect) const |
| 2350 { |
| 2351 ATLASSERT(::IsWindow(m_hWnd)); |
| 2352 ::SendMessage(m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect); |
| 2353 } |
| 2354 |
| 2355 void SetMargin(LPRECT lpRect) |
| 2356 { |
| 2357 ATLASSERT(::IsWindow(m_hWnd)); |
| 2358 ::SendMessage(m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect); |
| 2359 } |
| 2360 |
| 2361 int GetMaxTipWidth() const |
| 2362 { |
| 2363 ATLASSERT(::IsWindow(m_hWnd)); |
| 2364 return (int)::SendMessage(m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L); |
| 2365 } |
| 2366 |
| 2367 int SetMaxTipWidth(int nWidth) |
| 2368 { |
| 2369 ATLASSERT(::IsWindow(m_hWnd)); |
| 2370 return (int)::SendMessage(m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth)
; |
| 2371 } |
| 2372 |
| 2373 COLORREF GetTipBkColor() const |
| 2374 { |
| 2375 ATLASSERT(::IsWindow(m_hWnd)); |
| 2376 return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L)
; |
| 2377 } |
| 2378 |
| 2379 void SetTipBkColor(COLORREF clr) |
| 2380 { |
| 2381 ATLASSERT(::IsWindow(m_hWnd)); |
| 2382 ::SendMessage(m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L); |
| 2383 } |
| 2384 |
| 2385 COLORREF GetTipTextColor() const |
| 2386 { |
| 2387 ATLASSERT(::IsWindow(m_hWnd)); |
| 2388 return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0
L); |
| 2389 } |
| 2390 |
| 2391 void SetTipTextColor(COLORREF clr) |
| 2392 { |
| 2393 ATLASSERT(::IsWindow(m_hWnd)); |
| 2394 ::SendMessage(m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L); |
| 2395 } |
| 2396 |
| 2397 BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const |
| 2398 { |
| 2399 ATLASSERT(::IsWindow(m_hWnd)); |
| 2400 return (BOOL)::SendMessage(m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARA
M)lpToolInfo); |
| 2401 } |
| 2402 |
| 2403 #if (_WIN32_IE >= 0x0500) |
| 2404 SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const |
| 2405 { |
| 2406 ATLASSERT(::IsWindow(m_hWnd)); |
| 2407 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TTM_GETBUBBLESIZE, 0,
(LPARAM)lpToolInfo); |
| 2408 SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) }; |
| 2409 return size; |
| 2410 } |
| 2411 |
| 2412 BOOL SetTitle(UINT uIcon, LPCTSTR lpstrTitle) |
| 2413 { |
| 2414 ATLASSERT(::IsWindow(m_hWnd)); |
| 2415 return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)
lpstrTitle); |
| 2416 } |
| 2417 #endif // (_WIN32_IE >= 0x0500) |
| 2418 |
| 2419 #if (_WIN32_WINNT >= 0x0501) |
| 2420 void GetTitle(PTTGETTITLE pTTGetTitle) const |
| 2421 { |
| 2422 ATLASSERT(::IsWindow(m_hWnd)); |
| 2423 ::SendMessage(m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle); |
| 2424 } |
| 2425 |
| 2426 void SetWindowTheme(LPCWSTR lpstrTheme) |
| 2427 { |
| 2428 ATLASSERT(::IsWindow(m_hWnd)); |
| 2429 ::SendMessage(m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme)
; |
| 2430 } |
| 2431 #endif // (_WIN32_WINNT >= 0x0501) |
| 2432 |
| 2433 // Operations |
| 2434 void Activate(BOOL bActivate) |
| 2435 { |
| 2436 ATLASSERT(::IsWindow(m_hWnd)); |
| 2437 ::SendMessage(m_hWnd, TTM_ACTIVATE, bActivate, 0L); |
| 2438 } |
| 2439 |
| 2440 BOOL AddTool(LPTOOLINFO lpToolInfo) |
| 2441 { |
| 2442 ATLASSERT(::IsWindow(m_hWnd)); |
| 2443 return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToo
lInfo); |
| 2444 } |
| 2445 |
| 2446 BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LP
CRECT lpRectTool = NULL, UINT nIDTool = 0) |
| 2447 { |
| 2448 ATLASSERT(::IsWindow(m_hWnd)); |
| 2449 ATLASSERT(hWnd != NULL); |
| 2450 // the toolrect and toolid must both be zero or both valid |
| 2451 ATLASSERT((lpRectTool != NULL && nIDTool != 0) || (lpRectTool ==
NULL && nIDTool == 0)); |
| 2452 |
| 2453 CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.
m_lpstr); |
| 2454 return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, ti); |
| 2455 } |
| 2456 |
| 2457 void DelTool(LPTOOLINFO lpToolInfo) |
| 2458 { |
| 2459 ATLASSERT(::IsWindow(m_hWnd)); |
| 2460 ::SendMessage(m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo); |
| 2461 } |
| 2462 |
| 2463 void DelTool(HWND hWnd, UINT nIDTool = 0) |
| 2464 { |
| 2465 ATLASSERT(::IsWindow(m_hWnd)); |
| 2466 ATLASSERT(hWnd != NULL); |
| 2467 |
| 2468 CToolInfo ti(0, hWnd, nIDTool, NULL, NULL); |
| 2469 ::SendMessage(m_hWnd, TTM_DELTOOL, 0, ti); |
| 2470 } |
| 2471 |
| 2472 BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const |
| 2473 { |
| 2474 ATLASSERT(::IsWindow(m_hWnd)); |
| 2475 return (BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHit
TestInfo); |
| 2476 } |
| 2477 |
| 2478 BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const |
| 2479 { |
| 2480 ATLASSERT(::IsWindow(m_hWnd)); |
| 2481 ATLASSERT(hWnd != NULL); |
| 2482 ATLASSERT(lpToolInfo != NULL); |
| 2483 |
| 2484 TTHITTESTINFO hti = { 0 }; |
| 2485 hti.ti.cbSize = sizeof(TOOLINFO); |
| 2486 hti.hwnd = hWnd; |
| 2487 hti.pt.x = pt.x; |
| 2488 hti.pt.y = pt.y; |
| 2489 if((BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) !=
FALSE) |
| 2490 { |
| 2491 *lpToolInfo = hti.ti; |
| 2492 return TRUE; |
| 2493 } |
| 2494 return FALSE; |
| 2495 } |
| 2496 |
| 2497 void RelayEvent(LPMSG lpMsg) |
| 2498 { |
| 2499 ATLASSERT(::IsWindow(m_hWnd)); |
| 2500 ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); |
| 2501 } |
| 2502 |
| 2503 void UpdateTipText(LPTOOLINFO lpToolInfo) |
| 2504 { |
| 2505 ATLASSERT(::IsWindow(m_hWnd)); |
| 2506 ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo); |
| 2507 } |
| 2508 |
| 2509 void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT nIDTool = 0) |
| 2510 { |
| 2511 ATLASSERT(::IsWindow(m_hWnd)); |
| 2512 ATLASSERT(hWnd != NULL); |
| 2513 |
| 2514 CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr); |
| 2515 ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, ti); |
| 2516 } |
| 2517 |
| 2518 BOOL EnumTools(UINT nTool, LPTOOLINFO lpToolInfo) const |
| 2519 { |
| 2520 ATLASSERT(::IsWindow(m_hWnd)); |
| 2521 return (BOOL)::SendMessage(m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM
)lpToolInfo); |
| 2522 } |
| 2523 |
| 2524 void Pop() |
| 2525 { |
| 2526 ATLASSERT(::IsWindow(m_hWnd)); |
| 2527 ::SendMessage(m_hWnd, TTM_POP, 0, 0L); |
| 2528 } |
| 2529 |
| 2530 void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate) |
| 2531 { |
| 2532 ATLASSERT(::IsWindow(m_hWnd)); |
| 2533 ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpTo
olInfo); |
| 2534 } |
| 2535 |
| 2536 void TrackPosition(int xPos, int yPos) |
| 2537 { |
| 2538 ATLASSERT(::IsWindow(m_hWnd)); |
| 2539 ::SendMessage(m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPo
s)); |
| 2540 } |
| 2541 |
| 2542 #if (_WIN32_IE >= 0x0400) |
| 2543 void Update() |
| 2544 { |
| 2545 ATLASSERT(::IsWindow(m_hWnd)); |
| 2546 ::SendMessage(m_hWnd, TTM_UPDATE, 0, 0L); |
| 2547 } |
| 2548 #endif // (_WIN32_IE >= 0x0400) |
| 2549 |
| 2550 #if (_WIN32_IE >= 0x0500) |
| 2551 BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/) |
| 2552 { |
| 2553 ATLASSERT(::IsWindow(m_hWnd)); |
| 2554 return (BOOL)::SendMessage(m_hWnd, TTM_ADJUSTRECT, bLarger, (LPA
RAM)lpRect); |
| 2555 } |
| 2556 #endif // (_WIN32_IE >= 0x0500) |
| 2557 |
| 2558 #if (_WIN32_WINNT >= 0x0501) |
| 2559 void Popup() |
| 2560 { |
| 2561 ATLASSERT(::IsWindow(m_hWnd)); |
| 2562 ::SendMessage(m_hWnd, TTM_POPUP, 0, 0L); |
| 2563 } |
| 2564 #endif // (_WIN32_WINNT >= 0x0501) |
| 2565 }; |
| 2566 |
| 2567 typedef CToolTipCtrlT<ATL::CWindow> CToolTipCtrl; |
| 2568 |
| 2569 #endif // !_WIN32_WCE |
| 2570 |
| 2571 |
| 2572 /////////////////////////////////////////////////////////////////////////////// |
| 2573 // CHeaderCtrl |
| 2574 |
| 2575 template <class TBase> |
| 2576 class CHeaderCtrlT : public TBase |
| 2577 { |
| 2578 public: |
| 2579 // Constructors |
| 2580 CHeaderCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 2581 { } |
| 2582 |
| 2583 CHeaderCtrlT< TBase >& operator =(HWND hWnd) |
| 2584 { |
| 2585 m_hWnd = hWnd; |
| 2586 return *this; |
| 2587 } |
| 2588 |
| 2589 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 2590 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 2591 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 2592 { |
| 2593 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 2594 } |
| 2595 |
| 2596 // Attributes |
| 2597 static LPCTSTR GetWndClassName() |
| 2598 { |
| 2599 return WC_HEADER; |
| 2600 } |
| 2601 |
| 2602 int GetItemCount() const |
| 2603 { |
| 2604 ATLASSERT(::IsWindow(m_hWnd)); |
| 2605 return (int)::SendMessage(m_hWnd, HDM_GETITEMCOUNT, 0, 0L); |
| 2606 } |
| 2607 |
| 2608 BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const |
| 2609 { |
| 2610 ATLASSERT(::IsWindow(m_hWnd)); |
| 2611 return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nIndex, (LPARAM)
pHeaderItem); |
| 2612 } |
| 2613 |
| 2614 BOOL SetItem(int nIndex, LPHDITEM pHeaderItem) |
| 2615 { |
| 2616 ATLASSERT(::IsWindow(m_hWnd)); |
| 2617 return (BOOL)::SendMessage(m_hWnd, HDM_SETITEM, nIndex, (LPARAM)
pHeaderItem); |
| 2618 } |
| 2619 |
| 2620 CImageList GetImageList() const |
| 2621 { |
| 2622 ATLASSERT(::IsWindow(m_hWnd)); |
| 2623 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_GETIMAGE
LIST, 0, 0L)); |
| 2624 } |
| 2625 |
| 2626 CImageList SetImageList(HIMAGELIST hImageList) |
| 2627 { |
| 2628 ATLASSERT(::IsWindow(m_hWnd)); |
| 2629 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_SETIMAGE
LIST, 0, (LPARAM)hImageList)); |
| 2630 } |
| 2631 |
| 2632 BOOL GetOrderArray(int nSize, int* lpnArray) const |
| 2633 { |
| 2634 ATLASSERT(::IsWindow(m_hWnd)); |
| 2635 return (BOOL)::SendMessage(m_hWnd, HDM_GETORDERARRAY, nSize, (LP
ARAM)lpnArray); |
| 2636 } |
| 2637 |
| 2638 BOOL SetOrderArray(int nSize, int* lpnArray) |
| 2639 { |
| 2640 ATLASSERT(::IsWindow(m_hWnd)); |
| 2641 return (BOOL)::SendMessage(m_hWnd, HDM_SETORDERARRAY, nSize, (LP
ARAM)lpnArray); |
| 2642 } |
| 2643 |
| 2644 BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const |
| 2645 { |
| 2646 ATLASSERT(::IsWindow(m_hWnd)); |
| 2647 return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMRECT, nIndex, (LPA
RAM)lpItemRect); |
| 2648 } |
| 2649 |
| 2650 int SetHotDivider(BOOL bPos, DWORD dwInputValue) |
| 2651 { |
| 2652 ATLASSERT(::IsWindow(m_hWnd)); |
| 2653 return (int)::SendMessage(m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInp
utValue); |
| 2654 } |
| 2655 |
| 2656 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 2657 BOOL GetUnicodeFormat() const |
| 2658 { |
| 2659 ATLASSERT(::IsWindow(m_hWnd)); |
| 2660 return (BOOL)::SendMessage(m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L); |
| 2661 } |
| 2662 |
| 2663 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 2664 { |
| 2665 ATLASSERT(::IsWindow(m_hWnd)); |
| 2666 return (BOOL)::SendMessage(m_hWnd, HDM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 2667 } |
| 2668 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 2669 |
| 2670 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 2671 int GetBitmapMargin() const |
| 2672 { |
| 2673 ATLASSERT(::IsWindow(m_hWnd)); |
| 2674 return (int)::SendMessage(m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L); |
| 2675 } |
| 2676 |
| 2677 int SetBitmapMargin(int nWidth) |
| 2678 { |
| 2679 ATLASSERT(::IsWindow(m_hWnd)); |
| 2680 return (int)::SendMessage(m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0
L); |
| 2681 } |
| 2682 |
| 2683 int SetFilterChangeTimeout(DWORD dwTimeOut) |
| 2684 { |
| 2685 ATLASSERT(::IsWindow(m_hWnd)); |
| 2686 return (int)::SendMessage(m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0,
dwTimeOut); |
| 2687 } |
| 2688 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 2689 |
| 2690 #if (_WIN32_WINNT >= 0x0600) |
| 2691 BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const |
| 2692 { |
| 2693 ATLASSERT(::IsWindow(m_hWnd)); |
| 2694 return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMDROPDOWNRECT, nInd
ex, (LPARAM)lpRect); |
| 2695 } |
| 2696 |
| 2697 BOOL GetOverflowRect(LPRECT lpRect) const |
| 2698 { |
| 2699 ATLASSERT(::IsWindow(m_hWnd)); |
| 2700 return (BOOL)::SendMessage(m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPAR
AM)lpRect); |
| 2701 } |
| 2702 |
| 2703 int GetFocusedItem() const |
| 2704 { |
| 2705 ATLASSERT(::IsWindow(m_hWnd)); |
| 2706 return (int)::SendMessage(m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L); |
| 2707 } |
| 2708 |
| 2709 BOOL SetFocusedItem(int nIndex) |
| 2710 { |
| 2711 ATLASSERT(::IsWindow(m_hWnd)); |
| 2712 return (BOOL)::SendMessage(m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex
); |
| 2713 } |
| 2714 #endif // (_WIN32_WINNT >= 0x0600) |
| 2715 |
| 2716 // Operations |
| 2717 int InsertItem(int nIndex, LPHDITEM phdi) |
| 2718 { |
| 2719 ATLASSERT(::IsWindow(m_hWnd)); |
| 2720 return (int)::SendMessage(m_hWnd, HDM_INSERTITEM, nIndex, (LPARA
M)phdi); |
| 2721 } |
| 2722 |
| 2723 int AddItem(LPHDITEM phdi) |
| 2724 { |
| 2725 return InsertItem(GetItemCount(), phdi); |
| 2726 } |
| 2727 |
| 2728 BOOL DeleteItem(int nIndex) |
| 2729 { |
| 2730 ATLASSERT(::IsWindow(m_hWnd)); |
| 2731 return (BOOL)::SendMessage(m_hWnd, HDM_DELETEITEM, nIndex, 0L); |
| 2732 } |
| 2733 |
| 2734 BOOL Layout(HD_LAYOUT* pHeaderLayout) |
| 2735 { |
| 2736 ATLASSERT(::IsWindow(m_hWnd)); |
| 2737 return (BOOL)::SendMessage(m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeade
rLayout); |
| 2738 } |
| 2739 |
| 2740 int HitTest(LPHDHITTESTINFO lpHitTestInfo) const |
| 2741 { |
| 2742 ATLASSERT(::IsWindow(m_hWnd)); |
| 2743 return (int)::SendMessage(m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitT
estInfo); |
| 2744 } |
| 2745 |
| 2746 int OrderToIndex(int nOrder) |
| 2747 { |
| 2748 ATLASSERT(::IsWindow(m_hWnd)); |
| 2749 return (int)::SendMessage(m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L); |
| 2750 } |
| 2751 |
| 2752 CImageList CreateDragImage(int nIndex) |
| 2753 { |
| 2754 ATLASSERT(::IsWindow(m_hWnd)); |
| 2755 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_CREATEDR
AGIMAGE, nIndex, 0L)); |
| 2756 } |
| 2757 |
| 2758 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 2759 int EditFilter(int nColumn, BOOL bDiscardChanges) |
| 2760 { |
| 2761 ATLASSERT(::IsWindow(m_hWnd)); |
| 2762 return (int)::SendMessage(m_hWnd, HDM_EDITFILTER, nColumn, MAKEL
PARAM(bDiscardChanges, 0)); |
| 2763 } |
| 2764 |
| 2765 int ClearFilter(int nColumn) |
| 2766 { |
| 2767 ATLASSERT(::IsWindow(m_hWnd)); |
| 2768 return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, nColumn, 0L); |
| 2769 } |
| 2770 |
| 2771 int ClearAllFilters() |
| 2772 { |
| 2773 ATLASSERT(::IsWindow(m_hWnd)); |
| 2774 return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0
L); |
| 2775 } |
| 2776 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 2777 }; |
| 2778 |
| 2779 typedef CHeaderCtrlT<ATL::CWindow> CHeaderCtrl; |
| 2780 |
| 2781 |
| 2782 /////////////////////////////////////////////////////////////////////////////// |
| 2783 // CListViewCtrl |
| 2784 |
| 2785 template <class TBase> |
| 2786 class CListViewCtrlT : public TBase |
| 2787 { |
| 2788 public: |
| 2789 // Constructors |
| 2790 CListViewCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 2791 { } |
| 2792 |
| 2793 CListViewCtrlT< TBase >& operator =(HWND hWnd) |
| 2794 { |
| 2795 m_hWnd = hWnd; |
| 2796 return *this; |
| 2797 } |
| 2798 |
| 2799 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 2800 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 2801 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 2802 { |
| 2803 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 2804 } |
| 2805 |
| 2806 // Attributes |
| 2807 static LPCTSTR GetWndClassName() |
| 2808 { |
| 2809 return WC_LISTVIEW; |
| 2810 } |
| 2811 |
| 2812 COLORREF GetBkColor() const |
| 2813 { |
| 2814 ATLASSERT(::IsWindow(m_hWnd)); |
| 2815 return (COLORREF)::SendMessage(m_hWnd, LVM_GETBKCOLOR, 0, 0L); |
| 2816 } |
| 2817 |
| 2818 BOOL SetBkColor(COLORREF cr) |
| 2819 { |
| 2820 ATLASSERT(::IsWindow(m_hWnd)); |
| 2821 return (BOOL)::SendMessage(m_hWnd, LVM_SETBKCOLOR, 0, cr); |
| 2822 } |
| 2823 |
| 2824 CImageList GetImageList(int nImageListType) const |
| 2825 { |
| 2826 ATLASSERT(::IsWindow(m_hWnd)); |
| 2827 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_GETIMAGE
LIST, nImageListType, 0L)); |
| 2828 } |
| 2829 |
| 2830 CImageList SetImageList(HIMAGELIST hImageList, int nImageList) |
| 2831 { |
| 2832 ATLASSERT(::IsWindow(m_hWnd)); |
| 2833 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGE
LIST, nImageList, (LPARAM)hImageList)); |
| 2834 } |
| 2835 |
| 2836 int GetItemCount() const |
| 2837 { |
| 2838 ATLASSERT(::IsWindow(m_hWnd)); |
| 2839 return (int)::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L); |
| 2840 } |
| 2841 |
| 2842 BOOL SetItemCount(int nItems) |
| 2843 { |
| 2844 ATLASSERT(::IsWindow(m_hWnd)); |
| 2845 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, 0L)
; |
| 2846 } |
| 2847 |
| 2848 BOOL GetItem(LPLVITEM pItem) const |
| 2849 { |
| 2850 ATLASSERT(::IsWindow(m_hWnd)); |
| 2851 return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem
); |
| 2852 } |
| 2853 |
| 2854 BOOL SetItem(const LVITEM* pItem) |
| 2855 { |
| 2856 ATLASSERT(::IsWindow(m_hWnd)); |
| 2857 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem
); |
| 2858 } |
| 2859 |
| 2860 BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, |
| 2861 int nImage, UINT nState, UINT nStateMask, LPARAM lParam) |
| 2862 { |
| 2863 ATLASSERT(::IsWindow(m_hWnd)); |
| 2864 LVITEM lvi = { 0 }; |
| 2865 lvi.mask = nMask; |
| 2866 lvi.iItem = nItem; |
| 2867 lvi.iSubItem = nSubItem; |
| 2868 lvi.stateMask = nStateMask; |
| 2869 lvi.state = nState; |
| 2870 lvi.pszText = (LPTSTR) lpszItem; |
| 2871 lvi.iImage = nImage; |
| 2872 lvi.lParam = lParam; |
| 2873 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi)
; |
| 2874 } |
| 2875 |
| 2876 UINT GetItemState(int nItem, UINT nMask) const |
| 2877 { |
| 2878 ATLASSERT(::IsWindow(m_hWnd)); |
| 2879 return (UINT)::SendMessage(m_hWnd, LVM_GETITEMSTATE, nItem, nMas
k); |
| 2880 } |
| 2881 |
| 2882 BOOL SetItemState(int nItem, UINT nState, UINT nStateMask) |
| 2883 { |
| 2884 ATLASSERT(::IsWindow(m_hWnd)); |
| 2885 LVITEM lvi = { 0 }; |
| 2886 lvi.state = nState; |
| 2887 lvi.stateMask = nStateMask; |
| 2888 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPA
RAM)&lvi); |
| 2889 } |
| 2890 |
| 2891 BOOL SetItemState(int nItem, LPLVITEM pItem) |
| 2892 { |
| 2893 ATLASSERT(::IsWindow(m_hWnd)); |
| 2894 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPA
RAM)pItem); |
| 2895 } |
| 2896 |
| 2897 #ifndef _ATL_NO_COM |
| 2898 BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const |
| 2899 { |
| 2900 USES_CONVERSION; |
| 2901 ATLASSERT(::IsWindow(m_hWnd)); |
| 2902 ATLASSERT(bstrText == NULL); |
| 2903 LVITEM lvi = { 0 }; |
| 2904 lvi.iSubItem = nSubItem; |
| 2905 |
| 2906 LPTSTR lpstrText = NULL; |
| 2907 int nRes = 0; |
| 2908 for(int nLen = 256; ; nLen *= 2) |
| 2909 { |
| 2910 ATLTRY(lpstrText = new TCHAR[nLen]); |
| 2911 if(lpstrText == NULL) |
| 2912 break; |
| 2913 lpstrText[0] = NULL; |
| 2914 lvi.cchTextMax = nLen; |
| 2915 lvi.pszText = lpstrText; |
| 2916 nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPA
RAM)nItem, (LPARAM)&lvi); |
| 2917 if(nRes < nLen - 1) |
| 2918 break; |
| 2919 delete [] lpstrText; |
| 2920 lpstrText = NULL; |
| 2921 } |
| 2922 |
| 2923 if(lpstrText != NULL) |
| 2924 { |
| 2925 if(nRes != 0) |
| 2926 bstrText = ::SysAllocString(T2OLE(lpstrText)); |
| 2927 delete [] lpstrText; |
| 2928 } |
| 2929 |
| 2930 return (bstrText != NULL) ? TRUE : FALSE; |
| 2931 } |
| 2932 #endif // !_ATL_NO_COM |
| 2933 |
| 2934 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 2935 int GetItemText(int nItem, int nSubItem, _CSTRING_NS::CString& strText)
const |
| 2936 { |
| 2937 ATLASSERT(::IsWindow(m_hWnd)); |
| 2938 LVITEM lvi = { 0 }; |
| 2939 lvi.iSubItem = nSubItem; |
| 2940 |
| 2941 strText.Empty(); |
| 2942 int nRes = 0; |
| 2943 for(int nLen = 256; ; nLen *= 2) |
| 2944 { |
| 2945 lvi.cchTextMax = nLen; |
| 2946 lvi.pszText = strText.GetBufferSetLength(nLen); |
| 2947 if(lvi.pszText == NULL) |
| 2948 { |
| 2949 nRes = 0; |
| 2950 break; |
| 2951 } |
| 2952 nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPA
RAM)nItem, (LPARAM)&lvi); |
| 2953 if(nRes < nLen - 1) |
| 2954 break; |
| 2955 } |
| 2956 strText.ReleaseBuffer(); |
| 2957 return nRes; |
| 2958 } |
| 2959 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 2960 |
| 2961 int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) cons
t |
| 2962 { |
| 2963 ATLASSERT(::IsWindow(m_hWnd)); |
| 2964 LVITEM lvi = { 0 }; |
| 2965 lvi.iSubItem = nSubItem; |
| 2966 lvi.cchTextMax = nLen; |
| 2967 lvi.pszText = lpszText; |
| 2968 return (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem
, (LPARAM)&lvi); |
| 2969 } |
| 2970 |
| 2971 BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText) |
| 2972 { |
| 2973 ATLASSERT(::IsWindow(m_hWnd)); |
| 2974 return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0)
; |
| 2975 } |
| 2976 |
| 2977 DWORD_PTR GetItemData(int nItem) const |
| 2978 { |
| 2979 ATLASSERT(::IsWindow(m_hWnd)); |
| 2980 LVITEM lvi = { 0 }; |
| 2981 lvi.iItem = nItem; |
| 2982 lvi.mask = LVIF_PARAM; |
| 2983 BOOL bRet = (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)
&lvi); |
| 2984 return (DWORD_PTR)(bRet ? lvi.lParam : NULL); |
| 2985 } |
| 2986 |
| 2987 BOOL SetItemData(int nItem, DWORD_PTR dwData) |
| 2988 { |
| 2989 ATLASSERT(::IsWindow(m_hWnd)); |
| 2990 return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwDa
ta); |
| 2991 } |
| 2992 |
| 2993 UINT GetCallbackMask() const |
| 2994 { |
| 2995 ATLASSERT(::IsWindow(m_hWnd)); |
| 2996 return (UINT)::SendMessage(m_hWnd, LVM_GETCALLBACKMASK, 0, 0L); |
| 2997 } |
| 2998 |
| 2999 BOOL SetCallbackMask(UINT nMask) |
| 3000 { |
| 3001 ATLASSERT(::IsWindow(m_hWnd)); |
| 3002 return (BOOL)::SendMessage(m_hWnd, LVM_SETCALLBACKMASK, nMask, 0
L); |
| 3003 } |
| 3004 |
| 3005 BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const |
| 3006 { |
| 3007 ATLASSERT(::IsWindow(m_hWnd)); |
| 3008 return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMPOSITION, nItem, (
LPARAM)lpPoint); |
| 3009 } |
| 3010 |
| 3011 BOOL SetItemPosition(int nItem, POINT pt) |
| 3012 { |
| 3013 ATLASSERT(::IsWindow(m_hWnd)); |
| 3014 ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyl
e() & LVS_TYPEMASK) == LVS_SMALLICON)); |
| 3015 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem,
(LPARAM)&pt); |
| 3016 } |
| 3017 |
| 3018 BOOL SetItemPosition(int nItem, int x, int y) |
| 3019 { |
| 3020 ATLASSERT(::IsWindow(m_hWnd)); |
| 3021 ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyl
e() & LVS_TYPEMASK) == LVS_SMALLICON)); |
| 3022 POINT pt = { x, y }; |
| 3023 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem,
(LPARAM)&pt); |
| 3024 } |
| 3025 |
| 3026 int GetStringWidth(LPCTSTR lpsz) const |
| 3027 { |
| 3028 ATLASSERT(::IsWindow(m_hWnd)); |
| 3029 return (int)::SendMessage(m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM
)lpsz); |
| 3030 } |
| 3031 |
| 3032 CEdit GetEditControl() const |
| 3033 { |
| 3034 ATLASSERT(::IsWindow(m_hWnd)); |
| 3035 return CEdit((HWND)::SendMessage(m_hWnd, LVM_GETEDITCONTROL, 0,
0L)); |
| 3036 } |
| 3037 |
| 3038 BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const |
| 3039 { |
| 3040 ATLASSERT(::IsWindow(m_hWnd)); |
| 3041 return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)
pColumn); |
| 3042 } |
| 3043 |
| 3044 BOOL SetColumn(int nCol, const LVCOLUMN* pColumn) |
| 3045 { |
| 3046 ATLASSERT(::IsWindow(m_hWnd)); |
| 3047 return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)
pColumn); |
| 3048 } |
| 3049 |
| 3050 int GetColumnWidth(int nCol) const |
| 3051 { |
| 3052 ATLASSERT(::IsWindow(m_hWnd)); |
| 3053 return (int)::SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L); |
| 3054 } |
| 3055 |
| 3056 BOOL SetColumnWidth(int nCol, int cx) |
| 3057 { |
| 3058 ATLASSERT(::IsWindow(m_hWnd)); |
| 3059 return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAK
ELPARAM(cx, 0)); |
| 3060 } |
| 3061 |
| 3062 BOOL GetViewRect(LPRECT lpRect) const |
| 3063 { |
| 3064 ATLASSERT(::IsWindow(m_hWnd)); |
| 3065 return (BOOL)::SendMessage(m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)l
pRect); |
| 3066 } |
| 3067 |
| 3068 COLORREF GetTextColor() const |
| 3069 { |
| 3070 ATLASSERT(::IsWindow(m_hWnd)); |
| 3071 return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); |
| 3072 } |
| 3073 |
| 3074 BOOL SetTextColor(COLORREF cr) |
| 3075 { |
| 3076 ATLASSERT(::IsWindow(m_hWnd)); |
| 3077 return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr); |
| 3078 } |
| 3079 |
| 3080 COLORREF GetTextBkColor() const |
| 3081 { |
| 3082 ATLASSERT(::IsWindow(m_hWnd)); |
| 3083 return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L
); |
| 3084 } |
| 3085 |
| 3086 BOOL SetTextBkColor(COLORREF cr) |
| 3087 { |
| 3088 ATLASSERT(::IsWindow(m_hWnd)); |
| 3089 return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); |
| 3090 } |
| 3091 |
| 3092 int GetTopIndex() const |
| 3093 { |
| 3094 ATLASSERT(::IsWindow(m_hWnd)); |
| 3095 return (int)::SendMessage(m_hWnd, LVM_GETTOPINDEX, 0, 0L); |
| 3096 } |
| 3097 |
| 3098 int GetCountPerPage() const |
| 3099 { |
| 3100 ATLASSERT(::IsWindow(m_hWnd)); |
| 3101 return (int)::SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L); |
| 3102 } |
| 3103 |
| 3104 BOOL GetOrigin(LPPOINT lpPoint) const |
| 3105 { |
| 3106 ATLASSERT(::IsWindow(m_hWnd)); |
| 3107 return (BOOL)::SendMessage(m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpP
oint); |
| 3108 } |
| 3109 |
| 3110 UINT GetSelectedCount() const |
| 3111 { |
| 3112 ATLASSERT(::IsWindow(m_hWnd)); |
| 3113 return (UINT)::SendMessage(m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); |
| 3114 } |
| 3115 |
| 3116 BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const |
| 3117 { |
| 3118 ATLASSERT(::IsWindow(m_hWnd)); |
| 3119 lpRect->left = nCode; |
| 3120 return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMRECT, (WPARAM)nIte
m, (LPARAM)lpRect); |
| 3121 } |
| 3122 |
| 3123 #ifndef _WIN32_WCE |
| 3124 HCURSOR GetHotCursor() const |
| 3125 { |
| 3126 ATLASSERT(::IsWindow(m_hWnd)); |
| 3127 return (HCURSOR)::SendMessage(m_hWnd, LVM_GETHOTCURSOR, 0, 0L); |
| 3128 } |
| 3129 |
| 3130 HCURSOR SetHotCursor(HCURSOR hHotCursor) |
| 3131 { |
| 3132 ATLASSERT(::IsWindow(m_hWnd)); |
| 3133 return (HCURSOR)::SendMessage(m_hWnd, LVM_SETHOTCURSOR, 0, (LPAR
AM)hHotCursor); |
| 3134 } |
| 3135 |
| 3136 int GetHotItem() const |
| 3137 { |
| 3138 ATLASSERT(::IsWindow(m_hWnd)); |
| 3139 return (int)::SendMessage(m_hWnd, LVM_GETHOTITEM, 0, 0L); |
| 3140 } |
| 3141 |
| 3142 int SetHotItem(int nIndex) |
| 3143 { |
| 3144 ATLASSERT(::IsWindow(m_hWnd)); |
| 3145 return (int)::SendMessage(m_hWnd, LVM_SETHOTITEM, nIndex, 0L); |
| 3146 } |
| 3147 #endif // !_WIN32_WCE |
| 3148 |
| 3149 BOOL GetColumnOrderArray(int nCount, int* lpnArray) const |
| 3150 { |
| 3151 ATLASSERT(::IsWindow(m_hWnd)); |
| 3152 return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMNORDERARRAY, nCou
nt, (LPARAM)lpnArray); |
| 3153 } |
| 3154 |
| 3155 BOOL SetColumnOrderArray(int nCount, int* lpnArray) |
| 3156 { |
| 3157 ATLASSERT(::IsWindow(m_hWnd)); |
| 3158 return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNORDERARRAY, nCou
nt, (LPARAM)lpnArray); |
| 3159 } |
| 3160 |
| 3161 CHeaderCtrl GetHeader() const |
| 3162 { |
| 3163 ATLASSERT(::IsWindow(m_hWnd)); |
| 3164 return CHeaderCtrl((HWND)::SendMessage(m_hWnd, LVM_GETHEADER, 0,
0L)); |
| 3165 } |
| 3166 |
| 3167 BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) c
onst |
| 3168 { |
| 3169 ATLASSERT(::IsWindow(m_hWnd)); |
| 3170 ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_REPORT); |
| 3171 ATLASSERT(lpRect != NULL); |
| 3172 lpRect->top = nSubItem; |
| 3173 lpRect->left = nFlag; |
| 3174 return (BOOL)::SendMessage(m_hWnd, LVM_GETSUBITEMRECT, nItem, (L
PARAM)lpRect); |
| 3175 } |
| 3176 |
| 3177 DWORD SetIconSpacing(int cx, int cy) |
| 3178 { |
| 3179 ATLASSERT(::IsWindow(m_hWnd)); |
| 3180 ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_ICON); |
| 3181 return (DWORD)::SendMessage(m_hWnd, LVM_SETICONSPACING, 0, MAKEL
PARAM(cx, cy)); |
| 3182 } |
| 3183 |
| 3184 int GetISearchString(LPTSTR lpstr) const |
| 3185 { |
| 3186 ATLASSERT(::IsWindow(m_hWnd)); |
| 3187 return (int)::SendMessage(m_hWnd, LVM_GETISEARCHSTRING, 0, (LPAR
AM)lpstr); |
| 3188 } |
| 3189 |
| 3190 void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) cons
t |
| 3191 { |
| 3192 ATLASSERT(::IsWindow(m_hWnd)); |
| 3193 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, LVM_GETITEMSPACING, b
SmallIconView, 0L); |
| 3194 sizeSpacing.cx = GET_X_LPARAM(dwRet); |
| 3195 sizeSpacing.cy = GET_Y_LPARAM(dwRet); |
| 3196 } |
| 3197 |
| 3198 #if (_WIN32_WCE >= 410) |
| 3199 void SetItemSpacing(INT cySpacing) |
| 3200 { |
| 3201 ATLASSERT(::IsWindow(m_hWnd)); |
| 3202 ListView_SetItemSpacing(m_hWnd, cySpacing); |
| 3203 } |
| 3204 #endif // (_WIN32_WCE >= 410) |
| 3205 |
| 3206 // single-selection only |
| 3207 int GetSelectedIndex() const |
| 3208 { |
| 3209 ATLASSERT(::IsWindow(m_hWnd)); |
| 3210 ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); |
| 3211 return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, M
AKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); |
| 3212 } |
| 3213 |
| 3214 BOOL GetSelectedItem(LPLVITEM pItem) const |
| 3215 { |
| 3216 ATLASSERT(::IsWindow(m_hWnd)); |
| 3217 ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); |
| 3218 ATLASSERT(pItem != NULL); |
| 3219 pItem->iItem = (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPAR
AM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0)); |
| 3220 if(pItem->iItem == -1) |
| 3221 return FALSE; |
| 3222 return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem
); |
| 3223 } |
| 3224 |
| 3225 // extended list view styles |
| 3226 DWORD GetExtendedListViewStyle() const |
| 3227 { |
| 3228 ATLASSERT(::IsWindow(m_hWnd)); |
| 3229 return (DWORD)::SendMessage(m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0L); |
| 3230 } |
| 3231 |
| 3232 // dwExMask = 0 means all styles |
| 3233 DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0) |
| 3234 { |
| 3235 ATLASSERT(::IsWindow(m_hWnd)); |
| 3236 return (DWORD)::SendMessage(m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE
, dwExMask, dwExStyle); |
| 3237 } |
| 3238 |
| 3239 // checkboxes only |
| 3240 BOOL GetCheckState(int nIndex) const |
| 3241 { |
| 3242 ATLASSERT(::IsWindow(m_hWnd)); |
| 3243 ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0)
; |
| 3244 UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK); |
| 3245 return (uRet >> 12) - 1; |
| 3246 } |
| 3247 |
| 3248 BOOL SetCheckState(int nItem, BOOL bCheck) |
| 3249 { |
| 3250 int nCheck = bCheck ? 2 : 1; // one based index |
| 3251 return SetItemState(nItem, INDEXTOSTATEIMAGEMASK(nCheck), LVIS_S
TATEIMAGEMASK); |
| 3252 } |
| 3253 |
| 3254 // view type |
| 3255 DWORD GetViewType() const |
| 3256 { |
| 3257 ATLASSERT(::IsWindow(m_hWnd)); |
| 3258 return (GetStyle() & LVS_TYPEMASK); |
| 3259 } |
| 3260 |
| 3261 DWORD SetViewType(DWORD dwType) |
| 3262 { |
| 3263 ATLASSERT(::IsWindow(m_hWnd)); |
| 3264 ATLASSERT(dwType == LVS_ICON || dwType == LVS_SMALLICON || dwTyp
e == LVS_LIST || dwType == LVS_REPORT); |
| 3265 DWORD dwOldType = GetViewType(); |
| 3266 if(dwType != dwOldType) |
| 3267 ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK)); |
| 3268 return dwOldType; |
| 3269 } |
| 3270 |
| 3271 #if (_WIN32_IE >= 0x0400) |
| 3272 #ifndef _WIN32_WCE |
| 3273 BOOL GetBkImage(LPLVBKIMAGE plvbki) const |
| 3274 { |
| 3275 ATLASSERT(::IsWindow(m_hWnd)); |
| 3276 return (BOOL)::SendMessage(m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)pl
vbki); |
| 3277 } |
| 3278 |
| 3279 BOOL SetBkImage(LPLVBKIMAGE plvbki) |
| 3280 { |
| 3281 ATLASSERT(::IsWindow(m_hWnd)); |
| 3282 return (BOOL)::SendMessage(m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)pl
vbki); |
| 3283 } |
| 3284 #endif // !_WIN32_WCE |
| 3285 |
| 3286 int GetSelectionMark() const |
| 3287 { |
| 3288 ATLASSERT(::IsWindow(m_hWnd)); |
| 3289 return (int)::SendMessage(m_hWnd, LVM_GETSELECTIONMARK, 0, 0L); |
| 3290 } |
| 3291 |
| 3292 int SetSelectionMark(int nIndex) |
| 3293 { |
| 3294 ATLASSERT(::IsWindow(m_hWnd)); |
| 3295 return (int)::SendMessage(m_hWnd, LVM_SETSELECTIONMARK, 0, nInde
x); |
| 3296 } |
| 3297 |
| 3298 #ifndef _WIN32_WCE |
| 3299 BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const |
| 3300 { |
| 3301 ATLASSERT(::IsWindow(m_hWnd)); |
| 3302 return (BOOL)::SendMessage(m_hWnd, LVM_GETWORKAREAS, nWorkAreas,
(LPARAM)lpRect); |
| 3303 } |
| 3304 |
| 3305 BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect) |
| 3306 { |
| 3307 ATLASSERT(::IsWindow(m_hWnd)); |
| 3308 return (BOOL)::SendMessage(m_hWnd, LVM_SETWORKAREAS, nWorkAreas,
(LPARAM)lpRect); |
| 3309 } |
| 3310 |
| 3311 DWORD GetHoverTime() const |
| 3312 { |
| 3313 ATLASSERT(::IsWindow(m_hWnd)); |
| 3314 ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LV
S_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); |
| 3315 return (DWORD)::SendMessage(m_hWnd, LVM_GETHOVERTIME, 0, 0L); |
| 3316 } |
| 3317 |
| 3318 DWORD SetHoverTime(DWORD dwHoverTime) |
| 3319 { |
| 3320 ATLASSERT(::IsWindow(m_hWnd)); |
| 3321 ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LV
S_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0); |
| 3322 return (DWORD)::SendMessage(m_hWnd, LVM_SETHOVERTIME, 0, dwHover
Time); |
| 3323 } |
| 3324 |
| 3325 BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const |
| 3326 { |
| 3327 ATLASSERT(::IsWindow(m_hWnd)); |
| 3328 return (BOOL)::SendMessage(m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0,
(LPARAM)pnWorkAreas); |
| 3329 } |
| 3330 #endif // !_WIN32_WCE |
| 3331 |
| 3332 BOOL SetItemCountEx(int nItems, DWORD dwFlags) |
| 3333 { |
| 3334 ATLASSERT(::IsWindow(m_hWnd)); |
| 3335 ATLASSERT(((GetStyle() & LVS_OWNERDATA) != 0) && (((GetStyle() &
LVS_TYPEMASK) == LVS_REPORT) || ((GetStyle() & LVS_TYPEMASK) == LVS_LIST))); |
| 3336 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, dwF
lags); |
| 3337 } |
| 3338 |
| 3339 #ifndef _WIN32_WCE |
| 3340 CToolTipCtrl GetToolTips() const |
| 3341 { |
| 3342 ATLASSERT(::IsWindow(m_hWnd)); |
| 3343 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS,
0, 0L)); |
| 3344 } |
| 3345 |
| 3346 CToolTipCtrl SetToolTips(HWND hWndTT) |
| 3347 { |
| 3348 ATLASSERT(::IsWindow(m_hWnd)); |
| 3349 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS,
(WPARAM)hWndTT, 0L)); |
| 3350 } |
| 3351 |
| 3352 BOOL GetUnicodeFormat() const |
| 3353 { |
| 3354 ATLASSERT(::IsWindow(m_hWnd)); |
| 3355 return (BOOL)::SendMessage(m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L); |
| 3356 } |
| 3357 |
| 3358 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 3359 { |
| 3360 ATLASSERT(::IsWindow(m_hWnd)); |
| 3361 return (BOOL)::SendMessage(m_hWnd, LVM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 3362 } |
| 3363 #endif // !_WIN32_WCE |
| 3364 #endif // (_WIN32_IE >= 0x0400) |
| 3365 |
| 3366 #if (_WIN32_WINNT >= 0x0501) |
| 3367 int GetSelectedColumn() const |
| 3368 { |
| 3369 ATLASSERT(::IsWindow(m_hWnd)); |
| 3370 return (int)::SendMessage(m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L); |
| 3371 } |
| 3372 |
| 3373 void SetSelectedColumn(int nColumn) |
| 3374 { |
| 3375 ATLASSERT(::IsWindow(m_hWnd)); |
| 3376 ::SendMessage(m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L); |
| 3377 } |
| 3378 |
| 3379 DWORD GetView() const |
| 3380 { |
| 3381 ATLASSERT(::IsWindow(m_hWnd)); |
| 3382 return (DWORD)::SendMessage(m_hWnd, LVM_GETVIEW, 0, 0L); |
| 3383 } |
| 3384 |
| 3385 int SetView(DWORD dwView) |
| 3386 { |
| 3387 ATLASSERT(::IsWindow(m_hWnd)); |
| 3388 return (int)::SendMessage(m_hWnd, LVM_SETVIEW, dwView, 0L); |
| 3389 } |
| 3390 |
| 3391 BOOL IsGroupViewEnabled() const |
| 3392 { |
| 3393 ATLASSERT(::IsWindow(m_hWnd)); |
| 3394 return (BOOL)::SendMessage(m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L
); |
| 3395 } |
| 3396 |
| 3397 int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const |
| 3398 { |
| 3399 ATLASSERT(::IsWindow(m_hWnd)); |
| 3400 return (int)::SendMessage(m_hWnd, LVM_GETGROUPINFO, nGroupID, (L
PARAM)pGroup); |
| 3401 } |
| 3402 |
| 3403 int SetGroupInfo(int nGroupID, PLVGROUP pGroup) |
| 3404 { |
| 3405 ATLASSERT(::IsWindow(m_hWnd)); |
| 3406 return (int)::SendMessage(m_hWnd, LVM_SETGROUPINFO, nGroupID, (L
PARAM)pGroup); |
| 3407 } |
| 3408 |
| 3409 void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const |
| 3410 { |
| 3411 ATLASSERT(::IsWindow(m_hWnd)); |
| 3412 ::SendMessage(m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetr
ics); |
| 3413 } |
| 3414 |
| 3415 void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) |
| 3416 { |
| 3417 ATLASSERT(::IsWindow(m_hWnd)); |
| 3418 ::SendMessage(m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetr
ics); |
| 3419 } |
| 3420 |
| 3421 void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const |
| 3422 { |
| 3423 ATLASSERT(::IsWindow(m_hWnd)); |
| 3424 ::SendMessage(m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewI
nfo); |
| 3425 } |
| 3426 |
| 3427 BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) |
| 3428 { |
| 3429 ATLASSERT(::IsWindow(m_hWnd)); |
| 3430 return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPAR
AM)pTileViewInfo); |
| 3431 } |
| 3432 |
| 3433 void GetTileInfo(PLVTILEINFO pTileInfo) const |
| 3434 { |
| 3435 ATLASSERT(::IsWindow(m_hWnd)); |
| 3436 ::SendMessage(m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo); |
| 3437 } |
| 3438 |
| 3439 BOOL SetTileInfo(PLVTILEINFO pTileInfo) |
| 3440 { |
| 3441 ATLASSERT(::IsWindow(m_hWnd)); |
| 3442 return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)p
TileInfo); |
| 3443 } |
| 3444 |
| 3445 BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const |
| 3446 { |
| 3447 ATLASSERT(::IsWindow(m_hWnd)); |
| 3448 return (BOOL)::SendMessage(m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM
)pInsertMark); |
| 3449 } |
| 3450 |
| 3451 BOOL SetInsertMark(LPLVINSERTMARK pInsertMark) |
| 3452 { |
| 3453 ATLASSERT(::IsWindow(m_hWnd)); |
| 3454 return (BOOL)::SendMessage(m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM
)pInsertMark); |
| 3455 } |
| 3456 |
| 3457 int GetInsertMarkRect(LPRECT lpRect) const |
| 3458 { |
| 3459 ATLASSERT(::IsWindow(m_hWnd)); |
| 3460 return (int)::SendMessage(m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPA
RAM)lpRect); |
| 3461 } |
| 3462 |
| 3463 COLORREF GetInsertMarkColor() const |
| 3464 { |
| 3465 ATLASSERT(::IsWindow(m_hWnd)); |
| 3466 return (COLORREF)::SendMessage(m_hWnd, LVM_GETINSERTMARKCOLOR, 0
, 0L); |
| 3467 } |
| 3468 |
| 3469 COLORREF SetInsertMarkColor(COLORREF clr) |
| 3470 { |
| 3471 ATLASSERT(::IsWindow(m_hWnd)); |
| 3472 return (COLORREF)::SendMessage(m_hWnd, LVM_SETINSERTMARKCOLOR, 0
, clr); |
| 3473 } |
| 3474 |
| 3475 COLORREF GetOutlineColor() const |
| 3476 { |
| 3477 ATLASSERT(::IsWindow(m_hWnd)); |
| 3478 return (COLORREF)::SendMessage(m_hWnd, LVM_GETOUTLINECOLOR, 0, 0
L); |
| 3479 } |
| 3480 |
| 3481 COLORREF SetOutlineColor(COLORREF clr) |
| 3482 { |
| 3483 ATLASSERT(::IsWindow(m_hWnd)); |
| 3484 return (COLORREF)::SendMessage(m_hWnd, LVM_SETOUTLINECOLOR, 0, c
lr); |
| 3485 } |
| 3486 #endif // (_WIN32_WINNT >= 0x0501) |
| 3487 |
| 3488 #if (_WIN32_WINNT >= 0x0600) |
| 3489 int GetGroupCount() const |
| 3490 { |
| 3491 ATLASSERT(::IsWindow(m_hWnd)); |
| 3492 return (int)::SendMessage(m_hWnd, LVM_GETGROUPCOUNT, 0, 0L); |
| 3493 } |
| 3494 |
| 3495 BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const |
| 3496 { |
| 3497 ATLASSERT(::IsWindow(m_hWnd)); |
| 3498 return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPINFOBYINDEX, nInd
ex, (LPARAM)pGroup); |
| 3499 } |
| 3500 |
| 3501 BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const |
| 3502 { |
| 3503 ATLASSERT(::IsWindow(m_hWnd)); |
| 3504 ATLASSERT(lpRect != NULL); |
| 3505 if(lpRect != NULL) |
| 3506 lpRect->top = nType; |
| 3507 return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPRECT, nGroupID, (
LPARAM)lpRect); |
| 3508 } |
| 3509 |
| 3510 UINT GetGroupState(int nGroupID, UINT uMask) const |
| 3511 { |
| 3512 ATLASSERT(::IsWindow(m_hWnd)); |
| 3513 return (UINT)::SendMessage(m_hWnd, LVM_GETGROUPSTATE, nGroupID,
(LPARAM)uMask); |
| 3514 } |
| 3515 |
| 3516 int GetFocusedGroup() const |
| 3517 { |
| 3518 ATLASSERT(::IsWindow(m_hWnd)); |
| 3519 return (int)::SendMessage(m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L); |
| 3520 } |
| 3521 |
| 3522 BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const |
| 3523 { |
| 3524 ATLASSERT(::IsWindow(m_hWnd)); |
| 3525 return (BOOL)::SendMessage(m_hWnd, LVM_GETEMPTYTEXT, cchText, (L
PARAM)lpstrText); |
| 3526 } |
| 3527 |
| 3528 BOOL GetFooterRect(LPRECT lpRect) const |
| 3529 { |
| 3530 ATLASSERT(::IsWindow(m_hWnd)); |
| 3531 return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM
)lpRect); |
| 3532 } |
| 3533 |
| 3534 BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const |
| 3535 { |
| 3536 ATLASSERT(::IsWindow(m_hWnd)); |
| 3537 return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM
)lpFooterInfo); |
| 3538 } |
| 3539 |
| 3540 BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const |
| 3541 { |
| 3542 ATLASSERT(::IsWindow(m_hWnd)); |
| 3543 return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEMRECT, nItem,
(LPARAM)lpRect); |
| 3544 } |
| 3545 |
| 3546 BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const |
| 3547 { |
| 3548 ATLASSERT(::IsWindow(m_hWnd)); |
| 3549 return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEM, nItem, (LP
ARAM)lpFooterItem); |
| 3550 } |
| 3551 |
| 3552 BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType,
LPRECT lpRect) const |
| 3553 { |
| 3554 ATLASSERT(::IsWindow(m_hWnd)); |
| 3555 ATLASSERT(pItemIndex != NULL); |
| 3556 ATLASSERT(lpRect != NULL); |
| 3557 if(lpRect != NULL) |
| 3558 { |
| 3559 lpRect->top = nSubItem; |
| 3560 lpRect->left = nType; |
| 3561 } |
| 3562 return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM
)pItemIndex, (LPARAM)lpRect); |
| 3563 } |
| 3564 |
| 3565 BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask
) |
| 3566 { |
| 3567 ATLASSERT(::IsWindow(m_hWnd)); |
| 3568 LVITEM lvi = { 0 }; |
| 3569 lvi.state = uState; |
| 3570 lvi.stateMask = dwMask; |
| 3571 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMINDEXSTATE, (WPARA
M)pItemIndex, (LPARAM)&lvi); |
| 3572 } |
| 3573 |
| 3574 BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const |
| 3575 { |
| 3576 ATLASSERT(::IsWindow(m_hWnd)); |
| 3577 return (BOOL)::SendMessage(m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM
)pItemIndex, MAKELPARAM(wFlags, 0)); |
| 3578 } |
| 3579 #endif // (_WIN32_WINNT >= 0x0600) |
| 3580 |
| 3581 // Operations |
| 3582 int InsertColumn(int nCol, const LVCOLUMN* pColumn) |
| 3583 { |
| 3584 ATLASSERT(::IsWindow(m_hWnd)); |
| 3585 return (int)::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARA
M)pColumn); |
| 3586 } |
| 3587 |
| 3588 int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCF
MT_LEFT, |
| 3589 int nWidth = -1, int nSubItem = -1, int iImage = -1, int
iOrder = -1) |
| 3590 { |
| 3591 LVCOLUMN column = { 0 }; |
| 3592 column.mask = LVCF_TEXT|LVCF_FMT; |
| 3593 column.pszText = (LPTSTR)lpszColumnHeading; |
| 3594 column.fmt = nFormat; |
| 3595 if (nWidth != -1) |
| 3596 { |
| 3597 column.mask |= LVCF_WIDTH; |
| 3598 column.cx = nWidth; |
| 3599 } |
| 3600 if (nSubItem != -1) |
| 3601 { |
| 3602 column.mask |= LVCF_SUBITEM; |
| 3603 column.iSubItem = nSubItem; |
| 3604 } |
| 3605 if (iImage != -1) |
| 3606 { |
| 3607 column.mask |= LVCF_IMAGE; |
| 3608 column.iImage = iImage; |
| 3609 } |
| 3610 if (iOrder != -1) |
| 3611 { |
| 3612 column.mask |= LVCF_ORDER; |
| 3613 column.iOrder = iOrder; |
| 3614 } |
| 3615 return InsertColumn(nCol, &column); |
| 3616 } |
| 3617 |
| 3618 BOOL DeleteColumn(int nCol) |
| 3619 { |
| 3620 ATLASSERT(::IsWindow(m_hWnd)); |
| 3621 return (BOOL)::SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0L); |
| 3622 } |
| 3623 |
| 3624 int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UIN
T nStateMask, int nImage, LPARAM lParam) |
| 3625 { |
| 3626 ATLASSERT(::IsWindow(m_hWnd)); |
| 3627 LVITEM item = { 0 }; |
| 3628 item.mask = nMask; |
| 3629 item.iItem = nItem; |
| 3630 item.iSubItem = 0; |
| 3631 item.pszText = (LPTSTR)lpszItem; |
| 3632 item.state = nState; |
| 3633 item.stateMask = nStateMask; |
| 3634 item.iImage = nImage; |
| 3635 item.lParam = lParam; |
| 3636 return InsertItem(&item); |
| 3637 } |
| 3638 |
| 3639 int InsertItem(const LVITEM* pItem) |
| 3640 { |
| 3641 ATLASSERT(::IsWindow(m_hWnd)); |
| 3642 return (int)::SendMessage(m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pIt
em); |
| 3643 } |
| 3644 |
| 3645 int InsertItem(int nItem, LPCTSTR lpszItem) |
| 3646 { |
| 3647 ATLASSERT(::IsWindow(m_hWnd)); |
| 3648 return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); |
| 3649 } |
| 3650 |
| 3651 int InsertItem(int nItem, LPCTSTR lpszItem, int nImage) |
| 3652 { |
| 3653 ATLASSERT(::IsWindow(m_hWnd)); |
| 3654 return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, n
Image, 0); |
| 3655 } |
| 3656 |
| 3657 int GetNextItem(int nItem, int nFlags) const |
| 3658 { |
| 3659 ATLASSERT(::IsWindow(m_hWnd)); |
| 3660 return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, nItem, MAKELP
ARAM(nFlags, 0)); |
| 3661 } |
| 3662 |
| 3663 BOOL DeleteItem(int nItem) |
| 3664 { |
| 3665 ATLASSERT(::IsWindow(m_hWnd)); |
| 3666 return (BOOL)::SendMessage(m_hWnd, LVM_DELETEITEM, nItem, 0L); |
| 3667 } |
| 3668 |
| 3669 BOOL DeleteAllItems() |
| 3670 { |
| 3671 ATLASSERT(::IsWindow(m_hWnd)); |
| 3672 return (BOOL)::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L); |
| 3673 } |
| 3674 |
| 3675 int FindItem(LVFINDINFO* pFindInfo, int nStart) const |
| 3676 { |
| 3677 ATLASSERT(::IsWindow(m_hWnd)); |
| 3678 return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)
pFindInfo); |
| 3679 } |
| 3680 |
| 3681 int HitTest(LVHITTESTINFO* pHitTestInfo) const |
| 3682 { |
| 3683 ATLASSERT(::IsWindow(m_hWnd)); |
| 3684 return (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTe
stInfo); |
| 3685 } |
| 3686 |
| 3687 int HitTest(POINT pt, UINT* pFlags) const |
| 3688 { |
| 3689 ATLASSERT(::IsWindow(m_hWnd)); |
| 3690 LVHITTESTINFO hti = { 0 }; |
| 3691 hti.pt = pt; |
| 3692 int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)&h
ti); |
| 3693 if (pFlags != NULL) |
| 3694 *pFlags = hti.flags; |
| 3695 return nRes; |
| 3696 } |
| 3697 |
| 3698 BOOL EnsureVisible(int nItem, BOOL bPartialOK) |
| 3699 { |
| 3700 ATLASSERT(::IsWindow(m_hWnd)); |
| 3701 return (BOOL)::SendMessage(m_hWnd, LVM_ENSUREVISIBLE, nItem, MAK
ELPARAM(bPartialOK, 0)); |
| 3702 } |
| 3703 |
| 3704 BOOL Scroll(SIZE size) |
| 3705 { |
| 3706 ATLASSERT(::IsWindow(m_hWnd)); |
| 3707 return (BOOL)::SendMessage(m_hWnd, LVM_SCROLL, size.cx, size.cy)
; |
| 3708 } |
| 3709 |
| 3710 BOOL RedrawItems(int nFirst, int nLast) |
| 3711 { |
| 3712 ATLASSERT(::IsWindow(m_hWnd)); |
| 3713 return (BOOL)::SendMessage(m_hWnd, LVM_REDRAWITEMS, nFirst, nLas
t); |
| 3714 } |
| 3715 |
| 3716 BOOL Arrange(UINT nCode) |
| 3717 { |
| 3718 ATLASSERT(::IsWindow(m_hWnd)); |
| 3719 return (BOOL)::SendMessage(m_hWnd, LVM_ARRANGE, nCode, 0L); |
| 3720 } |
| 3721 |
| 3722 CEdit EditLabel(int nItem) |
| 3723 { |
| 3724 ATLASSERT(::IsWindow(m_hWnd)); |
| 3725 return CEdit((HWND)::SendMessage(m_hWnd, LVM_EDITLABEL, nItem, 0
L)); |
| 3726 } |
| 3727 |
| 3728 BOOL Update(int nItem) |
| 3729 { |
| 3730 ATLASSERT(::IsWindow(m_hWnd)); |
| 3731 return (BOOL)::SendMessage(m_hWnd, LVM_UPDATE, nItem, 0L); |
| 3732 } |
| 3733 |
| 3734 BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) |
| 3735 { |
| 3736 ATLASSERT(::IsWindow(m_hWnd)); |
| 3737 return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMS, (WPARAM)lParam
Sort, (LPARAM)pfnCompare); |
| 3738 } |
| 3739 |
| 3740 CImageList RemoveImageList(int nImageList) |
| 3741 { |
| 3742 ATLASSERT(::IsWindow(m_hWnd)); |
| 3743 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGE
LIST, (WPARAM)nImageList, NULL)); |
| 3744 } |
| 3745 |
| 3746 CImageList CreateDragImage(int nItem, LPPOINT lpPoint) |
| 3747 { |
| 3748 ATLASSERT(::IsWindow(m_hWnd)); |
| 3749 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_CREATEDR
AGIMAGE, nItem, (LPARAM)lpPoint)); |
| 3750 } |
| 3751 |
| 3752 DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1) |
| 3753 { |
| 3754 ATLASSERT(::IsWindow(m_hWnd)); |
| 3755 return (DWORD)::SendMessage(m_hWnd, LVM_APPROXIMATEVIEWRECT, nCo
unt, MAKELPARAM(cx, cy)); |
| 3756 } |
| 3757 |
| 3758 int SubItemHitTest(LPLVHITTESTINFO lpInfo) const |
| 3759 { |
| 3760 ATLASSERT(::IsWindow(m_hWnd)); |
| 3761 return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM
)lpInfo); |
| 3762 } |
| 3763 |
| 3764 int AddColumn(LPCTSTR strItem, int nItem, int nSubItem = -1, |
| 3765 int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUB
ITEM, |
| 3766 int nFmt = LVCFMT_LEFT) |
| 3767 { |
| 3768 const int cxOffset = 15; |
| 3769 ATLASSERT(::IsWindow(m_hWnd)); |
| 3770 LVCOLUMN lvc = { 0 }; |
| 3771 lvc.mask = nMask; |
| 3772 lvc.fmt = nFmt; |
| 3773 lvc.pszText = (LPTSTR)strItem; |
| 3774 lvc.cx = GetStringWidth(lvc.pszText) + cxOffset; |
| 3775 if(nMask & LVCF_SUBITEM) |
| 3776 lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem; |
| 3777 return InsertColumn(nItem, &lvc); |
| 3778 } |
| 3779 |
| 3780 int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex =
-1) |
| 3781 { |
| 3782 ATLASSERT(::IsWindow(m_hWnd)); |
| 3783 LVITEM lvItem = { 0 }; |
| 3784 lvItem.mask = LVIF_TEXT; |
| 3785 lvItem.iItem = nItem; |
| 3786 lvItem.iSubItem = nSubItem; |
| 3787 lvItem.pszText = (LPTSTR)strItem; |
| 3788 if(nImageIndex != -1) |
| 3789 { |
| 3790 lvItem.mask |= LVIF_IMAGE; |
| 3791 lvItem.iImage = nImageIndex; |
| 3792 } |
| 3793 if(nSubItem == 0) |
| 3794 return InsertItem(&lvItem); |
| 3795 return SetItem(&lvItem) ? nItem : -1; |
| 3796 } |
| 3797 |
| 3798 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 3799 BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort) |
| 3800 { |
| 3801 ATLASSERT(::IsWindow(m_hWnd)); |
| 3802 return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMSEX, (WPARAM)lPar
amSort, (LPARAM)pfnCompare); |
| 3803 } |
| 3804 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 3805 |
| 3806 #if (_WIN32_WINNT >= 0x0501) |
| 3807 int InsertGroup(int nItem, PLVGROUP pGroup) |
| 3808 { |
| 3809 ATLASSERT(::IsWindow(m_hWnd)); |
| 3810 return (int)::SendMessage(m_hWnd, LVM_INSERTGROUP, nItem, (LPARA
M)pGroup); |
| 3811 } |
| 3812 |
| 3813 int AddGroup(PLVGROUP pGroup) |
| 3814 { |
| 3815 return InsertGroup(-1, pGroup); |
| 3816 } |
| 3817 |
| 3818 int RemoveGroup(int nGroupID) |
| 3819 { |
| 3820 ATLASSERT(::IsWindow(m_hWnd)); |
| 3821 return (int)::SendMessage(m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L)
; |
| 3822 } |
| 3823 |
| 3824 void MoveGroup(int nGroupID, int nItem) |
| 3825 { |
| 3826 ATLASSERT(::IsWindow(m_hWnd)); |
| 3827 ::SendMessage(m_hWnd, LVM_MOVEGROUP, nGroupID, nItem); |
| 3828 } |
| 3829 |
| 3830 void MoveItemToGroup(int nItem, int nGroupID) |
| 3831 { |
| 3832 ATLASSERT(::IsWindow(m_hWnd)); |
| 3833 ::SendMessage(m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID); |
| 3834 } |
| 3835 |
| 3836 int EnableGroupView(BOOL bEnable) |
| 3837 { |
| 3838 ATLASSERT(::IsWindow(m_hWnd)); |
| 3839 return (int)::SendMessage(m_hWnd, LVM_ENABLEGROUPVIEW, bEnable,
0L); |
| 3840 } |
| 3841 |
| 3842 int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL) |
| 3843 { |
| 3844 ATLASSERT(::IsWindow(m_hWnd)); |
| 3845 return (int)::SendMessage(m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompa
reFunc, (LPARAM)lpVoid); |
| 3846 } |
| 3847 |
| 3848 void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted) |
| 3849 { |
| 3850 ATLASSERT(::IsWindow(m_hWnd)); |
| 3851 ::SendMessage(m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGrou
pSorted, 0L); |
| 3852 } |
| 3853 |
| 3854 void RemoveAllGroups() |
| 3855 { |
| 3856 ATLASSERT(::IsWindow(m_hWnd)); |
| 3857 ::SendMessage(m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L); |
| 3858 } |
| 3859 |
| 3860 BOOL HasGroup(int nGroupID) |
| 3861 { |
| 3862 ATLASSERT(::IsWindow(m_hWnd)); |
| 3863 return (BOOL)::SendMessage(m_hWnd, LVM_HASGROUP, nGroupID, 0L); |
| 3864 } |
| 3865 |
| 3866 BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) cons
t |
| 3867 { |
| 3868 ATLASSERT(::IsWindow(m_hWnd)); |
| 3869 return (BOOL)::SendMessage(m_hWnd, LVM_INSERTMARKHITTEST, (WPARA
M)lpPoint, (LPARAM)pInsertMark); |
| 3870 } |
| 3871 |
| 3872 BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip) |
| 3873 { |
| 3874 ATLASSERT(::IsWindow(m_hWnd)); |
| 3875 return (BOOL)::SendMessage(m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pS
etInfoTip); |
| 3876 } |
| 3877 |
| 3878 void CancelEditLabel() |
| 3879 { |
| 3880 ATLASSERT(::IsWindow(m_hWnd)); |
| 3881 ::SendMessage(m_hWnd, LVM_CANCELEDITLABEL, 0, 0L); |
| 3882 } |
| 3883 |
| 3884 UINT MapIndexToID(int nIndex) const |
| 3885 { |
| 3886 ATLASSERT(::IsWindow(m_hWnd)); |
| 3887 return (UINT)::SendMessage(m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L)
; |
| 3888 } |
| 3889 |
| 3890 int MapIDToIndex(UINT uID) const |
| 3891 { |
| 3892 ATLASSERT(::IsWindow(m_hWnd)); |
| 3893 return (int)::SendMessage(m_hWnd, LVM_MAPIDTOINDEX, uID, 0L); |
| 3894 } |
| 3895 #endif // (_WIN32_WINNT >= 0x0501) |
| 3896 |
| 3897 #if (_WIN32_WINNT >= 0x0600) |
| 3898 int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const |
| 3899 { |
| 3900 ATLASSERT(::IsWindow(m_hWnd)); |
| 3901 return (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPAR
AM)lpHitTestInfo); |
| 3902 } |
| 3903 |
| 3904 int HitTestEx(POINT pt, UINT* pFlags) const |
| 3905 { |
| 3906 ATLASSERT(::IsWindow(m_hWnd)); |
| 3907 LVHITTESTINFO hti = { 0 }; |
| 3908 hti.pt = pt; |
| 3909 int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (
LPARAM)&hti); |
| 3910 if (pFlags != NULL) |
| 3911 *pFlags = hti.flags; |
| 3912 return nRes; |
| 3913 } |
| 3914 |
| 3915 int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const |
| 3916 { |
| 3917 ATLASSERT(::IsWindow(m_hWnd)); |
| 3918 return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1
, (LPARAM)lpHitTestInfo); |
| 3919 } |
| 3920 #endif // (_WIN32_WINNT >= 0x0600) |
| 3921 |
| 3922 // single-selection only |
| 3923 BOOL SelectItem(int nIndex) |
| 3924 { |
| 3925 ATLASSERT(::IsWindow(m_hWnd)); |
| 3926 ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0); |
| 3927 |
| 3928 BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, L
VIS_SELECTED | LVIS_FOCUSED); |
| 3929 if(bRet) |
| 3930 bRet = EnsureVisible(nIndex, FALSE); |
| 3931 return bRet; |
| 3932 } |
| 3933 }; |
| 3934 |
| 3935 typedef CListViewCtrlT<ATL::CWindow> CListViewCtrl; |
| 3936 |
| 3937 |
| 3938 /////////////////////////////////////////////////////////////////////////////// |
| 3939 // CTreeViewCtrl |
| 3940 |
| 3941 template <class TBase> |
| 3942 class CTreeViewCtrlT : public TBase |
| 3943 { |
| 3944 public: |
| 3945 // Constructors |
| 3946 CTreeViewCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 3947 { } |
| 3948 |
| 3949 CTreeViewCtrlT< TBase >& operator =(HWND hWnd) |
| 3950 { |
| 3951 m_hWnd = hWnd; |
| 3952 return *this; |
| 3953 } |
| 3954 |
| 3955 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 3956 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 3957 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 3958 { |
| 3959 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 3960 } |
| 3961 |
| 3962 // Attributes |
| 3963 static LPCTSTR GetWndClassName() |
| 3964 { |
| 3965 return WC_TREEVIEW; |
| 3966 } |
| 3967 |
| 3968 UINT GetCount() const |
| 3969 { |
| 3970 ATLASSERT(::IsWindow(m_hWnd)); |
| 3971 return (UINT)::SendMessage(m_hWnd, TVM_GETCOUNT, 0, 0L); |
| 3972 } |
| 3973 |
| 3974 UINT GetIndent() const |
| 3975 { |
| 3976 ATLASSERT(::IsWindow(m_hWnd)); |
| 3977 return (UINT)::SendMessage(m_hWnd, TVM_GETINDENT, 0, 0L); |
| 3978 } |
| 3979 |
| 3980 void SetIndent(UINT nIndent) |
| 3981 { |
| 3982 ATLASSERT(::IsWindow(m_hWnd)); |
| 3983 ::SendMessage(m_hWnd, TVM_SETINDENT, nIndent, 0L); |
| 3984 } |
| 3985 |
| 3986 CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const |
| 3987 { |
| 3988 ATLASSERT(::IsWindow(m_hWnd)); |
| 3989 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_GETIMAGE
LIST, (WPARAM)nImageListType, 0L)); |
| 3990 } |
| 3991 |
| 3992 CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSI
L_NORMAL) |
| 3993 { |
| 3994 ATLASSERT(::IsWindow(m_hWnd)); |
| 3995 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGE
LIST, (WPARAM)nImageListType, (LPARAM)hImageList)); |
| 3996 } |
| 3997 |
| 3998 BOOL GetItem(LPTVITEM pItem) const |
| 3999 { |
| 4000 ATLASSERT(::IsWindow(m_hWnd)); |
| 4001 return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem
); |
| 4002 } |
| 4003 |
| 4004 BOOL SetItem(LPTVITEM pItem) |
| 4005 { |
| 4006 ATLASSERT(::IsWindow(m_hWnd)); |
| 4007 return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem
); |
| 4008 } |
| 4009 |
| 4010 BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage, |
| 4011 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) |
| 4012 { |
| 4013 ATLASSERT(::IsWindow(m_hWnd)); |
| 4014 TVITEM item = { 0 }; |
| 4015 item.hItem = hItem; |
| 4016 item.mask = nMask; |
| 4017 item.pszText = (LPTSTR) lpszItem; |
| 4018 item.iImage = nImage; |
| 4019 item.iSelectedImage = nSelectedImage; |
| 4020 item.state = nState; |
| 4021 item.stateMask = nStateMask; |
| 4022 item.lParam = lParam; |
| 4023 return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)&item
); |
| 4024 } |
| 4025 |
| 4026 BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const |
| 4027 { |
| 4028 ATLASSERT(::IsWindow(m_hWnd)); |
| 4029 ATLASSERT(lpstrText != NULL); |
| 4030 |
| 4031 TVITEM item = { 0 }; |
| 4032 item.hItem = hItem; |
| 4033 item.mask = TVIF_TEXT; |
| 4034 item.pszText = lpstrText; |
| 4035 item.cchTextMax = nLen; |
| 4036 |
| 4037 return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item
); |
| 4038 } |
| 4039 |
| 4040 #ifndef _ATL_NO_COM |
| 4041 BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const |
| 4042 { |
| 4043 USES_CONVERSION; |
| 4044 ATLASSERT(::IsWindow(m_hWnd)); |
| 4045 ATLASSERT(bstrText == NULL); |
| 4046 TVITEM item = { 0 }; |
| 4047 item.hItem = hItem; |
| 4048 item.mask = TVIF_TEXT; |
| 4049 |
| 4050 LPTSTR lpstrText = NULL; |
| 4051 BOOL bRet = FALSE; |
| 4052 for(int nLen = 256; ; nLen *= 2) |
| 4053 { |
| 4054 ATLTRY(lpstrText = new TCHAR[nLen]); |
| 4055 if(lpstrText == NULL) |
| 4056 break; |
| 4057 lpstrText[0] = NULL; |
| 4058 item.pszText = lpstrText; |
| 4059 item.cchTextMax = nLen; |
| 4060 bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPAR
AM)&item); |
| 4061 if(!bRet || (lstrlen(item.pszText) < nLen - 1)) |
| 4062 break; |
| 4063 delete [] lpstrText; |
| 4064 lpstrText = NULL; |
| 4065 } |
| 4066 |
| 4067 if(lpstrText != NULL) |
| 4068 { |
| 4069 if(bRet) |
| 4070 bstrText = ::SysAllocString(T2OLE(lpstrText)); |
| 4071 delete [] lpstrText; |
| 4072 } |
| 4073 |
| 4074 return (bstrText != NULL) ? TRUE : FALSE; |
| 4075 } |
| 4076 #endif // !_ATL_NO_COM |
| 4077 |
| 4078 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 4079 BOOL GetItemText(HTREEITEM hItem, _CSTRING_NS::CString& strText) const |
| 4080 { |
| 4081 ATLASSERT(::IsWindow(m_hWnd)); |
| 4082 TVITEM item = { 0 }; |
| 4083 item.hItem = hItem; |
| 4084 item.mask = TVIF_TEXT; |
| 4085 |
| 4086 strText.Empty(); |
| 4087 BOOL bRet = FALSE; |
| 4088 for(int nLen = 256; ; nLen *= 2) |
| 4089 { |
| 4090 item.pszText = strText.GetBufferSetLength(nLen); |
| 4091 if(item.pszText == NULL) |
| 4092 { |
| 4093 bRet = FALSE; |
| 4094 break; |
| 4095 } |
| 4096 item.cchTextMax = nLen; |
| 4097 bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPAR
AM)&item); |
| 4098 if(!bRet || (lstrlen(item.pszText) < nLen - 1)) |
| 4099 break; |
| 4100 } |
| 4101 strText.ReleaseBuffer(); |
| 4102 return bRet; |
| 4103 } |
| 4104 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 4105 |
| 4106 BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem) |
| 4107 { |
| 4108 ATLASSERT(::IsWindow(m_hWnd)); |
| 4109 return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL); |
| 4110 } |
| 4111 |
| 4112 BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) con
st |
| 4113 { |
| 4114 ATLASSERT(::IsWindow(m_hWnd)); |
| 4115 TVITEM item = { 0 }; |
| 4116 item.hItem = hItem; |
| 4117 item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; |
| 4118 BOOL bRes = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)
&item); |
| 4119 if (bRes) |
| 4120 { |
| 4121 nImage = item.iImage; |
| 4122 nSelectedImage = item.iSelectedImage; |
| 4123 } |
| 4124 return bRes; |
| 4125 } |
| 4126 |
| 4127 BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage) |
| 4128 { |
| 4129 ATLASSERT(::IsWindow(m_hWnd)); |
| 4130 return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImag
e, nSelectedImage, 0, 0, NULL); |
| 4131 } |
| 4132 |
| 4133 UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const |
| 4134 { |
| 4135 ATLASSERT(::IsWindow(m_hWnd)); |
| 4136 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 4137 return (((UINT)::SendMessage(m_hWnd, TVM_GETITEMSTATE, (WPARAM)h
Item, (LPARAM)nStateMask)) & nStateMask); |
| 4138 #else // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)) |
| 4139 TVITEM item = { 0 }; |
| 4140 item.hItem = hItem; |
| 4141 item.mask = TVIF_STATE; |
| 4142 item.state = 0; |
| 4143 item.stateMask = nStateMask; |
| 4144 ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); |
| 4145 return (item.state & nStateMask); |
| 4146 #endif // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)) |
| 4147 } |
| 4148 |
| 4149 BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask) |
| 4150 { |
| 4151 ATLASSERT(::IsWindow(m_hWnd)); |
| 4152 return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask
, NULL); |
| 4153 } |
| 4154 |
| 4155 DWORD_PTR GetItemData(HTREEITEM hItem) const |
| 4156 { |
| 4157 ATLASSERT(::IsWindow(m_hWnd)); |
| 4158 TVITEM item = { 0 }; |
| 4159 item.hItem = hItem; |
| 4160 item.mask = TVIF_PARAM; |
| 4161 BOOL bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)
&item); |
| 4162 return (DWORD_PTR)(bRet ? item.lParam : NULL); |
| 4163 } |
| 4164 |
| 4165 BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData) |
| 4166 { |
| 4167 ATLASSERT(::IsWindow(m_hWnd)); |
| 4168 return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwDa
ta); |
| 4169 } |
| 4170 |
| 4171 CEdit GetEditControl() const |
| 4172 { |
| 4173 ATLASSERT(::IsWindow(m_hWnd)); |
| 4174 return CEdit((HWND)::SendMessage(m_hWnd, TVM_GETEDITCONTROL, 0,
0L)); |
| 4175 } |
| 4176 |
| 4177 UINT GetVisibleCount() const |
| 4178 { |
| 4179 ATLASSERT(::IsWindow(m_hWnd)); |
| 4180 return (UINT)::SendMessage(m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L); |
| 4181 } |
| 4182 |
| 4183 BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const |
| 4184 { |
| 4185 ATLASSERT(::IsWindow(m_hWnd)); |
| 4186 *(HTREEITEM*)lpRect = hItem; |
| 4187 return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMRECT, (WPARAM)bTex
tOnly, (LPARAM)lpRect); |
| 4188 } |
| 4189 |
| 4190 BOOL ItemHasChildren(HTREEITEM hItem) const |
| 4191 { |
| 4192 ATLASSERT(::IsWindow(m_hWnd)); |
| 4193 TVITEM item = { 0 }; |
| 4194 item.hItem = hItem; |
| 4195 item.mask = TVIF_CHILDREN; |
| 4196 ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item); |
| 4197 return item.cChildren; |
| 4198 } |
| 4199 |
| 4200 #ifndef _WIN32_WCE |
| 4201 CToolTipCtrl GetToolTips() const |
| 4202 { |
| 4203 ATLASSERT(::IsWindow(m_hWnd)); |
| 4204 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_GETTOOLTIPS,
0, 0L)); |
| 4205 } |
| 4206 |
| 4207 CToolTipCtrl SetToolTips(HWND hWndTT) |
| 4208 { |
| 4209 ATLASSERT(::IsWindow(m_hWnd)); |
| 4210 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_SETTOOLTIPS,
(WPARAM)hWndTT, 0L)); |
| 4211 } |
| 4212 #endif // !_WIN32_WCE |
| 4213 |
| 4214 int GetISearchString(LPTSTR lpstr) const |
| 4215 { |
| 4216 ATLASSERT(::IsWindow(m_hWnd)); |
| 4217 return (int)::SendMessage(m_hWnd, TVM_GETISEARCHSTRING, 0, (LPAR
AM)lpstr); |
| 4218 } |
| 4219 |
| 4220 // checkboxes only |
| 4221 BOOL GetCheckState(HTREEITEM hItem) const |
| 4222 { |
| 4223 ATLASSERT(::IsWindow(m_hWnd)); |
| 4224 ATLASSERT((GetStyle() & TVS_CHECKBOXES) != 0); |
| 4225 UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK); |
| 4226 return (uRet >> 12) - 1; |
| 4227 } |
| 4228 |
| 4229 BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck) |
| 4230 { |
| 4231 int nCheck = bCheck ? 2 : 1; // one based index |
| 4232 return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_S
TATEIMAGEMASK); |
| 4233 } |
| 4234 |
| 4235 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4236 COLORREF GetBkColor() const |
| 4237 { |
| 4238 ATLASSERT(::IsWindow(m_hWnd)); |
| 4239 return (COLORREF)::SendMessage(m_hWnd, TVM_GETBKCOLOR, 0, 0L); |
| 4240 } |
| 4241 |
| 4242 COLORREF SetBkColor(COLORREF clr) |
| 4243 { |
| 4244 ATLASSERT(::IsWindow(m_hWnd)); |
| 4245 return (COLORREF)::SendMessage(m_hWnd, TVM_SETBKCOLOR, 0, (LPARA
M)clr); |
| 4246 } |
| 4247 |
| 4248 COLORREF GetInsertMarkColor() const |
| 4249 { |
| 4250 ATLASSERT(::IsWindow(m_hWnd)); |
| 4251 return (COLORREF)::SendMessage(m_hWnd, TVM_GETINSERTMARKCOLOR, 0
, 0L); |
| 4252 } |
| 4253 |
| 4254 COLORREF SetInsertMarkColor(COLORREF clr) |
| 4255 { |
| 4256 ATLASSERT(::IsWindow(m_hWnd)); |
| 4257 return (COLORREF)::SendMessage(m_hWnd, TVM_SETINSERTMARKCOLOR, 0
, (LPARAM)clr); |
| 4258 } |
| 4259 |
| 4260 int GetItemHeight() const |
| 4261 { |
| 4262 ATLASSERT(::IsWindow(m_hWnd)); |
| 4263 return (int)::SendMessage(m_hWnd, TVM_GETITEMHEIGHT, 0, 0L); |
| 4264 } |
| 4265 |
| 4266 int SetItemHeight(int cyHeight) |
| 4267 { |
| 4268 ATLASSERT(::IsWindow(m_hWnd)); |
| 4269 return (int)::SendMessage(m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0
L); |
| 4270 } |
| 4271 |
| 4272 int GetScrollTime() const |
| 4273 { |
| 4274 ATLASSERT(::IsWindow(m_hWnd)); |
| 4275 return (int)::SendMessage(m_hWnd, TVM_GETSCROLLTIME, 0, 0L); |
| 4276 } |
| 4277 |
| 4278 int SetScrollTime(int nScrollTime) |
| 4279 { |
| 4280 ATLASSERT(::IsWindow(m_hWnd)); |
| 4281 return (int)::SendMessage(m_hWnd, TVM_SETSCROLLTIME, nScrollTime
, 0L); |
| 4282 } |
| 4283 |
| 4284 COLORREF GetTextColor() const |
| 4285 { |
| 4286 ATLASSERT(::IsWindow(m_hWnd)); |
| 4287 return (COLORREF)::SendMessage(m_hWnd, TVM_GETTEXTCOLOR, 0, 0L); |
| 4288 } |
| 4289 |
| 4290 COLORREF SetTextColor(COLORREF clr) |
| 4291 { |
| 4292 ATLASSERT(::IsWindow(m_hWnd)); |
| 4293 return (COLORREF)::SendMessage(m_hWnd, TVM_SETTEXTCOLOR, 0, (LPA
RAM)clr); |
| 4294 } |
| 4295 |
| 4296 BOOL GetUnicodeFormat() const |
| 4297 { |
| 4298 ATLASSERT(::IsWindow(m_hWnd)); |
| 4299 return (BOOL)::SendMessage(m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L); |
| 4300 } |
| 4301 |
| 4302 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 4303 { |
| 4304 ATLASSERT(::IsWindow(m_hWnd)); |
| 4305 return (BOOL)::SendMessage(m_hWnd, TVM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 4306 } |
| 4307 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4308 |
| 4309 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 4310 COLORREF GetLineColor() const |
| 4311 { |
| 4312 ATLASSERT(::IsWindow(m_hWnd)); |
| 4313 return (COLORREF)::SendMessage(m_hWnd, TVM_GETLINECOLOR, 0, 0L); |
| 4314 } |
| 4315 |
| 4316 COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/) |
| 4317 { |
| 4318 ATLASSERT(::IsWindow(m_hWnd)); |
| 4319 return (COLORREF)::SendMessage(m_hWnd, TVM_SETLINECOLOR, 0, (LPA
RAM)clrNew); |
| 4320 } |
| 4321 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 4322 |
| 4323 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4324 BOOL GetItem(LPTVITEMEX pItem) const |
| 4325 { |
| 4326 ATLASSERT(::IsWindow(m_hWnd)); |
| 4327 return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem
); |
| 4328 } |
| 4329 |
| 4330 BOOL SetItem(LPTVITEMEX pItem) |
| 4331 { |
| 4332 ATLASSERT(::IsWindow(m_hWnd)); |
| 4333 return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem
); |
| 4334 } |
| 4335 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4336 |
| 4337 DWORD GetExtendedStyle() const |
| 4338 { |
| 4339 #ifndef TVM_GETEXTENDEDSTYLE |
| 4340 const UINT TVM_GETEXTENDEDSTYLE = (TV_FIRST + 45); |
| 4341 #endif |
| 4342 ATLASSERT(::IsWindow(m_hWnd)); |
| 4343 return (DWORD)::SendMessage(m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L)
; |
| 4344 } |
| 4345 |
| 4346 DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) |
| 4347 { |
| 4348 #ifndef TVM_SETEXTENDEDSTYLE |
| 4349 const UINT TVM_SETEXTENDEDSTYLE = (TV_FIRST + 44); |
| 4350 #endif |
| 4351 ATLASSERT(::IsWindow(m_hWnd)); |
| 4352 return (DWORD)::SendMessage(m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask
, dwStyle); |
| 4353 } |
| 4354 |
| 4355 #if (_WIN32_WINNT >= 0x0600) |
| 4356 BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime) |
| 4357 { |
| 4358 ATLASSERT(::IsWindow(m_hWnd)); |
| 4359 return (BOOL)::SendMessage(m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARA
M)uPixPerSec, (LPARAM)uUpdateTime); |
| 4360 } |
| 4361 |
| 4362 DWORD GetSelectedCount() const |
| 4363 { |
| 4364 ATLASSERT(::IsWindow(m_hWnd)); |
| 4365 return (DWORD)::SendMessage(m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L)
; |
| 4366 } |
| 4367 |
| 4368 BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect)
const |
| 4369 { |
| 4370 ATLASSERT(::IsWindow(m_hWnd)); |
| 4371 TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID }; |
| 4372 return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMPARTRECT, 0, (LPAR
AM)&gipri); |
| 4373 } |
| 4374 #endif // (_WIN32_WINNT >= 0x0600) |
| 4375 |
| 4376 // Operations |
| 4377 HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct) |
| 4378 { |
| 4379 ATLASSERT(::IsWindow(m_hWnd)); |
| 4380 return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPAR
AM)lpInsertStruct); |
| 4381 } |
| 4382 |
| 4383 HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage, |
| 4384 int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) |
| 4385 { |
| 4386 ATLASSERT(::IsWindow(m_hWnd)); |
| 4387 return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, l
pszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); |
| 4388 } |
| 4389 |
| 4390 HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hIns
ertAfter) |
| 4391 { |
| 4392 ATLASSERT(::IsWindow(m_hWnd)); |
| 4393 return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, h
InsertAfter); |
| 4394 } |
| 4395 |
| 4396 HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, |
| 4397 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, |
| 4398 HTREEITEM hParent, HTREEITEM hInsertAfter) |
| 4399 { |
| 4400 ATLASSERT(::IsWindow(m_hWnd)); |
| 4401 TVINSERTSTRUCT tvis = { 0 }; |
| 4402 tvis.hParent = hParent; |
| 4403 tvis.hInsertAfter = hInsertAfter; |
| 4404 tvis.item.mask = nMask; |
| 4405 tvis.item.pszText = (LPTSTR) lpszItem; |
| 4406 tvis.item.iImage = nImage; |
| 4407 tvis.item.iSelectedImage = nSelectedImage; |
| 4408 tvis.item.state = nState; |
| 4409 tvis.item.stateMask = nStateMask; |
| 4410 tvis.item.lParam = lParam; |
| 4411 return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPAR
AM)&tvis); |
| 4412 } |
| 4413 |
| 4414 BOOL DeleteItem(HTREEITEM hItem) |
| 4415 { |
| 4416 ATLASSERT(::IsWindow(m_hWnd)); |
| 4417 return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hI
tem); |
| 4418 } |
| 4419 |
| 4420 BOOL DeleteAllItems() |
| 4421 { |
| 4422 ATLASSERT(::IsWindow(m_hWnd)); |
| 4423 return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TV
I_ROOT); |
| 4424 } |
| 4425 |
| 4426 BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND) |
| 4427 { |
| 4428 ATLASSERT(::IsWindow(m_hWnd)); |
| 4429 return (BOOL)::SendMessage(m_hWnd, TVM_EXPAND, nCode, (LPARAM)hI
tem); |
| 4430 } |
| 4431 |
| 4432 HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const |
| 4433 { |
| 4434 ATLASSERT(::IsWindow(m_hWnd)); |
| 4435 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode,
(LPARAM)hItem); |
| 4436 } |
| 4437 |
| 4438 HTREEITEM GetChildItem(HTREEITEM hItem) const |
| 4439 { |
| 4440 ATLASSERT(::IsWindow(m_hWnd)); |
| 4441 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CH
ILD, (LPARAM)hItem); |
| 4442 } |
| 4443 |
| 4444 HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const |
| 4445 { |
| 4446 ATLASSERT(::IsWindow(m_hWnd)); |
| 4447 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NE
XT, (LPARAM)hItem); |
| 4448 } |
| 4449 |
| 4450 HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const |
| 4451 { |
| 4452 ATLASSERT(::IsWindow(m_hWnd)); |
| 4453 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PR
EVIOUS, (LPARAM)hItem); |
| 4454 } |
| 4455 |
| 4456 HTREEITEM GetParentItem(HTREEITEM hItem) const |
| 4457 { |
| 4458 ATLASSERT(::IsWindow(m_hWnd)); |
| 4459 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PA
RENT, (LPARAM)hItem); |
| 4460 } |
| 4461 |
| 4462 HTREEITEM GetFirstVisibleItem() const |
| 4463 { |
| 4464 ATLASSERT(::IsWindow(m_hWnd)); |
| 4465 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FI
RSTVISIBLE, 0L); |
| 4466 } |
| 4467 |
| 4468 HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const |
| 4469 { |
| 4470 ATLASSERT(::IsWindow(m_hWnd)); |
| 4471 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NE
XTVISIBLE, (LPARAM)hItem); |
| 4472 } |
| 4473 |
| 4474 HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const |
| 4475 { |
| 4476 ATLASSERT(::IsWindow(m_hWnd)); |
| 4477 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PR
EVIOUSVISIBLE, (LPARAM)hItem); |
| 4478 } |
| 4479 |
| 4480 HTREEITEM GetSelectedItem() const |
| 4481 { |
| 4482 ATLASSERT(::IsWindow(m_hWnd)); |
| 4483 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CA
RET, 0L); |
| 4484 } |
| 4485 |
| 4486 HTREEITEM GetDropHilightItem() const |
| 4487 { |
| 4488 ATLASSERT(::IsWindow(m_hWnd)); |
| 4489 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DR
OPHILITE, 0L); |
| 4490 } |
| 4491 |
| 4492 HTREEITEM GetRootItem() const |
| 4493 { |
| 4494 ATLASSERT(::IsWindow(m_hWnd)); |
| 4495 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_RO
OT, 0L); |
| 4496 } |
| 4497 |
| 4498 #if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 4499 HTREEITEM GetLastVisibleItem() const |
| 4500 { |
| 4501 ATLASSERT(::IsWindow(m_hWnd)); |
| 4502 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LA
STVISIBLE, 0L); |
| 4503 } |
| 4504 #endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 4505 |
| 4506 #if (_WIN32_IE >= 0x0600) |
| 4507 HTREEITEM GetNextSelectedItem() const |
| 4508 { |
| 4509 ATLASSERT(::IsWindow(m_hWnd)); |
| 4510 return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NE
XTSELECTED, 0L); |
| 4511 } |
| 4512 #endif // (_WIN32_IE >= 0x0600) |
| 4513 |
| 4514 BOOL Select(HTREEITEM hItem, UINT nCode) |
| 4515 { |
| 4516 ATLASSERT(::IsWindow(m_hWnd)); |
| 4517 return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, nCode, (LPARA
M)hItem); |
| 4518 } |
| 4519 |
| 4520 BOOL SelectItem(HTREEITEM hItem) |
| 4521 { |
| 4522 ATLASSERT(::IsWindow(m_hWnd)); |
| 4523 return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_CARET, (
LPARAM)hItem); |
| 4524 } |
| 4525 |
| 4526 BOOL SelectDropTarget(HTREEITEM hItem) |
| 4527 { |
| 4528 ATLASSERT(::IsWindow(m_hWnd)); |
| 4529 return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_DROPHILI
TE, (LPARAM)hItem); |
| 4530 } |
| 4531 |
| 4532 BOOL SelectSetFirstVisible(HTREEITEM hItem) |
| 4533 { |
| 4534 ATLASSERT(::IsWindow(m_hWnd)); |
| 4535 return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVIS
IBLE, (LPARAM)hItem); |
| 4536 } |
| 4537 |
| 4538 CEdit EditLabel(HTREEITEM hItem) |
| 4539 { |
| 4540 ATLASSERT(::IsWindow(m_hWnd)); |
| 4541 return CEdit((HWND)::SendMessage(m_hWnd, TVM_EDITLABEL, 0, (LPAR
AM)hItem)); |
| 4542 } |
| 4543 |
| 4544 BOOL EndEditLabelNow(BOOL bCancel) |
| 4545 { |
| 4546 ATLASSERT(::IsWindow(m_hWnd)); |
| 4547 return (BOOL)::SendMessage(m_hWnd, TVM_ENDEDITLABELNOW, bCancel,
0L); |
| 4548 } |
| 4549 |
| 4550 HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const |
| 4551 { |
| 4552 ATLASSERT(::IsWindow(m_hWnd)); |
| 4553 return (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)
pHitTestInfo); |
| 4554 } |
| 4555 |
| 4556 HTREEITEM HitTest(POINT pt, UINT* pFlags) const |
| 4557 { |
| 4558 ATLASSERT(::IsWindow(m_hWnd)); |
| 4559 TVHITTESTINFO hti = { 0 }; |
| 4560 hti.pt = pt; |
| 4561 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTE
ST, 0, (LPARAM)&hti); |
| 4562 if (pFlags != NULL) |
| 4563 *pFlags = hti.flags; |
| 4564 return hTreeItem; |
| 4565 } |
| 4566 |
| 4567 BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE) |
| 4568 { |
| 4569 ATLASSERT(::IsWindow(m_hWnd)); |
| 4570 return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRe
curse, (LPARAM)hItem); |
| 4571 } |
| 4572 |
| 4573 BOOL EnsureVisible(HTREEITEM hItem) |
| 4574 { |
| 4575 ATLASSERT(::IsWindow(m_hWnd)); |
| 4576 return (BOOL)::SendMessage(m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM
)hItem); |
| 4577 } |
| 4578 |
| 4579 BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE) |
| 4580 { |
| 4581 ATLASSERT(::IsWindow(m_hWnd)); |
| 4582 return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)b
Recurse, (LPARAM)pSort); |
| 4583 } |
| 4584 |
| 4585 CImageList RemoveImageList(int nImageList) |
| 4586 { |
| 4587 ATLASSERT(::IsWindow(m_hWnd)); |
| 4588 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGE
LIST, (WPARAM)nImageList, NULL)); |
| 4589 } |
| 4590 |
| 4591 CImageList CreateDragImage(HTREEITEM hItem) |
| 4592 { |
| 4593 ATLASSERT(::IsWindow(m_hWnd)); |
| 4594 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_CREATEDR
AGIMAGE, 0, (LPARAM)hItem)); |
| 4595 } |
| 4596 |
| 4597 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4598 BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter) |
| 4599 { |
| 4600 ATLASSERT(::IsWindow(m_hWnd)); |
| 4601 return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, bAfter, (L
PARAM)hTreeItem); |
| 4602 } |
| 4603 |
| 4604 BOOL RemoveInsertMark() |
| 4605 { |
| 4606 ATLASSERT(::IsWindow(m_hWnd)); |
| 4607 return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, 0, 0L); |
| 4608 } |
| 4609 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4610 |
| 4611 #if (_WIN32_WINNT >= 0x0501) |
| 4612 HTREEITEM MapAccIDToHTREEITEM(UINT uID) const |
| 4613 { |
| 4614 ATLASSERT(::IsWindow(m_hWnd)); |
| 4615 return (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM,
uID, 0L); |
| 4616 } |
| 4617 |
| 4618 UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const |
| 4619 { |
| 4620 ATLASSERT(::IsWindow(m_hWnd)); |
| 4621 return (UINT)::SendMessage(m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPA
RAM)hTreeItem, 0L); |
| 4622 } |
| 4623 #endif // (_WIN32_WINNT >= 0x0501) |
| 4624 |
| 4625 #if (_WIN32_WINNT >= 0x0600) |
| 4626 void ShowInfoTip(HTREEITEM hItem) |
| 4627 { |
| 4628 ATLASSERT(::IsWindow(m_hWnd)); |
| 4629 ::SendMessage(m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem); |
| 4630 } |
| 4631 #endif // (_WIN32_WINNT >= 0x0600) |
| 4632 }; |
| 4633 |
| 4634 typedef CTreeViewCtrlT<ATL::CWindow> CTreeViewCtrl; |
| 4635 |
| 4636 |
| 4637 /////////////////////////////////////////////////////////////////////////////// |
| 4638 // CTreeViewCtrlEx |
| 4639 |
| 4640 // forward declaration |
| 4641 template <class TBase> class CTreeViewCtrlExT; |
| 4642 |
| 4643 // Note: TBase here is for CTreeViewCtrlExT, and not for CTreeItemT itself |
| 4644 template <class TBase> |
| 4645 class CTreeItemT |
| 4646 { |
| 4647 public: |
| 4648 HTREEITEM m_hTreeItem; |
| 4649 CTreeViewCtrlExT<TBase>* m_pTreeView; |
| 4650 |
| 4651 // Construction |
| 4652 CTreeItemT(HTREEITEM hTreeItem = NULL, CTreeViewCtrlExT<TBase>* pTreeVie
w = NULL) : m_hTreeItem(hTreeItem), m_pTreeView(pTreeView) |
| 4653 { } |
| 4654 |
| 4655 CTreeItemT(const CTreeItemT<TBase>& posSrc) |
| 4656 { |
| 4657 *this = posSrc; |
| 4658 } |
| 4659 |
| 4660 operator HTREEITEM() { return m_hTreeItem; } |
| 4661 |
| 4662 CTreeItemT<TBase>& operator =(const CTreeItemT<TBase>& itemSrc) |
| 4663 { |
| 4664 m_hTreeItem = itemSrc.m_hTreeItem; |
| 4665 m_pTreeView = itemSrc.m_pTreeView; |
| 4666 return *this; |
| 4667 } |
| 4668 |
| 4669 // Attributes |
| 4670 CTreeViewCtrlExT<TBase>* GetTreeView() const { return m_pTreeView; } |
| 4671 |
| 4672 BOOL operator !() const { return m_hTreeItem == NULL; } |
| 4673 |
| 4674 BOOL IsNull() const { return m_hTreeItem == NULL; } |
| 4675 |
| 4676 BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const; |
| 4677 BOOL GetText(LPTSTR lpstrText, int nLen) const; |
| 4678 #ifndef _ATL_NO_COM |
| 4679 BOOL GetText(BSTR& bstrText) const; |
| 4680 #endif // !_ATL_NO_COM |
| 4681 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 4682 BOOL GetText(_CSTRING_NS::CString& strText) const; |
| 4683 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 4684 BOOL SetText(LPCTSTR lpszItem); |
| 4685 BOOL GetImage(int& nImage, int& nSelectedImage) const; |
| 4686 BOOL SetImage(int nImage, int nSelectedImage); |
| 4687 UINT GetState(UINT nStateMask) const; |
| 4688 BOOL SetState(UINT nState, UINT nStateMask); |
| 4689 DWORD_PTR GetData() const; |
| 4690 BOOL SetData(DWORD_PTR dwData); |
| 4691 BOOL SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImag
e, UINT nState, UINT nStateMask, LPARAM lParam); |
| 4692 |
| 4693 // Operations |
| 4694 CTreeItemT<TBase> InsertAfter(LPCTSTR lpstrItem, HTREEITEM hItemAfter, i
nt nImageIndex) |
| 4695 { |
| 4696 return _Insert(lpstrItem, nImageIndex, hItemAfter); |
| 4697 } |
| 4698 |
| 4699 CTreeItemT<TBase> AddHead(LPCTSTR lpstrItem, int nImageIndex) |
| 4700 { |
| 4701 return _Insert(lpstrItem, nImageIndex, TVI_FIRST); |
| 4702 } |
| 4703 |
| 4704 CTreeItemT<TBase> AddTail(LPCTSTR lpstrItem, int nImageIndex) |
| 4705 { |
| 4706 return _Insert(lpstrItem, nImageIndex, TVI_LAST); |
| 4707 } |
| 4708 |
| 4709 CTreeItemT<TBase> GetChild() const; |
| 4710 CTreeItemT<TBase> GetNext(UINT nCode) const; |
| 4711 CTreeItemT<TBase> GetNextSibling() const; |
| 4712 CTreeItemT<TBase> GetPrevSibling() const; |
| 4713 CTreeItemT<TBase> GetParent() const; |
| 4714 CTreeItemT<TBase> GetFirstVisible() const; |
| 4715 CTreeItemT<TBase> GetNextVisible() const; |
| 4716 CTreeItemT<TBase> GetPrevVisible() const; |
| 4717 CTreeItemT<TBase> GetSelected() const; |
| 4718 CTreeItemT<TBase> GetDropHilight() const; |
| 4719 CTreeItemT<TBase> GetRoot() const; |
| 4720 #if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 4721 CTreeItemT<TBase> GetLastVisible() const; |
| 4722 #endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 4723 #if (_WIN32_IE >= 0x0600) |
| 4724 CTreeItemT<TBase> GetNextSelected() const; |
| 4725 #endif // (_WIN32_IE >= 0x0600) |
| 4726 BOOL HasChildren() const; |
| 4727 BOOL Delete(); |
| 4728 BOOL Expand(UINT nCode = TVE_EXPAND); |
| 4729 BOOL Select(UINT nCode); |
| 4730 BOOL Select(); |
| 4731 BOOL SelectDropTarget(); |
| 4732 BOOL SelectSetFirstVisible(); |
| 4733 HWND EditLabel(); |
| 4734 HIMAGELIST CreateDragImage(); |
| 4735 BOOL SortChildren(BOOL bRecurse = FALSE); |
| 4736 BOOL EnsureVisible(); |
| 4737 CTreeItemT<TBase> _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM
hItemAfter); |
| 4738 int GetImageIndex() const; |
| 4739 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4740 BOOL SetInsertMark(BOOL bAfter); |
| 4741 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 4742 #if (_WIN32_WINNT >= 0x0501) |
| 4743 UINT MapHTREEITEMToAccID() const; |
| 4744 #endif // (_WIN32_WINNT >= 0x0501) |
| 4745 #if (_WIN32_WINNT >= 0x0600) |
| 4746 void ShowInfoTip(); |
| 4747 BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const; |
| 4748 #endif // (_WIN32_WINNT >= 0x0600) |
| 4749 }; |
| 4750 |
| 4751 typedef CTreeItemT<ATL::CWindow> CTreeItem; |
| 4752 |
| 4753 |
| 4754 template <class TBase> |
| 4755 class CTreeViewCtrlExT : public CTreeViewCtrlT< TBase > |
| 4756 { |
| 4757 public: |
| 4758 // Constructors |
| 4759 CTreeViewCtrlExT(HWND hWnd = NULL) : CTreeViewCtrlT< TBase >(hWnd) |
| 4760 { } |
| 4761 |
| 4762 CTreeViewCtrlExT< TBase >& operator =(HWND hWnd) |
| 4763 { |
| 4764 m_hWnd = hWnd; |
| 4765 return *this; |
| 4766 } |
| 4767 |
| 4768 // Operations (overides that return CTreeItem) |
| 4769 CTreeItemT<TBase> InsertItem(LPTVINSERTSTRUCT lpInsertStruct) |
| 4770 { |
| 4771 ATLASSERT(::IsWindow(m_hWnd)); |
| 4772 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSER
TITEM, 0, (LPARAM)lpInsertStruct); |
| 4773 return CTreeItemT<TBase>(hTreeItem, this); |
| 4774 } |
| 4775 |
| 4776 CTreeItemT<TBase> InsertItem(LPCTSTR lpszItem, int nImage, |
| 4777 int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter) |
| 4778 { |
| 4779 ATLASSERT(::IsWindow(m_hWnd)); |
| 4780 return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, l
pszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter); |
| 4781 } |
| 4782 |
| 4783 CTreeItemT<TBase> InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEI
TEM hInsertAfter) |
| 4784 { |
| 4785 ATLASSERT(::IsWindow(m_hWnd)); |
| 4786 return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, h
InsertAfter); |
| 4787 } |
| 4788 |
| 4789 CTreeItemT<TBase> GetNextItem(HTREEITEM hItem, UINT nCode) const |
| 4790 { |
| 4791 ATLASSERT(::IsWindow(m_hWnd)); |
| 4792 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, nCode, (LPARAM)hItem); |
| 4793 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4794 } |
| 4795 |
| 4796 CTreeItemT<TBase> GetChildItem(HTREEITEM hItem) const |
| 4797 { |
| 4798 ATLASSERT(::IsWindow(m_hWnd)); |
| 4799 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_CHILD, (LPARAM)hItem); |
| 4800 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4801 } |
| 4802 |
| 4803 CTreeItemT<TBase> GetNextSiblingItem(HTREEITEM hItem) const |
| 4804 { |
| 4805 ATLASSERT(::IsWindow(m_hWnd)); |
| 4806 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_NEXT, (LPARAM)hItem); |
| 4807 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4808 } |
| 4809 |
| 4810 CTreeItemT<TBase> GetPrevSiblingItem(HTREEITEM hItem) const |
| 4811 { |
| 4812 ATLASSERT(::IsWindow(m_hWnd)); |
| 4813 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_PREVIOUS, (LPARAM)hItem); |
| 4814 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4815 } |
| 4816 |
| 4817 CTreeItemT<TBase> GetParentItem(HTREEITEM hItem) const |
| 4818 { |
| 4819 ATLASSERT(::IsWindow(m_hWnd)); |
| 4820 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_PARENT, (LPARAM)hItem); |
| 4821 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4822 } |
| 4823 |
| 4824 CTreeItemT<TBase> GetFirstVisibleItem() const |
| 4825 { |
| 4826 ATLASSERT(::IsWindow(m_hWnd)); |
| 4827 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_FIRSTVISIBLE, 0L); |
| 4828 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4829 } |
| 4830 |
| 4831 CTreeItemT<TBase> GetNextVisibleItem(HTREEITEM hItem) const |
| 4832 { |
| 4833 ATLASSERT(::IsWindow(m_hWnd)); |
| 4834 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem); |
| 4835 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4836 } |
| 4837 |
| 4838 CTreeItemT<TBase> GetPrevVisibleItem(HTREEITEM hItem) const |
| 4839 { |
| 4840 ATLASSERT(::IsWindow(m_hWnd)); |
| 4841 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem); |
| 4842 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4843 } |
| 4844 |
| 4845 CTreeItemT<TBase> GetSelectedItem() const |
| 4846 { |
| 4847 ATLASSERT(::IsWindow(m_hWnd)); |
| 4848 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_CARET, 0L); |
| 4849 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4850 } |
| 4851 |
| 4852 CTreeItemT<TBase> GetDropHilightItem() const |
| 4853 { |
| 4854 ATLASSERT(::IsWindow(m_hWnd)); |
| 4855 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_DROPHILITE, 0L); |
| 4856 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4857 } |
| 4858 |
| 4859 CTreeItemT<TBase> GetRootItem() const |
| 4860 { |
| 4861 ATLASSERT(::IsWindow(m_hWnd)); |
| 4862 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_ROOT, 0L); |
| 4863 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4864 } |
| 4865 |
| 4866 #if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 4867 CTreeItemT<TBase> GetLastVisibleItem() const |
| 4868 { |
| 4869 ATLASSERT(::IsWindow(m_hWnd)); |
| 4870 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_LASTVISIBLE, 0L); |
| 4871 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4872 } |
| 4873 #endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 4874 |
| 4875 #if (_WIN32_IE >= 0x0600) |
| 4876 CTreeItemT<TBase> GetNextSelectedItem() const |
| 4877 { |
| 4878 ATLASSERT(::IsWindow(m_hWnd)); |
| 4879 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNE
XTITEM, TVGN_NEXTSELECTED, 0L); |
| 4880 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4881 } |
| 4882 #endif // (_WIN32_IE >= 0x0600) |
| 4883 |
| 4884 CTreeItemT<TBase> HitTest(TVHITTESTINFO* pHitTestInfo) const |
| 4885 { |
| 4886 ATLASSERT(::IsWindow(m_hWnd)); |
| 4887 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTE
ST, 0, (LPARAM)pHitTestInfo); |
| 4888 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4889 } |
| 4890 |
| 4891 CTreeItemT<TBase> InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, |
| 4892 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, |
| 4893 HTREEITEM hParent, HTREEITEM hInsertAfter) |
| 4894 { |
| 4895 ATLASSERT(::IsWindow(m_hWnd)); |
| 4896 TVINSERTSTRUCT tvis = { 0 }; |
| 4897 tvis.hParent = hParent; |
| 4898 tvis.hInsertAfter = hInsertAfter; |
| 4899 tvis.item.mask = nMask; |
| 4900 tvis.item.pszText = (LPTSTR) lpszItem; |
| 4901 tvis.item.iImage = nImage; |
| 4902 tvis.item.iSelectedImage = nSelectedImage; |
| 4903 tvis.item.state = nState; |
| 4904 tvis.item.stateMask = nStateMask; |
| 4905 tvis.item.lParam = lParam; |
| 4906 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSER
TITEM, 0, (LPARAM)&tvis); |
| 4907 return CTreeItemT<TBase>(hTreeItem, this); |
| 4908 } |
| 4909 |
| 4910 CTreeItemT<TBase> HitTest(POINT pt, UINT* pFlags) const |
| 4911 { |
| 4912 ATLASSERT(::IsWindow(m_hWnd)); |
| 4913 TVHITTESTINFO hti = { 0 }; |
| 4914 hti.pt = pt; |
| 4915 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTE
ST, 0, (LPARAM)&hti); |
| 4916 if (pFlags != NULL) |
| 4917 *pFlags = hti.flags; |
| 4918 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4919 } |
| 4920 |
| 4921 #if (_WIN32_WINNT >= 0x0501) |
| 4922 CTreeItemT<TBase> MapAccIDToHTREEITEM(UINT uID) const |
| 4923 { |
| 4924 ATLASSERT(::IsWindow(m_hWnd)); |
| 4925 HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPAC
CIDTOHTREEITEM, uID, 0L); |
| 4926 return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)th
is); |
| 4927 } |
| 4928 #endif // (_WIN32_WINNT >= 0x0501) |
| 4929 }; |
| 4930 |
| 4931 typedef CTreeViewCtrlExT<ATL::CWindow> CTreeViewCtrlEx; |
| 4932 |
| 4933 |
| 4934 // CTreeItem inline methods |
| 4935 template <class TBase> |
| 4936 inline BOOL CTreeItemT<TBase>::GetRect(LPRECT lpRect, BOOL bTextOnly) const |
| 4937 { |
| 4938 ATLASSERT(m_pTreeView != NULL); |
| 4939 return m_pTreeView->GetItemRect(m_hTreeItem,lpRect,bTextOnly); |
| 4940 } |
| 4941 |
| 4942 template <class TBase> |
| 4943 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNext(UINT nCode) const |
| 4944 { |
| 4945 ATLASSERT(m_pTreeView != NULL); |
| 4946 return m_pTreeView->GetNextItem(m_hTreeItem,nCode); |
| 4947 } |
| 4948 |
| 4949 template <class TBase> |
| 4950 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetChild() const |
| 4951 { |
| 4952 ATLASSERT(m_pTreeView != NULL); |
| 4953 return m_pTreeView->GetChildItem(m_hTreeItem); |
| 4954 } |
| 4955 |
| 4956 template <class TBase> |
| 4957 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextSibling() const |
| 4958 { |
| 4959 ATLASSERT(m_pTreeView != NULL); |
| 4960 return m_pTreeView->GetNextSiblingItem(m_hTreeItem); |
| 4961 } |
| 4962 |
| 4963 template <class TBase> |
| 4964 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetPrevSibling() const |
| 4965 { |
| 4966 ATLASSERT(m_pTreeView != NULL); |
| 4967 return m_pTreeView->GetPrevSiblingItem(m_hTreeItem); |
| 4968 } |
| 4969 |
| 4970 template <class TBase> |
| 4971 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetParent() const |
| 4972 { |
| 4973 ATLASSERT(m_pTreeView != NULL); |
| 4974 return m_pTreeView->GetParentItem(m_hTreeItem); |
| 4975 } |
| 4976 |
| 4977 template <class TBase> |
| 4978 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetFirstVisible() const |
| 4979 { |
| 4980 ATLASSERT(m_pTreeView != NULL); |
| 4981 return m_pTreeView->GetFirstVisibleItem(); |
| 4982 } |
| 4983 |
| 4984 template <class TBase> |
| 4985 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextVisible() const |
| 4986 { |
| 4987 ATLASSERT(m_pTreeView != NULL); |
| 4988 return m_pTreeView->GetNextVisibleItem(m_hTreeItem); |
| 4989 } |
| 4990 |
| 4991 template <class TBase> |
| 4992 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetPrevVisible() const |
| 4993 { |
| 4994 ATLASSERT(m_pTreeView != NULL); |
| 4995 return m_pTreeView->GetPrevVisibleItem(m_hTreeItem); |
| 4996 } |
| 4997 |
| 4998 template <class TBase> |
| 4999 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetSelected() const |
| 5000 { |
| 5001 ATLASSERT(m_pTreeView != NULL); |
| 5002 return m_pTreeView->GetSelectedItem(); |
| 5003 } |
| 5004 |
| 5005 template <class TBase> |
| 5006 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetDropHilight() const |
| 5007 { |
| 5008 ATLASSERT(m_pTreeView != NULL); |
| 5009 return m_pTreeView->GetDropHilightItem(); |
| 5010 } |
| 5011 |
| 5012 template <class TBase> |
| 5013 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetRoot() const |
| 5014 { |
| 5015 ATLASSERT(m_pTreeView != NULL); |
| 5016 return m_pTreeView->GetRootItem(); |
| 5017 } |
| 5018 |
| 5019 #if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 5020 template <class TBase> |
| 5021 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetLastVisible() const |
| 5022 { |
| 5023 ATLASSERT(m_pTreeView != NULL); |
| 5024 return m_pTreeView->GetLastVisibleItem(); |
| 5025 } |
| 5026 #endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400) |
| 5027 |
| 5028 #if (_WIN32_IE >= 0x0600) |
| 5029 template <class TBase> |
| 5030 inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextSelected() const |
| 5031 { |
| 5032 ATLASSERT(m_pTreeView != NULL); |
| 5033 return m_pTreeView->GetNextSelectedItem(); |
| 5034 } |
| 5035 #endif // (_WIN32_IE >= 0x0600) |
| 5036 |
| 5037 template <class TBase> |
| 5038 inline BOOL CTreeItemT<TBase>::GetText(LPTSTR lpstrText, int nLen) const |
| 5039 { |
| 5040 ATLASSERT(m_pTreeView != NULL); |
| 5041 return m_pTreeView->GetItemText(m_hTreeItem, lpstrText, nLen); |
| 5042 } |
| 5043 |
| 5044 #ifndef _ATL_NO_COM |
| 5045 #ifdef _OLEAUTO_H_ |
| 5046 template <class TBase> |
| 5047 inline BOOL CTreeItemT<TBase>::GetText(BSTR& bstrText) const |
| 5048 { |
| 5049 ATLASSERT(m_pTreeView != NULL); |
| 5050 return m_pTreeView->GetItemText(m_hTreeItem, bstrText); |
| 5051 } |
| 5052 #endif // _OLEAUTO_H_ |
| 5053 #endif // !_ATL_NO_COM |
| 5054 |
| 5055 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 5056 template <class TBase> |
| 5057 inline BOOL CTreeItemT<TBase>::GetText(_CSTRING_NS::CString& strText) const |
| 5058 { |
| 5059 ATLASSERT(m_pTreeView != NULL); |
| 5060 return m_pTreeView->GetItemText(m_hTreeItem, strText); |
| 5061 } |
| 5062 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 5063 |
| 5064 template <class TBase> |
| 5065 inline BOOL CTreeItemT<TBase>::GetImage(int& nImage, int& nSelectedImage) const |
| 5066 { |
| 5067 ATLASSERT(m_pTreeView != NULL); |
| 5068 return m_pTreeView->GetItemImage(m_hTreeItem,nImage,nSelectedImage); |
| 5069 } |
| 5070 |
| 5071 template <class TBase> |
| 5072 inline UINT CTreeItemT<TBase>::GetState(UINT nStateMask) const |
| 5073 { |
| 5074 ATLASSERT(m_pTreeView != NULL); |
| 5075 return m_pTreeView->GetItemState(m_hTreeItem,nStateMask); |
| 5076 } |
| 5077 |
| 5078 template <class TBase> |
| 5079 inline DWORD_PTR CTreeItemT<TBase>::GetData() const |
| 5080 { |
| 5081 ATLASSERT(m_pTreeView != NULL); |
| 5082 return m_pTreeView->GetItemData(m_hTreeItem); |
| 5083 } |
| 5084 |
| 5085 template <class TBase> |
| 5086 inline BOOL CTreeItemT<TBase>::SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, |
| 5087 int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam) |
| 5088 { |
| 5089 ATLASSERT(m_pTreeView != NULL); |
| 5090 return m_pTreeView->SetItem(m_hTreeItem, nMask, lpszItem, nImage, nSelec
tedImage, nState, nStateMask, lParam); |
| 5091 } |
| 5092 |
| 5093 template <class TBase> |
| 5094 inline BOOL CTreeItemT<TBase>::SetText(LPCTSTR lpszItem) |
| 5095 { |
| 5096 ATLASSERT(m_pTreeView != NULL); |
| 5097 return m_pTreeView->SetItemText(m_hTreeItem,lpszItem); |
| 5098 } |
| 5099 |
| 5100 template <class TBase> |
| 5101 inline BOOL CTreeItemT<TBase>::SetImage(int nImage, int nSelectedImage) |
| 5102 { |
| 5103 ATLASSERT(m_pTreeView != NULL); |
| 5104 return m_pTreeView->SetItemImage(m_hTreeItem,nImage,nSelectedImage); |
| 5105 } |
| 5106 |
| 5107 template <class TBase> |
| 5108 inline BOOL CTreeItemT<TBase>::SetState(UINT nState, UINT nStateMask) |
| 5109 { |
| 5110 ATLASSERT(m_pTreeView != NULL); |
| 5111 return m_pTreeView->SetItemState(m_hTreeItem,nState,nStateMask); |
| 5112 } |
| 5113 |
| 5114 template <class TBase> |
| 5115 inline BOOL CTreeItemT<TBase>::SetData(DWORD_PTR dwData) |
| 5116 { |
| 5117 ATLASSERT(m_pTreeView != NULL); |
| 5118 return m_pTreeView->SetItemData(m_hTreeItem,dwData); |
| 5119 } |
| 5120 |
| 5121 template <class TBase> |
| 5122 inline BOOL CTreeItemT<TBase>::HasChildren() const |
| 5123 { |
| 5124 ATLASSERT(m_pTreeView != NULL); |
| 5125 return m_pTreeView->ItemHasChildren(m_hTreeItem); |
| 5126 } |
| 5127 |
| 5128 template <class TBase> |
| 5129 inline BOOL CTreeItemT<TBase>::Delete() |
| 5130 { |
| 5131 ATLASSERT(m_pTreeView != NULL); |
| 5132 return m_pTreeView->DeleteItem(m_hTreeItem); |
| 5133 } |
| 5134 |
| 5135 template <class TBase> |
| 5136 inline BOOL CTreeItemT<TBase>::Expand(UINT nCode /*= TVE_EXPAND*/) |
| 5137 { |
| 5138 ATLASSERT(m_pTreeView != NULL); |
| 5139 return m_pTreeView->Expand(m_hTreeItem,nCode); |
| 5140 } |
| 5141 |
| 5142 template <class TBase> |
| 5143 inline BOOL CTreeItemT<TBase>::Select(UINT nCode) |
| 5144 { |
| 5145 ATLASSERT(m_pTreeView != NULL); |
| 5146 return m_pTreeView->Select(m_hTreeItem,nCode); |
| 5147 } |
| 5148 |
| 5149 template <class TBase> |
| 5150 inline BOOL CTreeItemT<TBase>::Select() |
| 5151 { |
| 5152 ATLASSERT(m_pTreeView != NULL); |
| 5153 return m_pTreeView->SelectItem(m_hTreeItem); |
| 5154 } |
| 5155 |
| 5156 template <class TBase> |
| 5157 inline BOOL CTreeItemT<TBase>::SelectDropTarget() |
| 5158 { |
| 5159 ATLASSERT(m_pTreeView != NULL); |
| 5160 return m_pTreeView->SelectDropTarget(m_hTreeItem); |
| 5161 } |
| 5162 |
| 5163 template <class TBase> |
| 5164 inline BOOL CTreeItemT<TBase>::SelectSetFirstVisible() |
| 5165 { |
| 5166 ATLASSERT(m_pTreeView != NULL); |
| 5167 return m_pTreeView->SelectSetFirstVisible(m_hTreeItem); |
| 5168 } |
| 5169 |
| 5170 template <class TBase> |
| 5171 inline HWND CTreeItemT<TBase>::EditLabel() |
| 5172 { |
| 5173 ATLASSERT(m_pTreeView != NULL); |
| 5174 return m_pTreeView->EditLabel(m_hTreeItem); |
| 5175 } |
| 5176 |
| 5177 template <class TBase> |
| 5178 inline HIMAGELIST CTreeItemT<TBase>::CreateDragImage() |
| 5179 { |
| 5180 ATLASSERT(m_pTreeView != NULL); |
| 5181 return m_pTreeView->CreateDragImage(m_hTreeItem); |
| 5182 } |
| 5183 |
| 5184 template <class TBase> |
| 5185 inline BOOL CTreeItemT<TBase>::SortChildren(BOOL bRecurse /*= FALSE*/) |
| 5186 { |
| 5187 ATLASSERT(m_pTreeView != NULL); |
| 5188 return m_pTreeView->SortChildren(m_hTreeItem, bRecurse); |
| 5189 } |
| 5190 |
| 5191 template <class TBase> |
| 5192 inline BOOL CTreeItemT<TBase>::EnsureVisible() |
| 5193 { |
| 5194 ATLASSERT(m_pTreeView != NULL); |
| 5195 return m_pTreeView->EnsureVisible(m_hTreeItem); |
| 5196 } |
| 5197 |
| 5198 template <class TBase> |
| 5199 inline CTreeItemT<TBase> CTreeItemT<TBase>::_Insert(LPCTSTR lpstrItem, int nImag
eIndex, HTREEITEM hItemAfter) |
| 5200 { |
| 5201 ATLASSERT(m_pTreeView != NULL); |
| 5202 TVINSERTSTRUCT ins = { 0 }; |
| 5203 ins.hParent = m_hTreeItem; |
| 5204 ins.hInsertAfter = hItemAfter; |
| 5205 ins.item.mask = TVIF_TEXT; |
| 5206 ins.item.pszText = (LPTSTR)lpstrItem; |
| 5207 if(nImageIndex != -1) |
| 5208 { |
| 5209 ins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE; |
| 5210 ins.item.iImage = nImageIndex; |
| 5211 ins.item.iSelectedImage = nImageIndex; |
| 5212 } |
| 5213 return CTreeItemT<TBase>(m_pTreeView->InsertItem(&ins), m_pTreeView); |
| 5214 } |
| 5215 |
| 5216 template <class TBase> |
| 5217 inline int CTreeItemT<TBase>::GetImageIndex() const |
| 5218 { |
| 5219 ATLASSERT(m_pTreeView != NULL); |
| 5220 TVITEM item = { 0 }; |
| 5221 item.mask = TVIF_HANDLE | TVIF_IMAGE; |
| 5222 item.hItem = m_hTreeItem; |
| 5223 m_pTreeView->GetItem(&item); |
| 5224 return item.iImage; |
| 5225 } |
| 5226 |
| 5227 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 5228 template <class TBase> |
| 5229 inline BOOL CTreeItemT<TBase>::SetInsertMark(BOOL bAfter) |
| 5230 { |
| 5231 ATLASSERT(m_pTreeView != NULL); |
| 5232 return m_pTreeView->SetInsertMark(m_hTreeItem, bAfter); |
| 5233 } |
| 5234 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 5235 |
| 5236 #if (_WIN32_WINNT >= 0x0501) |
| 5237 template <class TBase> |
| 5238 inline UINT CTreeItemT<TBase>::MapHTREEITEMToAccID() const |
| 5239 { |
| 5240 ATLASSERT(m_pTreeView != NULL); |
| 5241 return m_pTreeView->MapHTREEITEMToAccID(m_hTreeItem); |
| 5242 } |
| 5243 #endif // (_WIN32_WINNT >= 0x0501) |
| 5244 |
| 5245 #if (_WIN32_WINNT >= 0x0600) |
| 5246 template <class TBase> |
| 5247 inline void CTreeItemT<TBase>::ShowInfoTip() |
| 5248 { |
| 5249 ATLASSERT(m_pTreeView != NULL); |
| 5250 m_pTreeView->ShowInfoTip(m_hTreeItem); |
| 5251 } |
| 5252 |
| 5253 template <class TBase> |
| 5254 inline BOOL CTreeItemT<TBase>::GetPartRect(TVITEMPART partID, LPRECT lpRect) con
st |
| 5255 { |
| 5256 ATLASSERT(m_pTreeView != NULL); |
| 5257 return m_pTreeView->GetItemPartRect(m_hTreeItem, partID, lpRect); |
| 5258 } |
| 5259 #endif // (_WIN32_WINNT >= 0x0600) |
| 5260 |
| 5261 |
| 5262 /////////////////////////////////////////////////////////////////////////////// |
| 5263 // CToolBarCtrl |
| 5264 |
| 5265 template <class TBase> |
| 5266 class CToolBarCtrlT : public TBase |
| 5267 { |
| 5268 public: |
| 5269 // Construction |
| 5270 CToolBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 5271 { } |
| 5272 |
| 5273 CToolBarCtrlT< TBase >& operator =(HWND hWnd) |
| 5274 { |
| 5275 m_hWnd = hWnd; |
| 5276 return *this; |
| 5277 } |
| 5278 |
| 5279 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 5280 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 5281 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 5282 { |
| 5283 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 5284 } |
| 5285 |
| 5286 // Attributes |
| 5287 static LPCTSTR GetWndClassName() |
| 5288 { |
| 5289 return TOOLBARCLASSNAME; |
| 5290 } |
| 5291 |
| 5292 BOOL IsButtonEnabled(int nID) const |
| 5293 { |
| 5294 ATLASSERT(::IsWindow(m_hWnd)); |
| 5295 return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONENABLED, nID, 0L); |
| 5296 } |
| 5297 |
| 5298 BOOL IsButtonChecked(int nID) const |
| 5299 { |
| 5300 ATLASSERT(::IsWindow(m_hWnd)); |
| 5301 return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONCHECKED, nID, 0L); |
| 5302 } |
| 5303 |
| 5304 BOOL IsButtonPressed(int nID) const |
| 5305 { |
| 5306 ATLASSERT(::IsWindow(m_hWnd)); |
| 5307 return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONPRESSED, nID, 0L); |
| 5308 } |
| 5309 |
| 5310 BOOL IsButtonHidden(int nID) const |
| 5311 { |
| 5312 ATLASSERT(::IsWindow(m_hWnd)); |
| 5313 return(BOOL) ::SendMessage(m_hWnd, TB_ISBUTTONHIDDEN, nID, 0L); |
| 5314 } |
| 5315 |
| 5316 BOOL IsButtonIndeterminate(int nID) const |
| 5317 { |
| 5318 ATLASSERT(::IsWindow(m_hWnd)); |
| 5319 return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONINDETERMINATE, nID
, 0L); |
| 5320 } |
| 5321 |
| 5322 int GetState(int nID) const |
| 5323 { |
| 5324 ATLASSERT(::IsWindow(m_hWnd)); |
| 5325 return (int)::SendMessage(m_hWnd, TB_GETSTATE, nID, 0L); |
| 5326 } |
| 5327 |
| 5328 BOOL SetState(int nID, UINT nState) |
| 5329 { |
| 5330 ATLASSERT(::IsWindow(m_hWnd)); |
| 5331 return (BOOL)::SendMessage(m_hWnd, TB_SETSTATE, nID, MAKELPARAM(
nState, 0)); |
| 5332 } |
| 5333 |
| 5334 BOOL GetButton(int nIndex, LPTBBUTTON lpButton) const |
| 5335 { |
| 5336 ATLASSERT(::IsWindow(m_hWnd)); |
| 5337 return (BOOL)::SendMessage(m_hWnd, TB_GETBUTTON, nIndex, (LPARAM
)lpButton); |
| 5338 } |
| 5339 |
| 5340 int GetButtonCount() const |
| 5341 { |
| 5342 ATLASSERT(::IsWindow(m_hWnd)); |
| 5343 return (int)::SendMessage(m_hWnd, TB_BUTTONCOUNT, 0, 0L); |
| 5344 } |
| 5345 |
| 5346 BOOL GetItemRect(int nIndex, LPRECT lpRect) const |
| 5347 { |
| 5348 ATLASSERT(::IsWindow(m_hWnd)); |
| 5349 return (BOOL)::SendMessage(m_hWnd, TB_GETITEMRECT, nIndex, (LPAR
AM)lpRect); |
| 5350 } |
| 5351 |
| 5352 void SetButtonStructSize(int nSize = sizeof(TBBUTTON)) |
| 5353 { |
| 5354 ATLASSERT(::IsWindow(m_hWnd)); |
| 5355 ::SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, nSize, 0L); |
| 5356 } |
| 5357 |
| 5358 BOOL SetButtonSize(SIZE size) |
| 5359 { |
| 5360 ATLASSERT(::IsWindow(m_hWnd)); |
| 5361 return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPAR
AM(size.cx, size.cy)); |
| 5362 } |
| 5363 |
| 5364 BOOL SetButtonSize(int cx, int cy) |
| 5365 { |
| 5366 ATLASSERT(::IsWindow(m_hWnd)); |
| 5367 return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONSIZE, 0, MAKELPAR
AM(cx, cy)); |
| 5368 } |
| 5369 |
| 5370 BOOL SetBitmapSize(SIZE size) |
| 5371 { |
| 5372 ATLASSERT(::IsWindow(m_hWnd)); |
| 5373 return (BOOL)::SendMessage(m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPAR
AM(size.cx, size.cy)); |
| 5374 } |
| 5375 |
| 5376 BOOL SetBitmapSize(int cx, int cy) |
| 5377 { |
| 5378 ATLASSERT(::IsWindow(m_hWnd)); |
| 5379 return (BOOL)::SendMessage(m_hWnd, TB_SETBITMAPSIZE, 0, MAKELPAR
AM(cx, cy)); |
| 5380 } |
| 5381 |
| 5382 #ifndef _WIN32_WCE |
| 5383 CToolTipCtrl GetToolTips() const |
| 5384 { |
| 5385 ATLASSERT(::IsWindow(m_hWnd)); |
| 5386 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TB_GETTOOLTIPS,
0, 0L)); |
| 5387 } |
| 5388 |
| 5389 void SetToolTips(HWND hWndToolTip) |
| 5390 { |
| 5391 ATLASSERT(::IsWindow(m_hWnd)); |
| 5392 ::SendMessage(m_hWnd, TB_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); |
| 5393 } |
| 5394 #endif // !_WIN32_WCE |
| 5395 |
| 5396 void SetNotifyWnd(HWND hWnd) |
| 5397 { |
| 5398 ATLASSERT(::IsWindow(m_hWnd)); |
| 5399 ::SendMessage(m_hWnd, TB_SETPARENT, (WPARAM)hWnd, 0L); |
| 5400 } |
| 5401 |
| 5402 int GetRows() const |
| 5403 { |
| 5404 ATLASSERT(::IsWindow(m_hWnd)); |
| 5405 return (int)::SendMessage(m_hWnd, TB_GETROWS, 0, 0L); |
| 5406 } |
| 5407 |
| 5408 void SetRows(int nRows, BOOL bLarger, LPRECT lpRect) |
| 5409 { |
| 5410 ATLASSERT(::IsWindow(m_hWnd)); |
| 5411 ::SendMessage(m_hWnd, TB_SETROWS, MAKELPARAM(nRows, bLarger), (L
PARAM)lpRect); |
| 5412 } |
| 5413 |
| 5414 BOOL SetCmdID(int nIndex, UINT nID) |
| 5415 { |
| 5416 ATLASSERT(::IsWindow(m_hWnd)); |
| 5417 return (BOOL)::SendMessage(m_hWnd, TB_SETCMDID, nIndex, nID); |
| 5418 } |
| 5419 |
| 5420 DWORD GetBitmapFlags() const |
| 5421 { |
| 5422 ATLASSERT(::IsWindow(m_hWnd)); |
| 5423 return (DWORD)::SendMessage(m_hWnd, TB_GETBITMAPFLAGS, 0, 0L); |
| 5424 } |
| 5425 |
| 5426 int GetBitmap(int nID) const |
| 5427 { |
| 5428 ATLASSERT(::IsWindow(m_hWnd)); |
| 5429 return (int)::SendMessage(m_hWnd, TB_GETBITMAP, nID, 0L); |
| 5430 } |
| 5431 |
| 5432 int GetButtonText(int nID, LPTSTR lpstrText) const |
| 5433 { |
| 5434 ATLASSERT(::IsWindow(m_hWnd)); |
| 5435 return (int)::SendMessage(m_hWnd, TB_GETBUTTONTEXT, nID, (LPARAM
)lpstrText); |
| 5436 } |
| 5437 |
| 5438 // nIndex - IE5 or higher only |
| 5439 CImageList GetImageList(int nIndex = 0) const |
| 5440 { |
| 5441 ATLASSERT(::IsWindow(m_hWnd)); |
| 5442 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETIMAGEL
IST, nIndex, 0L)); |
| 5443 } |
| 5444 |
| 5445 // nIndex - IE5 or higher only |
| 5446 CImageList SetImageList(HIMAGELIST hImageList, int nIndex = 0) |
| 5447 { |
| 5448 ATLASSERT(::IsWindow(m_hWnd)); |
| 5449 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETIMAGEL
IST, nIndex, (LPARAM)hImageList)); |
| 5450 } |
| 5451 |
| 5452 // nIndex - IE5 or higher only |
| 5453 CImageList GetDisabledImageList(int nIndex = 0) const |
| 5454 { |
| 5455 ATLASSERT(::IsWindow(m_hWnd)); |
| 5456 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETDISABL
EDIMAGELIST, nIndex, 0L)); |
| 5457 } |
| 5458 |
| 5459 // nIndex - IE5 or higher only |
| 5460 CImageList SetDisabledImageList(HIMAGELIST hImageList, int nIndex = 0) |
| 5461 { |
| 5462 ATLASSERT(::IsWindow(m_hWnd)); |
| 5463 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETDISABL
EDIMAGELIST, nIndex, (LPARAM)hImageList)); |
| 5464 } |
| 5465 |
| 5466 #ifndef _WIN32_WCE |
| 5467 // nIndex - IE5 or higher only |
| 5468 CImageList GetHotImageList(int nIndex = 0) const |
| 5469 { |
| 5470 ATLASSERT(::IsWindow(m_hWnd)); |
| 5471 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETHOTIMA
GELIST, nIndex, 0L)); |
| 5472 } |
| 5473 |
| 5474 // nIndex - IE5 or higher only |
| 5475 CImageList SetHotImageList(HIMAGELIST hImageList, int nIndex = 0) |
| 5476 { |
| 5477 ATLASSERT(::IsWindow(m_hWnd)); |
| 5478 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETHOTIMA
GELIST, nIndex, (LPARAM)hImageList)); |
| 5479 } |
| 5480 #endif // !_WIN32_WCE |
| 5481 |
| 5482 DWORD GetStyle() const |
| 5483 { |
| 5484 ATLASSERT(::IsWindow(m_hWnd)); |
| 5485 return (DWORD)::SendMessage(m_hWnd, TB_GETSTYLE, 0, 0L); |
| 5486 } |
| 5487 |
| 5488 void SetStyle(DWORD dwStyle) |
| 5489 { |
| 5490 ATLASSERT(::IsWindow(m_hWnd)); |
| 5491 ::SendMessage(m_hWnd, TB_SETSTYLE, 0, dwStyle); |
| 5492 } |
| 5493 |
| 5494 DWORD GetButtonSize() const |
| 5495 { |
| 5496 ATLASSERT(::IsWindow(m_hWnd)); |
| 5497 return (DWORD)::SendMessage(m_hWnd, TB_GETBUTTONSIZE, 0, 0L); |
| 5498 } |
| 5499 |
| 5500 void GetButtonSize(SIZE& size) const |
| 5501 { |
| 5502 ATLASSERT(::IsWindow(m_hWnd)); |
| 5503 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_GETBUTTONSIZE, 0,
0L); |
| 5504 size.cx = LOWORD(dwRet); |
| 5505 size.cy = HIWORD(dwRet); |
| 5506 } |
| 5507 |
| 5508 BOOL GetRect(int nID, LPRECT lpRect) const |
| 5509 { |
| 5510 ATLASSERT(::IsWindow(m_hWnd)); |
| 5511 return (BOOL)::SendMessage(m_hWnd, TB_GETRECT, nID, (LPARAM)lpRe
ct); |
| 5512 } |
| 5513 |
| 5514 int GetTextRows() const |
| 5515 { |
| 5516 ATLASSERT(::IsWindow(m_hWnd)); |
| 5517 return (int)::SendMessage(m_hWnd, TB_GETTEXTROWS, 0, 0L); |
| 5518 } |
| 5519 |
| 5520 BOOL SetButtonWidth(int cxMin, int cxMax) |
| 5521 { |
| 5522 ATLASSERT(::IsWindow(m_hWnd)); |
| 5523 return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONWIDTH, 0, MAKELPA
RAM(cxMin, cxMax)); |
| 5524 } |
| 5525 |
| 5526 BOOL SetIndent(int nIndent) |
| 5527 { |
| 5528 ATLASSERT(::IsWindow(m_hWnd)); |
| 5529 return (BOOL)::SendMessage(m_hWnd, TB_SETINDENT, nIndent, 0L); |
| 5530 } |
| 5531 |
| 5532 BOOL SetMaxTextRows(int nMaxTextRows) |
| 5533 { |
| 5534 ATLASSERT(::IsWindow(m_hWnd)); |
| 5535 return (BOOL)::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, nMaxTextRo
ws, 0L); |
| 5536 } |
| 5537 |
| 5538 #if (_WIN32_IE >= 0x0400) |
| 5539 #ifndef _WIN32_WCE |
| 5540 BOOL GetAnchorHighlight() const |
| 5541 { |
| 5542 ATLASSERT(::IsWindow(m_hWnd)); |
| 5543 return (BOOL)::SendMessage(m_hWnd, TB_GETANCHORHIGHLIGHT, 0, 0L)
; |
| 5544 } |
| 5545 |
| 5546 BOOL SetAnchorHighlight(BOOL bEnable = TRUE) |
| 5547 { |
| 5548 ATLASSERT(::IsWindow(m_hWnd)); |
| 5549 return (BOOL)::SendMessage(m_hWnd, TB_SETANCHORHIGHLIGHT, bEnabl
e, 0L); |
| 5550 } |
| 5551 #endif // !_WIN32_WCE |
| 5552 |
| 5553 int GetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) const |
| 5554 { |
| 5555 ATLASSERT(::IsWindow(m_hWnd)); |
| 5556 return (int)::SendMessage(m_hWnd, TB_GETBUTTONINFO, nID, (LPARAM
)lptbbi); |
| 5557 } |
| 5558 |
| 5559 BOOL SetButtonInfo(int nID, LPTBBUTTONINFO lptbbi) |
| 5560 { |
| 5561 ATLASSERT(::IsWindow(m_hWnd)); |
| 5562 return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARA
M)lptbbi); |
| 5563 } |
| 5564 |
| 5565 BOOL SetButtonInfo(int nID, DWORD dwMask, BYTE Style, BYTE State, LPCTST
R lpszItem, |
| 5566 int iImage, WORD cx, int iCommand, DWORD_PTR lParam) |
| 5567 { |
| 5568 ATLASSERT(::IsWindow(m_hWnd)); |
| 5569 TBBUTTONINFO tbbi = { 0 }; |
| 5570 tbbi.cbSize = sizeof(TBBUTTONINFO); |
| 5571 tbbi.dwMask = dwMask; |
| 5572 tbbi.idCommand = iCommand; |
| 5573 tbbi.iImage = iImage; |
| 5574 tbbi.fsState = State; |
| 5575 tbbi.fsStyle = Style; |
| 5576 tbbi.cx = cx; |
| 5577 tbbi.pszText = (LPTSTR) lpszItem; |
| 5578 tbbi.lParam = lParam; |
| 5579 return (BOOL)::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARA
M)&tbbi); |
| 5580 } |
| 5581 |
| 5582 #ifndef _WIN32_WCE |
| 5583 int GetHotItem() const |
| 5584 { |
| 5585 ATLASSERT(::IsWindow(m_hWnd)); |
| 5586 return (int)::SendMessage(m_hWnd, TB_GETHOTITEM, 0, 0L); |
| 5587 } |
| 5588 |
| 5589 int SetHotItem(int nItem) |
| 5590 { |
| 5591 ATLASSERT(::IsWindow(m_hWnd)); |
| 5592 return (int)::SendMessage(m_hWnd, TB_SETHOTITEM, nItem, 0L); |
| 5593 } |
| 5594 #endif // !_WIN32_WCE |
| 5595 |
| 5596 BOOL IsButtonHighlighted(int nButtonID) const |
| 5597 { |
| 5598 ATLASSERT(::IsWindow(m_hWnd)); |
| 5599 return (BOOL)::SendMessage(m_hWnd, TB_ISBUTTONHIGHLIGHTED, nButt
onID, 0L); |
| 5600 } |
| 5601 |
| 5602 DWORD SetDrawTextFlags(DWORD dwMask, DWORD dwFlags) |
| 5603 { |
| 5604 ATLASSERT(::IsWindow(m_hWnd)); |
| 5605 return (DWORD)::SendMessage(m_hWnd, TB_SETDRAWTEXTFLAGS, dwMask,
dwFlags); |
| 5606 } |
| 5607 |
| 5608 #ifndef _WIN32_WCE |
| 5609 BOOL GetColorScheme(LPCOLORSCHEME lpcs) const |
| 5610 { |
| 5611 ATLASSERT(::IsWindow(m_hWnd)); |
| 5612 return (BOOL)::SendMessage(m_hWnd, TB_GETCOLORSCHEME, 0, (LPARAM
)lpcs); |
| 5613 } |
| 5614 |
| 5615 void SetColorScheme(LPCOLORSCHEME lpcs) |
| 5616 { |
| 5617 ATLASSERT(::IsWindow(m_hWnd)); |
| 5618 ::SendMessage(m_hWnd, TB_SETCOLORSCHEME, 0, (LPARAM)lpcs); |
| 5619 } |
| 5620 |
| 5621 DWORD GetExtendedStyle() const |
| 5622 { |
| 5623 ATLASSERT(::IsWindow(m_hWnd)); |
| 5624 return (DWORD)::SendMessage(m_hWnd, TB_GETEXTENDEDSTYLE, 0, 0L); |
| 5625 } |
| 5626 |
| 5627 DWORD SetExtendedStyle(DWORD dwStyle) |
| 5628 { |
| 5629 ATLASSERT(::IsWindow(m_hWnd)); |
| 5630 return (DWORD)::SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, dwSt
yle); |
| 5631 } |
| 5632 |
| 5633 void GetInsertMark(LPTBINSERTMARK lptbim) const |
| 5634 { |
| 5635 ATLASSERT(::IsWindow(m_hWnd)); |
| 5636 ::SendMessage(m_hWnd, TB_GETINSERTMARK, 0, (LPARAM)lptbim); |
| 5637 } |
| 5638 |
| 5639 void SetInsertMark(LPTBINSERTMARK lptbim) |
| 5640 { |
| 5641 ATLASSERT(::IsWindow(m_hWnd)); |
| 5642 ::SendMessage(m_hWnd, TB_SETINSERTMARK, 0, (LPARAM)lptbim); |
| 5643 } |
| 5644 |
| 5645 COLORREF GetInsertMarkColor() const |
| 5646 { |
| 5647 ATLASSERT(::IsWindow(m_hWnd)); |
| 5648 return (COLORREF)::SendMessage(m_hWnd, TB_GETINSERTMARKCOLOR, 0,
0L); |
| 5649 } |
| 5650 |
| 5651 COLORREF SetInsertMarkColor(COLORREF clr) |
| 5652 { |
| 5653 ATLASSERT(::IsWindow(m_hWnd)); |
| 5654 return (COLORREF)::SendMessage(m_hWnd, TB_SETINSERTMARKCOLOR, 0,
(LPARAM)clr); |
| 5655 } |
| 5656 |
| 5657 BOOL GetMaxSize(LPSIZE lpSize) const |
| 5658 { |
| 5659 ATLASSERT(::IsWindow(m_hWnd)); |
| 5660 return (BOOL)::SendMessage(m_hWnd, TB_GETMAXSIZE, 0, (LPARAM)lpS
ize); |
| 5661 } |
| 5662 |
| 5663 void GetPadding(LPSIZE lpSizePadding) const |
| 5664 { |
| 5665 ATLASSERT(::IsWindow(m_hWnd)); |
| 5666 ATLASSERT(lpSizePadding != NULL); |
| 5667 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_GETPADDING, 0, 0L)
; |
| 5668 lpSizePadding->cx = GET_X_LPARAM(dwRet); |
| 5669 lpSizePadding->cy = GET_Y_LPARAM(dwRet); |
| 5670 } |
| 5671 |
| 5672 void SetPadding(int cx, int cy, LPSIZE lpSizePadding = NULL) |
| 5673 { |
| 5674 ATLASSERT(::IsWindow(m_hWnd)); |
| 5675 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TB_SETPADDING, 0, MAK
ELPARAM(cx, cy)); |
| 5676 if(lpSizePadding != NULL) |
| 5677 { |
| 5678 lpSizePadding->cx = GET_X_LPARAM(dwRet); |
| 5679 lpSizePadding->cy = GET_Y_LPARAM(dwRet); |
| 5680 } |
| 5681 } |
| 5682 |
| 5683 BOOL GetUnicodeFormat() const |
| 5684 { |
| 5685 ATLASSERT(::IsWindow(m_hWnd)); |
| 5686 return (BOOL)::SendMessage(m_hWnd, TB_GETUNICODEFORMAT, 0, 0L); |
| 5687 } |
| 5688 |
| 5689 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 5690 { |
| 5691 ATLASSERT(::IsWindow(m_hWnd)); |
| 5692 return (BOOL)::SendMessage(m_hWnd, TB_SETUNICODEFORMAT, bUnicode
, 0L); |
| 5693 } |
| 5694 #endif // !_WIN32_WCE |
| 5695 #endif // (_WIN32_IE >= 0x0400) |
| 5696 |
| 5697 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 5698 int GetString(int nString, LPTSTR lpstrString, int cchMaxLen) const |
| 5699 { |
| 5700 ATLASSERT(::IsWindow(m_hWnd)); |
| 5701 return (int)::SendMessage(m_hWnd, TB_GETSTRING, MAKEWPARAM(cchMa
xLen, nString), (LPARAM)lpstrString); |
| 5702 } |
| 5703 |
| 5704 int GetStringBSTR(int nString, BSTR& bstrString) const |
| 5705 { |
| 5706 USES_CONVERSION; |
| 5707 ATLASSERT(::IsWindow(m_hWnd)); |
| 5708 ATLASSERT(bstrString == NULL); |
| 5709 int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, TB_GETSTR
ING, MAKEWPARAM(0, nString), NULL)); |
| 5710 if(nLength != -1) |
| 5711 { |
| 5712 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 5713 LPTSTR lpstrText = buff.Allocate(nLength + 1); |
| 5714 if(lpstrText != NULL) |
| 5715 { |
| 5716 nLength = (int)::SendMessage(m_hWnd, TB_GETSTRIN
G, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstrText); |
| 5717 if(nLength != -1) |
| 5718 bstrString = ::SysAllocString(T2OLE(lpst
rText)); |
| 5719 } |
| 5720 else |
| 5721 { |
| 5722 nLength = -1; |
| 5723 } |
| 5724 } |
| 5725 |
| 5726 return nLength; |
| 5727 } |
| 5728 |
| 5729 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 5730 int GetString(int nString, _CSTRING_NS::CString& str) const |
| 5731 { |
| 5732 ATLASSERT(::IsWindow(m_hWnd)); |
| 5733 int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, TB_GETSTR
ING, MAKEWPARAM(0, nString), NULL)); |
| 5734 if(nLength != -1) |
| 5735 { |
| 5736 LPTSTR lpstr = str.GetBufferSetLength(nLength + 1); |
| 5737 if(lpstr != NULL) |
| 5738 nLength = (int)::SendMessage(m_hWnd, TB_GETSTRIN
G, MAKEWPARAM(nLength + 1, nString), (LPARAM)lpstr); |
| 5739 else |
| 5740 nLength = -1; |
| 5741 str.ReleaseBuffer(); |
| 5742 } |
| 5743 return nLength; |
| 5744 } |
| 5745 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 5746 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 5747 |
| 5748 #if (_WIN32_WINNT >= 0x0501) |
| 5749 void GetMetrics(LPTBMETRICS lptbm) const |
| 5750 { |
| 5751 ATLASSERT(::IsWindow(m_hWnd)); |
| 5752 ::SendMessage(m_hWnd, TB_GETMETRICS, 0, (LPARAM)lptbm); |
| 5753 } |
| 5754 |
| 5755 void SetMetrics(LPTBMETRICS lptbm) |
| 5756 { |
| 5757 ATLASSERT(::IsWindow(m_hWnd)); |
| 5758 ::SendMessage(m_hWnd, TB_SETMETRICS, 0, (LPARAM)lptbm); |
| 5759 } |
| 5760 |
| 5761 void SetWindowTheme(LPCWSTR lpstrTheme) |
| 5762 { |
| 5763 ATLASSERT(::IsWindow(m_hWnd)); |
| 5764 ::SendMessage(m_hWnd, TB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); |
| 5765 } |
| 5766 #endif // (_WIN32_WINNT >= 0x0501) |
| 5767 |
| 5768 #if (_WIN32_WINNT >= 0x0600) |
| 5769 CImageList GetPressedImageList(int nIndex = 0) const |
| 5770 { |
| 5771 ATLASSERT(::IsWindow(m_hWnd)); |
| 5772 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_GETPRESSE
DIMAGELIST, nIndex, 0L)); |
| 5773 } |
| 5774 |
| 5775 CImageList SetPressedImageList(HIMAGELIST hImageList, int nIndex = 0) |
| 5776 { |
| 5777 ATLASSERT(::IsWindow(m_hWnd)); |
| 5778 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TB_SETPRESSE
DIMAGELIST, nIndex, (LPARAM)hImageList)); |
| 5779 } |
| 5780 #endif // (_WIN32_WINNT >= 0x0600) |
| 5781 |
| 5782 // Operations |
| 5783 BOOL EnableButton(int nID, BOOL bEnable = TRUE) |
| 5784 { |
| 5785 ATLASSERT(::IsWindow(m_hWnd)); |
| 5786 return (BOOL)::SendMessage(m_hWnd, TB_ENABLEBUTTON, nID, MAKELPA
RAM(bEnable, 0)); |
| 5787 } |
| 5788 |
| 5789 BOOL CheckButton(int nID, BOOL bCheck = TRUE) |
| 5790 { |
| 5791 ATLASSERT(::IsWindow(m_hWnd)); |
| 5792 return (BOOL)::SendMessage(m_hWnd, TB_CHECKBUTTON, nID, MAKELPAR
AM(bCheck, 0)); |
| 5793 } |
| 5794 |
| 5795 BOOL PressButton(int nID, BOOL bPress = TRUE) |
| 5796 { |
| 5797 ATLASSERT(::IsWindow(m_hWnd)); |
| 5798 return (BOOL)::SendMessage(m_hWnd, TB_PRESSBUTTON, nID, MAKELPAR
AM(bPress, 0)); |
| 5799 } |
| 5800 |
| 5801 BOOL HideButton(int nID, BOOL bHide = TRUE) |
| 5802 { |
| 5803 ATLASSERT(::IsWindow(m_hWnd)); |
| 5804 return (BOOL)::SendMessage(m_hWnd, TB_HIDEBUTTON, nID, MAKELPARA
M(bHide, 0)); |
| 5805 } |
| 5806 |
| 5807 BOOL Indeterminate(int nID, BOOL bIndeterminate = TRUE) |
| 5808 { |
| 5809 ATLASSERT(::IsWindow(m_hWnd)); |
| 5810 return (BOOL)::SendMessage(m_hWnd, TB_INDETERMINATE, nID, MAKELP
ARAM(bIndeterminate, 0)); |
| 5811 } |
| 5812 |
| 5813 int AddBitmap(int nNumButtons, UINT nBitmapID) |
| 5814 { |
| 5815 ATLASSERT(::IsWindow(m_hWnd)); |
| 5816 TBADDBITMAP tbab = { 0 }; |
| 5817 tbab.hInst = ModuleHelper::GetResourceInstance(); |
| 5818 ATLASSERT(tbab.hInst != NULL); |
| 5819 tbab.nID = nBitmapID; |
| 5820 return (int)::SendMessage(m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButt
ons, (LPARAM)&tbab); |
| 5821 } |
| 5822 |
| 5823 int AddBitmap(int nNumButtons, HBITMAP hBitmap) |
| 5824 { |
| 5825 ATLASSERT(::IsWindow(m_hWnd)); |
| 5826 TBADDBITMAP tbab = { 0 }; |
| 5827 tbab.hInst = NULL; |
| 5828 tbab.nID = (UINT_PTR)hBitmap; |
| 5829 return (int)::SendMessage(m_hWnd, TB_ADDBITMAP, (WPARAM)nNumButt
ons, (LPARAM)&tbab); |
| 5830 } |
| 5831 |
| 5832 BOOL AddButtons(int nNumButtons, LPTBBUTTON lpButtons) |
| 5833 { |
| 5834 ATLASSERT(::IsWindow(m_hWnd)); |
| 5835 return (BOOL)::SendMessage(m_hWnd, TB_ADDBUTTONS, nNumButtons, (
LPARAM)lpButtons); |
| 5836 } |
| 5837 |
| 5838 BOOL InsertButton(int nIndex, LPTBBUTTON lpButton) |
| 5839 { |
| 5840 ATLASSERT(::IsWindow(m_hWnd)); |
| 5841 return (BOOL)::SendMessage(m_hWnd, TB_INSERTBUTTON, nIndex, (LPA
RAM)lpButton); |
| 5842 } |
| 5843 |
| 5844 BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int
iBitmap, |
| 5845 INT_PTR iString, DWORD_PTR lParam) |
| 5846 { |
| 5847 ATLASSERT(::IsWindow(m_hWnd)); |
| 5848 TBBUTTON tbb = { 0 }; |
| 5849 tbb.fsStyle = Style; |
| 5850 tbb.fsState = State; |
| 5851 tbb.idCommand = iCommand; |
| 5852 tbb.iBitmap = iBitmap; |
| 5853 tbb.iString = iString; |
| 5854 tbb.dwData = lParam; |
| 5855 return (BOOL)::SendMessage(m_hWnd, TB_INSERTBUTTON, nIndex, (LPA
RAM)&tbb); |
| 5856 } |
| 5857 |
| 5858 BOOL InsertButton(int nIndex, int iCommand, BYTE Style, BYTE State, int
iBitmap, |
| 5859 LPCTSTR lpszItem, DWORD_PTR lParam) |
| 5860 { |
| 5861 return InsertButton(nIndex, iCommand, Style, State, iBitmap, (IN
T_PTR)lpszItem, lParam); |
| 5862 } |
| 5863 |
| 5864 BOOL AddButton(LPTBBUTTON lpButton) |
| 5865 { |
| 5866 return InsertButton(-1, lpButton); |
| 5867 } |
| 5868 |
| 5869 BOOL AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, INT_PT
R iString, DWORD_PTR lParam) |
| 5870 { |
| 5871 return InsertButton(-1, iCommand, Style, State, iBitmap, iString
, lParam); |
| 5872 } |
| 5873 |
| 5874 BOOL AddButton(int iCommand, BYTE Style, BYTE State, int iBitmap, LPCTST
R lpszItem, DWORD_PTR lParam) |
| 5875 { |
| 5876 return InsertButton(-1, iCommand, Style, State, iBitmap, lpszIte
m, lParam); |
| 5877 } |
| 5878 |
| 5879 BOOL DeleteButton(int nIndex) |
| 5880 { |
| 5881 ATLASSERT(::IsWindow(m_hWnd)); |
| 5882 return (BOOL)::SendMessage(m_hWnd, TB_DELETEBUTTON, nIndex, 0L); |
| 5883 } |
| 5884 |
| 5885 UINT CommandToIndex(UINT nID) const |
| 5886 { |
| 5887 ATLASSERT(::IsWindow(m_hWnd)); |
| 5888 return (UINT)::SendMessage(m_hWnd, TB_COMMANDTOINDEX, nID, 0L); |
| 5889 } |
| 5890 |
| 5891 #ifndef _WIN32_WCE |
| 5892 void SaveState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueName) |
| 5893 { |
| 5894 ATLASSERT(::IsWindow(m_hWnd)); |
| 5895 TBSAVEPARAMS tbs = { 0 }; |
| 5896 tbs.hkr = hKeyRoot; |
| 5897 tbs.pszSubKey = lpszSubKey; |
| 5898 tbs.pszValueName = lpszValueName; |
| 5899 ::SendMessage(m_hWnd, TB_SAVERESTORE, (WPARAM)TRUE, (LPARAM)&tbs
); |
| 5900 } |
| 5901 |
| 5902 void RestoreState(HKEY hKeyRoot, LPCTSTR lpszSubKey, LPCTSTR lpszValueNa
me) |
| 5903 { |
| 5904 ATLASSERT(::IsWindow(m_hWnd)); |
| 5905 TBSAVEPARAMS tbs = { 0 }; |
| 5906 tbs.hkr = hKeyRoot; |
| 5907 tbs.pszSubKey = lpszSubKey; |
| 5908 tbs.pszValueName = lpszValueName; |
| 5909 ::SendMessage(m_hWnd, TB_SAVERESTORE, (WPARAM)FALSE, (LPARAM)&tb
s); |
| 5910 } |
| 5911 |
| 5912 void Customize() |
| 5913 { |
| 5914 ATLASSERT(::IsWindow(m_hWnd)); |
| 5915 ::SendMessage(m_hWnd, TB_CUSTOMIZE, 0, 0L); |
| 5916 } |
| 5917 #endif // !_WIN32_WCE |
| 5918 |
| 5919 int AddString(UINT nStringID) |
| 5920 { |
| 5921 ATLASSERT(::IsWindow(m_hWnd)); |
| 5922 return (int)::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)ModuleHe
lper::GetResourceInstance(), (LPARAM)nStringID); |
| 5923 } |
| 5924 |
| 5925 int AddStrings(LPCTSTR lpszStrings) |
| 5926 { |
| 5927 ATLASSERT(::IsWindow(m_hWnd)); |
| 5928 return (int)::SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM)lpszS
trings); |
| 5929 } |
| 5930 |
| 5931 void AutoSize() |
| 5932 { |
| 5933 ATLASSERT(::IsWindow(m_hWnd)); |
| 5934 ::SendMessage(m_hWnd, TB_AUTOSIZE, 0, 0L); |
| 5935 } |
| 5936 |
| 5937 BOOL ChangeBitmap(int nID, int nBitmap) |
| 5938 { |
| 5939 ATLASSERT(::IsWindow(m_hWnd)); |
| 5940 return (BOOL)::SendMessage(m_hWnd, TB_CHANGEBITMAP, nID, MAKELPA
RAM(nBitmap, 0)); |
| 5941 } |
| 5942 |
| 5943 int LoadImages(int nBitmapID) |
| 5944 { |
| 5945 ATLASSERT(::IsWindow(m_hWnd)); |
| 5946 return (int)::SendMessage(m_hWnd, TB_LOADIMAGES, nBitmapID, (LPA
RAM)ModuleHelper::GetResourceInstance()); |
| 5947 } |
| 5948 |
| 5949 int LoadStdImages(int nBitmapID) |
| 5950 { |
| 5951 ATLASSERT(::IsWindow(m_hWnd)); |
| 5952 return (int)::SendMessage(m_hWnd, TB_LOADIMAGES, nBitmapID, (LPA
RAM)HINST_COMMCTRL); |
| 5953 } |
| 5954 |
| 5955 BOOL ReplaceBitmap(LPTBREPLACEBITMAP ptbrb) |
| 5956 { |
| 5957 ATLASSERT(::IsWindow(m_hWnd)); |
| 5958 return (BOOL)::SendMessage(m_hWnd, TB_REPLACEBITMAP, 0, (LPARAM)
ptbrb); |
| 5959 } |
| 5960 |
| 5961 #if (_WIN32_IE >= 0x0400) |
| 5962 int HitTest(LPPOINT lpPoint) const |
| 5963 { |
| 5964 ATLASSERT(::IsWindow(m_hWnd)); |
| 5965 return (int)::SendMessage(m_hWnd, TB_HITTEST, 0, (LPARAM)lpPoint
); |
| 5966 } |
| 5967 |
| 5968 #ifndef _WIN32_WCE |
| 5969 BOOL InsertMarkHitTest(LPPOINT lpPoint, LPTBINSERTMARK lptbim) const |
| 5970 { |
| 5971 ATLASSERT(::IsWindow(m_hWnd)); |
| 5972 return (BOOL)::SendMessage(m_hWnd, TB_INSERTMARKHITTEST, (WPARAM
)lpPoint, (LPARAM)lptbim); |
| 5973 } |
| 5974 |
| 5975 BOOL InsertMarkHitTest(int x, int y, LPTBINSERTMARK lptbim) const |
| 5976 { |
| 5977 ATLASSERT(::IsWindow(m_hWnd)); |
| 5978 POINT pt = { x, y }; |
| 5979 return (BOOL)::SendMessage(m_hWnd, TB_INSERTMARKHITTEST, (WPARAM
)&pt, (LPARAM)lptbim); |
| 5980 } |
| 5981 |
| 5982 BOOL MapAccelerator(TCHAR chAccel, int& nID) const |
| 5983 { |
| 5984 ATLASSERT(::IsWindow(m_hWnd)); |
| 5985 return (BOOL)::SendMessage(m_hWnd, TB_MAPACCELERATOR, (WPARAM)ch
Accel, (LPARAM)&nID); |
| 5986 } |
| 5987 |
| 5988 BOOL MarkButton(int nID, BOOL bHighlight = TRUE) |
| 5989 { |
| 5990 ATLASSERT(::IsWindow(m_hWnd)); |
| 5991 return (BOOL)::SendMessage(m_hWnd, TB_MARKBUTTON, nID, MAKELPARA
M(bHighlight, 0)); |
| 5992 } |
| 5993 |
| 5994 BOOL MoveButton(int nOldPos, int nNewPos) |
| 5995 { |
| 5996 ATLASSERT(::IsWindow(m_hWnd)); |
| 5997 return (BOOL)::SendMessage(m_hWnd, TB_MOVEBUTTON, nOldPos, nNewP
os); |
| 5998 } |
| 5999 |
| 6000 HRESULT GetObject(REFIID iid, LPVOID* ppvObject) |
| 6001 { |
| 6002 ATLASSERT(::IsWindow(m_hWnd)); |
| 6003 return (HRESULT)::SendMessage(m_hWnd, TB_GETOBJECT, (WPARAM)&iid
, (LPARAM)ppvObject); |
| 6004 } |
| 6005 #endif // !_WIN32_WCE |
| 6006 #endif // (_WIN32_IE >= 0x0400) |
| 6007 }; |
| 6008 |
| 6009 typedef CToolBarCtrlT<ATL::CWindow> CToolBarCtrl; |
| 6010 |
| 6011 |
| 6012 /////////////////////////////////////////////////////////////////////////////// |
| 6013 // CStatusBarCtrl |
| 6014 |
| 6015 template <class TBase> |
| 6016 class CStatusBarCtrlT : public TBase |
| 6017 { |
| 6018 public: |
| 6019 // Constructors |
| 6020 CStatusBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 6021 { } |
| 6022 |
| 6023 CStatusBarCtrlT< TBase >& operator =(HWND hWnd) |
| 6024 { |
| 6025 m_hWnd = hWnd; |
| 6026 return *this; |
| 6027 } |
| 6028 |
| 6029 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 6030 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 6031 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 6032 { |
| 6033 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 6034 } |
| 6035 |
| 6036 // Methods |
| 6037 static LPCTSTR GetWndClassName() |
| 6038 { |
| 6039 return STATUSCLASSNAME; |
| 6040 } |
| 6041 |
| 6042 int GetParts(int nParts, int* pParts) const |
| 6043 { |
| 6044 ATLASSERT(::IsWindow(m_hWnd)); |
| 6045 return (int)::SendMessage(m_hWnd, SB_GETPARTS, nParts, (LPARAM)p
Parts); |
| 6046 } |
| 6047 |
| 6048 BOOL SetParts(int nParts, int* pWidths) |
| 6049 { |
| 6050 ATLASSERT(::IsWindow(m_hWnd)); |
| 6051 return (BOOL)::SendMessage(m_hWnd, SB_SETPARTS, nParts, (LPARAM)
pWidths); |
| 6052 } |
| 6053 |
| 6054 int GetTextLength(int nPane, int* pType = NULL) const |
| 6055 { |
| 6056 ATLASSERT(::IsWindow(m_hWnd)); |
| 6057 ATLASSERT(nPane < 256); |
| 6058 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, SB_GETTEXTLENGTH, (WP
ARAM)nPane, 0L); |
| 6059 if (pType != NULL) |
| 6060 *pType = (int)(short)HIWORD(dwRet); |
| 6061 return (int)(short)LOWORD(dwRet); |
| 6062 } |
| 6063 |
| 6064 int GetText(int nPane, LPTSTR lpszText, int* pType = NULL) const |
| 6065 { |
| 6066 ATLASSERT(::IsWindow(m_hWnd)); |
| 6067 ATLASSERT(nPane < 256); |
| 6068 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, SB_GETTEXT, (WPARAM)n
Pane, (LPARAM)lpszText); |
| 6069 if(pType != NULL) |
| 6070 *pType = (int)(short)HIWORD(dwRet); |
| 6071 return (int)(short)LOWORD(dwRet); |
| 6072 } |
| 6073 |
| 6074 #ifndef _ATL_NO_COM |
| 6075 BOOL GetTextBSTR(int nPane, BSTR& bstrText, int* pType = NULL) const |
| 6076 { |
| 6077 USES_CONVERSION; |
| 6078 ATLASSERT(::IsWindow(m_hWnd)); |
| 6079 ATLASSERT(nPane < 256); |
| 6080 ATLASSERT(bstrText == NULL); |
| 6081 int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, SB_GETTEX
TLENGTH, (WPARAM)nPane, 0L)); |
| 6082 if(nLength == 0) |
| 6083 return FALSE; |
| 6084 |
| 6085 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 6086 LPTSTR lpstrText = buff.Allocate(nLength + 1); |
| 6087 if(lpstrText == NULL) |
| 6088 return FALSE; |
| 6089 |
| 6090 if(!GetText(nPane, lpstrText, pType)) |
| 6091 return FALSE; |
| 6092 |
| 6093 bstrText = ::SysAllocString(T2OLE(lpstrText)); |
| 6094 return (bstrText != NULL) ? TRUE : FALSE; |
| 6095 } |
| 6096 #endif // !_ATL_NO_COM |
| 6097 |
| 6098 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 6099 int GetText(int nPane, _CSTRING_NS::CString& strText, int* pType = NULL)
const |
| 6100 { |
| 6101 ATLASSERT(::IsWindow(m_hWnd)); |
| 6102 ATLASSERT(nPane < 256); |
| 6103 int nLength = (int)(short)LOWORD(::SendMessage(m_hWnd, SB_GETTEX
TLENGTH, (WPARAM)nPane, 0L)); |
| 6104 if(nLength == 0) |
| 6105 return 0; |
| 6106 |
| 6107 LPTSTR lpstr = strText.GetBufferSetLength(nLength); |
| 6108 if(lpstr == NULL) |
| 6109 return 0; |
| 6110 return GetText(nPane, lpstr, pType); |
| 6111 } |
| 6112 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 6113 |
| 6114 BOOL SetText(int nPane, LPCTSTR lpszText, int nType = 0) |
| 6115 { |
| 6116 ATLASSERT(::IsWindow(m_hWnd)); |
| 6117 ATLASSERT(nPane < 256); |
| 6118 return (BOOL)::SendMessage(m_hWnd, SB_SETTEXT, (nPane | nType),
(LPARAM)lpszText); |
| 6119 } |
| 6120 |
| 6121 BOOL GetRect(int nPane, LPRECT lpRect) const |
| 6122 { |
| 6123 ATLASSERT(::IsWindow(m_hWnd)); |
| 6124 ATLASSERT(nPane < 256); |
| 6125 return (BOOL)::SendMessage(m_hWnd, SB_GETRECT, nPane, (LPARAM)lp
Rect); |
| 6126 } |
| 6127 |
| 6128 BOOL GetBorders(int* pBorders) const |
| 6129 { |
| 6130 ATLASSERT(::IsWindow(m_hWnd)); |
| 6131 return (BOOL)::SendMessage(m_hWnd, SB_GETBORDERS, 0, (LPARAM)pBo
rders); |
| 6132 } |
| 6133 |
| 6134 BOOL GetBorders(int& nHorz, int& nVert, int& nSpacing) const |
| 6135 { |
| 6136 ATLASSERT(::IsWindow(m_hWnd)); |
| 6137 int borders[3] = { 0, 0, 0 }; |
| 6138 BOOL bResult = (BOOL)::SendMessage(m_hWnd, SB_GETBORDERS, 0, (LP
ARAM)&borders); |
| 6139 if(bResult) |
| 6140 { |
| 6141 nHorz = borders[0]; |
| 6142 nVert = borders[1]; |
| 6143 nSpacing = borders[2]; |
| 6144 } |
| 6145 return bResult; |
| 6146 } |
| 6147 |
| 6148 void SetMinHeight(int nMin) |
| 6149 { |
| 6150 ATLASSERT(::IsWindow(m_hWnd)); |
| 6151 ::SendMessage(m_hWnd, SB_SETMINHEIGHT, nMin, 0L); |
| 6152 } |
| 6153 |
| 6154 BOOL SetSimple(BOOL bSimple = TRUE) |
| 6155 { |
| 6156 ATLASSERT(::IsWindow(m_hWnd)); |
| 6157 return (BOOL)::SendMessage(m_hWnd, SB_SIMPLE, bSimple, 0L); |
| 6158 } |
| 6159 |
| 6160 BOOL IsSimple() const |
| 6161 { |
| 6162 ATLASSERT(::IsWindow(m_hWnd)); |
| 6163 return (BOOL)::SendMessage(m_hWnd, SB_ISSIMPLE, 0, 0L); |
| 6164 } |
| 6165 |
| 6166 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 6167 BOOL GetUnicodeFormat() const |
| 6168 { |
| 6169 ATLASSERT(::IsWindow(m_hWnd)); |
| 6170 return (BOOL)::SendMessage(m_hWnd, SB_GETUNICODEFORMAT, 0, 0L); |
| 6171 } |
| 6172 |
| 6173 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 6174 { |
| 6175 ATLASSERT(::IsWindow(m_hWnd)); |
| 6176 return (BOOL)::SendMessage(m_hWnd, SB_SETUNICODEFORMAT, bUnicode
, 0L); |
| 6177 } |
| 6178 |
| 6179 void GetTipText(int nPane, LPTSTR lpstrText, int nSize) const |
| 6180 { |
| 6181 ATLASSERT(::IsWindow(m_hWnd)); |
| 6182 ATLASSERT(nPane < 256); |
| 6183 ::SendMessage(m_hWnd, SB_GETTIPTEXT, MAKEWPARAM(nPane, nSize), (
LPARAM)lpstrText); |
| 6184 } |
| 6185 |
| 6186 void SetTipText(int nPane, LPCTSTR lpstrText) |
| 6187 { |
| 6188 ATLASSERT(::IsWindow(m_hWnd)); |
| 6189 ATLASSERT(nPane < 256); |
| 6190 ::SendMessage(m_hWnd, SB_SETTIPTEXT, nPane, (LPARAM)lpstrText); |
| 6191 } |
| 6192 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 6193 |
| 6194 #if ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (
_WIN32_WCE >= 0x0500)) |
| 6195 COLORREF SetBkColor(COLORREF clrBk) |
| 6196 { |
| 6197 ATLASSERT(::IsWindow(m_hWnd)); |
| 6198 return (COLORREF)::SendMessage(m_hWnd, SB_SETBKCOLOR, 0, (LPARAM
)clrBk); |
| 6199 } |
| 6200 |
| 6201 HICON GetIcon(int nPane) const |
| 6202 { |
| 6203 ATLASSERT(::IsWindow(m_hWnd)); |
| 6204 ATLASSERT(nPane < 256); |
| 6205 return (HICON)::SendMessage(m_hWnd, SB_GETICON, nPane, 0L); |
| 6206 } |
| 6207 |
| 6208 BOOL SetIcon(int nPane, HICON hIcon) |
| 6209 { |
| 6210 ATLASSERT(::IsWindow(m_hWnd)); |
| 6211 ATLASSERT(nPane < 256); |
| 6212 return (BOOL)::SendMessage(m_hWnd, SB_SETICON, nPane, (LPARAM)hI
con); |
| 6213 } |
| 6214 #endif // ((_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE
) && (_WIN32_WCE >= 0x0500)) |
| 6215 }; |
| 6216 |
| 6217 typedef CStatusBarCtrlT<ATL::CWindow> CStatusBarCtrl; |
| 6218 |
| 6219 |
| 6220 /////////////////////////////////////////////////////////////////////////////// |
| 6221 // CTabCtrl |
| 6222 |
| 6223 template <class TBase> |
| 6224 class CTabCtrlT : public TBase |
| 6225 { |
| 6226 public: |
| 6227 // Constructors |
| 6228 CTabCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 6229 { } |
| 6230 |
| 6231 CTabCtrlT< TBase >& operator =(HWND hWnd) |
| 6232 { |
| 6233 m_hWnd = hWnd; |
| 6234 return *this; |
| 6235 } |
| 6236 |
| 6237 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 6238 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 6239 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 6240 { |
| 6241 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 6242 } |
| 6243 |
| 6244 // Attributes |
| 6245 static LPCTSTR GetWndClassName() |
| 6246 { |
| 6247 return WC_TABCONTROL; |
| 6248 } |
| 6249 |
| 6250 CImageList GetImageList() const |
| 6251 { |
| 6252 ATLASSERT(::IsWindow(m_hWnd)); |
| 6253 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TCM_GETIMAGE
LIST, 0, 0L)); |
| 6254 } |
| 6255 |
| 6256 CImageList SetImageList(HIMAGELIST hImageList) |
| 6257 { |
| 6258 ATLASSERT(::IsWindow(m_hWnd)); |
| 6259 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TCM_SETIMAGE
LIST, 0, (LPARAM)hImageList)); |
| 6260 } |
| 6261 |
| 6262 int GetItemCount() const |
| 6263 { |
| 6264 ATLASSERT(::IsWindow(m_hWnd)); |
| 6265 return (int)::SendMessage(m_hWnd, TCM_GETITEMCOUNT, 0, 0L); |
| 6266 } |
| 6267 |
| 6268 BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const |
| 6269 { |
| 6270 ATLASSERT(::IsWindow(m_hWnd)); |
| 6271 return (BOOL)::SendMessage(m_hWnd, TCM_GETITEM, nItem, (LPARAM)p
TabCtrlItem); |
| 6272 } |
| 6273 |
| 6274 BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem) |
| 6275 { |
| 6276 ATLASSERT(::IsWindow(m_hWnd)); |
| 6277 return (BOOL)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)p
TabCtrlItem); |
| 6278 } |
| 6279 |
| 6280 int SetItem(int nItem, UINT mask, LPCTSTR lpszItem, DWORD dwState, DWORD
dwStateMask, int iImage, LPARAM lParam) |
| 6281 { |
| 6282 ATLASSERT(::IsWindow(m_hWnd)); |
| 6283 TCITEM tci = { 0 }; |
| 6284 tci.mask = mask; |
| 6285 tci.pszText = (LPTSTR) lpszItem; |
| 6286 tci.dwState = dwState; |
| 6287 tci.dwStateMask = dwStateMask; |
| 6288 tci.iImage = iImage; |
| 6289 tci.lParam = lParam; |
| 6290 return (int)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)&t
ci); |
| 6291 } |
| 6292 |
| 6293 BOOL GetItemRect(int nItem, LPRECT lpRect) const |
| 6294 { |
| 6295 ATLASSERT(::IsWindow(m_hWnd)); |
| 6296 return (BOOL)::SendMessage(m_hWnd, TCM_GETITEMRECT, nItem, (LPAR
AM)lpRect); |
| 6297 } |
| 6298 |
| 6299 int GetCurSel() const |
| 6300 { |
| 6301 ATLASSERT(::IsWindow(m_hWnd)); |
| 6302 return (int)::SendMessage(m_hWnd, TCM_GETCURSEL, 0, 0L); |
| 6303 } |
| 6304 |
| 6305 int SetCurSel(int nItem) |
| 6306 { |
| 6307 ATLASSERT(::IsWindow(m_hWnd)); |
| 6308 return (int)::SendMessage(m_hWnd, TCM_SETCURSEL, nItem, 0L); |
| 6309 } |
| 6310 |
| 6311 SIZE SetItemSize(SIZE size) |
| 6312 { |
| 6313 ATLASSERT(::IsWindow(m_hWnd)); |
| 6314 DWORD dwSize = (DWORD)::SendMessage(m_hWnd, TCM_SETITEMSIZE, 0,
MAKELPARAM(size.cx, size.cy)); |
| 6315 SIZE sizeRet = { GET_X_LPARAM(dwSize), GET_Y_LPARAM(dwSize) }; |
| 6316 return sizeRet; |
| 6317 } |
| 6318 |
| 6319 void SetItemSize(int cx, int cy) |
| 6320 { |
| 6321 ATLASSERT(::IsWindow(m_hWnd)); |
| 6322 ::SendMessage(m_hWnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy)); |
| 6323 } |
| 6324 |
| 6325 void SetPadding(SIZE size) |
| 6326 { |
| 6327 ATLASSERT(::IsWindow(m_hWnd)); |
| 6328 ::SendMessage(m_hWnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, siz
e.cy)); |
| 6329 } |
| 6330 |
| 6331 int GetRowCount() const |
| 6332 { |
| 6333 ATLASSERT(::IsWindow(m_hWnd)); |
| 6334 return (int)::SendMessage(m_hWnd, TCM_GETROWCOUNT, 0, 0L); |
| 6335 } |
| 6336 |
| 6337 #ifndef _WIN32_WCE |
| 6338 CToolTipCtrl GetTooltips() const |
| 6339 { |
| 6340 ATLASSERT(::IsWindow(m_hWnd)); |
| 6341 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TCM_GETTOOLTIPS,
0, 0L)); |
| 6342 } |
| 6343 |
| 6344 void SetTooltips(HWND hWndToolTip) |
| 6345 { |
| 6346 ATLASSERT(::IsWindow(m_hWnd)); |
| 6347 ::SendMessage(m_hWnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L); |
| 6348 } |
| 6349 #endif // !_WIN32_WCE |
| 6350 |
| 6351 int GetCurFocus() const |
| 6352 { |
| 6353 ATLASSERT(::IsWindow(m_hWnd)); |
| 6354 return (int)::SendMessage(m_hWnd, TCM_GETCURFOCUS, 0, 0L); |
| 6355 } |
| 6356 |
| 6357 void SetCurFocus(int nItem) |
| 6358 { |
| 6359 ATLASSERT(::IsWindow(m_hWnd)); |
| 6360 ::SendMessage(m_hWnd, TCM_SETCURFOCUS, nItem, 0L); |
| 6361 } |
| 6362 |
| 6363 BOOL SetItemExtra(int cbExtra) |
| 6364 { |
| 6365 ATLASSERT(::IsWindow(m_hWnd)); |
| 6366 ATLASSERT(GetItemCount() == 0); // must be empty |
| 6367 return (BOOL)::SendMessage(m_hWnd, TCM_SETITEMEXTRA, cbExtra, 0L
); |
| 6368 } |
| 6369 |
| 6370 int SetMinTabWidth(int nWidth = -1) |
| 6371 { |
| 6372 ATLASSERT(::IsWindow(m_hWnd)); |
| 6373 return (int)::SendMessage(m_hWnd, TCM_SETMINTABWIDTH, 0, nWidth)
; |
| 6374 } |
| 6375 |
| 6376 #if (_WIN32_IE >= 0x0400) |
| 6377 DWORD GetExtendedStyle() const |
| 6378 { |
| 6379 ATLASSERT(::IsWindow(m_hWnd)); |
| 6380 return (DWORD)::SendMessage(m_hWnd, TCM_GETEXTENDEDSTYLE, 0, 0L)
; |
| 6381 } |
| 6382 |
| 6383 DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) |
| 6384 { |
| 6385 ATLASSERT(::IsWindow(m_hWnd)); |
| 6386 return (DWORD)::SendMessage(m_hWnd, TCM_SETEXTENDEDSTYLE, dwExMa
sk, dwExStyle); |
| 6387 } |
| 6388 |
| 6389 #ifndef _WIN32_WCE |
| 6390 BOOL GetUnicodeFormat() const |
| 6391 { |
| 6392 ATLASSERT(::IsWindow(m_hWnd)); |
| 6393 return (BOOL)::SendMessage(m_hWnd, TCM_GETUNICODEFORMAT, 0, 0L); |
| 6394 } |
| 6395 |
| 6396 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 6397 { |
| 6398 ATLASSERT(::IsWindow(m_hWnd)); |
| 6399 return (BOOL)::SendMessage(m_hWnd, TCM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 6400 } |
| 6401 #endif // !_WIN32_WCE |
| 6402 #endif // (_WIN32_IE >= 0x0400) |
| 6403 |
| 6404 // Operations |
| 6405 int InsertItem(int nItem, LPTCITEM pTabCtrlItem) |
| 6406 { |
| 6407 ATLASSERT(::IsWindow(m_hWnd)); |
| 6408 return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM
)pTabCtrlItem); |
| 6409 } |
| 6410 |
| 6411 int InsertItem(int nItem, UINT mask, LPCTSTR lpszItem, int iImage, LPARA
M lParam) |
| 6412 { |
| 6413 ATLASSERT(::IsWindow(m_hWnd)); |
| 6414 TCITEM tci = { 0 }; |
| 6415 tci.mask = mask; |
| 6416 tci.pszText = (LPTSTR) lpszItem; |
| 6417 tci.iImage = iImage; |
| 6418 tci.lParam = lParam; |
| 6419 return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM
)&tci); |
| 6420 } |
| 6421 |
| 6422 int InsertItem(int nItem, LPCTSTR lpszItem) |
| 6423 { |
| 6424 ATLASSERT(::IsWindow(m_hWnd)); |
| 6425 TCITEM tci = { 0 }; |
| 6426 tci.mask = TCIF_TEXT; |
| 6427 tci.pszText = (LPTSTR) lpszItem; |
| 6428 return (int)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM
)&tci); |
| 6429 } |
| 6430 |
| 6431 int AddItem(LPTCITEM pTabCtrlItem) |
| 6432 { |
| 6433 return InsertItem(GetItemCount(), pTabCtrlItem); |
| 6434 } |
| 6435 |
| 6436 int AddItem(UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam) |
| 6437 { |
| 6438 return InsertItem(GetItemCount(), mask, lpszItem, iImage, lParam
); |
| 6439 } |
| 6440 |
| 6441 int AddItem(LPCTSTR lpszItem) |
| 6442 { |
| 6443 return InsertItem(GetItemCount(), lpszItem); |
| 6444 } |
| 6445 |
| 6446 BOOL DeleteItem(int nItem) |
| 6447 { |
| 6448 ATLASSERT(::IsWindow(m_hWnd)); |
| 6449 return (BOOL)::SendMessage(m_hWnd, TCM_DELETEITEM, nItem, 0L); |
| 6450 } |
| 6451 |
| 6452 BOOL DeleteAllItems() |
| 6453 { |
| 6454 ATLASSERT(::IsWindow(m_hWnd)); |
| 6455 return (BOOL)::SendMessage(m_hWnd, TCM_DELETEALLITEMS, 0, 0L); |
| 6456 } |
| 6457 |
| 6458 void AdjustRect(BOOL bLarger, LPRECT lpRect) |
| 6459 { |
| 6460 ATLASSERT(::IsWindow(m_hWnd)); |
| 6461 ::SendMessage(m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect); |
| 6462 } |
| 6463 |
| 6464 void RemoveImage(int nImage) |
| 6465 { |
| 6466 ATLASSERT(::IsWindow(m_hWnd)); |
| 6467 ::SendMessage(m_hWnd, TCM_REMOVEIMAGE, nImage, 0L); |
| 6468 } |
| 6469 |
| 6470 int HitTest(TC_HITTESTINFO* pHitTestInfo) const |
| 6471 { |
| 6472 ATLASSERT(::IsWindow(m_hWnd)); |
| 6473 return (int)::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM)pHitTe
stInfo); |
| 6474 } |
| 6475 |
| 6476 void DeselectAll(BOOL bExcludeFocus = TRUE) |
| 6477 { |
| 6478 ATLASSERT(::IsWindow(m_hWnd)); |
| 6479 ::SendMessage(m_hWnd, TCM_DESELECTALL, bExcludeFocus, 0L); |
| 6480 } |
| 6481 |
| 6482 #if (_WIN32_IE >= 0x0400) |
| 6483 BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE) |
| 6484 { |
| 6485 ATLASSERT(::IsWindow(m_hWnd)); |
| 6486 return (BOOL)::SendMessage(m_hWnd, TCM_HIGHLIGHTITEM, nIndex, MA
KELPARAM(bHighlight, 0)); |
| 6487 } |
| 6488 #endif // (_WIN32_IE >= 0x0400) |
| 6489 }; |
| 6490 |
| 6491 typedef CTabCtrlT<ATL::CWindow> CTabCtrl; |
| 6492 |
| 6493 |
| 6494 /////////////////////////////////////////////////////////////////////////////// |
| 6495 // CTrackBarCtrl |
| 6496 |
| 6497 template <class TBase> |
| 6498 class CTrackBarCtrlT : public TBase |
| 6499 { |
| 6500 public: |
| 6501 // Constructors |
| 6502 CTrackBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 6503 { } |
| 6504 |
| 6505 CTrackBarCtrlT< TBase >& operator =(HWND hWnd) |
| 6506 { |
| 6507 m_hWnd = hWnd; |
| 6508 return *this; |
| 6509 } |
| 6510 |
| 6511 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 6512 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 6513 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 6514 { |
| 6515 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 6516 } |
| 6517 |
| 6518 // Attributes |
| 6519 static LPCTSTR GetWndClassName() |
| 6520 { |
| 6521 return TRACKBAR_CLASS; |
| 6522 } |
| 6523 |
| 6524 int GetLineSize() const |
| 6525 { |
| 6526 ATLASSERT(::IsWindow(m_hWnd)); |
| 6527 return (int)::SendMessage(m_hWnd, TBM_GETLINESIZE, 0, 0L); |
| 6528 } |
| 6529 |
| 6530 int SetLineSize(int nSize) |
| 6531 { |
| 6532 ATLASSERT(::IsWindow(m_hWnd)); |
| 6533 return (int)::SendMessage(m_hWnd, TBM_SETLINESIZE, 0, nSize); |
| 6534 } |
| 6535 |
| 6536 int GetPageSize() const |
| 6537 { |
| 6538 ATLASSERT(::IsWindow(m_hWnd)); |
| 6539 return (int)::SendMessage(m_hWnd, TBM_GETPAGESIZE, 0, 0L); |
| 6540 } |
| 6541 |
| 6542 int SetPageSize(int nSize) |
| 6543 { |
| 6544 ATLASSERT(::IsWindow(m_hWnd)); |
| 6545 return (int)::SendMessage(m_hWnd, TBM_SETPAGESIZE, 0, nSize); |
| 6546 } |
| 6547 |
| 6548 int GetRangeMin() const |
| 6549 { |
| 6550 ATLASSERT(::IsWindow(m_hWnd)); |
| 6551 return (int)::SendMessage(m_hWnd, TBM_GETRANGEMIN, 0, 0L); |
| 6552 } |
| 6553 |
| 6554 void SetRangeMin(int nMin, BOOL bRedraw = FALSE) |
| 6555 { |
| 6556 ATLASSERT(::IsWindow(m_hWnd)); |
| 6557 ::SendMessage(m_hWnd, TBM_SETRANGEMIN, bRedraw, nMin); |
| 6558 } |
| 6559 |
| 6560 int GetRangeMax() const |
| 6561 { |
| 6562 ATLASSERT(::IsWindow(m_hWnd)); |
| 6563 return (int)::SendMessage(m_hWnd, TBM_GETRANGEMAX, 0, 0L); |
| 6564 } |
| 6565 |
| 6566 void SetRangeMax(int nMax, BOOL bRedraw = FALSE) |
| 6567 { |
| 6568 ATLASSERT(::IsWindow(m_hWnd)); |
| 6569 ::SendMessage(m_hWnd, TBM_SETRANGEMAX, bRedraw, nMax); |
| 6570 } |
| 6571 |
| 6572 void GetRange(int& nMin, int& nMax) const |
| 6573 { |
| 6574 nMin = GetRangeMin(); |
| 6575 nMax = GetRangeMax(); |
| 6576 } |
| 6577 |
| 6578 void SetRange(int nMin, int nMax, BOOL bRedraw = TRUE) |
| 6579 { |
| 6580 ATLASSERT(::IsWindow(m_hWnd)); |
| 6581 ::SendMessage(m_hWnd, TBM_SETRANGE, bRedraw, MAKELPARAM(nMin, nM
ax)); |
| 6582 } |
| 6583 |
| 6584 int GetSelStart() const |
| 6585 { |
| 6586 ATLASSERT(::IsWindow(m_hWnd)); |
| 6587 return (int)::SendMessage(m_hWnd, TBM_GETSELSTART, 0, 0L); |
| 6588 } |
| 6589 |
| 6590 void SetSelStart(int nMin) |
| 6591 { |
| 6592 ATLASSERT(::IsWindow(m_hWnd)); |
| 6593 ::SendMessage(m_hWnd, TBM_SETSELSTART, 0, (LPARAM)nMin); |
| 6594 } |
| 6595 |
| 6596 int GetSelEnd() const |
| 6597 { |
| 6598 ATLASSERT(::IsWindow(m_hWnd)); |
| 6599 return (int)::SendMessage(m_hWnd, TBM_GETSELEND, 0, 0L); |
| 6600 } |
| 6601 |
| 6602 void SetSelEnd(int nMax) |
| 6603 { |
| 6604 ATLASSERT(::IsWindow(m_hWnd)); |
| 6605 ::SendMessage(m_hWnd, TBM_SETSELEND, 0, (LPARAM)nMax); |
| 6606 } |
| 6607 |
| 6608 void GetSelection(int& nMin, int& nMax) const |
| 6609 { |
| 6610 nMin = GetSelStart(); |
| 6611 nMax = GetSelEnd(); |
| 6612 } |
| 6613 |
| 6614 void SetSelection(int nMin, int nMax) |
| 6615 { |
| 6616 SetSelStart(nMin); |
| 6617 SetSelEnd(nMax); |
| 6618 } |
| 6619 |
| 6620 void GetChannelRect(LPRECT lprc) const |
| 6621 { |
| 6622 ATLASSERT(::IsWindow(m_hWnd)); |
| 6623 ::SendMessage(m_hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)lprc); |
| 6624 } |
| 6625 |
| 6626 void GetThumbRect(LPRECT lprc) const |
| 6627 { |
| 6628 ATLASSERT(::IsWindow(m_hWnd)); |
| 6629 ::SendMessage(m_hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)lprc); |
| 6630 } |
| 6631 |
| 6632 int GetPos() const |
| 6633 { |
| 6634 ATLASSERT(::IsWindow(m_hWnd)); |
| 6635 return (int)::SendMessage(m_hWnd, TBM_GETPOS, 0, 0L); |
| 6636 } |
| 6637 |
| 6638 void SetPos(int nPos) |
| 6639 { |
| 6640 ATLASSERT(::IsWindow(m_hWnd)); |
| 6641 ::SendMessage(m_hWnd, TBM_SETPOS, TRUE, nPos); |
| 6642 } |
| 6643 |
| 6644 UINT GetNumTics() const |
| 6645 { |
| 6646 ATLASSERT(::IsWindow(m_hWnd)); |
| 6647 return (UINT)::SendMessage(m_hWnd, TBM_GETNUMTICS, 0, 0L); |
| 6648 } |
| 6649 |
| 6650 DWORD* GetTicArray() const |
| 6651 { |
| 6652 ATLASSERT(::IsWindow(m_hWnd)); |
| 6653 return (DWORD*)::SendMessage(m_hWnd, TBM_GETPTICS, 0, 0L); |
| 6654 } |
| 6655 |
| 6656 int GetTic(int nTic) const |
| 6657 { |
| 6658 ATLASSERT(::IsWindow(m_hWnd)); |
| 6659 return (int)::SendMessage(m_hWnd, TBM_GETTIC, nTic, 0L); |
| 6660 } |
| 6661 |
| 6662 BOOL SetTic(int nTic) |
| 6663 { |
| 6664 ATLASSERT(::IsWindow(m_hWnd)); |
| 6665 return (BOOL)::SendMessage(m_hWnd, TBM_SETTIC, 0, nTic); |
| 6666 } |
| 6667 |
| 6668 int GetTicPos(int nTic) const |
| 6669 { |
| 6670 ATLASSERT(::IsWindow(m_hWnd)); |
| 6671 return (int)::SendMessage(m_hWnd, TBM_GETTICPOS, nTic, 0L); |
| 6672 } |
| 6673 |
| 6674 void SetTicFreq(int nFreq) |
| 6675 { |
| 6676 ATLASSERT(::IsWindow(m_hWnd)); |
| 6677 ::SendMessage(m_hWnd, TBM_SETTICFREQ, nFreq, 0L); |
| 6678 } |
| 6679 |
| 6680 int GetThumbLength() const |
| 6681 { |
| 6682 ATLASSERT(::IsWindow(m_hWnd)); |
| 6683 return (int)::SendMessage(m_hWnd, TBM_GETTHUMBLENGTH, 0, 0L); |
| 6684 } |
| 6685 |
| 6686 void SetThumbLength(int nLength) |
| 6687 { |
| 6688 ATLASSERT(::IsWindow(m_hWnd)); |
| 6689 ::SendMessage(m_hWnd, TBM_SETTHUMBLENGTH, nLength, 0L); |
| 6690 } |
| 6691 |
| 6692 void SetSel(int nStart, int nEnd, BOOL bRedraw = TRUE) |
| 6693 { |
| 6694 ATLASSERT(::IsWindow(m_hWnd)); |
| 6695 ATLASSERT((GetStyle() & TBS_ENABLESELRANGE) != 0); |
| 6696 ::SendMessage(m_hWnd, TBM_SETSEL, bRedraw, MAKELPARAM(nStart, nE
nd)); |
| 6697 } |
| 6698 |
| 6699 ATL::CWindow GetBuddy(BOOL bLeft = TRUE) const |
| 6700 { |
| 6701 ATLASSERT(::IsWindow(m_hWnd)); |
| 6702 return ATL::CWindow((HWND)::SendMessage(m_hWnd, TBM_GETBUDDY, bL
eft, 0L)); |
| 6703 } |
| 6704 |
| 6705 ATL::CWindow SetBuddy(HWND hWndBuddy, BOOL bLeft = TRUE) |
| 6706 { |
| 6707 ATLASSERT(::IsWindow(m_hWnd)); |
| 6708 return ATL::CWindow((HWND)::SendMessage(m_hWnd, TBM_SETBUDDY, bL
eft, (LPARAM)hWndBuddy)); |
| 6709 } |
| 6710 |
| 6711 #ifndef _WIN32_WCE |
| 6712 CToolTipCtrl GetToolTips() const |
| 6713 { |
| 6714 ATLASSERT(::IsWindow(m_hWnd)); |
| 6715 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TBM_GETTOOLTIPS,
0, 0L)); |
| 6716 } |
| 6717 |
| 6718 void SetToolTips(HWND hWndTT) |
| 6719 { |
| 6720 ATLASSERT(::IsWindow(m_hWnd)); |
| 6721 ::SendMessage(m_hWnd, TBM_SETTOOLTIPS, (WPARAM)hWndTT, 0L); |
| 6722 } |
| 6723 |
| 6724 int SetTipSide(int nSide) |
| 6725 { |
| 6726 ATLASSERT(::IsWindow(m_hWnd)); |
| 6727 return (int)::SendMessage(m_hWnd, TBM_SETTIPSIDE, nSide, 0L); |
| 6728 } |
| 6729 #endif // !_WIN32_WCE |
| 6730 |
| 6731 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 6732 BOOL GetUnicodeFormat() const |
| 6733 { |
| 6734 ATLASSERT(::IsWindow(m_hWnd)); |
| 6735 return (BOOL)::SendMessage(m_hWnd, TBM_GETUNICODEFORMAT, 0, 0L); |
| 6736 } |
| 6737 |
| 6738 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 6739 { |
| 6740 ATLASSERT(::IsWindow(m_hWnd)); |
| 6741 return (BOOL)::SendMessage(m_hWnd, TBM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 6742 } |
| 6743 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 6744 |
| 6745 // Operations |
| 6746 void ClearSel(BOOL bRedraw = FALSE) |
| 6747 { |
| 6748 ATLASSERT(::IsWindow(m_hWnd)); |
| 6749 ::SendMessage(m_hWnd, TBM_CLEARSEL, bRedraw, 0L); |
| 6750 } |
| 6751 |
| 6752 void VerifyPos() |
| 6753 { |
| 6754 ATLASSERT(::IsWindow(m_hWnd)); |
| 6755 ::SendMessage(m_hWnd, TBM_SETPOS, FALSE, 0L); |
| 6756 } |
| 6757 |
| 6758 void ClearTics(BOOL bRedraw = FALSE) |
| 6759 { |
| 6760 ATLASSERT(::IsWindow(m_hWnd)); |
| 6761 ::SendMessage(m_hWnd, TBM_CLEARTICS, bRedraw, 0L); |
| 6762 } |
| 6763 }; |
| 6764 |
| 6765 typedef CTrackBarCtrlT<ATL::CWindow> CTrackBarCtrl; |
| 6766 |
| 6767 |
| 6768 /////////////////////////////////////////////////////////////////////////////// |
| 6769 // CUpDownCtrl |
| 6770 |
| 6771 template <class TBase> |
| 6772 class CUpDownCtrlT : public TBase |
| 6773 { |
| 6774 public: |
| 6775 // Constructors |
| 6776 CUpDownCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 6777 { } |
| 6778 |
| 6779 CUpDownCtrlT< TBase >& operator =(HWND hWnd) |
| 6780 { |
| 6781 m_hWnd = hWnd; |
| 6782 return *this; |
| 6783 } |
| 6784 |
| 6785 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 6786 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 6787 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 6788 { |
| 6789 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 6790 } |
| 6791 |
| 6792 // Attributes |
| 6793 static LPCTSTR GetWndClassName() |
| 6794 { |
| 6795 return UPDOWN_CLASS; |
| 6796 } |
| 6797 |
| 6798 UINT GetAccel(int nAccel, UDACCEL* pAccel) const |
| 6799 { |
| 6800 ATLASSERT(::IsWindow(m_hWnd)); |
| 6801 return (UINT)LOWORD(::SendMessage(m_hWnd, UDM_GETACCEL, nAccel,
(LPARAM)pAccel)); |
| 6802 } |
| 6803 |
| 6804 BOOL SetAccel(int nAccel, UDACCEL* pAccel) |
| 6805 { |
| 6806 ATLASSERT(::IsWindow(m_hWnd)); |
| 6807 return (BOOL)LOWORD(::SendMessage(m_hWnd, UDM_SETACCEL, nAccel,
(LPARAM)pAccel)); |
| 6808 } |
| 6809 |
| 6810 UINT GetBase() const |
| 6811 { |
| 6812 ATLASSERT(::IsWindow(m_hWnd)); |
| 6813 return (UINT)LOWORD(::SendMessage(m_hWnd, UDM_GETBASE, 0, 0L)); |
| 6814 } |
| 6815 |
| 6816 int SetBase(int nBase) |
| 6817 { |
| 6818 ATLASSERT(::IsWindow(m_hWnd)); |
| 6819 return (int)::SendMessage(m_hWnd, UDM_SETBASE, nBase, 0L); |
| 6820 } |
| 6821 |
| 6822 ATL::CWindow GetBuddy() const |
| 6823 { |
| 6824 ATLASSERT(::IsWindow(m_hWnd)); |
| 6825 return ATL::CWindow((HWND)::SendMessage(m_hWnd, UDM_GETBUDDY, 0,
0L)); |
| 6826 } |
| 6827 |
| 6828 ATL::CWindow SetBuddy(HWND hWndBuddy) |
| 6829 { |
| 6830 ATLASSERT(::IsWindow(m_hWnd)); |
| 6831 return ATL::CWindow((HWND)::SendMessage(m_hWnd, UDM_SETBUDDY, (W
PARAM)hWndBuddy, 0L)); |
| 6832 } |
| 6833 |
| 6834 int GetPos(LPBOOL lpbError = NULL) const |
| 6835 { |
| 6836 ATLASSERT(::IsWindow(m_hWnd)); |
| 6837 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, UDM_GETPOS, 0, 0L); |
| 6838 // Note: Seems that Windows always sets error to TRUE if |
| 6839 // UDS_SETBUDDYINT style is not used |
| 6840 if(lpbError != NULL) |
| 6841 *lpbError = (HIWORD(dwRet) != 0) ? TRUE : FALSE; |
| 6842 return (int)(short)LOWORD(dwRet); |
| 6843 } |
| 6844 |
| 6845 int SetPos(int nPos) |
| 6846 { |
| 6847 ATLASSERT(::IsWindow(m_hWnd)); |
| 6848 return (int)(short)LOWORD(::SendMessage(m_hWnd, UDM_SETPOS, 0, M
AKELPARAM(nPos, 0))); |
| 6849 } |
| 6850 |
| 6851 DWORD GetRange() const |
| 6852 { |
| 6853 ATLASSERT(::IsWindow(m_hWnd)); |
| 6854 return (DWORD)::SendMessage(m_hWnd, UDM_GETRANGE, 0, 0L); |
| 6855 } |
| 6856 |
| 6857 void GetRange(int& nLower, int& nUpper) const |
| 6858 { |
| 6859 ATLASSERT(::IsWindow(m_hWnd)); |
| 6860 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, UDM_GETRANGE, 0, 0L); |
| 6861 nLower = (int)(short)HIWORD(dwRet); |
| 6862 nUpper = (int)(short)LOWORD(dwRet); |
| 6863 } |
| 6864 |
| 6865 void SetRange(int nLower, int nUpper) |
| 6866 { |
| 6867 ATLASSERT(::IsWindow(m_hWnd)); |
| 6868 ::SendMessage(m_hWnd, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower
)); |
| 6869 } |
| 6870 |
| 6871 #if (_WIN32_IE >= 0x0400) |
| 6872 void SetRange32(int nLower, int nUpper) |
| 6873 { |
| 6874 ATLASSERT(::IsWindow(m_hWnd)); |
| 6875 ::SendMessage(m_hWnd, UDM_SETRANGE32, nLower, nUpper); |
| 6876 } |
| 6877 |
| 6878 void GetRange32(int& nLower, int& nUpper) const |
| 6879 { |
| 6880 ATLASSERT(::IsWindow(m_hWnd)); |
| 6881 ::SendMessage(m_hWnd, UDM_GETRANGE32, (WPARAM)&nLower, (LPARAM)&
nUpper); |
| 6882 } |
| 6883 |
| 6884 #ifndef _WIN32_WCE |
| 6885 BOOL GetUnicodeFormat() const |
| 6886 { |
| 6887 ATLASSERT(::IsWindow(m_hWnd)); |
| 6888 return (BOOL)::SendMessage(m_hWnd, UDM_GETUNICODEFORMAT, 0, 0L); |
| 6889 } |
| 6890 |
| 6891 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 6892 { |
| 6893 ATLASSERT(::IsWindow(m_hWnd)); |
| 6894 return (BOOL)::SendMessage(m_hWnd, UDM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 6895 } |
| 6896 #endif // !_WIN32_WCE |
| 6897 #endif // (_WIN32_IE >= 0x0400) |
| 6898 |
| 6899 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 6900 int GetPos32(LPBOOL lpbError = NULL) const |
| 6901 { |
| 6902 ATLASSERT(::IsWindow(m_hWnd)); |
| 6903 // Note: Seems that Windows always sets error to TRUE if |
| 6904 // UDS_SETBUDDYINT style is not used |
| 6905 return (int)::SendMessage(m_hWnd, UDM_GETPOS32, 0, (LPARAM)lpbEr
ror); |
| 6906 } |
| 6907 |
| 6908 int SetPos32(int nPos) |
| 6909 { |
| 6910 ATLASSERT(::IsWindow(m_hWnd)); |
| 6911 return (int)::SendMessage(m_hWnd, UDM_SETPOS32, 0, (LPARAM)nPos)
; |
| 6912 } |
| 6913 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 6914 }; |
| 6915 |
| 6916 typedef CUpDownCtrlT<ATL::CWindow> CUpDownCtrl; |
| 6917 |
| 6918 |
| 6919 /////////////////////////////////////////////////////////////////////////////// |
| 6920 // CProgressBarCtrl |
| 6921 |
| 6922 template <class TBase> |
| 6923 class CProgressBarCtrlT : public TBase |
| 6924 { |
| 6925 public: |
| 6926 // Constructors |
| 6927 CProgressBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 6928 { } |
| 6929 |
| 6930 CProgressBarCtrlT< TBase >& operator =(HWND hWnd) |
| 6931 { |
| 6932 m_hWnd = hWnd; |
| 6933 return *this; |
| 6934 } |
| 6935 |
| 6936 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 6937 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 6938 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 6939 { |
| 6940 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 6941 } |
| 6942 |
| 6943 // Attributes |
| 6944 static LPCTSTR GetWndClassName() |
| 6945 { |
| 6946 return PROGRESS_CLASS; |
| 6947 } |
| 6948 |
| 6949 DWORD SetRange(int nLower, int nUpper) |
| 6950 { |
| 6951 ATLASSERT(::IsWindow(m_hWnd)); |
| 6952 return (DWORD)::SendMessage(m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(
nLower, nUpper)); |
| 6953 } |
| 6954 |
| 6955 int SetPos(int nPos) |
| 6956 { |
| 6957 ATLASSERT(::IsWindow(m_hWnd)); |
| 6958 return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_SETPOS, nPos
, 0L)); |
| 6959 } |
| 6960 |
| 6961 int OffsetPos(int nPos) |
| 6962 { |
| 6963 ATLASSERT(::IsWindow(m_hWnd)); |
| 6964 return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_DELTAPOS, nP
os, 0L)); |
| 6965 } |
| 6966 |
| 6967 int SetStep(int nStep) |
| 6968 { |
| 6969 ATLASSERT(::IsWindow(m_hWnd)); |
| 6970 return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_SETSTEP, nSt
ep, 0L)); |
| 6971 } |
| 6972 |
| 6973 UINT GetPos() const |
| 6974 { |
| 6975 ATLASSERT(::IsWindow(m_hWnd)); |
| 6976 return (UINT)::SendMessage(m_hWnd, PBM_GETPOS, 0, 0L); |
| 6977 } |
| 6978 |
| 6979 void GetRange(PPBRANGE pPBRange) const |
| 6980 { |
| 6981 ATLASSERT(::IsWindow(m_hWnd)); |
| 6982 ATLASSERT(pPBRange != NULL); |
| 6983 ::SendMessage(m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)pPBRange); |
| 6984 } |
| 6985 |
| 6986 void GetRange(int& nLower, int& nUpper) const |
| 6987 { |
| 6988 ATLASSERT(::IsWindow(m_hWnd)); |
| 6989 PBRANGE range = { 0 }; |
| 6990 ::SendMessage(m_hWnd, PBM_GETRANGE, TRUE, (LPARAM)&range); |
| 6991 nLower = range.iLow; |
| 6992 nUpper = range.iHigh; |
| 6993 } |
| 6994 |
| 6995 int GetRangeLimit(BOOL bLowLimit) const |
| 6996 { |
| 6997 ATLASSERT(::IsWindow(m_hWnd)); |
| 6998 return (int)::SendMessage(m_hWnd, PBM_GETRANGE, bLowLimit, (LPAR
AM)NULL); |
| 6999 } |
| 7000 |
| 7001 DWORD SetRange32(int nMin, int nMax) |
| 7002 { |
| 7003 ATLASSERT(::IsWindow(m_hWnd)); |
| 7004 return (DWORD)::SendMessage(m_hWnd, PBM_SETRANGE32, nMin, nMax); |
| 7005 } |
| 7006 |
| 7007 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 7008 COLORREF SetBarColor(COLORREF clr) |
| 7009 { |
| 7010 ATLASSERT(::IsWindow(m_hWnd)); |
| 7011 return (COLORREF)::SendMessage(m_hWnd, PBM_SETBARCOLOR, 0, (LPAR
AM)clr); |
| 7012 } |
| 7013 |
| 7014 COLORREF SetBkColor(COLORREF clr) |
| 7015 { |
| 7016 ATLASSERT(::IsWindow(m_hWnd)); |
| 7017 return (COLORREF)::SendMessage(m_hWnd, PBM_SETBKCOLOR, 0, (LPARA
M)clr); |
| 7018 } |
| 7019 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 7020 |
| 7021 #if (_WIN32_WINNT >= 0x0501) && defined(PBM_SETMARQUEE) |
| 7022 BOOL SetMarquee(BOOL bMarquee, UINT uUpdateTime = 0U) |
| 7023 { |
| 7024 ATLASSERT(::IsWindow(m_hWnd)); |
| 7025 return (BOOL)::SendMessage(m_hWnd, PBM_SETMARQUEE, (WPARAM)bMarq
uee, (LPARAM)uUpdateTime); |
| 7026 } |
| 7027 #endif // (_WIN32_WINNT >= 0x0501) && defined(PBM_SETMARQUEE) |
| 7028 |
| 7029 #if (_WIN32_WINNT >= 0x0600) |
| 7030 int GetStep() const |
| 7031 { |
| 7032 ATLASSERT(::IsWindow(m_hWnd)); |
| 7033 return (int)::SendMessage(m_hWnd, PBM_GETSTEP, 0, 0L); |
| 7034 } |
| 7035 |
| 7036 COLORREF GetBkColor() const |
| 7037 { |
| 7038 ATLASSERT(::IsWindow(m_hWnd)); |
| 7039 return (COLORREF)::SendMessage(m_hWnd, PBM_GETBKCOLOR, 0, 0L); |
| 7040 } |
| 7041 |
| 7042 COLORREF GetBarColor() const |
| 7043 { |
| 7044 ATLASSERT(::IsWindow(m_hWnd)); |
| 7045 return (COLORREF)::SendMessage(m_hWnd, PBM_GETBARCOLOR, 0, 0L); |
| 7046 } |
| 7047 |
| 7048 int GetState() const |
| 7049 { |
| 7050 ATLASSERT(::IsWindow(m_hWnd)); |
| 7051 return (int)::SendMessage(m_hWnd, PBM_GETSTATE, 0, 0L); |
| 7052 } |
| 7053 |
| 7054 int SetState(int nState) |
| 7055 { |
| 7056 ATLASSERT(::IsWindow(m_hWnd)); |
| 7057 return (int)::SendMessage(m_hWnd, PBM_SETSTATE, nState, 0L); |
| 7058 } |
| 7059 #endif // (_WIN32_WINNT >= 0x0600) |
| 7060 |
| 7061 // Operations |
| 7062 int StepIt() |
| 7063 { |
| 7064 ATLASSERT(::IsWindow(m_hWnd)); |
| 7065 return (int)(short)LOWORD(::SendMessage(m_hWnd, PBM_STEPIT, 0, 0
L)); |
| 7066 } |
| 7067 }; |
| 7068 |
| 7069 typedef CProgressBarCtrlT<ATL::CWindow> CProgressBarCtrl; |
| 7070 |
| 7071 |
| 7072 /////////////////////////////////////////////////////////////////////////////// |
| 7073 // CHotKeyCtrl |
| 7074 |
| 7075 #ifndef _WIN32_WCE |
| 7076 |
| 7077 template <class TBase> |
| 7078 class CHotKeyCtrlT : public TBase |
| 7079 { |
| 7080 public: |
| 7081 // Constructors |
| 7082 CHotKeyCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 7083 { } |
| 7084 |
| 7085 CHotKeyCtrlT< TBase >& operator =(HWND hWnd) |
| 7086 { |
| 7087 m_hWnd = hWnd; |
| 7088 return *this; |
| 7089 } |
| 7090 |
| 7091 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 7092 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 7093 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 7094 { |
| 7095 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 7096 } |
| 7097 |
| 7098 // Attributes |
| 7099 static LPCTSTR GetWndClassName() |
| 7100 { |
| 7101 return HOTKEY_CLASS; |
| 7102 } |
| 7103 |
| 7104 DWORD GetHotKey() const |
| 7105 { |
| 7106 ATLASSERT(::IsWindow(m_hWnd)); |
| 7107 return (DWORD)::SendMessage(m_hWnd, HKM_GETHOTKEY, 0, 0L); |
| 7108 } |
| 7109 |
| 7110 void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const |
| 7111 { |
| 7112 ATLASSERT(::IsWindow(m_hWnd)); |
| 7113 DWORD dw = (DWORD)::SendMessage(m_hWnd, HKM_GETHOTKEY, 0, 0L); |
| 7114 wVirtualKeyCode = LOBYTE(LOWORD(dw)); |
| 7115 wModifiers = HIBYTE(LOWORD(dw)); |
| 7116 } |
| 7117 |
| 7118 void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers) |
| 7119 { |
| 7120 ATLASSERT(::IsWindow(m_hWnd)); |
| 7121 ::SendMessage(m_hWnd, HKM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, w
Modifiers), 0L); |
| 7122 } |
| 7123 |
| 7124 void SetRules(WORD wInvalidComb, WORD wModifiers) |
| 7125 { |
| 7126 ATLASSERT(::IsWindow(m_hWnd)); |
| 7127 ::SendMessage(m_hWnd, HKM_SETRULES, wInvalidComb, MAKELPARAM(wMo
difiers, 0)); |
| 7128 } |
| 7129 }; |
| 7130 |
| 7131 typedef CHotKeyCtrlT<ATL::CWindow> CHotKeyCtrl; |
| 7132 |
| 7133 #endif // !_WIN32_WCE |
| 7134 |
| 7135 |
| 7136 /////////////////////////////////////////////////////////////////////////////// |
| 7137 // CAnimateCtrl |
| 7138 |
| 7139 #ifndef _WIN32_WCE |
| 7140 |
| 7141 template <class TBase> |
| 7142 class CAnimateCtrlT : public TBase |
| 7143 { |
| 7144 public: |
| 7145 // Constructors |
| 7146 CAnimateCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 7147 { } |
| 7148 |
| 7149 CAnimateCtrlT< TBase >& operator =(HWND hWnd) |
| 7150 { |
| 7151 m_hWnd = hWnd; |
| 7152 return *this; |
| 7153 } |
| 7154 |
| 7155 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 7156 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 7157 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 7158 { |
| 7159 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 7160 } |
| 7161 |
| 7162 // Attributes |
| 7163 static LPCTSTR GetWndClassName() |
| 7164 { |
| 7165 return ANIMATE_CLASS; |
| 7166 } |
| 7167 |
| 7168 // Operations |
| 7169 BOOL Open(ATL::_U_STRINGorID FileName) |
| 7170 { |
| 7171 ATLASSERT(::IsWindow(m_hWnd)); |
| 7172 return (BOOL)::SendMessage(m_hWnd, ACM_OPEN, 0, (LPARAM)FileName
.m_lpstr); |
| 7173 } |
| 7174 |
| 7175 BOOL Play(UINT nFrom, UINT nTo, UINT nRep) |
| 7176 { |
| 7177 ATLASSERT(::IsWindow(m_hWnd)); |
| 7178 return (BOOL)::SendMessage(m_hWnd, ACM_PLAY, nRep, MAKELPARAM(nF
rom, nTo)); |
| 7179 } |
| 7180 |
| 7181 BOOL Stop() |
| 7182 { |
| 7183 ATLASSERT(::IsWindow(m_hWnd)); |
| 7184 return (BOOL)::SendMessage(m_hWnd, ACM_STOP, 0, 0L); |
| 7185 } |
| 7186 |
| 7187 BOOL Close() |
| 7188 { |
| 7189 ATLASSERT(::IsWindow(m_hWnd)); |
| 7190 return (BOOL)::SendMessage(m_hWnd, ACM_OPEN, 0, 0L); |
| 7191 } |
| 7192 |
| 7193 BOOL Seek(UINT nTo) |
| 7194 { |
| 7195 ATLASSERT(::IsWindow(m_hWnd)); |
| 7196 return (BOOL)::SendMessage(m_hWnd, ACM_PLAY, 0, MAKELPARAM(nTo,
nTo)); |
| 7197 } |
| 7198 |
| 7199 // Vista only |
| 7200 BOOL IsPlaying() const |
| 7201 { |
| 7202 #ifndef ACM_ISPLAYING |
| 7203 const UINT ACM_ISPLAYING = (WM_USER+104); |
| 7204 #endif |
| 7205 ATLASSERT(::IsWindow(m_hWnd)); |
| 7206 return (BOOL)::SendMessage(m_hWnd, ACM_ISPLAYING, 0, 0L); |
| 7207 } |
| 7208 }; |
| 7209 |
| 7210 typedef CAnimateCtrlT<ATL::CWindow> CAnimateCtrl; |
| 7211 |
| 7212 #endif // !_WIN32_WCE |
| 7213 |
| 7214 |
| 7215 /////////////////////////////////////////////////////////////////////////////// |
| 7216 // CRichEditCtrl |
| 7217 |
| 7218 #ifndef _WIN32_WCE |
| 7219 |
| 7220 #ifdef _UNICODE |
| 7221 #if (_RICHEDIT_VER == 0x0100) |
| 7222 #undef RICHEDIT_CLASS |
| 7223 #define RICHEDIT_CLASS L"RICHEDIT" |
| 7224 #endif // (_RICHEDIT_VER == 0x0100) |
| 7225 #endif // _UNICODE |
| 7226 |
| 7227 template <class TBase> |
| 7228 class CRichEditCtrlT : public TBase |
| 7229 { |
| 7230 public: |
| 7231 // Constructors |
| 7232 CRichEditCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 7233 { } |
| 7234 |
| 7235 CRichEditCtrlT< TBase >& operator =(HWND hWnd) |
| 7236 { |
| 7237 m_hWnd = hWnd; |
| 7238 return *this; |
| 7239 } |
| 7240 |
| 7241 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 7242 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 7243 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 7244 { |
| 7245 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 7246 } |
| 7247 |
| 7248 // Attributes |
| 7249 static LPCTSTR GetWndClassName() |
| 7250 { |
| 7251 return RICHEDIT_CLASS; |
| 7252 } |
| 7253 |
| 7254 static LPCTSTR GetLibraryName() |
| 7255 { |
| 7256 #if (_RICHEDIT_VER >= 0x0200) |
| 7257 return _T("RICHED20.DLL"); |
| 7258 #else |
| 7259 return _T("RICHED32.DLL"); |
| 7260 #endif |
| 7261 } |
| 7262 |
| 7263 int GetLineCount() const |
| 7264 { |
| 7265 ATLASSERT(::IsWindow(m_hWnd)); |
| 7266 return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L); |
| 7267 } |
| 7268 |
| 7269 BOOL GetModify() const |
| 7270 { |
| 7271 ATLASSERT(::IsWindow(m_hWnd)); |
| 7272 return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L); |
| 7273 } |
| 7274 |
| 7275 void SetModify(BOOL bModified = TRUE) |
| 7276 { |
| 7277 ATLASSERT(::IsWindow(m_hWnd)); |
| 7278 ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L); |
| 7279 } |
| 7280 |
| 7281 void GetRect(LPRECT lpRect) const |
| 7282 { |
| 7283 ATLASSERT(::IsWindow(m_hWnd)); |
| 7284 ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect); |
| 7285 } |
| 7286 |
| 7287 DWORD GetOptions() const |
| 7288 { |
| 7289 ATLASSERT(::IsWindow(m_hWnd)); |
| 7290 return (DWORD)::SendMessage(m_hWnd, EM_GETOPTIONS, 0, 0L); |
| 7291 } |
| 7292 |
| 7293 DWORD SetOptions(WORD wOperation, DWORD dwOptions) |
| 7294 { |
| 7295 ATLASSERT(::IsWindow(m_hWnd)); |
| 7296 return (DWORD)::SendMessage(m_hWnd, EM_SETOPTIONS, wOperation, d
wOptions); |
| 7297 } |
| 7298 |
| 7299 // NOTE: first word in lpszBuffer must contain the size of the buffer! |
| 7300 int GetLine(int nIndex, LPTSTR lpszBuffer) const |
| 7301 { |
| 7302 ATLASSERT(::IsWindow(m_hWnd)); |
| 7303 return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lp
szBuffer); |
| 7304 } |
| 7305 |
| 7306 int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const |
| 7307 { |
| 7308 ATLASSERT(::IsWindow(m_hWnd)); |
| 7309 *(LPWORD)lpszBuffer = (WORD)nMaxLength; |
| 7310 return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lp
szBuffer); |
| 7311 } |
| 7312 |
| 7313 BOOL CanUndo() const |
| 7314 { |
| 7315 ATLASSERT(::IsWindow(m_hWnd)); |
| 7316 return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L); |
| 7317 } |
| 7318 |
| 7319 BOOL CanPaste(UINT nFormat = 0) const |
| 7320 { |
| 7321 ATLASSERT(::IsWindow(m_hWnd)); |
| 7322 return (BOOL)::SendMessage(m_hWnd, EM_CANPASTE, nFormat, 0L); |
| 7323 } |
| 7324 |
| 7325 void GetSel(LONG& nStartChar, LONG& nEndChar) const |
| 7326 { |
| 7327 ATLASSERT(::IsWindow(m_hWnd)); |
| 7328 CHARRANGE cr = { 0, 0 }; |
| 7329 ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); |
| 7330 nStartChar = cr.cpMin; |
| 7331 nEndChar = cr.cpMax; |
| 7332 } |
| 7333 |
| 7334 void GetSel(CHARRANGE &cr) const |
| 7335 { |
| 7336 ATLASSERT(::IsWindow(m_hWnd)); |
| 7337 ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); |
| 7338 } |
| 7339 |
| 7340 int SetSel(LONG nStartChar, LONG nEndChar) |
| 7341 { |
| 7342 ATLASSERT(::IsWindow(m_hWnd)); |
| 7343 CHARRANGE cr = { nStartChar, nEndChar }; |
| 7344 return (int)::SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); |
| 7345 } |
| 7346 |
| 7347 int SetSel(CHARRANGE &cr) |
| 7348 { |
| 7349 ATLASSERT(::IsWindow(m_hWnd)); |
| 7350 return (int)::SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr); |
| 7351 } |
| 7352 |
| 7353 int SetSelAll() |
| 7354 { |
| 7355 return SetSel(0, -1); |
| 7356 } |
| 7357 |
| 7358 int SetSelNone() |
| 7359 { |
| 7360 return SetSel(-1, 0); |
| 7361 } |
| 7362 |
| 7363 DWORD GetDefaultCharFormat(CHARFORMAT& cf) const |
| 7364 { |
| 7365 ATLASSERT(::IsWindow(m_hWnd)); |
| 7366 cf.cbSize = sizeof(CHARFORMAT); |
| 7367 return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM
)&cf); |
| 7368 } |
| 7369 |
| 7370 DWORD GetSelectionCharFormat(CHARFORMAT& cf) const |
| 7371 { |
| 7372 ATLASSERT(::IsWindow(m_hWnd)); |
| 7373 cf.cbSize = sizeof(CHARFORMAT); |
| 7374 return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM
)&cf); |
| 7375 } |
| 7376 |
| 7377 DWORD GetEventMask() const |
| 7378 { |
| 7379 ATLASSERT(::IsWindow(m_hWnd)); |
| 7380 return (DWORD)::SendMessage(m_hWnd, EM_GETEVENTMASK, 0, 0L); |
| 7381 } |
| 7382 |
| 7383 LONG GetLimitText() const |
| 7384 { |
| 7385 ATLASSERT(::IsWindow(m_hWnd)); |
| 7386 return (LONG)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L); |
| 7387 } |
| 7388 |
| 7389 DWORD GetParaFormat(PARAFORMAT& pf) const |
| 7390 { |
| 7391 ATLASSERT(::IsWindow(m_hWnd)); |
| 7392 pf.cbSize = sizeof(PARAFORMAT); |
| 7393 return (DWORD)::SendMessage(m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM
)&pf); |
| 7394 } |
| 7395 |
| 7396 #if (_RICHEDIT_VER >= 0x0200) |
| 7397 LONG GetSelText(LPTSTR lpstrBuff) const |
| 7398 { |
| 7399 ATLASSERT(::IsWindow(m_hWnd)); |
| 7400 return (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lps
trBuff); |
| 7401 } |
| 7402 #else // !(_RICHEDIT_VER >= 0x0200) |
| 7403 // RichEdit 1.0 EM_GETSELTEXT is ANSI only |
| 7404 LONG GetSelText(LPSTR lpstrBuff) const |
| 7405 { |
| 7406 ATLASSERT(::IsWindow(m_hWnd)); |
| 7407 return (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lps
trBuff); |
| 7408 } |
| 7409 #endif // !(_RICHEDIT_VER >= 0x0200) |
| 7410 |
| 7411 #ifndef _ATL_NO_COM |
| 7412 BOOL GetSelTextBSTR(BSTR& bstrText) const |
| 7413 { |
| 7414 USES_CONVERSION; |
| 7415 ATLASSERT(::IsWindow(m_hWnd)); |
| 7416 ATLASSERT(bstrText == NULL); |
| 7417 |
| 7418 CHARRANGE cr = { 0, 0 }; |
| 7419 ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); |
| 7420 |
| 7421 #if (_RICHEDIT_VER >= 0x0200) |
| 7422 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 7423 LPTSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); |
| 7424 if(lpstrText == NULL) |
| 7425 return FALSE; |
| 7426 if(::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) ==
0) |
| 7427 return FALSE; |
| 7428 |
| 7429 bstrText = ::SysAllocString(T2W(lpstrText)); |
| 7430 #else // !(_RICHEDIT_VER >= 0x0200) |
| 7431 CTempBuffer<char, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 7432 LPSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); |
| 7433 if(lpstrText == NULL) |
| 7434 return FALSE; |
| 7435 if(::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpstrText) ==
0) |
| 7436 return FALSE; |
| 7437 |
| 7438 bstrText = ::SysAllocString(A2W(lpstrText)); |
| 7439 #endif // !(_RICHEDIT_VER >= 0x0200) |
| 7440 |
| 7441 return (bstrText != NULL) ? TRUE : FALSE; |
| 7442 } |
| 7443 #endif // !_ATL_NO_COM |
| 7444 |
| 7445 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 7446 LONG GetSelText(_CSTRING_NS::CString& strText) const |
| 7447 { |
| 7448 ATLASSERT(::IsWindow(m_hWnd)); |
| 7449 |
| 7450 CHARRANGE cr = { 0, 0 }; |
| 7451 ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); |
| 7452 |
| 7453 #if (_RICHEDIT_VER >= 0x0200) |
| 7454 LONG lLen = 0; |
| 7455 LPTSTR lpstrText = strText.GetBufferSetLength(cr.cpMax - cr.cpMi
n); |
| 7456 if(lpstrText != NULL) |
| 7457 { |
| 7458 lLen = (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LP
ARAM)lpstrText); |
| 7459 strText.ReleaseBuffer(); |
| 7460 } |
| 7461 #else // !(_RICHEDIT_VER >= 0x0200) |
| 7462 CTempBuffer<char, _WTL_STACK_ALLOC_THRESHOLD> buff; |
| 7463 LPSTR lpstrText = buff.Allocate(cr.cpMax - cr.cpMin + 1); |
| 7464 if(lpstrText == NULL) |
| 7465 return 0; |
| 7466 LONG lLen = (LONG)::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARA
M)lpstrText); |
| 7467 if(lLen == 0) |
| 7468 return 0; |
| 7469 |
| 7470 USES_CONVERSION; |
| 7471 strText = A2T(lpstrText); |
| 7472 #endif // !(_RICHEDIT_VER >= 0x0200) |
| 7473 |
| 7474 return lLen; |
| 7475 } |
| 7476 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 7477 |
| 7478 WORD GetSelectionType() const |
| 7479 { |
| 7480 ATLASSERT(::IsWindow(m_hWnd)); |
| 7481 return (WORD)::SendMessage(m_hWnd, EM_SELECTIONTYPE, 0, 0L); |
| 7482 } |
| 7483 |
| 7484 COLORREF SetBackgroundColor(COLORREF cr) |
| 7485 { |
| 7486 ATLASSERT(::IsWindow(m_hWnd)); |
| 7487 return (COLORREF)::SendMessage(m_hWnd, EM_SETBKGNDCOLOR, 0, cr); |
| 7488 } |
| 7489 |
| 7490 COLORREF SetBackgroundColor() // sets to system background |
| 7491 { |
| 7492 ATLASSERT(::IsWindow(m_hWnd)); |
| 7493 return (COLORREF)::SendMessage(m_hWnd, EM_SETBKGNDCOLOR, 1, 0); |
| 7494 } |
| 7495 |
| 7496 BOOL SetCharFormat(CHARFORMAT& cf, WORD wFlags) |
| 7497 { |
| 7498 ATLASSERT(::IsWindow(m_hWnd)); |
| 7499 cf.cbSize = sizeof(CHARFORMAT); |
| 7500 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFl
ags, (LPARAM)&cf); |
| 7501 } |
| 7502 |
| 7503 BOOL SetDefaultCharFormat(CHARFORMAT& cf) |
| 7504 { |
| 7505 ATLASSERT(::IsWindow(m_hWnd)); |
| 7506 cf.cbSize = sizeof(CHARFORMAT); |
| 7507 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)
&cf); |
| 7508 } |
| 7509 |
| 7510 BOOL SetSelectionCharFormat(CHARFORMAT& cf) |
| 7511 { |
| 7512 ATLASSERT(::IsWindow(m_hWnd)); |
| 7513 cf.cbSize = sizeof(CHARFORMAT); |
| 7514 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTI
ON, (LPARAM)&cf); |
| 7515 } |
| 7516 |
| 7517 BOOL SetWordCharFormat(CHARFORMAT& cf) |
| 7518 { |
| 7519 ATLASSERT(::IsWindow(m_hWnd)); |
| 7520 cf.cbSize = sizeof(CHARFORMAT); |
| 7521 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTI
ON | SCF_WORD, (LPARAM)&cf); |
| 7522 } |
| 7523 |
| 7524 DWORD SetEventMask(DWORD dwEventMask) |
| 7525 { |
| 7526 ATLASSERT(::IsWindow(m_hWnd)); |
| 7527 return (DWORD)::SendMessage(m_hWnd, EM_SETEVENTMASK, 0, dwEventM
ask); |
| 7528 } |
| 7529 |
| 7530 BOOL SetParaFormat(PARAFORMAT& pf) |
| 7531 { |
| 7532 ATLASSERT(::IsWindow(m_hWnd)); |
| 7533 pf.cbSize = sizeof(PARAFORMAT); |
| 7534 return (BOOL)::SendMessage(m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)
&pf); |
| 7535 } |
| 7536 |
| 7537 BOOL SetTargetDevice(HDC hDC, int cxLineWidth) |
| 7538 { |
| 7539 ATLASSERT(::IsWindow(m_hWnd)); |
| 7540 return (BOOL)::SendMessage(m_hWnd, EM_SETTARGETDEVICE, (WPARAM)h
DC, cxLineWidth); |
| 7541 } |
| 7542 |
| 7543 int GetTextLength() const |
| 7544 { |
| 7545 ATLASSERT(::IsWindow(m_hWnd)); |
| 7546 return (int)::SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0L); |
| 7547 } |
| 7548 |
| 7549 BOOL SetReadOnly(BOOL bReadOnly = TRUE) |
| 7550 { |
| 7551 ATLASSERT(::IsWindow(m_hWnd)); |
| 7552 return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L
); |
| 7553 } |
| 7554 |
| 7555 int GetFirstVisibleLine() const |
| 7556 { |
| 7557 ATLASSERT(::IsWindow(m_hWnd)); |
| 7558 return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L)
; |
| 7559 } |
| 7560 |
| 7561 EDITWORDBREAKPROCEX GetWordBreakProcEx() const |
| 7562 { |
| 7563 ATLASSERT(::IsWindow(m_hWnd)); |
| 7564 return (EDITWORDBREAKPROCEX)::SendMessage(m_hWnd, EM_GETWORDBREA
KPROCEX, 0, 0L); |
| 7565 } |
| 7566 |
| 7567 EDITWORDBREAKPROCEX SetWordBreakProcEx(EDITWORDBREAKPROCEX pfnEditWordBr
eakProcEx) |
| 7568 { |
| 7569 ATLASSERT(::IsWindow(m_hWnd)); |
| 7570 return (EDITWORDBREAKPROCEX)::SendMessage(m_hWnd, EM_SETWORDBREA
KPROCEX, 0, (LPARAM)pfnEditWordBreakProcEx); |
| 7571 } |
| 7572 |
| 7573 int GetTextRange(TEXTRANGE* pTextRange) const |
| 7574 { |
| 7575 ATLASSERT(::IsWindow(m_hWnd)); |
| 7576 return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)pT
extRange); |
| 7577 } |
| 7578 |
| 7579 #if (_RICHEDIT_VER >= 0x0200) |
| 7580 int GetTextRange(LONG nStartChar, LONG nEndChar, LPTSTR lpstrText) const |
| 7581 { |
| 7582 ATLASSERT(::IsWindow(m_hWnd)); |
| 7583 TEXTRANGE tr = { 0 }; |
| 7584 tr.chrg.cpMin = nStartChar; |
| 7585 tr.chrg.cpMax = nEndChar; |
| 7586 tr.lpstrText = lpstrText; |
| 7587 return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&t
r); |
| 7588 } |
| 7589 #else // !(_RICHEDIT_VER >= 0x0200) |
| 7590 |
| 7591 int GetTextRange(LONG nStartChar, LONG nEndChar, LPSTR lpstrText) const |
| 7592 { |
| 7593 ATLASSERT(::IsWindow(m_hWnd)); |
| 7594 TEXTRANGE tr = { 0 }; |
| 7595 tr.chrg.cpMin = nStartChar; |
| 7596 tr.chrg.cpMax = nEndChar; |
| 7597 tr.lpstrText = lpstrText; |
| 7598 return (int)::SendMessage(m_hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&t
r); |
| 7599 } |
| 7600 #endif // !(_RICHEDIT_VER >= 0x0200) |
| 7601 |
| 7602 #if (_RICHEDIT_VER >= 0x0200) |
| 7603 DWORD GetDefaultCharFormat(CHARFORMAT2& cf) const |
| 7604 { |
| 7605 ATLASSERT(::IsWindow(m_hWnd)); |
| 7606 cf.cbSize = sizeof(CHARFORMAT2); |
| 7607 return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 0, (LPARAM
)&cf); |
| 7608 } |
| 7609 |
| 7610 BOOL SetCharFormat(CHARFORMAT2& cf, WORD wFlags) |
| 7611 { |
| 7612 ATLASSERT(::IsWindow(m_hWnd)); |
| 7613 cf.cbSize = sizeof(CHARFORMAT2); |
| 7614 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, (WPARAM)wFl
ags, (LPARAM)&cf); |
| 7615 } |
| 7616 |
| 7617 BOOL SetDefaultCharFormat(CHARFORMAT2& cf) |
| 7618 { |
| 7619 ATLASSERT(::IsWindow(m_hWnd)); |
| 7620 cf.cbSize = sizeof(CHARFORMAT2); |
| 7621 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)
&cf); |
| 7622 } |
| 7623 |
| 7624 DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const |
| 7625 { |
| 7626 ATLASSERT(::IsWindow(m_hWnd)); |
| 7627 cf.cbSize = sizeof(CHARFORMAT2); |
| 7628 return (DWORD)::SendMessage(m_hWnd, EM_GETCHARFORMAT, 1, (LPARAM
)&cf); |
| 7629 } |
| 7630 |
| 7631 BOOL SetSelectionCharFormat(CHARFORMAT2& cf) |
| 7632 { |
| 7633 ATLASSERT(::IsWindow(m_hWnd)); |
| 7634 cf.cbSize = sizeof(CHARFORMAT2); |
| 7635 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTI
ON, (LPARAM)&cf); |
| 7636 } |
| 7637 |
| 7638 BOOL SetWordCharFormat(CHARFORMAT2& cf) |
| 7639 { |
| 7640 ATLASSERT(::IsWindow(m_hWnd)); |
| 7641 cf.cbSize = sizeof(CHARFORMAT2); |
| 7642 return (BOOL)::SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_SELECTI
ON | SCF_WORD, (LPARAM)&cf); |
| 7643 } |
| 7644 |
| 7645 DWORD GetParaFormat(PARAFORMAT2& pf) const |
| 7646 { |
| 7647 ATLASSERT(::IsWindow(m_hWnd)); |
| 7648 pf.cbSize = sizeof(PARAFORMAT2); |
| 7649 return (DWORD)::SendMessage(m_hWnd, EM_GETPARAFORMAT, 0, (LPARAM
)&pf); |
| 7650 } |
| 7651 |
| 7652 BOOL SetParaFormat(PARAFORMAT2& pf) |
| 7653 { |
| 7654 ATLASSERT(::IsWindow(m_hWnd)); |
| 7655 pf.cbSize = sizeof(PARAFORMAT2); |
| 7656 return (BOOL)::SendMessage(m_hWnd, EM_SETPARAFORMAT, 0, (LPARAM)
&pf); |
| 7657 } |
| 7658 |
| 7659 TEXTMODE GetTextMode() const |
| 7660 { |
| 7661 ATLASSERT(::IsWindow(m_hWnd)); |
| 7662 return (TEXTMODE)::SendMessage(m_hWnd, EM_GETTEXTMODE, 0, 0L); |
| 7663 } |
| 7664 |
| 7665 BOOL SetTextMode(TEXTMODE enumTextMode) |
| 7666 { |
| 7667 ATLASSERT(::IsWindow(m_hWnd)); |
| 7668 return !(BOOL)::SendMessage(m_hWnd, EM_SETTEXTMODE, enumTextMode
, 0L); |
| 7669 } |
| 7670 |
| 7671 UNDONAMEID GetUndoName() const |
| 7672 { |
| 7673 ATLASSERT(::IsWindow(m_hWnd)); |
| 7674 return (UNDONAMEID)::SendMessage(m_hWnd, EM_GETUNDONAME, 0, 0L); |
| 7675 } |
| 7676 |
| 7677 UNDONAMEID GetRedoName() const |
| 7678 { |
| 7679 ATLASSERT(::IsWindow(m_hWnd)); |
| 7680 return (UNDONAMEID)::SendMessage(m_hWnd, EM_GETREDONAME, 0, 0L); |
| 7681 } |
| 7682 |
| 7683 BOOL CanRedo() const |
| 7684 { |
| 7685 ATLASSERT(::IsWindow(m_hWnd)); |
| 7686 return (BOOL)::SendMessage(m_hWnd, EM_CANREDO, 0, 0L); |
| 7687 } |
| 7688 |
| 7689 BOOL GetAutoURLDetect() const |
| 7690 { |
| 7691 ATLASSERT(::IsWindow(m_hWnd)); |
| 7692 return (BOOL)::SendMessage(m_hWnd, EM_GETAUTOURLDETECT, 0, 0L); |
| 7693 } |
| 7694 |
| 7695 BOOL SetAutoURLDetect(BOOL bAutoDetect = TRUE) |
| 7696 { |
| 7697 ATLASSERT(::IsWindow(m_hWnd)); |
| 7698 return !(BOOL)::SendMessage(m_hWnd, EM_AUTOURLDETECT, bAutoDetec
t, 0L); |
| 7699 } |
| 7700 |
| 7701 // this method is deprecated, please use SetAutoURLDetect |
| 7702 BOOL EnableAutoURLDetect(BOOL bEnable = TRUE) { return SetAutoURLDetect(
bEnable); } |
| 7703 |
| 7704 UINT SetUndoLimit(UINT uUndoLimit) |
| 7705 { |
| 7706 ATLASSERT(::IsWindow(m_hWnd)); |
| 7707 return (UINT)::SendMessage(m_hWnd, EM_SETUNDOLIMIT, uUndoLimit,
0L); |
| 7708 } |
| 7709 |
| 7710 void SetPalette(HPALETTE hPalette) |
| 7711 { |
| 7712 ATLASSERT(::IsWindow(m_hWnd)); |
| 7713 ::SendMessage(m_hWnd, EM_SETPALETTE, (WPARAM)hPalette, 0L); |
| 7714 } |
| 7715 |
| 7716 int GetTextEx(GETTEXTEX* pGetTextEx, LPTSTR lpstrText) const |
| 7717 { |
| 7718 ATLASSERT(::IsWindow(m_hWnd)); |
| 7719 return (int)::SendMessage(m_hWnd, EM_GETTEXTEX, (WPARAM)pGetText
Ex, (LPARAM)lpstrText); |
| 7720 } |
| 7721 |
| 7722 int GetTextEx(LPTSTR lpstrText, int nTextLen, DWORD dwFlags = GT_DEFAULT
, UINT uCodePage = CP_ACP, LPCSTR lpDefaultChar = NULL, LPBOOL lpUsedDefChar = N
ULL) const |
| 7723 { |
| 7724 ATLASSERT(::IsWindow(m_hWnd)); |
| 7725 GETTEXTEX gte = { 0 }; |
| 7726 gte.cb = nTextLen * sizeof(TCHAR); |
| 7727 gte.codepage = uCodePage; |
| 7728 gte.flags = dwFlags; |
| 7729 gte.lpDefaultChar = lpDefaultChar; |
| 7730 gte.lpUsedDefChar = lpUsedDefChar; |
| 7731 return (int)::SendMessage(m_hWnd, EM_GETTEXTEX, (WPARAM)>e, (L
PARAM)lpstrText); |
| 7732 } |
| 7733 |
| 7734 int GetTextLengthEx(GETTEXTLENGTHEX* pGetTextLengthEx) const |
| 7735 { |
| 7736 ATLASSERT(::IsWindow(m_hWnd)); |
| 7737 return (int)::SendMessage(m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)pG
etTextLengthEx, 0L); |
| 7738 } |
| 7739 |
| 7740 int GetTextLengthEx(DWORD dwFlags = GTL_DEFAULT, UINT uCodePage = CP_ACP
) const |
| 7741 { |
| 7742 ATLASSERT(::IsWindow(m_hWnd)); |
| 7743 GETTEXTLENGTHEX gtle = { 0 }; |
| 7744 gtle.codepage = uCodePage; |
| 7745 gtle.flags = dwFlags; |
| 7746 return (int)::SendMessage(m_hWnd, EM_GETTEXTLENGTHEX, (WPARAM)&g
tle, 0L); |
| 7747 } |
| 7748 #endif // (_RICHEDIT_VER >= 0x0200) |
| 7749 |
| 7750 #if (_RICHEDIT_VER >= 0x0300) |
| 7751 int SetTextEx(SETTEXTEX* pSetTextEx, LPCTSTR lpstrText) |
| 7752 { |
| 7753 ATLASSERT(::IsWindow(m_hWnd)); |
| 7754 return (int)::SendMessage(m_hWnd, EM_SETTEXTEX, (WPARAM)pSetText
Ex, (LPARAM)lpstrText); |
| 7755 } |
| 7756 |
| 7757 int SetTextEx(LPCTSTR lpstrText, DWORD dwFlags = ST_DEFAULT, UINT uCodeP
age = CP_ACP) |
| 7758 { |
| 7759 ATLASSERT(::IsWindow(m_hWnd)); |
| 7760 SETTEXTEX ste = { 0 }; |
| 7761 ste.flags = dwFlags; |
| 7762 ste.codepage = uCodePage; |
| 7763 return (int)::SendMessage(m_hWnd, EM_SETTEXTEX, (WPARAM)&ste, (L
PARAM)lpstrText); |
| 7764 } |
| 7765 |
| 7766 int GetEditStyle() const |
| 7767 { |
| 7768 ATLASSERT(::IsWindow(m_hWnd)); |
| 7769 return (int)::SendMessage(m_hWnd, EM_GETEDITSTYLE, 0, 0L); |
| 7770 } |
| 7771 |
| 7772 int SetEditStyle(int nStyle, int nMask = -1) |
| 7773 { |
| 7774 ATLASSERT(::IsWindow(m_hWnd)); |
| 7775 if(nMask == -1) |
| 7776 nMask = nStyle; // set everything specified |
| 7777 return (int)::SendMessage(m_hWnd, EM_SETEDITSTYLE, nStyle, nMask
); |
| 7778 } |
| 7779 |
| 7780 BOOL SetFontSize(int nFontSizeDelta) |
| 7781 { |
| 7782 ATLASSERT(::IsWindow(m_hWnd)); |
| 7783 ATLASSERT(nFontSizeDelta >= -1637 && nFontSizeDelta <= 1638); |
| 7784 return (BOOL)::SendMessage(m_hWnd, EM_SETFONTSIZE, nFontSizeDelt
a, 0L); |
| 7785 } |
| 7786 |
| 7787 void GetScrollPos(LPPOINT lpPoint) const |
| 7788 { |
| 7789 ATLASSERT(::IsWindow(m_hWnd)); |
| 7790 ATLASSERT(lpPoint != NULL); |
| 7791 ::SendMessage(m_hWnd, EM_GETSCROLLPOS, 0, (LPARAM)lpPoint); |
| 7792 } |
| 7793 |
| 7794 void SetScrollPos(LPPOINT lpPoint) |
| 7795 { |
| 7796 ATLASSERT(::IsWindow(m_hWnd)); |
| 7797 ATLASSERT(lpPoint != NULL); |
| 7798 ::SendMessage(m_hWnd, EM_SETSCROLLPOS, 0, (LPARAM)lpPoint); |
| 7799 } |
| 7800 |
| 7801 BOOL GetZoom(int& nNum, int& nDen) const |
| 7802 { |
| 7803 ATLASSERT(::IsWindow(m_hWnd)); |
| 7804 return (BOOL)::SendMessage(m_hWnd, EM_GETZOOM, (WPARAM)&nNum, (L
PARAM)&nDen); |
| 7805 } |
| 7806 |
| 7807 BOOL SetZoom(int nNum, int nDen) |
| 7808 { |
| 7809 ATLASSERT(::IsWindow(m_hWnd)); |
| 7810 ATLASSERT(nNum >= 0 && nNum <= 64); |
| 7811 ATLASSERT(nDen >= 0 && nDen <= 64); |
| 7812 return (BOOL)::SendMessage(m_hWnd, EM_SETZOOM, nNum, nDen); |
| 7813 } |
| 7814 |
| 7815 BOOL SetZoomOff() |
| 7816 { |
| 7817 ATLASSERT(::IsWindow(m_hWnd)); |
| 7818 return (BOOL)::SendMessage(m_hWnd, EM_SETZOOM, 0, 0L); |
| 7819 } |
| 7820 #endif // (_RICHEDIT_VER >= 0x0300) |
| 7821 |
| 7822 // Operations |
| 7823 void LimitText(LONG nChars = 0) |
| 7824 { |
| 7825 ATLASSERT(::IsWindow(m_hWnd)); |
| 7826 ::SendMessage(m_hWnd, EM_EXLIMITTEXT, 0, nChars); |
| 7827 } |
| 7828 |
| 7829 int LineFromChar(LONG nIndex) const |
| 7830 { |
| 7831 ATLASSERT(::IsWindow(m_hWnd)); |
| 7832 return (int)::SendMessage(m_hWnd, EM_EXLINEFROMCHAR, 0, nIndex); |
| 7833 } |
| 7834 |
| 7835 POINT PosFromChar(LONG nChar) const |
| 7836 { |
| 7837 ATLASSERT(::IsWindow(m_hWnd)); |
| 7838 POINT point = { 0, 0 }; |
| 7839 ::SendMessage(m_hWnd, EM_POSFROMCHAR, (WPARAM)&point, nChar); |
| 7840 return point; |
| 7841 } |
| 7842 |
| 7843 int CharFromPos(POINT pt) const |
| 7844 { |
| 7845 ATLASSERT(::IsWindow(m_hWnd)); |
| 7846 POINTL ptl = { pt.x, pt.y }; |
| 7847 return (int)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, (LPARAM)&pt
l); |
| 7848 } |
| 7849 |
| 7850 void EmptyUndoBuffer() |
| 7851 { |
| 7852 ATLASSERT(::IsWindow(m_hWnd)); |
| 7853 ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L); |
| 7854 } |
| 7855 |
| 7856 int LineIndex(int nLine = -1) const |
| 7857 { |
| 7858 ATLASSERT(::IsWindow(m_hWnd)); |
| 7859 return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L); |
| 7860 } |
| 7861 |
| 7862 int LineLength(int nLine = -1) const |
| 7863 { |
| 7864 ATLASSERT(::IsWindow(m_hWnd)); |
| 7865 return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L); |
| 7866 } |
| 7867 |
| 7868 BOOL LineScroll(int nLines, int nChars = 0) |
| 7869 { |
| 7870 ATLASSERT(::IsWindow(m_hWnd)); |
| 7871 return (BOOL)::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines
); |
| 7872 } |
| 7873 |
| 7874 void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE) |
| 7875 { |
| 7876 ATLASSERT(::IsWindow(m_hWnd)); |
| 7877 ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)
lpszNewText); |
| 7878 } |
| 7879 |
| 7880 void SetRect(LPCRECT lpRect) |
| 7881 { |
| 7882 ATLASSERT(::IsWindow(m_hWnd)); |
| 7883 ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect); |
| 7884 } |
| 7885 |
| 7886 BOOL DisplayBand(LPRECT pDisplayRect) |
| 7887 { |
| 7888 ATLASSERT(::IsWindow(m_hWnd)); |
| 7889 return (BOOL)::SendMessage(m_hWnd, EM_DISPLAYBAND, 0, (LPARAM)pD
isplayRect); |
| 7890 } |
| 7891 |
| 7892 LONG FindText(DWORD dwFlags, FINDTEXT& ft) const |
| 7893 { |
| 7894 ATLASSERT(::IsWindow(m_hWnd)); |
| 7895 #if (_RICHEDIT_VER >= 0x0200) && defined(_UNICODE) |
| 7896 return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTW, dwFlags, (LPARA
M)&ft); |
| 7897 #else |
| 7898 return (LONG)::SendMessage(m_hWnd, EM_FINDTEXT, dwFlags, (LPARAM
)&ft); |
| 7899 #endif |
| 7900 } |
| 7901 |
| 7902 LONG FindText(DWORD dwFlags, FINDTEXTEX& ft) const |
| 7903 { |
| 7904 ATLASSERT(::IsWindow(m_hWnd)); |
| 7905 #if (_RICHEDIT_VER >= 0x0200) && defined(_UNICODE) |
| 7906 return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTEXW, dwFlags, (LPA
RAM)&ft); |
| 7907 #else |
| 7908 return (LONG)::SendMessage(m_hWnd, EM_FINDTEXTEX, dwFlags, (LPAR
AM)&ft); |
| 7909 #endif |
| 7910 } |
| 7911 |
| 7912 LONG FormatRange(FORMATRANGE& fr, BOOL bDisplay = TRUE) |
| 7913 { |
| 7914 ATLASSERT(::IsWindow(m_hWnd)); |
| 7915 return (LONG)::SendMessage(m_hWnd, EM_FORMATRANGE, bDisplay, (LP
ARAM)&fr); |
| 7916 } |
| 7917 |
| 7918 LONG FormatRange(FORMATRANGE* pFormatRange, BOOL bDisplay = TRUE) |
| 7919 { |
| 7920 ATLASSERT(::IsWindow(m_hWnd)); |
| 7921 return (LONG)::SendMessage(m_hWnd, EM_FORMATRANGE, bDisplay, (LP
ARAM)pFormatRange); |
| 7922 } |
| 7923 |
| 7924 void HideSelection(BOOL bHide = TRUE, BOOL bChangeStyle = FALSE) |
| 7925 { |
| 7926 ATLASSERT(::IsWindow(m_hWnd)); |
| 7927 ::SendMessage(m_hWnd, EM_HIDESELECTION, bHide, bChangeStyle); |
| 7928 } |
| 7929 |
| 7930 void PasteSpecial(UINT uClipFormat, DWORD dwAspect = 0, HMETAFILE hMF =
0) |
| 7931 { |
| 7932 ATLASSERT(::IsWindow(m_hWnd)); |
| 7933 REPASTESPECIAL reps = { dwAspect, (DWORD_PTR)hMF }; |
| 7934 ::SendMessage(m_hWnd, EM_PASTESPECIAL, uClipFormat, (LPARAM)&rep
s); |
| 7935 } |
| 7936 |
| 7937 void RequestResize() |
| 7938 { |
| 7939 ATLASSERT(::IsWindow(m_hWnd)); |
| 7940 ::SendMessage(m_hWnd, EM_REQUESTRESIZE, 0, 0L); |
| 7941 } |
| 7942 |
| 7943 LONG StreamIn(UINT uFormat, EDITSTREAM& es) |
| 7944 { |
| 7945 ATLASSERT(::IsWindow(m_hWnd)); |
| 7946 return (LONG)::SendMessage(m_hWnd, EM_STREAMIN, uFormat, (LPARAM
)&es); |
| 7947 } |
| 7948 |
| 7949 LONG StreamOut(UINT uFormat, EDITSTREAM& es) |
| 7950 { |
| 7951 ATLASSERT(::IsWindow(m_hWnd)); |
| 7952 return (LONG)::SendMessage(m_hWnd, EM_STREAMOUT, uFormat, (LPARA
M)&es); |
| 7953 } |
| 7954 |
| 7955 DWORD FindWordBreak(int nCode, LONG nStartChar) |
| 7956 { |
| 7957 ATLASSERT(::IsWindow(m_hWnd)); |
| 7958 return (DWORD)::SendMessage(m_hWnd, EM_FINDWORDBREAK, nCode, nSt
artChar); |
| 7959 } |
| 7960 |
| 7961 // Additional operations |
| 7962 void ScrollCaret() |
| 7963 { |
| 7964 ATLASSERT(::IsWindow(m_hWnd)); |
| 7965 ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L); |
| 7966 } |
| 7967 |
| 7968 int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo =
FALSE) |
| 7969 { |
| 7970 int nRet = SetSel(nInsertAfterChar, nInsertAfterChar); |
| 7971 ReplaceSel(lpstrText, bCanUndo); |
| 7972 return nRet; |
| 7973 } |
| 7974 |
| 7975 int AppendText(LPCTSTR lpstrText, BOOL bCanUndo = FALSE) |
| 7976 { |
| 7977 return InsertText(GetWindowTextLength(), lpstrText, bCanUndo); |
| 7978 } |
| 7979 |
| 7980 // Clipboard operations |
| 7981 BOOL Undo() |
| 7982 { |
| 7983 ATLASSERT(::IsWindow(m_hWnd)); |
| 7984 return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L); |
| 7985 } |
| 7986 |
| 7987 void Clear() |
| 7988 { |
| 7989 ATLASSERT(::IsWindow(m_hWnd)); |
| 7990 ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L); |
| 7991 } |
| 7992 |
| 7993 void Copy() |
| 7994 { |
| 7995 ATLASSERT(::IsWindow(m_hWnd)); |
| 7996 ::SendMessage(m_hWnd, WM_COPY, 0, 0L); |
| 7997 } |
| 7998 |
| 7999 void Cut() |
| 8000 { |
| 8001 ATLASSERT(::IsWindow(m_hWnd)); |
| 8002 ::SendMessage(m_hWnd, WM_CUT, 0, 0L); |
| 8003 } |
| 8004 |
| 8005 void Paste() |
| 8006 { |
| 8007 ATLASSERT(::IsWindow(m_hWnd)); |
| 8008 ::SendMessage(m_hWnd, WM_PASTE, 0, 0L); |
| 8009 } |
| 8010 |
| 8011 // OLE support |
| 8012 IRichEditOle* GetOleInterface() const |
| 8013 { |
| 8014 ATLASSERT(::IsWindow(m_hWnd)); |
| 8015 IRichEditOle *pRichEditOle = NULL; |
| 8016 ::SendMessage(m_hWnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditO
le); |
| 8017 return pRichEditOle; |
| 8018 } |
| 8019 |
| 8020 BOOL SetOleCallback(IRichEditOleCallback* pCallback) |
| 8021 { |
| 8022 ATLASSERT(::IsWindow(m_hWnd)); |
| 8023 return (BOOL)::SendMessage(m_hWnd, EM_SETOLECALLBACK, 0, (LPARAM
)pCallback); |
| 8024 } |
| 8025 |
| 8026 #if (_RICHEDIT_VER >= 0x0200) |
| 8027 BOOL Redo() |
| 8028 { |
| 8029 ATLASSERT(::IsWindow(m_hWnd)); |
| 8030 return (BOOL)::SendMessage(m_hWnd, EM_REDO, 0, 0L); |
| 8031 } |
| 8032 |
| 8033 void StopGroupTyping() |
| 8034 { |
| 8035 ATLASSERT(::IsWindow(m_hWnd)); |
| 8036 ::SendMessage(m_hWnd, EM_STOPGROUPTYPING, 0, 0L); |
| 8037 } |
| 8038 |
| 8039 void ShowScrollBar(int nBarType, BOOL bVisible = TRUE) |
| 8040 { |
| 8041 ATLASSERT(::IsWindow(m_hWnd)); |
| 8042 ::SendMessage(m_hWnd, EM_SHOWSCROLLBAR, nBarType, bVisible); |
| 8043 } |
| 8044 #endif // (_RICHEDIT_VER >= 0x0200) |
| 8045 |
| 8046 #if (_RICHEDIT_VER >= 0x0300) |
| 8047 BOOL SetTabStops(int nTabStops, LPINT rgTabStops) |
| 8048 { |
| 8049 ATLASSERT(::IsWindow(m_hWnd)); |
| 8050 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (L
PARAM)rgTabStops); |
| 8051 } |
| 8052 |
| 8053 BOOL SetTabStops() |
| 8054 { |
| 8055 ATLASSERT(::IsWindow(m_hWnd)); |
| 8056 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L); |
| 8057 } |
| 8058 |
| 8059 BOOL SetTabStops(const int& cxEachStop) // takes an 'int' |
| 8060 { |
| 8061 ATLASSERT(::IsWindow(m_hWnd)); |
| 8062 return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(L
PINT)&cxEachStop); |
| 8063 } |
| 8064 #endif // (_RICHEDIT_VER >= 0x0300) |
| 8065 }; |
| 8066 |
| 8067 typedef CRichEditCtrlT<ATL::CWindow> CRichEditCtrl; |
| 8068 |
| 8069 #endif // !_WIN32_WCE |
| 8070 |
| 8071 |
| 8072 /////////////////////////////////////////////////////////////////////////////// |
| 8073 // CRichEditCommands - message handlers for standard EDIT commands |
| 8074 |
| 8075 #ifndef _WIN32_WCE |
| 8076 |
| 8077 // Chain to CRichEditCommands message map. Your class must also derive from CRic
hEditCtrl. |
| 8078 // Example: |
| 8079 // class CMyRichEdit : public CWindowImpl<CMyRichEdit, CRichEditCtrl>, |
| 8080 // public CRichEditCommands<CMyRichEdit> |
| 8081 // { |
| 8082 // public: |
| 8083 // BEGIN_MSG_MAP(CMyRichEdit) |
| 8084 // // your handlers... |
| 8085 // CHAIN_MSG_MAP_ALT(CRichEditCommands<CMyRichEdit>, 1) |
| 8086 // END_MSG_MAP() |
| 8087 // // other stuff... |
| 8088 // }; |
| 8089 |
| 8090 template <class T> |
| 8091 class CRichEditCommands : public CEditCommands< T > |
| 8092 { |
| 8093 public: |
| 8094 BEGIN_MSG_MAP(CRichEditCommands< T >) |
| 8095 ALT_MSG_MAP(1) |
| 8096 COMMAND_ID_HANDLER(ID_EDIT_CLEAR, CEditCommands< T >::OnEditClea
r) |
| 8097 COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, CEditCommands< T >::OnEdit
ClearAll) |
| 8098 COMMAND_ID_HANDLER(ID_EDIT_COPY, CEditCommands< T >::OnEditCopy) |
| 8099 COMMAND_ID_HANDLER(ID_EDIT_CUT, CEditCommands< T >::OnEditCut) |
| 8100 COMMAND_ID_HANDLER(ID_EDIT_PASTE, CEditCommands< T >::OnEditPast
e) |
| 8101 COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, CEditCommands< T >::OnEdi
tSelectAll) |
| 8102 COMMAND_ID_HANDLER(ID_EDIT_UNDO, CEditCommands< T >::OnEditUndo) |
| 8103 #if (_RICHEDIT_VER >= 0x0200) |
| 8104 COMMAND_ID_HANDLER(ID_EDIT_REDO, OnEditRedo) |
| 8105 #endif // (_RICHEDIT_VER >= 0x0200) |
| 8106 END_MSG_MAP() |
| 8107 |
| 8108 #if (_RICHEDIT_VER >= 0x0200) |
| 8109 LRESULT OnEditRedo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/,
BOOL& /*bHandled*/) |
| 8110 { |
| 8111 T* pT = static_cast<T*>(this); |
| 8112 pT->Redo(); |
| 8113 return 0; |
| 8114 } |
| 8115 #endif // (_RICHEDIT_VER >= 0x0200) |
| 8116 |
| 8117 // State (update UI) helpers |
| 8118 BOOL CanCut() const |
| 8119 { return HasSelection(); } |
| 8120 |
| 8121 BOOL CanCopy() const |
| 8122 { return HasSelection(); } |
| 8123 |
| 8124 BOOL CanClear() const |
| 8125 { return HasSelection(); } |
| 8126 |
| 8127 // Implementation |
| 8128 BOOL HasSelection() const |
| 8129 { |
| 8130 const T* pT = static_cast<const T*>(this); |
| 8131 return (pT->GetSelectionType() != SEL_EMPTY); |
| 8132 } |
| 8133 }; |
| 8134 |
| 8135 #endif // _WIN32_WCE |
| 8136 |
| 8137 |
| 8138 /////////////////////////////////////////////////////////////////////////////// |
| 8139 // CDragListBox |
| 8140 |
| 8141 #ifndef _WIN32_WCE |
| 8142 |
| 8143 template <class TBase> |
| 8144 class CDragListBoxT : public CListBoxT< TBase > |
| 8145 { |
| 8146 public: |
| 8147 // Constructors |
| 8148 CDragListBoxT(HWND hWnd = NULL) : CListBoxT< TBase >(hWnd) |
| 8149 { } |
| 8150 |
| 8151 CDragListBoxT< TBase >& operator =(HWND hWnd) |
| 8152 { |
| 8153 m_hWnd = hWnd; |
| 8154 return *this; |
| 8155 } |
| 8156 |
| 8157 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 8158 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 8159 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 8160 { |
| 8161 HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_
lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 8162 if(hWnd != NULL) |
| 8163 MakeDragList(); |
| 8164 return hWnd; |
| 8165 } |
| 8166 |
| 8167 // Operations |
| 8168 BOOL MakeDragList() |
| 8169 { |
| 8170 ATLASSERT(::IsWindow(m_hWnd)); |
| 8171 ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) ==
0); |
| 8172 return ::MakeDragList(m_hWnd); |
| 8173 } |
| 8174 |
| 8175 int LBItemFromPt(POINT pt, BOOL bAutoScroll = TRUE) |
| 8176 { |
| 8177 ATLASSERT(::IsWindow(m_hWnd)); |
| 8178 return ::LBItemFromPt(m_hWnd, pt, bAutoScroll); |
| 8179 } |
| 8180 |
| 8181 void DrawInsert(int nItem) |
| 8182 { |
| 8183 ATLASSERT(::IsWindow(m_hWnd)); |
| 8184 ::DrawInsert(GetParent(), m_hWnd, nItem); |
| 8185 } |
| 8186 |
| 8187 static UINT GetDragListMessage() |
| 8188 { |
| 8189 static UINT uDragListMessage = 0; |
| 8190 if(uDragListMessage == 0) |
| 8191 { |
| 8192 CStaticDataInitCriticalSectionLock lock; |
| 8193 if(FAILED(lock.Lock())) |
| 8194 { |
| 8195 ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to l
ock critical section in CDragListBox::GetDragListMessage.\n")); |
| 8196 ATLASSERT(FALSE); |
| 8197 return 0; |
| 8198 } |
| 8199 |
| 8200 if(uDragListMessage == 0) |
| 8201 uDragListMessage = ::RegisterWindowMessage(DRAGL
ISTMSGSTRING); |
| 8202 |
| 8203 lock.Unlock(); |
| 8204 } |
| 8205 ATLASSERT(uDragListMessage != 0); |
| 8206 return uDragListMessage; |
| 8207 } |
| 8208 }; |
| 8209 |
| 8210 typedef CDragListBoxT<ATL::CWindow> CDragListBox; |
| 8211 |
| 8212 template <class T> |
| 8213 class CDragListNotifyImpl |
| 8214 { |
| 8215 public: |
| 8216 BEGIN_MSG_MAP(CDragListNotifyImpl< T >) |
| 8217 MESSAGE_HANDLER(CDragListBox::GetDragListMessage(), OnDragListNo
tify) |
| 8218 END_MSG_MAP() |
| 8219 |
| 8220 LRESULT OnDragListNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled) |
| 8221 { |
| 8222 uMsg; // avoid level 4 warning |
| 8223 ATLASSERT(uMsg == CDragListBox::GetDragListMessage()); |
| 8224 T* pT = static_cast<T*>(this); |
| 8225 LPDRAGLISTINFO lpDragListInfo = (LPDRAGLISTINFO)lParam; |
| 8226 LRESULT lRet = 0; |
| 8227 switch(lpDragListInfo->uNotification) |
| 8228 { |
| 8229 case DL_BEGINDRAG: |
| 8230 lRet = (LPARAM)pT->OnBeginDrag((int)wParam, lpDragListIn
fo->hWnd, lpDragListInfo->ptCursor); |
| 8231 break; |
| 8232 case DL_CANCELDRAG: |
| 8233 pT->OnCancelDrag((int)wParam, lpDragListInfo->hWnd, lpDr
agListInfo->ptCursor); |
| 8234 break; |
| 8235 case DL_DRAGGING: |
| 8236 lRet = (LPARAM)pT->OnDragging((int)wParam, lpDragListInf
o->hWnd, lpDragListInfo->ptCursor); |
| 8237 break; |
| 8238 case DL_DROPPED: |
| 8239 pT->OnDropped((int)wParam, lpDragListInfo->hWnd, lpDragL
istInfo->ptCursor); |
| 8240 break; |
| 8241 default: |
| 8242 ATLTRACE2(atlTraceUI, 0, _T("Unknown DragListBox notific
ation\n")); |
| 8243 bHandled = FALSE; // don't handle it |
| 8244 break; |
| 8245 } |
| 8246 return lRet; |
| 8247 } |
| 8248 |
| 8249 // Overrideables |
| 8250 BOOL OnBeginDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor
*/) |
| 8251 { |
| 8252 return TRUE; // allow dragging |
| 8253 } |
| 8254 |
| 8255 void OnCancelDrag(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCurso
r*/) |
| 8256 { |
| 8257 // nothing to do |
| 8258 } |
| 8259 |
| 8260 int OnDragging(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/
) |
| 8261 { |
| 8262 return 0; // don't change cursor |
| 8263 } |
| 8264 |
| 8265 void OnDropped(int /*nCtlID*/, HWND /*hWndDragList*/, POINT /*ptCursor*/
) |
| 8266 { |
| 8267 // nothing to do |
| 8268 } |
| 8269 }; |
| 8270 |
| 8271 #endif // _WIN32_WCE |
| 8272 |
| 8273 |
| 8274 /////////////////////////////////////////////////////////////////////////////// |
| 8275 // CReBarCtrl |
| 8276 |
| 8277 template <class TBase> |
| 8278 class CReBarCtrlT : public TBase |
| 8279 { |
| 8280 public: |
| 8281 // Constructors |
| 8282 CReBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 8283 { } |
| 8284 |
| 8285 CReBarCtrlT< TBase >& operator =(HWND hWnd) |
| 8286 { |
| 8287 m_hWnd = hWnd; |
| 8288 return *this; |
| 8289 } |
| 8290 |
| 8291 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 8292 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 8293 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 8294 { |
| 8295 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 8296 } |
| 8297 |
| 8298 // Attributes |
| 8299 static LPCTSTR GetWndClassName() |
| 8300 { |
| 8301 return REBARCLASSNAME; |
| 8302 } |
| 8303 |
| 8304 UINT GetBandCount() const |
| 8305 { |
| 8306 ATLASSERT(::IsWindow(m_hWnd)); |
| 8307 return (UINT)::SendMessage(m_hWnd, RB_GETBANDCOUNT, 0, 0L); |
| 8308 } |
| 8309 |
| 8310 BOOL GetBandInfo(int nBand, LPREBARBANDINFO lprbbi) const |
| 8311 { |
| 8312 ATLASSERT(::IsWindow(m_hWnd)); |
| 8313 return (BOOL)::SendMessage(m_hWnd, RB_GETBANDINFO, nBand, (LPARA
M)lprbbi); |
| 8314 } |
| 8315 |
| 8316 BOOL SetBandInfo(int nBand, LPREBARBANDINFO lprbbi) |
| 8317 { |
| 8318 ATLASSERT(::IsWindow(m_hWnd)); |
| 8319 return (BOOL)::SendMessage(m_hWnd, RB_SETBANDINFO, nBand, (LPARA
M)lprbbi); |
| 8320 } |
| 8321 |
| 8322 BOOL GetBarInfo(LPREBARINFO lprbi) const |
| 8323 { |
| 8324 ATLASSERT(::IsWindow(m_hWnd)); |
| 8325 return (BOOL)::SendMessage(m_hWnd, RB_GETBARINFO, 0, (LPARAM)lpr
bi); |
| 8326 } |
| 8327 |
| 8328 BOOL SetBarInfo(LPREBARINFO lprbi) |
| 8329 { |
| 8330 ATLASSERT(::IsWindow(m_hWnd)); |
| 8331 return (BOOL)::SendMessage(m_hWnd, RB_SETBARINFO, 0, (LPARAM)lpr
bi); |
| 8332 } |
| 8333 |
| 8334 CImageList GetImageList() const |
| 8335 { |
| 8336 ATLASSERT(::IsWindow(m_hWnd)); |
| 8337 REBARINFO rbi = { 0 }; |
| 8338 rbi.cbSize = sizeof(REBARINFO); |
| 8339 rbi.fMask = RBIM_IMAGELIST; |
| 8340 if( (BOOL)::SendMessage(m_hWnd, RB_GETBARINFO, 0, (LPARAM)&rbi)
== FALSE ) return CImageList(); |
| 8341 return CImageList(rbi.himl); |
| 8342 } |
| 8343 |
| 8344 BOOL SetImageList(HIMAGELIST hImageList) |
| 8345 { |
| 8346 ATLASSERT(::IsWindow(m_hWnd)); |
| 8347 REBARINFO rbi = { 0 }; |
| 8348 rbi.cbSize = sizeof(REBARINFO); |
| 8349 rbi.fMask = RBIM_IMAGELIST; |
| 8350 rbi.himl = hImageList; |
| 8351 return (BOOL)::SendMessage(m_hWnd, RB_SETBARINFO, 0, (LPARAM)&rb
i); |
| 8352 } |
| 8353 |
| 8354 UINT GetRowCount() const |
| 8355 { |
| 8356 ATLASSERT(::IsWindow(m_hWnd)); |
| 8357 return (UINT)::SendMessage(m_hWnd, RB_GETROWCOUNT, 0, 0L); |
| 8358 } |
| 8359 |
| 8360 UINT GetRowHeight(int nBand) const |
| 8361 { |
| 8362 ATLASSERT(::IsWindow(m_hWnd)); |
| 8363 return (UINT)::SendMessage(m_hWnd, RB_GETROWHEIGHT, nBand, 0L); |
| 8364 } |
| 8365 |
| 8366 #if (_WIN32_IE >= 0x0400) |
| 8367 COLORREF GetTextColor() const |
| 8368 { |
| 8369 ATLASSERT(::IsWindow(m_hWnd)); |
| 8370 return (COLORREF)::SendMessage(m_hWnd, RB_GETTEXTCOLOR, 0, 0L); |
| 8371 } |
| 8372 |
| 8373 COLORREF SetTextColor(COLORREF clr) |
| 8374 { |
| 8375 ATLASSERT(::IsWindow(m_hWnd)); |
| 8376 return (COLORREF)::SendMessage(m_hWnd, RB_SETTEXTCOLOR, 0, (LPAR
AM)clr); |
| 8377 } |
| 8378 |
| 8379 COLORREF GetBkColor() const |
| 8380 { |
| 8381 ATLASSERT(::IsWindow(m_hWnd)); |
| 8382 return (COLORREF)::SendMessage(m_hWnd, RB_GETBKCOLOR, 0, 0L); |
| 8383 } |
| 8384 |
| 8385 COLORREF SetBkColor(COLORREF clr) |
| 8386 { |
| 8387 ATLASSERT(::IsWindow(m_hWnd)); |
| 8388 return (COLORREF)::SendMessage(m_hWnd, RB_SETBKCOLOR, 0, (LPARAM
)clr); |
| 8389 } |
| 8390 |
| 8391 UINT GetBarHeight() const |
| 8392 { |
| 8393 ATLASSERT(::IsWindow(m_hWnd)); |
| 8394 return (UINT)::SendMessage(m_hWnd, RB_GETBARHEIGHT, 0, 0L); |
| 8395 } |
| 8396 |
| 8397 BOOL GetRect(int nBand, LPRECT lpRect) const |
| 8398 { |
| 8399 ATLASSERT(::IsWindow(m_hWnd)); |
| 8400 return (BOOL)::SendMessage(m_hWnd, RB_GETRECT, nBand, (LPARAM)lp
Rect); |
| 8401 } |
| 8402 |
| 8403 #ifndef _WIN32_WCE |
| 8404 CToolTipCtrl GetToolTips() const |
| 8405 { |
| 8406 ATLASSERT(::IsWindow(m_hWnd)); |
| 8407 return CToolTipCtrl((HWND)::SendMessage(m_hWnd, RB_GETTOOLTIPS,
0, 0L)); |
| 8408 } |
| 8409 |
| 8410 void SetToolTips(HWND hwndToolTip) |
| 8411 { |
| 8412 ATLASSERT(::IsWindow(m_hWnd)); |
| 8413 ::SendMessage(m_hWnd, RB_SETTOOLTIPS, (WPARAM)hwndToolTip, 0L); |
| 8414 } |
| 8415 #endif // !_WIN32_WCE |
| 8416 |
| 8417 void GetBandBorders(int nBand, LPRECT lpRect) const |
| 8418 { |
| 8419 ATLASSERT(::IsWindow(m_hWnd)); |
| 8420 ATLASSERT(lpRect != NULL); |
| 8421 ::SendMessage(m_hWnd, RB_GETBANDBORDERS, nBand, (LPARAM)lpRect); |
| 8422 } |
| 8423 |
| 8424 #ifndef _WIN32_WCE |
| 8425 BOOL GetColorScheme(LPCOLORSCHEME lpColorScheme) const |
| 8426 { |
| 8427 ATLASSERT(::IsWindow(m_hWnd)); |
| 8428 ATLASSERT(lpColorScheme != NULL); |
| 8429 return (BOOL)::SendMessage(m_hWnd, RB_GETCOLORSCHEME, 0, (LPARAM
)lpColorScheme); |
| 8430 } |
| 8431 |
| 8432 void SetColorScheme(LPCOLORSCHEME lpColorScheme) |
| 8433 { |
| 8434 ATLASSERT(::IsWindow(m_hWnd)); |
| 8435 ATLASSERT(lpColorScheme != NULL); |
| 8436 ::SendMessage(m_hWnd, RB_SETCOLORSCHEME, 0, (LPARAM)lpColorSchem
e); |
| 8437 } |
| 8438 |
| 8439 HPALETTE GetPalette() const |
| 8440 { |
| 8441 ATLASSERT(::IsWindow(m_hWnd)); |
| 8442 return (HPALETTE)::SendMessage(m_hWnd, RB_GETPALETTE, 0, 0L); |
| 8443 } |
| 8444 |
| 8445 HPALETTE SetPalette(HPALETTE hPalette) |
| 8446 { |
| 8447 ATLASSERT(::IsWindow(m_hWnd)); |
| 8448 return (HPALETTE)::SendMessage(m_hWnd, RB_SETPALETTE, 0, (LPARAM
)hPalette); |
| 8449 } |
| 8450 |
| 8451 BOOL GetUnicodeFormat() const |
| 8452 { |
| 8453 ATLASSERT(::IsWindow(m_hWnd)); |
| 8454 return (BOOL)::SendMessage(m_hWnd, RB_GETUNICODEFORMAT, 0, 0L); |
| 8455 } |
| 8456 |
| 8457 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 8458 { |
| 8459 ATLASSERT(::IsWindow(m_hWnd)); |
| 8460 return (BOOL)::SendMessage(m_hWnd, RB_SETUNICODEFORMAT, bUnicode
, 0L); |
| 8461 } |
| 8462 #endif // !_WIN32_WCE |
| 8463 #endif // (_WIN32_IE >= 0x0400) |
| 8464 |
| 8465 #if (_WIN32_WINNT >= 0x0501) |
| 8466 // requires uxtheme.h to be included to use MARGINS struct |
| 8467 #ifndef _UXTHEME_H_ |
| 8468 typedef struct _MARGINS* PMARGINS; |
| 8469 #endif // !_UXTHEME_H_ |
| 8470 void GetBandMargins(PMARGINS pMargins) const |
| 8471 { |
| 8472 ATLASSERT(::IsWindow(m_hWnd)); |
| 8473 ::SendMessage(m_hWnd, RB_GETBANDMARGINS, 0, (LPARAM)pMargins); |
| 8474 } |
| 8475 |
| 8476 void SetWindowTheme(LPCWSTR lpstrTheme) |
| 8477 { |
| 8478 ATLASSERT(::IsWindow(m_hWnd)); |
| 8479 ::SendMessage(m_hWnd, RB_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme); |
| 8480 } |
| 8481 #endif // (_WIN32_WINNT >= 0x0501) |
| 8482 |
| 8483 #if (_WIN32_IE >= 0x0600) |
| 8484 DWORD GetExtendedStyle() const |
| 8485 { |
| 8486 ATLASSERT(::IsWindow(m_hWnd)); |
| 8487 return (DWORD)::SendMessage(m_hWnd, RB_GETEXTENDEDSTYLE, 0, 0L); |
| 8488 } |
| 8489 |
| 8490 DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask) |
| 8491 { |
| 8492 ATLASSERT(::IsWindow(m_hWnd)); |
| 8493 return (DWORD)::SendMessage(m_hWnd, RB_SETEXTENDEDSTYLE, dwMask,
dwStyle); |
| 8494 } |
| 8495 #endif // (_WIN32_IE >= 0x0600) |
| 8496 |
| 8497 // Operations |
| 8498 BOOL InsertBand(int nBand, LPREBARBANDINFO lprbbi) |
| 8499 { |
| 8500 ATLASSERT(::IsWindow(m_hWnd)); |
| 8501 return (BOOL)::SendMessage(m_hWnd, RB_INSERTBAND, nBand, (LPARAM
)lprbbi); |
| 8502 } |
| 8503 |
| 8504 BOOL AddBand(LPREBARBANDINFO lprbbi) |
| 8505 { |
| 8506 return InsertBand(-1, lprbbi); |
| 8507 } |
| 8508 |
| 8509 BOOL DeleteBand(int nBand) |
| 8510 { |
| 8511 ATLASSERT(::IsWindow(m_hWnd)); |
| 8512 return (BOOL)::SendMessage(m_hWnd, RB_DELETEBAND, nBand, 0L); |
| 8513 } |
| 8514 |
| 8515 ATL::CWindow SetNotifyWnd(HWND hWnd) |
| 8516 { |
| 8517 ATLASSERT(::IsWindow(m_hWnd)); |
| 8518 return ATL::CWindow((HWND)::SendMessage(m_hWnd, RB_SETPARENT, (W
PARAM)hWnd, 0L)); |
| 8519 } |
| 8520 |
| 8521 #if (_WIN32_IE >= 0x0400) |
| 8522 void BeginDrag(int nBand, DWORD dwPos) |
| 8523 { |
| 8524 ATLASSERT(::IsWindow(m_hWnd)); |
| 8525 ::SendMessage(m_hWnd, RB_BEGINDRAG, nBand, dwPos); |
| 8526 } |
| 8527 |
| 8528 void BeginDrag(int nBand, int xPos, int yPos) |
| 8529 { |
| 8530 ATLASSERT(::IsWindow(m_hWnd)); |
| 8531 ::SendMessage(m_hWnd, RB_BEGINDRAG, nBand, MAKELPARAM(xPos, yPos
)); |
| 8532 } |
| 8533 |
| 8534 void EndDrag() |
| 8535 { |
| 8536 ATLASSERT(::IsWindow(m_hWnd)); |
| 8537 ::SendMessage(m_hWnd, RB_ENDDRAG, 0, 0L); |
| 8538 } |
| 8539 |
| 8540 void DragMove(DWORD dwPos) |
| 8541 { |
| 8542 ATLASSERT(::IsWindow(m_hWnd)); |
| 8543 ::SendMessage(m_hWnd, RB_DRAGMOVE, 0, dwPos); |
| 8544 } |
| 8545 |
| 8546 void DragMove(int xPos, int yPos) |
| 8547 { |
| 8548 ATLASSERT(::IsWindow(m_hWnd)); |
| 8549 ::SendMessage(m_hWnd, RB_DRAGMOVE, 0, MAKELPARAM(xPos, yPos)); |
| 8550 } |
| 8551 |
| 8552 #ifndef _WIN32_WCE |
| 8553 void GetDropTarget(IDropTarget** ppDropTarget) const |
| 8554 { |
| 8555 ATLASSERT(::IsWindow(m_hWnd)); |
| 8556 ::SendMessage(m_hWnd, RB_GETDROPTARGET, 0, (LPARAM)ppDropTarget)
; |
| 8557 } |
| 8558 #endif // !_WIN32_WCE |
| 8559 |
| 8560 void MaximizeBand(int nBand, BOOL bIdeal = FALSE) |
| 8561 { |
| 8562 ATLASSERT(::IsWindow(m_hWnd)); |
| 8563 ::SendMessage(m_hWnd, RB_MAXIMIZEBAND, nBand, bIdeal); |
| 8564 } |
| 8565 |
| 8566 void MinimizeBand(int nBand) |
| 8567 { |
| 8568 ATLASSERT(::IsWindow(m_hWnd)); |
| 8569 ::SendMessage(m_hWnd, RB_MINIMIZEBAND, nBand, 0L); |
| 8570 } |
| 8571 |
| 8572 BOOL SizeToRect(LPRECT lpRect) |
| 8573 { |
| 8574 ATLASSERT(::IsWindow(m_hWnd)); |
| 8575 return (BOOL)::SendMessage(m_hWnd, RB_SIZETORECT, 0, (LPARAM)lpR
ect); |
| 8576 } |
| 8577 |
| 8578 int IdToIndex(UINT uBandID) const |
| 8579 { |
| 8580 ATLASSERT(::IsWindow(m_hWnd)); |
| 8581 return (int)::SendMessage(m_hWnd, RB_IDTOINDEX, uBandID, 0L); |
| 8582 } |
| 8583 |
| 8584 int HitTest(LPRBHITTESTINFO lprbht) const |
| 8585 { |
| 8586 ATLASSERT(::IsWindow(m_hWnd)); |
| 8587 return (int)::SendMessage(m_hWnd, RB_HITTEST, 0, (LPARAM)lprbht)
; |
| 8588 } |
| 8589 |
| 8590 BOOL ShowBand(int nBand, BOOL bShow) |
| 8591 { |
| 8592 ATLASSERT(::IsWindow(m_hWnd)); |
| 8593 return (BOOL)::SendMessage(m_hWnd, RB_SHOWBAND, nBand, bShow); |
| 8594 } |
| 8595 |
| 8596 #ifndef _WIN32_WCE |
| 8597 BOOL MoveBand(int nBand, int nNewPos) |
| 8598 { |
| 8599 ATLASSERT(::IsWindow(m_hWnd)); |
| 8600 ATLASSERT(nNewPos >= 0 && nNewPos <= ((int)GetBandCount() - 1)); |
| 8601 return (BOOL)::SendMessage(m_hWnd, RB_MOVEBAND, nBand, nNewPos); |
| 8602 } |
| 8603 #endif // !_WIN32_WCE |
| 8604 #endif // (_WIN32_IE >= 0x0400) |
| 8605 |
| 8606 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 8607 void PushChevron(int nBand, LPARAM lAppValue) |
| 8608 { |
| 8609 ATLASSERT(::IsWindow(m_hWnd)); |
| 8610 ::SendMessage(m_hWnd, RB_PUSHCHEVRON, nBand, lAppValue); |
| 8611 } |
| 8612 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) |
| 8613 |
| 8614 // Extra operations |
| 8615 #if (_WIN32_IE >= 0x0400) |
| 8616 void LockBands(bool bLock) |
| 8617 { |
| 8618 int nBandCount = GetBandCount(); |
| 8619 for(int i =0; i < nBandCount; i++) |
| 8620 { |
| 8621 REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDIN
FO() }; |
| 8622 rbbi.fMask = RBBIM_STYLE; |
| 8623 BOOL bRet = GetBandInfo(i, &rbbi); |
| 8624 ATLASSERT(bRet); |
| 8625 |
| 8626 if((rbbi.fStyle & RBBS_GRIPPERALWAYS) == 0) |
| 8627 { |
| 8628 rbbi.fStyle |= RBBS_GRIPPERALWAYS; |
| 8629 bRet = SetBandInfo(i, &rbbi); |
| 8630 ATLASSERT(bRet); |
| 8631 rbbi.fStyle &= ~RBBS_GRIPPERALWAYS; |
| 8632 } |
| 8633 |
| 8634 if(bLock) |
| 8635 rbbi.fStyle |= RBBS_NOGRIPPER; |
| 8636 else |
| 8637 rbbi.fStyle &= ~RBBS_NOGRIPPER; |
| 8638 |
| 8639 bRet = SetBandInfo(i, &rbbi); |
| 8640 ATLASSERT(bRet); |
| 8641 } |
| 8642 } |
| 8643 #endif // (_WIN32_IE >= 0x0400) |
| 8644 |
| 8645 #if (_WIN32_WINNT >= 0x0600) |
| 8646 BOOL SetBandWidth(int nBand, int cxWidth) |
| 8647 { |
| 8648 ATLASSERT(::IsWindow(m_hWnd)); |
| 8649 return (BOOL)::SendMessage(m_hWnd, RB_SETBANDWIDTH, nBand, cxWid
th); |
| 8650 } |
| 8651 #endif // (_WIN32_WINNT >= 0x0600) |
| 8652 }; |
| 8653 |
| 8654 typedef CReBarCtrlT<ATL::CWindow> CReBarCtrl; |
| 8655 |
| 8656 |
| 8657 /////////////////////////////////////////////////////////////////////////////// |
| 8658 // CComboBoxEx |
| 8659 |
| 8660 #ifndef _WIN32_WCE |
| 8661 |
| 8662 template <class TBase> |
| 8663 class CComboBoxExT : public CComboBoxT< TBase > |
| 8664 { |
| 8665 public: |
| 8666 // Constructors |
| 8667 CComboBoxExT(HWND hWnd = NULL) : CComboBoxT< TBase >(hWnd) |
| 8668 { } |
| 8669 |
| 8670 CComboBoxExT< TBase >& operator =(HWND hWnd) |
| 8671 { |
| 8672 m_hWnd = hWnd; |
| 8673 return *this; |
| 8674 } |
| 8675 |
| 8676 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 8677 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 8678 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 8679 { |
| 8680 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 8681 } |
| 8682 |
| 8683 // Attributes |
| 8684 static LPCTSTR GetWndClassName() |
| 8685 { |
| 8686 return WC_COMBOBOXEX; |
| 8687 } |
| 8688 |
| 8689 CImageList GetImageList() const |
| 8690 { |
| 8691 ATLASSERT(::IsWindow(m_hWnd)); |
| 8692 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, CBEM_GETIMAG
ELIST, 0, 0L)); |
| 8693 } |
| 8694 |
| 8695 CImageList SetImageList(HIMAGELIST hImageList) |
| 8696 { |
| 8697 ATLASSERT(::IsWindow(m_hWnd)); |
| 8698 return CImageList((HIMAGELIST)::SendMessage(m_hWnd, CBEM_SETIMAG
ELIST, 0, (LPARAM)hImageList)); |
| 8699 } |
| 8700 |
| 8701 #if (_WIN32_IE >= 0x0400) |
| 8702 DWORD GetExtendedStyle() const |
| 8703 { |
| 8704 ATLASSERT(::IsWindow(m_hWnd)); |
| 8705 return (DWORD)::SendMessage(m_hWnd, CBEM_GETEXTENDEDSTYLE, 0, 0L
); |
| 8706 } |
| 8707 |
| 8708 DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle) |
| 8709 { |
| 8710 ATLASSERT(::IsWindow(m_hWnd)); |
| 8711 return (DWORD)::SendMessage(m_hWnd, CBEM_SETEXTENDEDSTYLE, dwExM
ask, dwExStyle); |
| 8712 } |
| 8713 |
| 8714 BOOL GetUnicodeFormat() const |
| 8715 { |
| 8716 ATLASSERT(::IsWindow(m_hWnd)); |
| 8717 return (BOOL)::SendMessage(m_hWnd, CBEM_GETUNICODEFORMAT, 0, 0L)
; |
| 8718 } |
| 8719 |
| 8720 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 8721 { |
| 8722 ATLASSERT(::IsWindow(m_hWnd)); |
| 8723 return (BOOL)::SendMessage(m_hWnd, CBEM_SETUNICODEFORMAT, bUnico
de, 0L); |
| 8724 } |
| 8725 #endif // (_WIN32_IE >= 0x0400) |
| 8726 |
| 8727 #if (_WIN32_WINNT >= 0x0501) |
| 8728 void SetWindowTheme(LPCWSTR lpstrTheme) |
| 8729 { |
| 8730 ATLASSERT(::IsWindow(m_hWnd)); |
| 8731 ::SendMessage(m_hWnd, CBEM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme
); |
| 8732 } |
| 8733 #endif // (_WIN32_WINNT >= 0x0501) |
| 8734 |
| 8735 // Operations |
| 8736 int InsertItem(const COMBOBOXEXITEM* lpcCBItem) |
| 8737 { |
| 8738 ATLASSERT(::IsWindow(m_hWnd)); |
| 8739 return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)lp
cCBItem); |
| 8740 } |
| 8741 |
| 8742 int InsertItem(UINT nMask, int nIndex, LPCTSTR lpszItem, int nImage, int
nSelImage, |
| 8743 int iIndent, int iOverlay, LPARAM lParam) |
| 8744 { |
| 8745 ATLASSERT(::IsWindow(m_hWnd)); |
| 8746 COMBOBOXEXITEM cbex = { 0 }; |
| 8747 cbex.mask = nMask; |
| 8748 cbex.iItem = nIndex; |
| 8749 cbex.pszText = (LPTSTR) lpszItem; |
| 8750 cbex.iImage = nImage; |
| 8751 cbex.iSelectedImage = nSelImage; |
| 8752 cbex.iIndent = iIndent; |
| 8753 cbex.iOverlay = iOverlay; |
| 8754 cbex.lParam = lParam; |
| 8755 return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&c
bex); |
| 8756 } |
| 8757 |
| 8758 int InsertItem(int nIndex, LPCTSTR lpszItem, int nImage, int nSelImage,
int iIndent, LPARAM lParam = 0) |
| 8759 { |
| 8760 ATLASSERT(::IsWindow(m_hWnd)); |
| 8761 COMBOBOXEXITEM cbex = { 0 }; |
| 8762 cbex.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBE
IF_INDENT | CBEIF_LPARAM; |
| 8763 cbex.iItem = nIndex; |
| 8764 cbex.pszText = (LPTSTR) lpszItem; |
| 8765 cbex.iImage = nImage; |
| 8766 cbex.iSelectedImage = nSelImage; |
| 8767 cbex.iIndent = iIndent; |
| 8768 cbex.lParam = lParam; |
| 8769 return (int)::SendMessage(m_hWnd, CBEM_INSERTITEM, 0, (LPARAM)&c
bex); |
| 8770 } |
| 8771 |
| 8772 int AddItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelImage, int
iIndent, int iOverlay, LPARAM lParam) |
| 8773 { |
| 8774 return InsertItem(nMask, -1, lpszItem, nImage, nSelImage, iInden
t, iOverlay, lParam); |
| 8775 } |
| 8776 |
| 8777 int AddItem(LPCTSTR lpszItem, int nImage, int nSelImage, int iIndent, LP
ARAM lParam = 0) |
| 8778 { |
| 8779 return InsertItem(-1, lpszItem, nImage, nSelImage, iIndent, lPar
am); |
| 8780 } |
| 8781 |
| 8782 int DeleteItem(int nIndex) |
| 8783 { |
| 8784 ATLASSERT(::IsWindow(m_hWnd)); |
| 8785 return (int)::SendMessage(m_hWnd, CBEM_DELETEITEM, nIndex, 0L); |
| 8786 } |
| 8787 |
| 8788 BOOL GetItem(PCOMBOBOXEXITEM pCBItem) const |
| 8789 { |
| 8790 ATLASSERT(::IsWindow(m_hWnd)); |
| 8791 return (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)pCBI
tem); |
| 8792 } |
| 8793 |
| 8794 BOOL SetItem(const COMBOBOXEXITEM* lpcCBItem) |
| 8795 { |
| 8796 ATLASSERT(::IsWindow(m_hWnd)); |
| 8797 return (BOOL)::SendMessage(m_hWnd, CBEM_SETITEM, 0, (LPARAM)lpcC
BItem); |
| 8798 } |
| 8799 |
| 8800 int SetItem(int nIndex, UINT nMask, LPCTSTR lpszItem, int nImage, int nS
elImage, |
| 8801 int iIndent, int iOverlay, LPARAM lParam) |
| 8802 { |
| 8803 ATLASSERT(::IsWindow(m_hWnd)); |
| 8804 COMBOBOXEXITEM cbex = { 0 }; |
| 8805 cbex.mask = nMask; |
| 8806 cbex.iItem = nIndex; |
| 8807 cbex.pszText = (LPTSTR) lpszItem; |
| 8808 cbex.iImage = nImage; |
| 8809 cbex.iSelectedImage = nSelImage; |
| 8810 cbex.iIndent = iIndent; |
| 8811 cbex.iOverlay = iOverlay; |
| 8812 cbex.lParam = lParam; |
| 8813 return (int)::SendMessage(m_hWnd, CBEM_SETITEM, 0, (LPARAM)&cbex
); |
| 8814 } |
| 8815 |
| 8816 BOOL GetItemText(int nIndex, LPTSTR lpszItem, int nLen) const |
| 8817 { |
| 8818 ATLASSERT(::IsWindow(m_hWnd)); |
| 8819 ATLASSERT(lpszItem != NULL); |
| 8820 |
| 8821 COMBOBOXEXITEM cbex = { 0 }; |
| 8822 cbex.mask = CBEIF_TEXT; |
| 8823 cbex.iItem = nIndex; |
| 8824 cbex.pszText = lpszItem; |
| 8825 cbex.cchTextMax = nLen; |
| 8826 |
| 8827 return (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPARAM)&cbe
x); |
| 8828 } |
| 8829 |
| 8830 #ifndef _ATL_NO_COM |
| 8831 BOOL GetItemText(int nIndex, BSTR& bstrText) const |
| 8832 { |
| 8833 USES_CONVERSION; |
| 8834 ATLASSERT(::IsWindow(m_hWnd)); |
| 8835 ATLASSERT(bstrText == NULL); |
| 8836 |
| 8837 COMBOBOXEXITEM cbex = { 0 }; |
| 8838 cbex.mask = CBEIF_TEXT; |
| 8839 cbex.iItem = nIndex; |
| 8840 |
| 8841 LPTSTR lpstrText = NULL; |
| 8842 BOOL bRet = FALSE; |
| 8843 for(int nLen = 256; ; nLen *= 2) |
| 8844 { |
| 8845 ATLTRY(lpstrText = new TCHAR[nLen]); |
| 8846 if(lpstrText == NULL) |
| 8847 break; |
| 8848 lpstrText[0] = NULL; |
| 8849 cbex.pszText = lpstrText; |
| 8850 cbex.cchTextMax = nLen; |
| 8851 bRet = (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPA
RAM)&cbex); |
| 8852 if(!bRet || (lstrlen(cbex.pszText) < nLen - 1)) |
| 8853 break; |
| 8854 delete [] lpstrText; |
| 8855 lpstrText = NULL; |
| 8856 } |
| 8857 |
| 8858 if(lpstrText != NULL) |
| 8859 { |
| 8860 if(bRet) |
| 8861 bstrText = ::SysAllocString(T2OLE(lpstrText)); |
| 8862 delete [] lpstrText; |
| 8863 } |
| 8864 |
| 8865 return (bstrText != NULL) ? TRUE : FALSE; |
| 8866 } |
| 8867 #endif // !_ATL_NO_COM |
| 8868 |
| 8869 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 8870 BOOL GetItemText(int nIndex, _CSTRING_NS::CString& strText) const |
| 8871 { |
| 8872 ATLASSERT(::IsWindow(m_hWnd)); |
| 8873 |
| 8874 COMBOBOXEXITEM cbex = { 0 }; |
| 8875 cbex.mask = CBEIF_TEXT; |
| 8876 cbex.iItem = nIndex; |
| 8877 |
| 8878 strText.Empty(); |
| 8879 BOOL bRet = FALSE; |
| 8880 for(int nLen = 256; ; nLen *= 2) |
| 8881 { |
| 8882 cbex.pszText = strText.GetBufferSetLength(nLen); |
| 8883 if(cbex.pszText == NULL) |
| 8884 { |
| 8885 bRet = FALSE; |
| 8886 break; |
| 8887 } |
| 8888 cbex.cchTextMax = nLen; |
| 8889 bRet = (BOOL)::SendMessage(m_hWnd, CBEM_GETITEM, 0, (LPA
RAM)&cbex); |
| 8890 if(!bRet || (lstrlen(cbex.pszText) < nLen - 1)) |
| 8891 break; |
| 8892 } |
| 8893 strText.ReleaseBuffer(); |
| 8894 return bRet; |
| 8895 } |
| 8896 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) |
| 8897 |
| 8898 BOOL SetItemText(int nIndex, LPCTSTR lpszItem) |
| 8899 { |
| 8900 ATLASSERT(::IsWindow(m_hWnd)); |
| 8901 return SetItem(nIndex, CBEIF_TEXT, lpszItem, 0, 0, 0, 0, 0); |
| 8902 } |
| 8903 |
| 8904 CComboBox GetComboCtrl() const |
| 8905 { |
| 8906 ATLASSERT(::IsWindow(m_hWnd)); |
| 8907 return CComboBox((HWND)::SendMessage(m_hWnd, CBEM_GETCOMBOCONTRO
L, 0, 0L)); |
| 8908 } |
| 8909 |
| 8910 CEdit GetEditCtrl() const |
| 8911 { |
| 8912 ATLASSERT(::IsWindow(m_hWnd)); |
| 8913 return CEdit((HWND)::SendMessage(m_hWnd, CBEM_GETEDITCONTROL, 0,
0L)); |
| 8914 } |
| 8915 |
| 8916 BOOL HasEditChanged() const |
| 8917 { |
| 8918 ATLASSERT(::IsWindow(m_hWnd)); |
| 8919 return (BOOL)::SendMessage(m_hWnd, CBEM_HASEDITCHANGED, 0, 0L); |
| 8920 } |
| 8921 |
| 8922 // Non-functional |
| 8923 int AddString(LPCTSTR /*lpszItem*/) |
| 8924 { |
| 8925 ATLASSERT(FALSE); // Not available in CComboBoxEx; use InsertIt
em |
| 8926 return 0; |
| 8927 } |
| 8928 |
| 8929 int InsertString(int /*nIndex*/, LPCTSTR /*lpszString*/) |
| 8930 { |
| 8931 ATLASSERT(FALSE); // Not available in CComboBoxEx; use InsertIt
em |
| 8932 return 0; |
| 8933 } |
| 8934 |
| 8935 int Dir(UINT /*attr*/, LPCTSTR /*lpszWildCard*/) |
| 8936 { |
| 8937 ATLASSERT(FALSE); // Not available in CComboBoxEx |
| 8938 return 0; |
| 8939 } |
| 8940 |
| 8941 int FindString(int /*nStartAfter*/, LPCTSTR /*lpszString*/) const |
| 8942 { |
| 8943 ATLASSERT(FALSE); // Not available in CComboBoxEx; try FindStri
ngExact |
| 8944 return 0; |
| 8945 } |
| 8946 }; |
| 8947 |
| 8948 typedef CComboBoxExT<ATL::CWindow> CComboBoxEx; |
| 8949 |
| 8950 #endif // !_WIN32_WCE |
| 8951 |
| 8952 |
| 8953 /////////////////////////////////////////////////////////////////////////////// |
| 8954 // CMonthCalendarCtrl |
| 8955 |
| 8956 template <class TBase> |
| 8957 class CMonthCalendarCtrlT : public TBase |
| 8958 { |
| 8959 public: |
| 8960 // Constructors |
| 8961 CMonthCalendarCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 8962 { } |
| 8963 |
| 8964 CMonthCalendarCtrlT< TBase >& operator =(HWND hWnd) |
| 8965 { |
| 8966 m_hWnd = hWnd; |
| 8967 return *this; |
| 8968 } |
| 8969 |
| 8970 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 8971 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 8972 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 8973 { |
| 8974 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 8975 } |
| 8976 |
| 8977 // Attributes |
| 8978 static LPCTSTR GetWndClassName() |
| 8979 { |
| 8980 return MONTHCAL_CLASS; |
| 8981 } |
| 8982 |
| 8983 COLORREF GetColor(int nColorType) const |
| 8984 { |
| 8985 ATLASSERT(::IsWindow(m_hWnd)); |
| 8986 return (COLORREF)::SendMessage(m_hWnd, MCM_GETCOLOR, nColorType,
0L); |
| 8987 } |
| 8988 |
| 8989 COLORREF SetColor(int nColorType, COLORREF clr) |
| 8990 { |
| 8991 ATLASSERT(::IsWindow(m_hWnd)); |
| 8992 return (COLORREF)::SendMessage(m_hWnd, MCM_SETCOLOR, nColorType,
clr); |
| 8993 } |
| 8994 |
| 8995 BOOL GetCurSel(LPSYSTEMTIME lpSysTime) const |
| 8996 { |
| 8997 ATLASSERT(::IsWindow(m_hWnd)); |
| 8998 return (BOOL)::SendMessage(m_hWnd, MCM_GETCURSEL, 0, (LPARAM)lpS
ysTime); |
| 8999 } |
| 9000 |
| 9001 BOOL SetCurSel(LPSYSTEMTIME lpSysTime) |
| 9002 { |
| 9003 ATLASSERT(::IsWindow(m_hWnd)); |
| 9004 return (BOOL)::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM)lpS
ysTime); |
| 9005 } |
| 9006 |
| 9007 int GetFirstDayOfWeek(BOOL* pbLocaleVal = NULL) const |
| 9008 { |
| 9009 ATLASSERT(::IsWindow(m_hWnd)); |
| 9010 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, MCM_GETFIRSTDAYOFWEEK
, 0, 0L); |
| 9011 if(pbLocaleVal != NULL) |
| 9012 *pbLocaleVal = (BOOL)HIWORD(dwRet); |
| 9013 return (int)(short)LOWORD(dwRet); |
| 9014 } |
| 9015 |
| 9016 int SetFirstDayOfWeek(int nDay, BOOL* pbLocaleVal = NULL) |
| 9017 { |
| 9018 ATLASSERT(::IsWindow(m_hWnd)); |
| 9019 DWORD dwRet = (DWORD)::SendMessage(m_hWnd, MCM_SETFIRSTDAYOFWEEK
, 0, nDay); |
| 9020 if(pbLocaleVal != NULL) |
| 9021 *pbLocaleVal = (BOOL)HIWORD(dwRet); |
| 9022 return (int)(short)LOWORD(dwRet); |
| 9023 } |
| 9024 |
| 9025 int GetMaxSelCount() const |
| 9026 { |
| 9027 ATLASSERT(::IsWindow(m_hWnd)); |
| 9028 return (int)::SendMessage(m_hWnd, MCM_GETMAXSELCOUNT, 0, 0L); |
| 9029 } |
| 9030 |
| 9031 BOOL SetMaxSelCount(int nMax) |
| 9032 { |
| 9033 ATLASSERT(::IsWindow(m_hWnd)); |
| 9034 return (BOOL)::SendMessage(m_hWnd, MCM_SETMAXSELCOUNT, nMax, 0L)
; |
| 9035 } |
| 9036 |
| 9037 int GetMonthDelta() const |
| 9038 { |
| 9039 ATLASSERT(::IsWindow(m_hWnd)); |
| 9040 return (int)::SendMessage(m_hWnd, MCM_GETMONTHDELTA, 0, 0L); |
| 9041 } |
| 9042 |
| 9043 int SetMonthDelta(int nDelta) |
| 9044 { |
| 9045 ATLASSERT(::IsWindow(m_hWnd)); |
| 9046 return (int)::SendMessage(m_hWnd, MCM_SETMONTHDELTA, nDelta, 0L)
; |
| 9047 } |
| 9048 |
| 9049 DWORD GetRange(LPSYSTEMTIME lprgSysTimeArray) const |
| 9050 { |
| 9051 ATLASSERT(::IsWindow(m_hWnd)); |
| 9052 return (DWORD)::SendMessage(m_hWnd, MCM_GETRANGE, 0, (LPARAM)lpr
gSysTimeArray); |
| 9053 } |
| 9054 |
| 9055 BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) |
| 9056 { |
| 9057 ATLASSERT(::IsWindow(m_hWnd)); |
| 9058 return (BOOL)::SendMessage(m_hWnd, MCM_SETRANGE, dwFlags, (LPARA
M)lprgSysTimeArray); |
| 9059 } |
| 9060 |
| 9061 BOOL GetSelRange(LPSYSTEMTIME lprgSysTimeArray) const |
| 9062 { |
| 9063 ATLASSERT(::IsWindow(m_hWnd)); |
| 9064 return (BOOL)::SendMessage(m_hWnd, MCM_GETSELRANGE, 0, (LPARAM)l
prgSysTimeArray); |
| 9065 } |
| 9066 |
| 9067 BOOL SetSelRange(LPSYSTEMTIME lprgSysTimeArray) |
| 9068 { |
| 9069 ATLASSERT(::IsWindow(m_hWnd)); |
| 9070 return (BOOL)::SendMessage(m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)l
prgSysTimeArray); |
| 9071 } |
| 9072 |
| 9073 BOOL GetToday(LPSYSTEMTIME lpSysTime) const |
| 9074 { |
| 9075 ATLASSERT(::IsWindow(m_hWnd)); |
| 9076 return (BOOL)::SendMessage(m_hWnd, MCM_GETTODAY, 0, (LPARAM)lpSy
sTime); |
| 9077 } |
| 9078 |
| 9079 void SetToday(LPSYSTEMTIME lpSysTime) |
| 9080 { |
| 9081 ATLASSERT(::IsWindow(m_hWnd)); |
| 9082 ::SendMessage(m_hWnd, MCM_SETTODAY, 0, (LPARAM)lpSysTime); |
| 9083 } |
| 9084 |
| 9085 BOOL GetMinReqRect(LPRECT lpRectInfo) const |
| 9086 { |
| 9087 ATLASSERT(::IsWindow(m_hWnd)); |
| 9088 return (BOOL)::SendMessage(m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM
)lpRectInfo); |
| 9089 } |
| 9090 |
| 9091 int GetMaxTodayWidth() const |
| 9092 { |
| 9093 ATLASSERT(::IsWindow(m_hWnd)); |
| 9094 return (int)::SendMessage(m_hWnd, MCM_GETMAXTODAYWIDTH, 0, 0L); |
| 9095 } |
| 9096 |
| 9097 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 9098 BOOL GetUnicodeFormat() const |
| 9099 { |
| 9100 ATLASSERT(::IsWindow(m_hWnd)); |
| 9101 return (BOOL)::SendMessage(m_hWnd, MCM_GETUNICODEFORMAT, 0, 0L); |
| 9102 } |
| 9103 |
| 9104 BOOL SetUnicodeFormat(BOOL bUnicode = TRUE) |
| 9105 { |
| 9106 ATLASSERT(::IsWindow(m_hWnd)); |
| 9107 return (BOOL)::SendMessage(m_hWnd, MCM_SETUNICODEFORMAT, bUnicod
e, 0L); |
| 9108 } |
| 9109 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 9110 |
| 9111 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) |
| 9112 DWORD GetCurrentView() const |
| 9113 { |
| 9114 ATLASSERT(::IsWindow(m_hWnd)); |
| 9115 return (DWORD)::SendMessage(m_hWnd, MCM_GETCURRENTVIEW, 0, 0L); |
| 9116 } |
| 9117 |
| 9118 BOOL SetCurrentView(DWORD dwView) |
| 9119 { |
| 9120 ATLASSERT(::IsWindow(m_hWnd)); |
| 9121 return (BOOL)::SendMessage(m_hWnd, MCM_SETCURRENTVIEW, 0, dwView
); |
| 9122 } |
| 9123 |
| 9124 DWORD GetCalendarCount() const |
| 9125 { |
| 9126 ATLASSERT(::IsWindow(m_hWnd)); |
| 9127 return (DWORD)::SendMessage(m_hWnd, MCM_GETCALENDARCOUNT, 0, 0L)
; |
| 9128 } |
| 9129 |
| 9130 BOOL GetCalendarGridInfo(PMCGRIDINFO pGridInfo) const |
| 9131 { |
| 9132 ATLASSERT(::IsWindow(m_hWnd)); |
| 9133 return (BOOL)::SendMessage(m_hWnd, MCM_GETCALENDARGRIDINFO, 0, (
LPARAM)pGridInfo); |
| 9134 } |
| 9135 |
| 9136 CALID GetCALID() const |
| 9137 { |
| 9138 ATLASSERT(::IsWindow(m_hWnd)); |
| 9139 return (CALID)::SendMessage(m_hWnd, MCM_GETCALID, 0, 0L); |
| 9140 } |
| 9141 |
| 9142 void SetCALID(CALID calid) |
| 9143 { |
| 9144 ATLASSERT(::IsWindow(m_hWnd)); |
| 9145 ::SendMessage(m_hWnd, MCM_SETCALID, (LPARAM)calid, 0L); |
| 9146 } |
| 9147 |
| 9148 int GetCalendarBorder() const |
| 9149 { |
| 9150 ATLASSERT(::IsWindow(m_hWnd)); |
| 9151 return (int)::SendMessage(m_hWnd, MCM_GETCALENDARBORDER, 0, 0L); |
| 9152 } |
| 9153 |
| 9154 void SetCalendarBorder(int cxyBorder, BOOL bSet = TRUE) |
| 9155 { |
| 9156 ATLASSERT(::IsWindow(m_hWnd)); |
| 9157 ::SendMessage(m_hWnd, MCM_SETCALENDARBORDER, (WPARAM)bSet, (LPAR
AM)cxyBorder); |
| 9158 } |
| 9159 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) |
| 9160 |
| 9161 // Operations |
| 9162 int GetMonthRange(DWORD dwFlags, LPSYSTEMTIME lprgSysTimeArray) const |
| 9163 { |
| 9164 ATLASSERT(::IsWindow(m_hWnd)); |
| 9165 return (int)::SendMessage(m_hWnd, MCM_GETMONTHRANGE, dwFlags, (L
PARAM)lprgSysTimeArray); |
| 9166 } |
| 9167 |
| 9168 BOOL SetDayState(int nMonths, LPMONTHDAYSTATE lpDayStateArray) |
| 9169 { |
| 9170 ATLASSERT(::IsWindow(m_hWnd)); |
| 9171 return (BOOL)::SendMessage(m_hWnd, MCM_SETDAYSTATE, nMonths, (LP
ARAM)lpDayStateArray); |
| 9172 } |
| 9173 |
| 9174 DWORD HitTest(PMCHITTESTINFO pMCHitTest) const |
| 9175 { |
| 9176 ATLASSERT(::IsWindow(m_hWnd)); |
| 9177 return (DWORD)::SendMessage(m_hWnd, MCM_HITTEST, 0, (LPARAM)pMCH
itTest); |
| 9178 } |
| 9179 |
| 9180 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) |
| 9181 void SizeRectToMin(LPRECT lpRect) |
| 9182 { |
| 9183 ATLASSERT(::IsWindow(m_hWnd)); |
| 9184 ::SendMessage(m_hWnd, MCM_SIZERECTTOMIN, 0, (LPARAM)lpRect); |
| 9185 } |
| 9186 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) |
| 9187 }; |
| 9188 |
| 9189 typedef CMonthCalendarCtrlT<ATL::CWindow> CMonthCalendarCtrl; |
| 9190 |
| 9191 |
| 9192 /////////////////////////////////////////////////////////////////////////////// |
| 9193 // CDateTimePickerCtrl |
| 9194 |
| 9195 template <class TBase> |
| 9196 class CDateTimePickerCtrlT : public TBase |
| 9197 { |
| 9198 public: |
| 9199 // Constructors |
| 9200 CDateTimePickerCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 9201 { } |
| 9202 |
| 9203 CDateTimePickerCtrlT< TBase >& operator =(HWND hWnd) |
| 9204 { |
| 9205 m_hWnd = hWnd; |
| 9206 return *this; |
| 9207 } |
| 9208 |
| 9209 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 9210 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 9211 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 9212 { |
| 9213 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 9214 } |
| 9215 |
| 9216 // Operations |
| 9217 static LPCTSTR GetWndClassName() |
| 9218 { |
| 9219 return DATETIMEPICK_CLASS; |
| 9220 } |
| 9221 |
| 9222 BOOL SetFormat(LPCTSTR lpszFormat) |
| 9223 { |
| 9224 ATLASSERT(::IsWindow(m_hWnd)); |
| 9225 return (BOOL)::SendMessage(m_hWnd, DTM_SETFORMAT, 0, (LPARAM)lps
zFormat); |
| 9226 } |
| 9227 |
| 9228 COLORREF GetMonthCalColor(int nColorType) const |
| 9229 { |
| 9230 ATLASSERT(::IsWindow(m_hWnd)); |
| 9231 return (COLORREF)::SendMessage(m_hWnd, DTM_GETMCCOLOR, nColorTyp
e, 0L); |
| 9232 } |
| 9233 |
| 9234 COLORREF SetMonthCalColor(int nColorType, COLORREF clr) |
| 9235 { |
| 9236 ATLASSERT(::IsWindow(m_hWnd)); |
| 9237 return (COLORREF)::SendMessage(m_hWnd, DTM_SETMCCOLOR, nColorTyp
e, clr); |
| 9238 } |
| 9239 |
| 9240 DWORD GetRange(LPSYSTEMTIME lpSysTimeArray) const |
| 9241 { |
| 9242 ATLASSERT(::IsWindow(m_hWnd)); |
| 9243 return (DWORD)::SendMessage(m_hWnd, DTM_GETRANGE, 0, (LPARAM)lpS
ysTimeArray); |
| 9244 } |
| 9245 |
| 9246 BOOL SetRange(DWORD dwFlags, LPSYSTEMTIME lpSysTimeArray) |
| 9247 { |
| 9248 ATLASSERT(::IsWindow(m_hWnd)); |
| 9249 return (BOOL)::SendMessage(m_hWnd, DTM_SETRANGE, dwFlags, (LPARA
M)lpSysTimeArray); |
| 9250 } |
| 9251 |
| 9252 DWORD GetSystemTime(LPSYSTEMTIME lpSysTime) const |
| 9253 { |
| 9254 ATLASSERT(::IsWindow(m_hWnd)); |
| 9255 return (DWORD)::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARA
M)lpSysTime); |
| 9256 } |
| 9257 |
| 9258 BOOL SetSystemTime(DWORD dwFlags, LPSYSTEMTIME lpSysTime) |
| 9259 { |
| 9260 ATLASSERT(::IsWindow(m_hWnd)); |
| 9261 return (BOOL)::SendMessage(m_hWnd, DTM_SETSYSTEMTIME, dwFlags, (
LPARAM)lpSysTime); |
| 9262 } |
| 9263 |
| 9264 CMonthCalendarCtrl GetMonthCal() const |
| 9265 { |
| 9266 ATLASSERT(::IsWindow(m_hWnd)); |
| 9267 return CMonthCalendarCtrl((HWND)::SendMessage(m_hWnd, DTM_GETMON
THCAL, 0, 0L)); |
| 9268 } |
| 9269 |
| 9270 #if (_WIN32_IE >= 0x0400) |
| 9271 CFontHandle GetMonthCalFont() const |
| 9272 { |
| 9273 ATLASSERT(::IsWindow(m_hWnd)); |
| 9274 return CFontHandle((HFONT)::SendMessage(m_hWnd, DTM_GETMCFONT, 0
, 0L)); |
| 9275 } |
| 9276 |
| 9277 void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE) |
| 9278 { |
| 9279 ATLASSERT(::IsWindow(m_hWnd)); |
| 9280 ::SendMessage(m_hWnd, DTM_SETMCFONT, (WPARAM)hFont, MAKELPARAM(b
Redraw, 0)); |
| 9281 } |
| 9282 #endif // (_WIN32_IE >= 0x0400) |
| 9283 |
| 9284 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) |
| 9285 DWORD GetMonthCalStyle() const |
| 9286 { |
| 9287 ATLASSERT(::IsWindow(m_hWnd)); |
| 9288 return (DWORD)::SendMessage(m_hWnd, DTM_GETMCSTYLE, 0, 0L); |
| 9289 } |
| 9290 |
| 9291 DWORD SetMonthCalStyle(DWORD dwStyle) |
| 9292 { |
| 9293 ATLASSERT(::IsWindow(m_hWnd)); |
| 9294 return (DWORD)::SendMessage(m_hWnd, DTM_SETMCSTYLE, 0, (LPARAM)d
wStyle); |
| 9295 } |
| 9296 |
| 9297 void GetDateTimePickerInfo(LPDATETIMEPICKERINFO lpPickerInfo) const |
| 9298 { |
| 9299 ATLASSERT(::IsWindow(m_hWnd)); |
| 9300 ::SendMessage(m_hWnd, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)lpPi
ckerInfo); |
| 9301 } |
| 9302 |
| 9303 BOOL GetIdealSize(LPSIZE lpSize) const |
| 9304 { |
| 9305 ATLASSERT(::IsWindow(m_hWnd)); |
| 9306 return (BOOL)::SendMessage(m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)
lpSize); |
| 9307 } |
| 9308 |
| 9309 void CloseMonthCal() |
| 9310 { |
| 9311 ATLASSERT(::IsWindow(m_hWnd)); |
| 9312 ::SendMessage(m_hWnd, DTM_CLOSEMONTHCAL, 0, 0L); |
| 9313 } |
| 9314 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) |
| 9315 }; |
| 9316 |
| 9317 typedef CDateTimePickerCtrlT<ATL::CWindow> CDateTimePickerCtrl; |
| 9318 |
| 9319 |
| 9320 /////////////////////////////////////////////////////////////////////////////// |
| 9321 // CFlatScrollBarImpl - support for flat scroll bars |
| 9322 |
| 9323 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 9324 |
| 9325 template <class T> |
| 9326 class CFlatScrollBarImpl |
| 9327 { |
| 9328 public: |
| 9329 // Initialization |
| 9330 BOOL FlatSB_Initialize() |
| 9331 { |
| 9332 T* pT = static_cast<T*>(this); |
| 9333 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9334 return ::InitializeFlatSB(pT->m_hWnd); |
| 9335 } |
| 9336 |
| 9337 HRESULT FlatSB_Uninitialize() |
| 9338 { |
| 9339 T* pT = static_cast<T*>(this); |
| 9340 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9341 return ::UninitializeFlatSB(pT->m_hWnd); |
| 9342 } |
| 9343 |
| 9344 // Flat scroll bar properties |
| 9345 BOOL FlatSB_GetScrollProp(UINT uIndex, LPINT lpnValue) const |
| 9346 { |
| 9347 const T* pT = static_cast<const T*>(this); |
| 9348 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9349 return ::FlatSB_GetScrollProp(pT->m_hWnd, uIndex, lpnValue); |
| 9350 } |
| 9351 |
| 9352 BOOL FlatSB_SetScrollProp(UINT uIndex, int nValue, BOOL bRedraw = TRUE) |
| 9353 { |
| 9354 T* pT = static_cast<T*>(this); |
| 9355 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9356 return ::FlatSB_SetScrollProp(pT->m_hWnd, uIndex, nValue, bRedra
w); |
| 9357 } |
| 9358 |
| 9359 // Attributes |
| 9360 int FlatSB_GetScrollPos(int nBar) const |
| 9361 { |
| 9362 const T* pT = static_cast<const T*>(this); |
| 9363 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9364 return ::FlatSB_GetScrollPos(pT->m_hWnd, nBar); |
| 9365 } |
| 9366 |
| 9367 int FlatSB_SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE) |
| 9368 { |
| 9369 T* pT = static_cast<T*>(this); |
| 9370 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9371 return ::FlatSB_SetScrollPos(pT->m_hWnd, nBar, nPos, bRedraw); |
| 9372 } |
| 9373 |
| 9374 BOOL FlatSB_GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) con
st |
| 9375 { |
| 9376 const T* pT = static_cast<const T*>(this); |
| 9377 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9378 return ::FlatSB_GetScrollRange(pT->m_hWnd, nBar, lpMinPos, lpMax
Pos); |
| 9379 } |
| 9380 |
| 9381 BOOL FlatSB_SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRed
raw = TRUE) |
| 9382 { |
| 9383 T* pT = static_cast<T*>(this); |
| 9384 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9385 return ::FlatSB_SetScrollRange(pT->m_hWnd, nBar, nMinPos, nMaxPo
s, bRedraw); |
| 9386 } |
| 9387 |
| 9388 BOOL FlatSB_GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo) const |
| 9389 { |
| 9390 const T* pT = static_cast<const T*>(this); |
| 9391 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9392 return ::FlatSB_GetScrollInfo(pT->m_hWnd, nBar, lpScrollInfo); |
| 9393 } |
| 9394 |
| 9395 int FlatSB_SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedr
aw = TRUE) |
| 9396 { |
| 9397 T* pT = static_cast<T*>(this); |
| 9398 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9399 return ::FlatSB_SetScrollInfo(pT->m_hWnd, nBar, lpScrollInfo, bR
edraw); |
| 9400 } |
| 9401 |
| 9402 // Operations |
| 9403 BOOL FlatSB_ShowScrollBar(UINT nBar, BOOL bShow = TRUE) |
| 9404 { |
| 9405 T* pT = static_cast<T*>(this); |
| 9406 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9407 return ::FlatSB_ShowScrollBar(pT->m_hWnd, nBar, bShow); |
| 9408 } |
| 9409 |
| 9410 BOOL FlatSB_EnableScrollBar(UINT uSBFlags, UINT uArrowFlags = ESB_ENABLE
_BOTH) |
| 9411 { |
| 9412 T* pT = static_cast<T*>(this); |
| 9413 ATLASSERT(::IsWindow(pT->m_hWnd)); |
| 9414 return ::FlatSB_EnableScrollBar(pT->m_hWnd, uSBFlags, uArrowFlag
s); |
| 9415 } |
| 9416 }; |
| 9417 |
| 9418 template <class TBase> |
| 9419 class CFlatScrollBarT : public TBase, public CFlatScrollBarImpl<CFlatScrollBarT<
TBase > > |
| 9420 { |
| 9421 public: |
| 9422 CFlatScrollBarT(HWND hWnd = NULL) : TBase(hWnd) |
| 9423 { } |
| 9424 |
| 9425 CFlatScrollBarT< TBase >& operator =(HWND hWnd) |
| 9426 { |
| 9427 m_hWnd = hWnd; |
| 9428 return *this; |
| 9429 } |
| 9430 }; |
| 9431 |
| 9432 typedef CFlatScrollBarT<ATL::CWindow> CFlatScrollBar; |
| 9433 |
| 9434 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 9435 |
| 9436 |
| 9437 /////////////////////////////////////////////////////////////////////////////// |
| 9438 // CIPAddressCtrl |
| 9439 |
| 9440 #if (_WIN32_IE >= 0x0400) |
| 9441 |
| 9442 template <class TBase> |
| 9443 class CIPAddressCtrlT : public TBase |
| 9444 { |
| 9445 public: |
| 9446 // Constructors |
| 9447 CIPAddressCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 9448 { } |
| 9449 |
| 9450 CIPAddressCtrlT< TBase >& operator =(HWND hWnd) |
| 9451 { |
| 9452 m_hWnd = hWnd; |
| 9453 return *this; |
| 9454 } |
| 9455 |
| 9456 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 9457 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 9458 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 9459 { |
| 9460 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 9461 } |
| 9462 |
| 9463 // Atteributes |
| 9464 static LPCTSTR GetWndClassName() |
| 9465 { |
| 9466 return WC_IPADDRESS; |
| 9467 } |
| 9468 |
| 9469 BOOL IsBlank() const |
| 9470 { |
| 9471 ATLASSERT(::IsWindow(m_hWnd)); |
| 9472 return (BOOL)::SendMessage(m_hWnd, IPM_ISBLANK, 0, 0L); |
| 9473 } |
| 9474 |
| 9475 int GetAddress(LPDWORD lpdwAddress) const |
| 9476 { |
| 9477 ATLASSERT(::IsWindow(m_hWnd)); |
| 9478 return (int)::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpd
wAddress); |
| 9479 } |
| 9480 |
| 9481 void SetAddress(DWORD dwAddress) |
| 9482 { |
| 9483 ATLASSERT(::IsWindow(m_hWnd)); |
| 9484 ::SendMessage(m_hWnd, IPM_SETADDRESS, 0, dwAddress); |
| 9485 } |
| 9486 |
| 9487 void ClearAddress() |
| 9488 { |
| 9489 ATLASSERT(::IsWindow(m_hWnd)); |
| 9490 ::SendMessage(m_hWnd, IPM_CLEARADDRESS, 0, 0L); |
| 9491 } |
| 9492 |
| 9493 void SetRange(int nField, WORD wRange) |
| 9494 { |
| 9495 ATLASSERT(::IsWindow(m_hWnd)); |
| 9496 ::SendMessage(m_hWnd, IPM_SETRANGE, nField, wRange); |
| 9497 } |
| 9498 |
| 9499 void SetRange(int nField, BYTE nMin, BYTE nMax) |
| 9500 { |
| 9501 ATLASSERT(::IsWindow(m_hWnd)); |
| 9502 ::SendMessage(m_hWnd, IPM_SETRANGE, nField, MAKEIPRANGE(nMin, nM
ax)); |
| 9503 } |
| 9504 |
| 9505 void SetFocus(int nField) |
| 9506 { |
| 9507 ATLASSERT(::IsWindow(m_hWnd)); |
| 9508 ::SendMessage(m_hWnd, IPM_SETFOCUS, nField, 0L); |
| 9509 } |
| 9510 }; |
| 9511 |
| 9512 typedef CIPAddressCtrlT<ATL::CWindow> CIPAddressCtrl; |
| 9513 |
| 9514 #endif // (_WIN32_IE >= 0x0400) |
| 9515 |
| 9516 |
| 9517 /////////////////////////////////////////////////////////////////////////////// |
| 9518 // CPagerCtrl |
| 9519 |
| 9520 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 9521 |
| 9522 template <class TBase> |
| 9523 class CPagerCtrlT : public TBase |
| 9524 { |
| 9525 public: |
| 9526 // Constructors |
| 9527 CPagerCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 9528 { } |
| 9529 |
| 9530 CPagerCtrlT< TBase >& operator =(HWND hWnd) |
| 9531 { |
| 9532 m_hWnd = hWnd; |
| 9533 return *this; |
| 9534 } |
| 9535 |
| 9536 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 9537 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 9538 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 9539 { |
| 9540 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 9541 } |
| 9542 |
| 9543 // Attributes |
| 9544 static LPCTSTR GetWndClassName() |
| 9545 { |
| 9546 return WC_PAGESCROLLER; |
| 9547 } |
| 9548 |
| 9549 int GetButtonSize() const |
| 9550 { |
| 9551 ATLASSERT(::IsWindow(m_hWnd)); |
| 9552 return (int)::SendMessage(m_hWnd, PGM_GETBUTTONSIZE, 0, 0L); |
| 9553 } |
| 9554 |
| 9555 int SetButtonSize(int nButtonSize) |
| 9556 { |
| 9557 ATLASSERT(::IsWindow(m_hWnd)); |
| 9558 return (int)::SendMessage(m_hWnd, PGM_SETBUTTONSIZE, 0, nButtonS
ize); |
| 9559 } |
| 9560 |
| 9561 DWORD GetButtonState(int nButton) const |
| 9562 { |
| 9563 ATLASSERT(::IsWindow(m_hWnd)); |
| 9564 ATLASSERT(nButton == PGB_TOPORLEFT || nButton == PGB_BOTTOMORRIG
HT); |
| 9565 return (DWORD)::SendMessage(m_hWnd, PGM_GETBUTTONSTATE, 0, nButt
on); |
| 9566 } |
| 9567 |
| 9568 COLORREF GetBkColor() const |
| 9569 { |
| 9570 ATLASSERT(::IsWindow(m_hWnd)); |
| 9571 return (COLORREF)::SendMessage(m_hWnd, PGM_GETBKCOLOR, 0, 0L); |
| 9572 } |
| 9573 |
| 9574 COLORREF SetBkColor(COLORREF clrBk) |
| 9575 { |
| 9576 ATLASSERT(::IsWindow(m_hWnd)); |
| 9577 return (COLORREF)::SendMessage(m_hWnd, PGM_SETBKCOLOR, 0, (LPARA
M)clrBk); |
| 9578 } |
| 9579 |
| 9580 int GetBorder() const |
| 9581 { |
| 9582 ATLASSERT(::IsWindow(m_hWnd)); |
| 9583 return (int)::SendMessage(m_hWnd, PGM_GETBORDER, 0, 0L); |
| 9584 } |
| 9585 |
| 9586 int SetBorder(int nBorderSize) |
| 9587 { |
| 9588 ATLASSERT(::IsWindow(m_hWnd)); |
| 9589 return (int)::SendMessage(m_hWnd, PGM_SETBORDER, 0, nBorderSize)
; |
| 9590 } |
| 9591 |
| 9592 int GetPos() const |
| 9593 { |
| 9594 ATLASSERT(::IsWindow(m_hWnd)); |
| 9595 return (int)::SendMessage(m_hWnd, PGM_GETPOS, 0, 0L); |
| 9596 } |
| 9597 |
| 9598 int SetPos(int nPos) |
| 9599 { |
| 9600 ATLASSERT(::IsWindow(m_hWnd)); |
| 9601 return (int)::SendMessage(m_hWnd, PGM_SETPOS, 0, nPos); |
| 9602 } |
| 9603 |
| 9604 // Operations |
| 9605 void SetChild(HWND hWndChild) |
| 9606 { |
| 9607 ATLASSERT(::IsWindow(m_hWnd)); |
| 9608 ::SendMessage(m_hWnd, PGM_SETCHILD, 0, (LPARAM)hWndChild); |
| 9609 } |
| 9610 |
| 9611 void ForwardMouse(BOOL bForward = TRUE) |
| 9612 { |
| 9613 ATLASSERT(::IsWindow(m_hWnd)); |
| 9614 ::SendMessage(m_hWnd, PGM_FORWARDMOUSE, bForward, 0L); |
| 9615 } |
| 9616 |
| 9617 void RecalcSize() |
| 9618 { |
| 9619 ATLASSERT(::IsWindow(m_hWnd)); |
| 9620 ::SendMessage(m_hWnd, PGM_RECALCSIZE, 0, 0L); |
| 9621 } |
| 9622 |
| 9623 void GetDropTarget(IDropTarget** ppDropTarget) |
| 9624 { |
| 9625 ATLASSERT(::IsWindow(m_hWnd)); |
| 9626 ATLASSERT(ppDropTarget != NULL); |
| 9627 ::SendMessage(m_hWnd, PGM_GETDROPTARGET, 0, (LPARAM)ppDropTarget
); |
| 9628 } |
| 9629 }; |
| 9630 |
| 9631 typedef CPagerCtrlT<ATL::CWindow> CPagerCtrl; |
| 9632 |
| 9633 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) |
| 9634 |
| 9635 |
| 9636 /////////////////////////////////////////////////////////////////////////////// |
| 9637 // CLinkCtrl - Windows SYSLINK control |
| 9638 |
| 9639 #if (_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE) |
| 9640 |
| 9641 template <class TBase> |
| 9642 class CLinkCtrlT : public TBase |
| 9643 { |
| 9644 public: |
| 9645 // Constructors |
| 9646 CLinkCtrlT(HWND hWnd = NULL) : TBase(hWnd) |
| 9647 { } |
| 9648 |
| 9649 CLinkCtrlT< TBase >& operator =(HWND hWnd) |
| 9650 { |
| 9651 m_hWnd = hWnd; |
| 9652 return *this; |
| 9653 } |
| 9654 |
| 9655 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN
ame = NULL, |
| 9656 DWORD dwStyle = 0, DWORD dwExStyle = 0, |
| 9657 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N
ULL) |
| 9658 { |
| 9659 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRec
t, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam); |
| 9660 } |
| 9661 |
| 9662 // Attributes |
| 9663 static LPCTSTR GetWndClassName() |
| 9664 { |
| 9665 #ifdef _UNICODE |
| 9666 return WC_LINK; |
| 9667 #else // !_UNICODE |
| 9668 return "SysLink"; |
| 9669 #endif // !_UNICODE |
| 9670 } |
| 9671 |
| 9672 int GetIdealHeight(int cxMaxWidth = 0) const |
| 9673 { |
| 9674 ATLASSERT(::IsWindow(m_hWnd)); |
| 9675 return (int)::SendMessage(m_hWnd, LM_GETIDEALHEIGHT, cxMaxWidth,
0L); |
| 9676 } |
| 9677 |
| 9678 BOOL GetItem(PLITEM pLItem) const |
| 9679 { |
| 9680 ATLASSERT(::IsWindow(m_hWnd)); |
| 9681 return (BOOL)::SendMessage(m_hWnd, LM_GETITEM, 0, (LPARAM)pLItem
); |
| 9682 } |
| 9683 |
| 9684 BOOL SetItem(PLITEM pLItem) |
| 9685 { |
| 9686 ATLASSERT(::IsWindow(m_hWnd)); |
| 9687 return (BOOL)::SendMessage(m_hWnd, LM_SETITEM, 0, (LPARAM)pLItem
); |
| 9688 } |
| 9689 |
| 9690 // Vista only |
| 9691 int GetIdealSize(SIZE& size, int cxMaxWidth = 0) const |
| 9692 { |
| 9693 #ifndef LM_GETIDEALSIZE |
| 9694 const UINT LM_GETIDEALSIZE = LM_GETIDEALHEIGHT; |
| 9695 #endif |
| 9696 ATLASSERT(::IsWindow(m_hWnd)); |
| 9697 return (int)::SendMessage(m_hWnd, LM_GETIDEALSIZE, cxMaxWidth, (
LPARAM)&size); |
| 9698 } |
| 9699 |
| 9700 // Operations |
| 9701 BOOL HitTest(PLHITTESTINFO pLHitTestInfo) const |
| 9702 { |
| 9703 ATLASSERT(::IsWindow(m_hWnd)); |
| 9704 return (BOOL)::SendMessage(m_hWnd, LM_HITTEST, 0, (LPARAM)pLHitT
estInfo); |
| 9705 } |
| 9706 }; |
| 9707 |
| 9708 typedef CLinkCtrlT<ATL::CWindow> CLinkCtrl; |
| 9709 |
| 9710 #endif // (_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE) |
| 9711 |
| 9712 |
| 9713 /////////////////////////////////////////////////////////////////////////////// |
| 9714 // CCustomDraw - MI class for custom-draw support |
| 9715 |
| 9716 template <class T> |
| 9717 class CCustomDraw |
| 9718 { |
| 9719 public: |
| 9720 #if (_ATL_VER < 0x0700) |
| 9721 BOOL m_bHandledCD; |
| 9722 |
| 9723 BOOL IsMsgHandled() const |
| 9724 { |
| 9725 return m_bHandledCD; |
| 9726 } |
| 9727 |
| 9728 void SetMsgHandled(BOOL bHandled) |
| 9729 { |
| 9730 m_bHandledCD = bHandled; |
| 9731 } |
| 9732 #endif // !(_ATL_VER < 0x0700) |
| 9733 |
| 9734 // Message map and handlers |
| 9735 BEGIN_MSG_MAP(CCustomDraw< T >) |
| 9736 NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) |
| 9737 ALT_MSG_MAP(1) |
| 9738 REFLECTED_NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw) |
| 9739 END_MSG_MAP() |
| 9740 |
| 9741 // message handler |
| 9742 LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) |
| 9743 { |
| 9744 T* pT = static_cast<T*>(this); |
| 9745 pT->SetMsgHandled(TRUE); |
| 9746 LPNMCUSTOMDRAW lpNMCustomDraw = (LPNMCUSTOMDRAW)pnmh; |
| 9747 DWORD dwRet = 0; |
| 9748 switch(lpNMCustomDraw->dwDrawStage) |
| 9749 { |
| 9750 case CDDS_PREPAINT: |
| 9751 dwRet = pT->OnPrePaint(idCtrl, lpNMCustomDraw); |
| 9752 break; |
| 9753 case CDDS_POSTPAINT: |
| 9754 dwRet = pT->OnPostPaint(idCtrl, lpNMCustomDraw); |
| 9755 break; |
| 9756 case CDDS_PREERASE: |
| 9757 dwRet = pT->OnPreErase(idCtrl, lpNMCustomDraw); |
| 9758 break; |
| 9759 case CDDS_POSTERASE: |
| 9760 dwRet = pT->OnPostErase(idCtrl, lpNMCustomDraw); |
| 9761 break; |
| 9762 case CDDS_ITEMPREPAINT: |
| 9763 dwRet = pT->OnItemPrePaint(idCtrl, lpNMCustomDraw); |
| 9764 break; |
| 9765 case CDDS_ITEMPOSTPAINT: |
| 9766 dwRet = pT->OnItemPostPaint(idCtrl, lpNMCustomDraw); |
| 9767 break; |
| 9768 case CDDS_ITEMPREERASE: |
| 9769 dwRet = pT->OnItemPreErase(idCtrl, lpNMCustomDraw); |
| 9770 break; |
| 9771 case CDDS_ITEMPOSTERASE: |
| 9772 dwRet = pT->OnItemPostErase(idCtrl, lpNMCustomDraw); |
| 9773 break; |
| 9774 #if (_WIN32_IE >= 0x0400) |
| 9775 case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): |
| 9776 dwRet = pT->OnSubItemPrePaint(idCtrl, lpNMCustomDraw); |
| 9777 break; |
| 9778 #endif // (_WIN32_IE >= 0x0400) |
| 9779 default: |
| 9780 pT->SetMsgHandled(FALSE); |
| 9781 break; |
| 9782 } |
| 9783 bHandled = pT->IsMsgHandled(); |
| 9784 return dwRet; |
| 9785 } |
| 9786 |
| 9787 // Overrideables |
| 9788 DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9789 { |
| 9790 return CDRF_DODEFAULT; |
| 9791 } |
| 9792 |
| 9793 DWORD OnPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9794 { |
| 9795 return CDRF_DODEFAULT; |
| 9796 } |
| 9797 |
| 9798 DWORD OnPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9799 { |
| 9800 return CDRF_DODEFAULT; |
| 9801 } |
| 9802 |
| 9803 DWORD OnPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9804 { |
| 9805 return CDRF_DODEFAULT; |
| 9806 } |
| 9807 |
| 9808 DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9809 { |
| 9810 return CDRF_DODEFAULT; |
| 9811 } |
| 9812 |
| 9813 DWORD OnItemPostPaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9814 { |
| 9815 return CDRF_DODEFAULT; |
| 9816 } |
| 9817 |
| 9818 DWORD OnItemPreErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9819 { |
| 9820 return CDRF_DODEFAULT; |
| 9821 } |
| 9822 |
| 9823 DWORD OnItemPostErase(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/) |
| 9824 { |
| 9825 return CDRF_DODEFAULT; |
| 9826 } |
| 9827 |
| 9828 #if (_WIN32_IE >= 0x0400) |
| 9829 DWORD OnSubItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*
/) |
| 9830 { |
| 9831 return CDRF_DODEFAULT; |
| 9832 } |
| 9833 #endif // (_WIN32_IE >= 0x0400) |
| 9834 }; |
| 9835 |
| 9836 |
| 9837 // --- Windows CE common controls --- |
| 9838 |
| 9839 #ifdef _WIN32_WCE |
| 9840 |
| 9841 /////////////////////////////////////////////////////////////////////////////// |
| 9842 // CCECommandBarCtrl |
| 9843 |
| 9844 template <class TBase> |
| 9845 class CCECommandBarCtrlT : public TBase |
| 9846 { |
| 9847 public: |
| 9848 // Constructors |
| 9849 CCECommandBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) { } |
| 9850 |
| 9851 CCECommandBarCtrlT< TBase >& operator=(HWND hWnd) |
| 9852 { |
| 9853 m_hWnd = hWnd; |
| 9854 return *this; |
| 9855 } |
| 9856 |
| 9857 // Attributes |
| 9858 BOOL IsVisible() const |
| 9859 { |
| 9860 return IsWindowVisible(); |
| 9861 } |
| 9862 |
| 9863 int GetHeight() const |
| 9864 { |
| 9865 ATLASSERT(::IsWindow(m_hWnd)); |
| 9866 return ::CommandBar_Height(m_hWnd); |
| 9867 } |
| 9868 |
| 9869 HMENU GetMenu(WORD wButton) const |
| 9870 { |
| 9871 ATLASSERT(::IsWindow(m_hWnd)); |
| 9872 return ::CommandBar_GetMenu(m_hWnd, wButton); |
| 9873 } |
| 9874 |
| 9875 // Operations |
| 9876 HWND Create(HWND hWndParent, int nCmdBarID) |
| 9877 { |
| 9878 m_hWnd = ::CommandBar_Create(ModuleHelper::GetModuleInstance(),
hWndParent, nCmdBarID); |
| 9879 ATLASSERT(::IsWindow(m_hWnd)); |
| 9880 return m_hWnd; |
| 9881 } |
| 9882 |
| 9883 void Destroy() |
| 9884 { |
| 9885 DestroyWindow(); |
| 9886 } |
| 9887 |
| 9888 BOOL Show(BOOL bShow = TRUE) |
| 9889 { |
| 9890 ATLASSERT(::IsWindow(m_hWnd)); |
| 9891 return ::CommandBar_Show(m_hWnd, bShow); |
| 9892 } |
| 9893 |
| 9894 BOOL DrawMenuBar(WORD wButton) |
| 9895 { |
| 9896 ATLASSERT(::IsWindow(m_hWnd)); |
| 9897 return ::CommandBar_DrawMenuBar(m_hWnd, wButton); |
| 9898 } |
| 9899 |
| 9900 BOOL AddAdornments(DWORD dwFlags = 0) |
| 9901 { |
| 9902 ATLASSERT(::IsWindow(m_hWnd)); |
| 9903 return ::CommandBar_AddAdornments(m_hWnd, dwFlags, 0); |
| 9904 } |
| 9905 |
| 9906 int AddBitmap(int nBitmapID, int nNumImages) |
| 9907 { |
| 9908 ATLASSERT(::IsWindow(m_hWnd)); |
| 9909 return ::CommandBar_AddBitmap(m_hWnd, ModuleHelper::GetResourceI
nstance(), nBitmapID, nNumImages, 16, 16); |
| 9910 } |
| 9911 |
| 9912 BOOL AddButtons(UINT uNumButtons, LPTBBUTTON lpButtons) |
| 9913 { |
| 9914 ATLASSERT(::IsWindow(m_hWnd)); |
| 9915 return CommandBar_AddButtons(m_hWnd, uNumButtons, lpButtons); |
| 9916 } |
| 9917 |
| 9918 BOOL AddToolTips(UINT uNumToolTips, LPTSTR lpToolTips) |
| 9919 { |
| 9920 ATLASSERT(::IsWindow(m_hWnd)); |
| 9921 return CommandBar_AddToolTips(m_hWnd, uNumToolTips, lpToolTips); |
| 9922 } |
| 9923 |
| 9924 BOOL InsertButton(int nButton, LPTBBUTTON lpButton) |
| 9925 { |
| 9926 ATLASSERT(::IsWindow(m_hWnd)); |
| 9927 return CommandBar_InsertButton(m_hWnd, nButton, lpButton); |
| 9928 } |
| 9929 |
| 9930 HWND InsertComboBox(int nWidth, UINT dwStyle, WORD wComboBoxID, WORD wBu
tton) |
| 9931 { |
| 9932 ATLASSERT(::IsWindow(m_hWnd)); |
| 9933 return ::CommandBar_InsertComboBox(m_hWnd, ModuleHelper::GetModu
leInstance(), nWidth, dwStyle, wComboBoxID, wButton); |
| 9934 } |
| 9935 |
| 9936 BOOL InsertMenubar(WORD wMenuID, WORD wButton) |
| 9937 { |
| 9938 ATLASSERT(::IsWindow(m_hWnd)); |
| 9939 return ::CommandBar_InsertMenubar(m_hWnd, ModuleHelper::GetResou
rceInstance(), wMenuID, wButton); |
| 9940 } |
| 9941 |
| 9942 BOOL InsertMenubarEx(ATL::_U_STRINGorID menu, WORD wButton) |
| 9943 { |
| 9944 ATLASSERT(::IsWindow(m_hWnd)); |
| 9945 return ::CommandBar_InsertMenubarEx(m_hWnd, ModuleHelper::GetRes
ourceInstance(), (LPTSTR)menu.m_lpstr, wButton); |
| 9946 } |
| 9947 |
| 9948 BOOL IsCommandBarMessage(LPMSG lpMsg) |
| 9949 { |
| 9950 ATLASSERT(::IsWindow(m_hWnd)); |
| 9951 return ::IsCommandBarMessage(m_hWnd, lpMsg); |
| 9952 } |
| 9953 }; |
| 9954 |
| 9955 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC MenuBar |
| 9956 typedef CCECommandBarCtrlT<CToolBarCtrl> CMenuBarCtrl; |
| 9957 #else |
| 9958 typedef CCECommandBarCtrlT<CToolBarCtrl> CCECommandBarCtrl; |
| 9959 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) |
| 9960 |
| 9961 /////////////////////////////////////////////////////////////////////////////// |
| 9962 // CCECommandBandsCtrl |
| 9963 |
| 9964 template <class TBase> |
| 9965 class CCECommandBandsCtrlT : public TBase |
| 9966 { |
| 9967 public: |
| 9968 // Constructors |
| 9969 CCECommandBandsCtrlT(HWND hWnd = NULL) : TBase(hWnd) { } |
| 9970 |
| 9971 CCECommandBandsCtrlT< TBase >& operator=(HWND hWnd) |
| 9972 { |
| 9973 m_hWnd = hWnd; |
| 9974 return *this; |
| 9975 } |
| 9976 |
| 9977 // Attributes |
| 9978 BOOL IsVisible() const |
| 9979 { |
| 9980 return IsWindowVisible(); |
| 9981 } |
| 9982 |
| 9983 #if (_WIN32_IE >= 0x0400) |
| 9984 UINT GetHeight() const |
| 9985 { |
| 9986 ATLASSERT(::IsWindow(m_hWnd)); |
| 9987 return CommandBands_Height(m_hWnd); |
| 9988 } |
| 9989 #endif // (_WIN32_IE >= 0x0400) |
| 9990 |
| 9991 HWND GetCommandBar(UINT uBand) const |
| 9992 { |
| 9993 ATLASSERT(::IsWindow(m_hWnd)); |
| 9994 return ::CommandBands_GetCommandBar(m_hWnd, uBand); |
| 9995 } |
| 9996 |
| 9997 BOOL GetRestoreInformation(UINT uBand, LPCOMMANDBANDSRESTOREINFO pcbr) c
onst |
| 9998 { |
| 9999 ATLASSERT(::IsWindow(m_hWnd)); |
| 10000 return ::CommandBands_GetRestoreInformation(m_hWnd, uBand, pcbr)
; |
| 10001 } |
| 10002 |
| 10003 // Operations |
| 10004 HWND Create(HWND hWndParent, UINT wID, DWORD dwStyles, HIMAGELIST hImage
List = NULL) |
| 10005 { |
| 10006 m_hWnd = ::CommandBands_Create(ModuleHelper::GetModuleInstance()
, hWndParent, wID, dwStyles, hImageList); |
| 10007 ATLASSERT(::IsWindow(m_hWnd)); |
| 10008 return m_hWnd; |
| 10009 } |
| 10010 |
| 10011 BOOL AddAdornments(DWORD dwFlags = 0, LPREBARBANDINFO prbbi = NULL) |
| 10012 { |
| 10013 ATLASSERT(::IsWindow(m_hWnd)); |
| 10014 return ::CommandBands_AddAdornments(m_hWnd, ModuleHelper::GetMod
uleInstance(), dwFlags, prbbi); |
| 10015 } |
| 10016 |
| 10017 BOOL AddBands(UINT uBandCount, LPREBARBANDINFO prbbi) |
| 10018 { |
| 10019 ATLASSERT(::IsWindow(m_hWnd)); |
| 10020 return ::CommandBands_AddBands(m_hWnd, ModuleHelper::GetModuleIn
stance(), uBandCount, prbbi); |
| 10021 } |
| 10022 |
| 10023 BOOL Show(BOOL bShow = TRUE) |
| 10024 { |
| 10025 ATLASSERT(::IsWindow(m_hWnd)); |
| 10026 return ::CommandBands_Show(m_hWnd, bShow); |
| 10027 } |
| 10028 }; |
| 10029 |
| 10030 typedef CCECommandBandsCtrlT<ATL::CWindow> CCECommandBandsCtrl; |
| 10031 |
| 10032 #endif // _WIN32_WCE |
| 10033 |
| 10034 }; // namespace WTL |
| 10035 |
| 10036 #endif // __ATLCTRLS_H__ |
OLD | NEW |