blob: cbafb29cf40f58f9fde1492e2311b9d96c248dbc [file] [log] [blame]
// Windows Template Library - WTL version 8.0
// 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
// Microsoft Permissive License (Ms-PL) which can be found in the file
// Ms-PL.txt at the root of this distribution.
#ifndef __ATLCTRLS_H__
#define __ATLCTRLS_H__
#pragma once
#ifndef __cplusplus
#error ATL requires C++ compilation (use a .cpp suffix)
#endif
#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
#if (_WIN32_IE < 0x0300)
#error atlctrls.h requires IE Version 3.0 or higher
#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 = { 0 };
info.cbSize = sizeof(SCROLLINFO);
info.fMask = 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* pImageInfo) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo);
}
HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetIcon(m_hImageList, nIndex, uFlags);
}
BOOL GetIconSize(int& cx, int& cy) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetIconSize(m_hImageList, &cx, &cy);
}
BOOL GetIconSize(SIZE& size) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*)&size.cy);
}
BOOL SetIconSize(int cx, int cy)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetIconSize(m_hImageList, cx, cy);
}
BOOL SetIconSize(SIZE size)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetIconSize(m_hImageList, size.cx, size.cy);
}
BOOL SetImageCount(UINT uNewCount)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetImageCount(m_hImageList, uNewCount);
}
BOOL SetOverlayImage(int nImage, int nOverlay)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay);
}
// Operations
BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow)
{
ATLASSERT(m_hImageList == NULL);
m_hImageList = ImageList_Create(cx, cy, nFlags, nInitial, nGrow);
return (m_hImageList != NULL) ? TRUE : FALSE;
}
BOOL Create(ATL::_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMask)
{
ATLASSERT(m_hImageList == NULL);
m_hImageList = ImageList_LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr, cx, nGrow, crMask);
return (m_hImageList != NULL) ? TRUE : FALSE;
}
BOOL CreateFromImage(ATL::_U_STRINGorID image, int cx, int nGrow, COLORREF crMask, UINT uType, UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE)
{
ATLASSERT(m_hImageList == NULL);
m_hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInstance(), image.m_lpstr, cx, nGrow, crMask, uType, uFlags);
return (m_hImageList != NULL) ? TRUE : FALSE;
}
BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2, int nImage2, int dx, int dy)
{
ATLASSERT(m_hImageList == NULL);
m_hImageList = ImageList_Merge(hImageList1, nImage1, hImageList2, nImage2, dx, dy);
return (m_hImageList != NULL) ? TRUE : FALSE;
}
#ifndef _WIN32_WCE
#ifdef __IStream_INTERFACE_DEFINED__
BOOL CreateFromStream(LPSTREAM lpStream)
{
ATLASSERT(m_hImageList == NULL);
m_hImageList = ImageList_Read(lpStream);
return (m_hImageList != NULL) ? TRUE : FALSE;
}
#endif // __IStream_INTERFACE_DEFINED__
#endif // !_WIN32_WCE
BOOL Destroy()
{
if (m_hImageList == NULL)
return FALSE;
BOOL bRet = ImageList_Destroy(m_hImageList);
if(bRet)
m_hImageList = NULL;
return bRet;
}
int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_Add(m_hImageList, hBitmap, hBitmapMask);
}
int Add(HBITMAP hBitmap, COLORREF crMask)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_AddMasked(m_hImageList, hBitmap, crMask);
}
BOOL Remove(int nImage)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_Remove(m_hImageList, nImage);
}
BOOL RemoveAll()
{
ATLASSERT(m_hImageList != NULL);
return ImageList_RemoveAll(m_hImageList);
}
BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_Replace(m_hImageList, nImage, hBitmap, hBitmapMask);
}
int AddIcon(HICON hIcon)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_AddIcon(m_hImageList, hIcon);
}
int ReplaceIcon(int nImage, HICON hIcon)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon);
}
HICON ExtractIcon(int nImage)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_ExtractIcon(NULL, m_hImageList, nImage);
}
BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle)
{
ATLASSERT(m_hImageList != NULL);
ATLASSERT(hDC != NULL);
return ImageList_Draw(m_hImageList, nImage, hDC, x, y, nStyle);
}
BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle)
{
ATLASSERT(m_hImageList != NULL);
ATLASSERT(hDC != NULL);
return ImageList_Draw(m_hImageList, nImage, hDC, pt.x, pt.y, nStyle);
}
BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
{
ATLASSERT(m_hImageList != NULL);
ATLASSERT(hDC != NULL);
return ImageList_DrawEx(m_hImageList, nImage, hDC, x, y, dx, dy, rgbBk, rgbFg, fStyle);
}
BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
{
ATLASSERT(m_hImageList != NULL);
ATLASSERT(hDC != NULL);
return ImageList_DrawEx(m_hImageList, nImage, hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, rgbBk, rgbFg, fStyle);
}
static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp)
{
return ImageList_DrawIndirect(pimldp);
}
BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_Copy(m_hImageList, nDst, m_hImageList, nSrc, uFlags);
}
#ifdef __IStream_INTERFACE_DEFINED__
#ifndef _WIN32_WCE
static HIMAGELIST Read(LPSTREAM lpStream)
{
return ImageList_Read(lpStream);
}
BOOL Write(LPSTREAM lpStream)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_Write(m_hImageList, lpStream);
}
#endif // !_WIN32_WCE
#if (_WIN32_WINNT >= 0x0501)
static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv)
{
return ImageList_ReadEx(dwFlags, lpStream, riid, ppv);
}
HRESULT WriteEx(DWORD dwFlags, LPSTREAM lpStream)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_WriteEx(m_hImageList, dwFlags, lpStream);
}
#endif // (_WIN32_WINNT >= 0x0501)
#endif // __IStream_INTERFACE_DEFINED__
// Drag operations
BOOL BeginDrag(int nImage, POINT ptHotSpot)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, ptHotSpot.y);
}
BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_BeginDrag(m_hImageList, nImage, xHotSpot, yHotSpot);
}
static void EndDrag()
{
ImageList_EndDrag();
}
static BOOL DragMove(POINT pt)
{
return ImageList_DragMove(pt.x, pt.y);
}
static BOOL DragMove(int x, int y)
{
return ImageList_DragMove(x, y);
}
BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSpot.x, ptHotSpot.y);
}
BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetDragCursorImage(m_hImageList, nDrag, xHotSpot, yHotSpot);
}
static BOOL DragShowNolock(BOOL bShow = TRUE)
{
return ImageList_DragShowNolock(bShow);
}
static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot)
{
return CImageList(ImageList_GetDragImage(lpPoint, lpPointHotSpot));
}
static BOOL DragEnter(HWND hWnd, POINT point)
{
return ImageList_DragEnter(hWnd, point.x, point.y);
}
static BOOL DragEnter(HWND hWnd, int x, int y)
{
return ImageList_DragEnter(hWnd, x, y);
}
static BOOL DragLeave(HWND hWnd)
{
return ImageList_DragLeave(hWnd);
}
#if (_WIN32_IE >= 0x0400)
CImageList Duplicate() const
{
ATLASSERT(m_hImageList != NULL);
return CImageList(ImageList_Duplicate(m_hImageList));
}
static CImageList Duplicate(HIMAGELIST hImageList)
{
ATLASSERT(hImageList != NULL);
return CImageList(ImageList_Duplicate(hImageList));
}
#endif // (_WIN32_IE >= 0x0400)
};
///////////////////////////////////////////////////////////////////////////////
// CToolTipCtrl
#ifndef _WIN32_WCE
class CToolInfo : public TOOLINFO
{
public:
CToolInfo(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
{
Init(nFlags, hWnd, nIDTool, lpRect, lpstrText, lUserParam);
}
operator LPTOOLINFO() { return this; }
operator LPARAM() { return (LPARAM)this; }
void Init(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
{
ATLASSERT(::IsWindow(hWnd));
memset(this, 0, sizeof(TOOLINFO));
cbSize = sizeof(TOOLINFO);
uFlags = nFlags;
if(nIDTool == 0)
{
hwnd = ::GetParent(hWnd);
uFlags |= TTF_IDISHWND;
uId = (UINT_PTR)hWnd;
}
else
{
hwnd = hWnd;
uId = nIDTool;
}
if(lpRect != NULL)
rect = *lpRect;
hinst = ModuleHelper::GetResourceInstance();
lpszText = lpstrText;
lParam = lUserParam;
}
};
template <class TBase>
class CToolTipCtrlT : public TBase
{
public:
// Constructors
CToolTipCtrlT(HWND hWnd = NULL) : TBase(hWnd)
{ }
CToolTipCtrlT< 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 TOOLTIPS_CLASS;
}
void GetText(LPTOOLINFO lpToolInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo);
}
void GetText(LPTSTR lpstrText, HWND hWnd, UINT nIDTool = 0) const
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText);
::SendMessage(m_hWnd, TTM_GETTEXT, 0, ti);
}
BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo);
}
BOOL GetToolInfo(HWND hWnd, UINT nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
ATLASSERT(puFlags != NULL);
ATLASSERT(lpRect != NULL);
CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText);
BOOL bRet = (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, ti);
if(bRet != FALSE)
{
*puFlags = ti.uFlags;
*lpRect = ti.rect;
}
return bRet;
}
void SetToolInfo(LPTOOLINFO lpToolInfo)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo);
}
void SetToolRect(LPTOOLINFO lpToolInfo)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo);
}
void SetToolRect(HWND hWnd, UINT nIDTool, LPCRECT lpRect)
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
ATLASSERT(nIDTool != 0);
CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL);
::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, ti);
}
int GetToolCount() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, TTM_GETTOOLCOUNT, 0, 0L);
}
int GetDelayTime(DWORD dwType) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, TTM_GETDELAYTIME, dwType, 0L);
}
void SetDelayTime(DWORD dwType, int nTime)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0));
}
void GetMargin(LPRECT lpRect) const
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect);
}
void SetMargin(LPRECT lpRect)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect);
}
int GetMaxTipWidth() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L);
}
int SetMaxTipWidth(int nWidth)
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth);
}
COLORREF GetTipBkColor() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L);
}
void SetTipBkColor(COLORREF clr)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L);
}
COLORREF GetTipTextColor() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L);
}
void SetTipTextColor(COLORREF clr)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L);
}
BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo);
}
#if (_WIN32_IE >= 0x0500)
SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo);
SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) };
return size;
}
BOOL SetTitle(UINT uIcon, LPCTSTR lpstrTitle)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle);
}
#endif // (_WIN32_IE >= 0x0500)
#if (_WIN32_WINNT >= 0x0501)
void GetTitle(PTTGETTITLE pTTGetTitle) const
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle);
}
void SetWindowTheme(LPCWSTR lpstrTheme)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme);
}
#endif // (_WIN32_WINNT >= 0x0501)
// Operations
void Activate(BOOL bActivate)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_ACTIVATE, bActivate, 0L);
}
BOOL AddTool(LPTOOLINFO lpToolInfo)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo);
}
BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT nIDTool = 0)
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
// the toolrect and toolid must both be zero or both valid
ATLASSERT((lpRectTool != NULL && nIDTool != 0) || (lpRectTool == NULL && nIDTool == 0));
CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr);
return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, ti);
}
void DelTool(LPTOOLINFO lpToolInfo)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo);
}
void DelTool(HWND hWnd, UINT nIDTool = 0)
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
CToolInfo ti(0, hWnd, nIDTool, NULL, NULL);
::SendMessage(m_hWnd, TTM_DELTOOL, 0, ti);
}
BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo);
}
BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
ATLASSERT(lpToolInfo != NULL);
TTHITTESTINFO hti = { 0 };
hti.ti.cbSize = sizeof(TOOLINFO);
hti.hwnd = hWnd;
hti.pt.x = pt.x;
hti.pt.y = pt.y;
if((BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE)
{
*lpToolInfo = hti.ti;
return TRUE;
}
return FALSE;
}
void RelayEvent(LPMSG lpMsg)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg);
}
void UpdateTipText(LPTOOLINFO lpToolInfo)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo);
}
void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT nIDTool = 0)
{
ATLASSERT(::IsWindow(m_hWnd));
ATLASSERT(hWnd != NULL);
CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr);
::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, ti);
}
BOOL EnumTools(UINT nTool, LPTOOLINFO lpToolInfo) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo);
}
void Pop()
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_POP, 0, 0L);
}
void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo);
}
void TrackPosition(int xPos, int yPos)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
}
#if (_WIN32_IE >= 0x0400)
void Update()
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_UPDATE, 0, 0L);
}
#endif // (_WIN32_IE >= 0x0400)
#if (_WIN32_IE >= 0x0500)
BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect);
}
#endif // (_WIN32_IE >= 0x0500)
#if (_WIN32_WINNT >= 0x0501)
void Popup()
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, TTM_POPUP, 0, 0L);
}
#endif // (_WIN32_WINNT >= 0x0501)
};
typedef CToolTipCtrlT<ATL::CWindow> CToolTipCtrl;
#endif // !_WIN32_WCE
///////////////////////////////////////////////////////////////////////////////
// CHeaderCtrl
template <class TBase>
class CHeaderCtrlT : public TBase
{
public:
// Constructors
CHeaderCtrlT(HWND hWnd = NULL) : TBase(hWnd)
{ }
CHeaderCtrlT< 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 WC_HEADER;
}
int GetItemCount() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, HDM_GETITEMCOUNT, 0, 0L);
}
BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem);
}
BOOL SetItem(int nIndex, LPHDITEM pHeaderItem)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem);
}
CImageList GetImageList() const
{
ATLASSERT(::IsWindow(m_hWnd));
return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_GETIMAGELIST, 0, 0L));
}
CImageList SetImageList(HIMAGELIST hImageList)
{
ATLASSERT(::IsWindow(m_hWnd));
return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList));
}
BOOL GetOrderArray(int nSize, int* lpnArray) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray);
}
BOOL SetOrderArray(int nSize, int* lpnArray)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray);
}
BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect);
}
int SetHotDivider(BOOL bPos, DWORD dwInputValue)
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue);
}
#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
BOOL GetUnicodeFormat() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L);
}
BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L);
}
#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
int GetBitmapMargin() const
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L);
}
int SetBitmapMargin(int nWidth)
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L);
}
int SetFilterChangeTimeout(DWORD dwTimeOut)
{
ATLASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut);
}
#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
#if (_WIN32_WINNT >= 0x0600)
BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMDROPDOWNRECT,