/thirdparty/wtl/atlctrls.h
http://crashrpt.googlecode.com/ · C Header · 10033 lines · 8164 code · 1548 blank · 321 comment · 433 complexity · 568a835c698d37e8daf2a4b28c1f5c17 MD5 · raw file
Large files are truncated click here to view the full file
- // Windows Template Library - WTL version 8.1
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //
- // This file is a part of the Windows Template Library.
- // The use and distribution terms for this software are covered by the
- // Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
- // which can be found in the file CPL.TXT at the root of this distribution.
- // By using this software in any fashion, you are agreeing to be bound by
- // the terms of this license. You must not remove this notice, or
- // any other, from this software.
-
- #ifndef __ATLCTRLS_H__
- #define __ATLCTRLS_H__
-
- #pragma once
-
- #ifndef __ATLAPP_H__
- #error atlctrls.h requires atlapp.h to be included first
- #endif
-
- #ifndef __ATLWIN_H__
- #error atlctrls.h requires atlwin.h to be included first
- #endif
-
- #ifndef _WIN32_WCE
- #include <richedit.h>
- #include <richole.h>
- #elif defined(WIN32_PLATFORM_WFSP) && !defined(_WINUSERM_H_)
- #include <winuserm.h>
- #endif // !_WIN32_WCE
-
- // protect template members from windowsx.h macros
- #ifdef _INC_WINDOWSX
- #undef GetNextSibling
- #undef GetPrevSibling
- #endif // _INC_WINDOWSX
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // Classes in this file:
- //
- // CStaticT<TBase> - CStatic
- // CButtonT<TBase> - CButton
- // CListBoxT<TBase> - CListBox
- // CComboBoxT<TBase> - CComboBox
- // CEditT<TBase> - CEdit
- // CEditCommands<T>
- // CScrollBarT<TBase> - CScrollBar
- //
- // CImageList
- // CListViewCtrlT<TBase> - CListViewCtrl
- // CTreeViewCtrlT<TBase> - CTreeViewCtrl
- // CTreeItemT<TBase> - CTreeItem
- // CTreeViewCtrlExT<TBase> - CTreeViewCtrlEx
- // CHeaderCtrlT<TBase> - CHeaderCtrl
- // CToolBarCtrlT<TBase> - CToolBarCtrl
- // CStatusBarCtrlT<TBase> - CStatusBarCtrl
- // CTabCtrlT<TBase> - CTabCtrl
- // CToolInfo
- // CToolTipCtrlT<TBase> - CToolTipCtrl
- // CTrackBarCtrlT<TBase> - CTrackBarCtrl
- // CUpDownCtrlT<TBase> - CUpDownCtrl
- // CProgressBarCtrlT<TBase> - CProgressBarCtrl
- // CHotKeyCtrlT<TBase> - CHotKeyCtrl
- // CAnimateCtrlT<TBase> - CAnimateCtrl
- // CRichEditCtrlT<TBase> - CRichEditCtrl
- // CRichEditCommands<T>
- // CDragListBoxT<TBase> - CDragListBox
- // CDragListNotifyImpl<T>
- // CReBarCtrlT<TBase> - CReBarCtrl
- // CComboBoxExT<TBase> - CComboBoxEx
- // CDateTimePickerCtrlT<TBase> - CDateTimePickerCtrl
- // CMonthCalendarCtrlT<TBase> - CMonthCalendarCtrl
- // CFlatScrollBarImpl<T>
- // CFlatScrollBarT<TBase> - CFlatScrollBar
- // CIPAddressCtrlT<TBase> - CIPAddressCtrl
- // CPagerCtrlT<TBase> - CPagerCtrl
- // CLinkCtrlT<TBase> - CLinkCtrl
- //
- // CCustomDraw<T>
- //
- // CCECommandBarCtrlT<TBase> - CCECommandBarCtrl
- // CCECommandBandsCtrlT<TBase> - CCECommandBandsCtrl
-
-
- namespace WTL
- {
-
- // These are wrapper classes for Windows standard and common controls.
- // To implement a window based on a control, use following:
- // Example: Implementing a window based on a list box
- //
- // class CMyListBox : CWindowImpl<CMyListBox, CListBox>
- // {
- // public:
- // BEGIN_MSG_MAP(CMyListBox)
- // // put your message handler entries here
- // END_MSG_MAP()
- // };
-
-
-
- // --- Standard Windows controls ---
-
- ///////////////////////////////////////////////////////////////////////////////
- // CStatic - client side for a Windows STATIC control
-
- template <class TBase>
- class CStaticT : public TBase
- {
- public:
- // Constructors
- CStaticT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CStaticT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
- // Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("STATIC");
- }
-
- #ifndef _WIN32_WCE
- HICON GetIcon() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_GETICON, 0, 0L);
- }
-
- HICON SetIcon(HICON hIcon)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L);
- }
-
- HENHMETAFILE GetEnhMetaFile() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HENHMETAFILE)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L);
- }
-
- HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HENHMETAFILE)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile);
- }
- #else // CE specific
- HICON GetIcon() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ICON, 0L);
- }
-
- HICON SetIcon(HICON hIcon)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
- #endif // _WIN32_WCE
-
- CBitmapHandle GetBitmap() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L));
- }
-
- CBitmapHandle SetBitmap(HBITMAP hBitmap)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap));
- }
-
- HCURSOR GetCursor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HCURSOR)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L);
- }
-
- HCURSOR SetCursor(HCURSOR hCursor)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HCURSOR)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
- }
- };
-
- typedef CStaticT<ATL::CWindow> CStatic;
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // CButton - client side for a Windows BUTTON control
-
- template <class TBase>
- class CButtonT : public TBase
- {
- public:
- // Constructors
- CButtonT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CButtonT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
- // Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("BUTTON");
- }
-
- UINT GetState() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, BM_GETSTATE, 0, 0L);
- }
-
- void SetState(BOOL bHighlight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETSTATE, bHighlight, 0L);
- }
-
- int GetCheck() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0L);
- }
-
- void SetCheck(int nCheck)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0L);
- }
-
- UINT GetButtonStyle() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::GetWindowLong(m_hWnd, GWL_STYLE) & 0xFFFF;
- }
-
- void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw);
- }
-
- #ifndef _WIN32_WCE
- HICON GetIcon() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L);
- }
-
- HICON SetIcon(HICON hIcon)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
-
- CBitmapHandle GetBitmap() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L));
- }
-
- CBitmapHandle SetBitmap(HBITMAP hBitmap)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap));
- }
- #endif // !_WIN32_WCE
-
- #if (_WIN32_WINNT >= 0x0501)
- BOOL GetIdealSize(LPSIZE lpSize) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize);
- }
-
- BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist);
- }
-
- BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist);
- }
-
- BOOL GetTextMargin(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect);
- }
-
- BOOL SetTextMargin(LPRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect);
- }
- #endif // (_WIN32_WINNT >= 0x0501)
-
- #if (WINVER >= 0x0600)
- void SetDontClick(BOOL bDontClick)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L);
- }
- #endif // (WINVER >= 0x0600)
-
- #if (_WIN32_WINNT >= 0x0600)
- BOOL SetDropDownState(BOOL bDropDown)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L);
- }
-
- BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo);
- }
-
- BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo);
- }
-
- int GetNoteLength() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
- return (int)::SendMessage(m_hWnd, BCM_GETNOTELENGTH, 0, 0L);
- }
-
- BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText);
- }
-
- BOOL SetNote(LPCWSTR lpstrNoteText)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText);
- }
-
- LRESULT SetElevationRequiredState(BOOL bSet)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::SendMessage(m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet);
- }
- #endif // (_WIN32_WINNT >= 0x0600)
-
- // Operations
- void Click()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_CLICK, 0, 0L);
- }
- };
-
- typedef CButtonT<ATL::CWindow> CButton;
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // CListBox - client side for a Windows LISTBOX control
-
- template <class TBase>
- class CListBoxT : public TBase
- {
- public:
- // Constructors
- CListBoxT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CListBoxT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
- // Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("LISTBOX");
- }
-
- // for entire listbox
- int GetCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0L);
- }
-
- #ifndef _WIN32_WCE
- int SetCount(int cItems)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(((GetStyle() & LBS_NODATA) != 0) && ((GetStyle() & LBS_HASSTRINGS) == 0));
- return (int)::SendMessage(m_hWnd, LB_SETCOUNT, cItems, 0L);
- }
- #endif // !_WIN32_WCE
-
- int GetHorizontalExtent() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L);
- }
-
- void SetHorizontalExtent(int cxExtent)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L);
- }
-
- int GetTopIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETTOPINDEX, 0, 0L);
- }
-
- int SetTopIndex(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETTOPINDEX, nIndex, 0L);
- }
-
- LCID GetLocale() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0L);
- }
-
- LCID SetLocale(LCID nNewLocale)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L);
- }
-
- #if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
- DWORD GetListBoxInfo() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- #if (_WIN32_WINNT >= 0x0501)
- return (DWORD)::SendMessage(m_hWnd, LB_GETLISTBOXINFO, 0, 0L);
- #else // !(_WIN32_WINNT >= 0x0501)
- return ::GetListBoxInfo(m_hWnd);
- #endif // !(_WIN32_WINNT >= 0x0501)
- }
- #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
-
- // for single-selection listboxes
- int GetCurSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0);
- return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0L);
- }
-
- int SetCurSel(int nSelect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0);
- return (int)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0L);
- }
-
- // for multiple-selection listboxes
- int GetSel(int nIndex) const // also works for single-selection
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETSEL, nIndex, 0L);
- }
-
- int SetSel(int nIndex, BOOL bSelect = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_SETSEL, bSelect, nIndex);
- }
-
- int GetSelCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_GETSELCOUNT, 0, 0L);
- }
-
- int GetSelItems(int nMaxItems, LPINT rgIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex);
- }
-
- int GetAnchorIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_GETANCHORINDEX, 0, 0L);
- }
-
- void SetAnchorIndex(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- ::SendMessage(m_hWnd, LB_SETANCHORINDEX, nIndex, 0L);
- }
-
- int GetCaretIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETCARETINDEX, 0, 0);
- }
-
- int SetCaretIndex(int nIndex, BOOL bScroll = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0));
- }
-
- // for listbox items
- DWORD_PTR GetItemData(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD_PTR)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L);
- }
-
- int SetItemData(int nIndex, DWORD_PTR dwItemData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
- }
-
- void* GetItemDataPtr(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (void*)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L);
- }
-
- int SetItemDataPtr(int nIndex, void* pData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItemData(nIndex, (DWORD_PTR)pData);
- }
-
- int GetItemRect(int nIndex, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect);
- }
-
- int GetText(int nIndex, LPTSTR lpszBuffer) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer);
- }
-
- #ifndef _ATL_NO_COM
- #ifdef _OLEAUTO_H_
- BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const
- {
- USES_CONVERSION;
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(bstrText == NULL);
-
- int nLen = GetTextLen(nIndex);
- if(nLen == LB_ERR)
- return FALSE;
-
- CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
- LPTSTR lpstrText = buff.Allocate(nLen + 1);
- if(lpstrText == NULL)
- return FALSE;
-
- if(GetText(nIndex, lpstrText) == LB_ERR)
- return FALSE;
-
- bstrText = ::SysAllocString(T2OLE(lpstrText));
- return (bstrText != NULL) ? TRUE : FALSE;
- }
- #endif // _OLEAUTO_H_
- #endif // !_ATL_NO_COM
-
- #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- int GetText(int nIndex, _CSTRING_NS::CString& strText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- int cchLen = GetTextLen(nIndex);
- if(cchLen == LB_ERR)
- return LB_ERR;
- int nRet = LB_ERR;
- LPTSTR lpstr = strText.GetBufferSetLength(cchLen);
- if(lpstr != NULL)
- {
- nRet = GetText(nIndex, lpstr);
- strText.ReleaseBuffer();
- }
- return nRet;
- }
- #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
-
- int GetTextLen(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0L);
- }
-
- int GetItemHeight(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L);
- }
-
- int SetItemHeight(int nIndex, UINT cyItemHeight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
- }
-
- // Settable only attributes
- void SetColumnWidth(int cxWidth)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L);
- }
-
- BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
- }
-
- BOOL SetTabStops()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 0, 0L);
- }
-
- BOOL SetTabStops(const int& cxEachStop) // takes an 'int'
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
- }
-
- // Operations
- int InitStorage(int nItems, UINT nBytes)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes);
- }
-
- void ResetContent()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LB_RESETCONTENT, 0, 0L);
- }
-
- UINT ItemFromPoint(POINT pt, BOOL& bOutside) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
- bOutside = (BOOL)HIWORD(dw);
- return (UINT)LOWORD(dw);
- }
-
- // manipulating listbox items
- int AddString(LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem);
- }
-
- int DeleteString(UINT nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_DELETESTRING, nIndex, 0L);
- }
-
- int InsertString(int nIndex, LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem);
- }
-
- #ifndef _WIN32_WCE
- int Dir(UINT attr, LPCTSTR lpszWildCard)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard);
- }
-
- int AddFile(LPCTSTR lpstrFileName)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName);
- }
- #endif // !_WIN32_WCE
-
- // selection helpers
- int FindString(int nStartAfter, LPCTSTR lpszItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem);
- }
-
- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
- }
-
- int SelectString(int nStartAfter, LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem);
- }
-
- int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- ATLASSERT(nFirstItem <= nLastItem);
- return bSelect ? (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem);
- }
-
- #ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages
- DWORD GetInputMode(BOOL bCurrentMode = TRUE)
- {
- return SendMessage(LB_GETINPUTMODE, 0, (LPARAM)bCurrentMode);
- }
-
- BOOL SetInputMode(DWORD dwMode)
- {
- return SendMessage(LB_SETINPUTMODE, 0, (LPARAM)dwMode);
- }
- #endif // WIN32_PLATFORM_WFSP
- };
-
- typedef CListBoxT<ATL::CWindow> CListBox;
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // CComboBox - client side for a Windows COMBOBOX control
-
- #ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones
-
- template <class TBase>
- class CComboBoxT : public TBase
- {
- public:
- // Constructors
- CComboBoxT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CComboBoxT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
- // Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("COMBOBOX");
- }
-
- // for entire combo box
- int GetCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0L);
- }
-
- int GetCurSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0L);
- }
-
- int SetCurSel(int nSelect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0L);
- }
-
- LCID GetLocale() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0L);
- }
-
- LCID SetLocale(LCID nNewLocale)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L);
- }
-
- int GetTopIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0L);
- }
-
- int SetTopIndex(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0L);
- }
-
- UINT GetHorizontalExtent() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L);
- }
-
- void SetHorizontalExtent(UINT nExtent)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L);
- }
-
- int GetDroppedWidth() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L);
- }
-
- int SetDroppedWidth(UINT nWidth)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L);
- }
-
- #if ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- #if ((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- return (BOOL)::SendMessage(m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo);
- #else // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- return ::GetComboBoxInfo(m_hWnd, pComboBoxInfo);
- #endif // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- }
- #endif // ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
-
- // for edit control
- DWORD GetEditSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0L);
- }
-
- BOOL SetEditSel(int nStartChar, int nEndChar)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar));
- }
-
- // for combobox item
- DWORD_PTR GetItemData(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD_PTR)::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex, 0L);
- }
-
- int SetItemData(int nIndex, DWORD_PTR dwItemData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
- }
-
- void* GetItemDataPtr(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (void*)GetItemData(nIndex);
- }
-
- int SetItemDataPtr(int nIndex, void* pData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItemData(nIndex, (DWORD_PTR)pData);
- }
-
- int GetLBText(int nIndex, LPTSTR lpszText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText);
- }
-
- #ifndef _ATL_NO_COM
- BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const
- {
- USES_CONVERSION;
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(bstrText == NULL);
-
- int nLen = GetLBTextLen(nIndex);
- if(nLen == CB_ERR)
- return FALSE;
-
- CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
- LPTSTR lpstrText = buff.Allocate(nLen + 1);
- if(lpstrText == NULL)
- return FALSE;
-
- if(GetLBText(nIndex, lpstrText) == CB_ERR)
- return FALSE;
-
- bstrText = ::SysAllocString(T2OLE(lpstrText));
- return (bstrText != NULL) ? TRUE : FALSE;
- }
- #endif // !_ATL_NO_COM
-
- #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- int GetLBText(int nIndex, _CSTRING_NS::CString& strText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- int cchLen = GetLBTextLen(nIndex);
- if(cchLen == CB_ERR)
- return CB_ERR;
- int nRet = CB_ERR;
- LPTSTR lpstr = strText.GetBufferSetLength(cchLen);
- if(lpstr != NULL)
- {
- nRet = GetLBText(nIndex, lpstr);
- strText.ReleaseBuffer();
- }
- return nRet;
- }
- #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
-
- int GetLBTextLen(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L);
- }
-
- int GetItemHeight(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L);
- }
-
- int SetItemHeight(int nIndex, UINT cyItemHeight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
- }
-
- BOOL GetExtendedUI() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L);
- }
-
- int SetExtendedUI(BOOL bExtended = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L);
- }
-
- void GetDroppedControlRect(LPRECT lprect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect);
- }
-
- BOOL GetDroppedState() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L);
- }
-
- #if (_WIN32_WINNT >= 0x0501)
- int GetMinVisible() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETMINVISIBLE, 0, 0L);
- }
-
- BOOL SetMinVisible(int nMinVisible)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L);
- }
-
- // Vista only
- BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const
- {
- #ifndef CB_GETCUEBANNER
- const UINT CB_GETCUEBANNER = (CBM_FIRST + 4);
- #endif
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText);
- }
-
- // Vista only
- BOOL SetCueBannerText(LPCWSTR lpcwText)
- {
- #ifndef CB_SETCUEBANNER
- const UINT CB_SETCUEBANNER = (CBM_FIRST + 3);
- #endif
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText);
- }
- #endif // (_WIN32_WINNT >= 0x0501)
-
- // Operations
- int InitStorage(int nItems, UINT nBytes)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes);
- }
-
- void ResetContent()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0L);
- }
-
- // for edit control
- BOOL LimitText(int nMaxChars)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0L);
- }
-
- // for drop-down combo boxes
- void ShowDropDown(BOOL bShowIt = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L);
- }
-
- // manipulating listbox items
- int AddString(LPCTSTR lpszString)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString);
- }
-
- int DeleteString(UINT nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0L);
- }
-
- int InsertString(int nIndex, LPCTSTR lpszString)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString);
- }
-
- #ifndef _WIN32_WCE
- int Dir(UINT attr, LPCTSTR lpszWildCard)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard);
- }
- #endif // !_WIN32_WCE
-
- // selection helpers
- int FindString(int nStartAfter, LPCTSTR lpszString) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString);
- }
-
- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
- }
-
- int SelectString(int nStartAfter, LPCTSTR lpszString)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString);
- }
-
- // Clipboard operations
- void Clear()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
- }
-
- void Copy()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
- }
-
- void Cut()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
- }
-
- void Paste()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
- }
- };
-
- typedef CComboBoxT<ATL::CWindow> CComboBox;
-
- #endif // !WIN32_PLATFORM_WFSP
-
- ///////////////////////////////////////////////////////////////////////////////
- // CEdit - client side for a Windows EDIT control
-
- template <class TBase>
- class CEditT : public TBase
- {
- public:
- // Constructors
- CEditT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CEditT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
- // Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("EDIT");
- }
-
- BOOL CanUndo() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L);
- }
-
- int GetLineCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L);
- }
-
- BOOL GetModify() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L);
- }
-
- void SetModify(BOOL bModified = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L);
- }
-
- void GetRect(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect);
- }
-
- DWORD GetSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L);
- }
-
- void GetSel(int& nStartChar, int& nEndChar) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar);
- }
-
- #ifndef _WIN32_WCE
- HLOCAL GetHandle() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0L);
- }
-
- void SetHandle(HLOCAL hBuffer)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L);
- }
- #endif // !_WIN32_WCE
-
- DWORD GetMargins() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L);
- }
-
- void SetMargins(UINT nLeft, UINT nRight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(nLeft, nRight));
- }
-
- UINT GetLimitText() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L);
- }
-
- void SetLimitText(UINT nMax)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0L);
- }
-
- POINT PosFromChar(UINT nChar) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_POSFROMCHAR, nChar, 0);
- POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) };
- return point;
- }
-
- int CharFromPos(POINT pt, int* pLine = NULL) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y));
- if(pLine != NULL)
- *pLine = (int)(short)HIWORD(dwRet);
- return (int)(short)LOWORD(dwRet);
- }
-
- // NOTE: first word in lpszBuffer must contain the size of the buffer!
- int GetLine(int nIndex, LPTSTR lpszBuffer) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
- }
-
- int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- *(LPWORD)lpszBuffer = (WORD)nMaxLength;
- return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
- }
-
- TCHAR GetPasswordChar() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L);
- }
-
- void SetPasswordChar(TCHAR ch)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0L);
- }
-
- #ifndef _WIN32_WCE
- EDITWORDBREAKPROC GetWordBreakProc() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L);
- }
-
- void SetWordBreakProc(EDITWORDBREAKPROC ewbprc)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc);
- }
- #endif // !_WIN32_WCE
-
- int GetFirstVisibleLine() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L);
- }
-
- #ifndef _WIN32_WCE
- int GetThumb() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & ES_MULTILINE) != 0);
- return (int)::SendMessage(m_hWnd, EM_GETTHUMB, 0, 0L);
- }
- #endif // !_WIN32_WCE
-
- BOOL SetReadOnly(BOOL bReadOnly = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L);
- }
-
- #if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
- UINT GetImeStatus(UINT uStatus) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, EM_GETIMESTATUS, uStatus, 0L);
- }
-
- UINT SetImeStatus(UINT uStatus, UINT uData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, EM_SETIMESTATUS, uStatus, uData);
- }
- #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
-
- #if (_WIN32_WINNT >= 0x0501)
- BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText);
- }
-
- // bKeepWithFocus - Vista only
- BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText));
- }
- #endif // (_WIN32_WINNT >= 0x0501)
-
- // Operations
- void EmptyUndoBuffer()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L);
- }
-
- BOOL FmtLines(BOOL bAddEOL)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0L);
- }
-
- void LimitText(int nChars = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0L);
- }
-
- int LineFromChar(int nIndex = -1) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_LINEFROMCHAR, nIndex, 0L);
- }
-
- int LineIndex(int nLine = -1) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L);
- }
-
- int LineLength(int nLine = -1) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L);
- }
-
- void LineScroll(int nLines, int nChars = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines);
- }
-
- void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);
- }
-
- void SetRect(LPCRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect);
- }
-
- void SetRectNP(LPCRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect);
- }
-
- void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));
- if(!bNoScroll)
- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
- }
-
- void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
- if(!bNoScroll)
- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
- }
-
- void SetSelAll(BOOL bNoScroll = FALSE)
- {
- SetSel(0, -1, bNoScroll);
- }
-
- void SetSelNone(BOOL bNoScroll = FALSE)
- {
- SetSel(-1, 0, bNoScroll);
- }
-
- BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
- }
-
- BOOL SetTabStops()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L);
- }
-
- BOOL SetTabStops(const int& cxEachStop) // takes an 'int'
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
- }
-
- void ScrollCaret()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
- }
-
- int Scroll(int nScrollAction)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & ES_MULTILINE) != 0);
- LRESULT lRet = ::SendMessage(m_hWnd, EM_SCROLL, nScrollAction, 0L);
- if(!(BOOL)HIWORD(lRet))
- return -1; // failed
- return (int)(short)LOWORD(lRet);
-
- }
-
- void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)
- {
- SetSel(nInsertAfterChar, nInsertAfterChar, bNoScroll);
- ReplaceSel(lpstrText, bCanUndo);
- }
-
- void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)
- {
- InsertText(GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo);
- }
-
- #if (_WIN32_WINNT >= 0x0501)
- BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip);
- }
-
- BOOL HideBalloonTip()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_HIDEBALLOONTIP, 0, 0L);
- }
- #endif // (_WIN32_WINNT >= 0x0501)
-
- #if (_WIN32_WINNT >= 0x0600)
- DWORD GetHilite() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L);
- }
-
- void GetHilite(int& nStartChar, int& nEndChar) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L);
- nStartChar = (int)(short)LOWORD(dwRet);
- nEndChar = (int)(short)HIWORD(dwRet);
- }
-
- void SetHilite(int nStartChar, int nEndChar)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETHILITE, nStartChar, nEndChar);
- }
- #endif // (_WIN32_WINNT >= 0x0600)
-
- // Clipboard operations
- BOOL Undo()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L);
- }
-
- void Clear()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
- }
-
- void Copy()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
- }
-
- void Cut()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
- }
-
- void Paste()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
- }
-
- #ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages
- DWORD GetExtendedStyle()
- {
- return SendMessage(EM_GETEXTENDEDSTYLE);
- }
-
- DWORD SetExtendedStyle(DWORD dwMask, DWORD dwExStyle)
- {
- return SendMessage(EM_SETEXTENDEDSTYLE, (WPARAM)dwMask, (LPARAM)dwExStyle);
- }
-
- DWORD GetInputMode(BOOL bCurrentMode = TRUE)
- {
- return SendMessage(EM_GETINPUTMODE, 0, (LPARAM)bCurrentMode);
- }
-
- BOOL SetInputMode(DWORD dwMode)
- {
- return SendMessage(EM_SETINPUTMODE, 0, (LPARAM)dwMode);
- }
-
- BOOL SetSymbols(LPCTSTR szSymbols)
- {
- return SendMessage(EM_SETSYMBOLS, 0, (LPARAM)szSymbols);
- }
-
- BOOL ResetSymbols()
- {
- return SendMessage(EM_SETSYMBOLS);
- }
- #endif // WIN32_PLATFORM_WFSP
- };
-
- typedef CEditT<ATL::CWindow> CEdit;
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // CEditCommands - message handlers for standard EDIT commands
-
- // Chain to CEditCommands message map. Your class must also derive from CEdit.
- // Example:
- // class CMyEdit : public CWindowImpl<CMyEdit, CEdit>,
- // public CEditCommands<CMyEdit>
- // {
- // public:
- // BEGIN_MSG_MAP(CMyEdit)
- // // your handlers...
- // CHAIN_MSG_MAP_ALT(CEditCommands<CMyEdit>, 1)
- // END_MSG_MAP()
- // // other stuff...
- // };
-
- template <class T>
- class CEditCommands
- {
- public:
- BEGIN_MSG_MAP(CEditCommands< T >)
- ALT_MSG_MAP(1)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll)
- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
- COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut)
- COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste)
- COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll)
- COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo)
- END_MSG_MAP()
-
- LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->Clear();
- return 0;
- }
-
- LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->SetSel(0, -1);
- pT->Clear();
- return 0;
- }
-
- LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->Copy();
- return 0;
- }
-
- LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->Cut();
- return 0;
- }
-
- LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->Paste();
- return 0;
- }
-
- LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->SetSel(0, -1);
- return 0;
- }
-
- LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast<T*>(this);
- pT->Undo();
- return 0;
- }
-
- // State (update UI) helpers
- BOOL CanCut() const
- { return HasSelection(); }
-
- BOOL CanCopy() const
- { return HasSelection(); }
-
- BOOL CanClear() const
- { return HasSelection(); }
-
- BOOL CanSelectAll() const
- { return HasText(); }
-
- BOOL CanFind() const
- { return HasText(); }
-
- BOOL CanRepeat() const
- { return HasText(); }
-
- BOOL CanReplace() const
- { return HasText(); }
-
- BOOL CanClearAll() const
- { return HasText(); }
-
- // Implementation
- BOOL HasSelection() const
- {
- const T* pT = static_cast<const T*>(this);
- int nMin, nMax;
- ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nMin, (LPARAM)&nMax);
- return (nMin != nMax);
- }
-
- BOOL HasText() const
- {
- const T* pT = static_cast<const T*>(this);
- return (pT->GetWindowTextLength() > 0);
- }
- };
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // CScrollBar - client side for a Windows SCROLLBAR control
-
- template <class TBase>
- class CScrollBarT : public TBase
- {
- public:
- // Constructors
- CScrollBarT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CScrollBarT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
- // Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("SCROLLBAR");
- }
-
- #ifndef _WIN32_WCE
- int GetScrollPos() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::GetScrollPos(m_hWnd, SB_CTL);
- }
- #endif // !_WIN32_WCE
-
- int SetScrollPos(int nPos, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw);
- }
-
- #ifndef _WIN32_WCE
- void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos);
- }
- #endif // !_WIN32_WCE
-
- void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw);
- }
-
- BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::GetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo);
- }
-
- int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::SetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo, bRedraw);
- }
-
- #ifndef _WIN32_WCE
- int GetScrollLimit() const
- {
- int nMin = 0, nMax = 0;
- ::GetScrollRange(m_hWnd, SB_CTL, &nMin, &nMax);
- SCROLLINFO info = { sizeof(SCROLLINFO), SIF_PAGE };
- if(::GetScrollInfo(m_hWnd, SB_CTL, &info))
- nMax -= ((info.nPage - 1) > 0) ? (info.nPage - 1) : 0;
-
- return nMax;
- }
-
- #if (WINVER >= 0x0500)
- BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- #if (_WIN32_WINNT >= 0x0501)
- return (BOOL)::SendMessage(m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo);
- #else // !(_WIN32_WINNT >= 0x0501)
- return ::GetScrollBarInfo(m_hWnd, OBJID_CLIENT, pScrollBarInfo);
- #endif // !(_WIN32_WINNT >= 0x0501)
- }
- #endif // (WINVER >= 0x0500)
-
- // Operations
- void ShowScrollBar(BOOL bShow = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::ShowScrollBar(m_hWnd, SB_CTL, bShow);
- }
-
- BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags);
- }
- #endif // !_WIN32_WCE
- };
-
- typedef CScrollBarT<ATL::CWindow> CScrollBar;
-
-
- // --- Windows Common Controls ---
-
- ///////////////////////////////////////////////////////////////////////////////
- // CImageList
-
- class CImageList
- {
- public:
- HIMAGELIST m_hImageList;
-
- // Constructor
- CImageList(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList)
- { }
-
- // Operators, etc.
- CImageList& operator =(HIMAGELIST hImageList)
- {
- m_hImageList = hImageList;
- return *this;
- }
-
- operator HIMAGELIST() const { return m_hImageList; }
-
- void Attach(HIMAGELIST hImageList)
- {
- ATLASSERT(m_hImageList == NULL);
- ATLASSERT(hImageList != NULL);
- m_hImageList = hImageList;
- }
-
- HIMAGELIST Detach()
- {
- HIMAGELIST hImageList = m_hImageList;
- m_hImageList = NULL;
- return hImageList;
- }
-
- bool IsNull() const { return (m_hImageList == NULL); }
-
- // Attributes
- int GetImageCount() const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetImageCount(m_hImageList);
- }
-
- COLORREF GetBkColor() const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetBkColor(m_hImageList);
- }
-
- COLORREF SetBkColor(COLORREF cr)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetBkColor(m_hImageList, cr);
- }
-
- BOOL GetImageInfo(int nImage, IMAGEINFO* p…