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