• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-c誰得cocoaqtpythonrubywindowsphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

コミットメタ情報

リビジョンc78d4b22a6582b01fbb68b72b098da7e2da0b46e (tree)
日時2012-01-20 00:18:28
作者qwerty2501 <riot313@gmai...>
コミッターqwerty2501

ログメッセージ

2012/01/20 0:18:28

変更サマリ

  • delete: include/WTL/Include/atlapp.h
  • delete: include/WTL/Include/atlcrack.h
  • delete: include/WTL/Include/atlctrls.h
  • delete: include/WTL/Include/atlctrlw.h
  • delete: include/WTL/Include/atlctrlx.h
  • delete: include/WTL/Include/atlddx.h
  • delete: include/WTL/Include/atldlgs.h
  • delete: include/WTL/Include/atldwm.h
  • delete: include/WTL/Include/atlfind.h
  • delete: include/WTL/Include/atlframe.h
  • delete: include/WTL/Include/atlgdi.h
  • delete: include/WTL/Include/atlmisc.h
  • delete: include/WTL/Include/atlprint.h
  • delete: include/WTL/Include/atlres.h
  • delete: include/WTL/Include/atlresce.h
  • delete: include/WTL/Include/atlscrl.h
  • delete: include/WTL/Include/atlsplit.h
  • delete: include/WTL/Include/atltheme.h
  • delete: include/WTL/Include/atluser.h
  • delete: include/WTL/Include/atlwince.h
  • delete: include/WTL/Include/atlwinx.h

差分

--- a/include/WTL/Include/atlapp.h
+++ /dev/null
@@ -1,1690 +0,0 @@
1-// Windows Template Library - WTL version 8.1
2-// Copyright (C) Microsoft Corporation. All rights reserved.
3-//
4-// This file is a part of the Windows Template Library.
5-// The use and distribution terms for this software are covered by the
6-// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
7-// which can be found in the file CPL.TXT at the root of this distribution.
8-// By using this software in any fashion, you are agreeing to be bound by
9-// the terms of this license. You must not remove this notice, or
10-// any other, from this software.
11-
12-#ifndef __ATLAPP_H__
13-#define __ATLAPP_H__
14-
15-#pragma once
16-
17-#ifndef __cplusplus
18- #error ATL requires C++ compilation (use a .cpp suffix)
19-#endif
20-
21-#ifndef __ATLBASE_H__
22- #error atlapp.h requires atlbase.h to be included first
23-#endif
24-
25-#ifndef _WIN32_WCE
26- #if (WINVER < 0x0400)
27- #error WTL requires Windows version 4.0 or higher
28- #endif
29-
30- #if (_WIN32_IE < 0x0300)
31- #error WTL requires IE version 3.0 or higher
32- #endif
33-#endif
34-
35-#ifdef _ATL_NO_COMMODULE
36- #error WTL requires that _ATL_NO_COMMODULE is not defined
37-#endif // _ATL_NO_COMMODULE
38-
39-#if defined(_WIN32_WCE) && defined(_ATL_MIN_CRT)
40- #pragma message("Warning: WTL for Windows CE doesn't use _ATL_MIN_CRT")
41-#endif // defined(_WIN32_WCE) && defined(_ATL_MIN_CRT)
42-
43-#include <limits.h>
44-#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE)
45- #include <process.h> // for _beginthreadex
46-#endif
47-
48-#if (_ATL_VER < 0x0800) && !defined(_DEBUG)
49- #include <stdio.h>
50-#endif
51-
52-#include <commctrl.h>
53-#ifndef _WIN32_WCE
54-#pragma comment(lib, "comctl32.lib")
55-#endif // !_WIN32_WCE
56-
57-#ifndef _WIN32_WCE
58- #include "atlres.h"
59-#else // CE specific
60- #include "atlresce.h"
61-#endif // _WIN32_WCE
62-
63-// We need to disable this warning because of template class arguments
64-#pragma warning(disable: 4127)
65-
66-
67-///////////////////////////////////////////////////////////////////////////////
68-// WTL version number
69-
70-#define _WTL_VER 0x0810
71-
72-
73-///////////////////////////////////////////////////////////////////////////////
74-// Classes in this file:
75-//
76-// CMessageFilter
77-// CIdleHandler
78-// CMessageLoop
79-//
80-// CAppModule
81-// CServerAppModule
82-//
83-// Global functions:
84-// AtlGetDefaultGuiFont()
85-// AtlCreateBoldFont()
86-// AtlInitCommonControls()
87-
88-
89-///////////////////////////////////////////////////////////////////////////////
90-// Global support for Windows CE
91-
92-#ifdef _WIN32_WCE
93-
94-#ifndef SW_SHOWDEFAULT
95- #define SW_SHOWDEFAULT SW_SHOWNORMAL
96-#endif // !SW_SHOWDEFAULT
97-
98-// These get's OR-ed in a constant and will have no effect.
99-// Defining them reduces the number of #ifdefs required for CE.
100-#define LR_DEFAULTSIZE 0
101-#define LR_LOADFROMFILE 0
102-
103-#ifndef SM_CXCURSOR
104- #define SM_CXCURSOR 13
105-#endif
106-#ifndef SM_CYCURSOR
107- #define SM_CYCURSOR 14
108-#endif
109-
110-inline BOOL IsMenu(HMENU hMenu)
111-{
112- MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
113- ::SetLastError(0);
114- BOOL bRet = ::GetMenuItemInfo(hMenu, 0, TRUE, &mii);
115- if(!bRet)
116- bRet = (::GetLastError() != ERROR_INVALID_MENU_HANDLE) ? TRUE : FALSE;
117- return bRet;
118-}
119-
120-#if (_WIN32_WCE >= 410)
121-extern "C" void WINAPI ListView_SetItemSpacing(HWND hwndLV, int iHeight);
122-#endif // (_WIN32_WCE >= 410)
123-
124-inline int MulDiv(IN int nNumber, IN int nNumerator, IN int nDenominator)
125-{
126- __int64 multiple = nNumber * nNumerator;
127- return static_cast<int>(multiple / nDenominator);
128-}
129-
130-#if (_ATL_VER >= 0x0800)
131-
132-#ifndef _WTL_KEEP_WS_OVERLAPPEDWINDOW
133- #ifdef WS_OVERLAPPEDWINDOW
134- #undef WS_OVERLAPPEDWINDOW
135- #define WS_OVERLAPPEDWINDOW 0
136- #endif // WS_OVERLAPPEDWINDOW
137-#endif // !_WTL_KEEP_WS_OVERLAPPEDWINDOW
138-
139-#ifndef RDW_FRAME
140- #define RDW_FRAME 0
141-#endif // !RDW_FRAME
142-
143-#ifndef WM_WINDOWPOSCHANGING
144- #define WM_WINDOWPOSCHANGING 0
145-#endif // !WM_WINDOWPOSCHANGING
146-
147-#define FreeResource(x)
148-#define UnlockResource(x)
149-
150-namespace ATL
151-{
152- inline HRESULT CComModule::RegisterClassObjects(DWORD /*dwClsContext*/, DWORD /*dwFlags*/) throw()
153- { return E_NOTIMPL; }
154- inline HRESULT CComModule::RevokeClassObjects() throw()
155- { return E_NOTIMPL; }
156-}; // namespace ATL
157-
158-#ifndef lstrlenW
159- #define lstrlenW (int)ATL::lstrlenW
160-#endif // lstrlenW
161-
162-inline int WINAPI lstrlenA(LPCSTR lpszString)
163-{ return ATL::lstrlenA(lpszString); }
164-
165-#ifdef lstrcpyn
166- #undef lstrcpyn
167- #define lstrcpyn ATL::lstrcpynW
168-#endif // lstrcpyn
169-
170-#ifndef SetWindowLongPtrW
171- inline LONG_PTR tmp_SetWindowLongPtrW( HWND hWnd, int nIndex, LONG_PTR dwNewLong )
172- {
173- return( ::SetWindowLongW( hWnd, nIndex, LONG( dwNewLong ) ) );
174- }
175- #define SetWindowLongPtrW tmp_SetWindowLongPtrW
176-#endif
177-
178-#ifndef GetWindowLongPtrW
179- inline LONG_PTR tmp_GetWindowLongPtrW( HWND hWnd, int nIndex )
180- {
181- return( ::GetWindowLongW( hWnd, nIndex ) );
182- }
183- #define GetWindowLongPtrW tmp_GetWindowLongPtrW
184-#endif
185-
186-#ifndef LongToPtr
187- #define LongToPtr(x) ((void*)x)
188-#endif
189-
190-#ifndef PtrToInt
191- #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
192-#endif
193-
194-#else // !(_ATL_VER >= 0x0800)
195-
196-#ifdef lstrlenW
197- #undef lstrlenW
198- #define lstrlenW (int)::wcslen
199-#endif // lstrlenW
200-
201-#define lstrlenA (int)strlen
202-
203-#ifndef lstrcpyn
204- inline LPTSTR lstrcpyn(LPTSTR lpstrDest, LPCTSTR lpstrSrc, int nLength)
205- {
206- if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0)
207- return NULL;
208- int nLen = min(lstrlen(lpstrSrc), nLength - 1);
209- LPTSTR lpstrRet = (LPTSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(TCHAR));
210- lpstrDest[nLen] = 0;
211- return lpstrRet;
212- }
213-#endif // !lstrcpyn
214-
215-#ifndef lstrcpynW
216- inline LPWSTR lstrcpynW(LPWSTR lpstrDest, LPCWSTR lpstrSrc, int nLength)
217- {
218- return lstrcpyn(lpstrDest, lpstrSrc, nLength); // WinCE is Unicode only
219- }
220-#endif // !lstrcpynW
221-
222-#ifndef lstrcpynA
223- inline LPSTR lstrcpynA(LPSTR lpstrDest, LPCSTR lpstrSrc, int nLength)
224- {
225- if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0)
226- return NULL;
227- int nLen = min(lstrlenA(lpstrSrc), nLength - 1);
228- LPSTR lpstrRet = (LPSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(char));
229- lpstrDest[nLen] = 0;
230- return lpstrRet;
231- }
232-#endif // !lstrcpyn
233-
234-#ifdef TrackPopupMenu
235- #undef TrackPopupMenu
236-#endif // TrackPopupMenu
237-
238-#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \
239-static CWndClassInfo& GetWndClassInfo() \
240-{ \
241- static CWndClassInfo wc = \
242- { \
243- { style, StartWindowProc, \
244- 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \
245- NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \
246- }; \
247- return wc; \
248-}
249-
250-#ifndef _MAX_FNAME
251- #define _MAX_FNAME _MAX_PATH
252-#endif // _MAX_FNAME
253-
254-#if (_WIN32_WCE < 400)
255- #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
256-#endif // (_WIN32_WCE < 400)
257-
258-#if (_WIN32_WCE < 410)
259- #define WHEEL_PAGESCROLL (UINT_MAX)
260- #define WHEEL_DELTA 120
261-#endif // (_WIN32_WCE < 410)
262-
263-#ifdef DrawIcon
264- #undef DrawIcon
265-#endif
266-
267-#ifndef VARCMP_LT
268- #define VARCMP_LT 0
269-#endif
270-#ifndef VARCMP_EQ
271- #define VARCMP_EQ 1
272-#endif
273-#ifndef VARCMP_GT
274- #define VARCMP_GT 2
275-#endif
276-#ifndef VARCMP_NULL
277- #define VARCMP_NULL 3
278-#endif
279-
280-#ifndef RDW_ALLCHILDREN
281- #define RDW_ALLCHILDREN 0
282-#endif
283-
284-#endif // !(_ATL_VER >= 0x0800)
285-
286-#endif // _WIN32_WCE
287-
288-
289-///////////////////////////////////////////////////////////////////////////////
290-// Global support for using original VC++ 6.0 headers with WTL
291-
292-#ifndef _ATL_NO_OLD_HEADERS_WIN64
293-#if !defined(_WIN64) && (_ATL_VER < 0x0700)
294-
295- #ifndef PSM_INSERTPAGE
296- #define PSM_INSERTPAGE (WM_USER + 119)
297- #endif // !PSM_INSERTPAGE
298-
299- #ifndef GetClassLongPtr
300- #define GetClassLongPtrA GetClassLongA
301- #define GetClassLongPtrW GetClassLongW
302- #ifdef UNICODE
303- #define GetClassLongPtr GetClassLongPtrW
304- #else
305- #define GetClassLongPtr GetClassLongPtrA
306- #endif // !UNICODE
307- #endif // !GetClassLongPtr
308-
309- #ifndef GCLP_HICONSM
310- #define GCLP_HICONSM (-34)
311- #endif // !GCLP_HICONSM
312-
313- #ifndef GetWindowLongPtr
314- #define GetWindowLongPtrA GetWindowLongA
315- #define GetWindowLongPtrW GetWindowLongW
316- #ifdef UNICODE
317- #define GetWindowLongPtr GetWindowLongPtrW
318- #else
319- #define GetWindowLongPtr GetWindowLongPtrA
320- #endif // !UNICODE
321- #endif // !GetWindowLongPtr
322-
323- #ifndef SetWindowLongPtr
324- #define SetWindowLongPtrA SetWindowLongA
325- #define SetWindowLongPtrW SetWindowLongW
326- #ifdef UNICODE
327- #define SetWindowLongPtr SetWindowLongPtrW
328- #else
329- #define SetWindowLongPtr SetWindowLongPtrA
330- #endif // !UNICODE
331- #endif // !SetWindowLongPtr
332-
333- #ifndef GWLP_WNDPROC
334- #define GWLP_WNDPROC (-4)
335- #endif
336- #ifndef GWLP_HINSTANCE
337- #define GWLP_HINSTANCE (-6)
338- #endif
339- #ifndef GWLP_HWNDPARENT
340- #define GWLP_HWNDPARENT (-8)
341- #endif
342- #ifndef GWLP_USERDATA
343- #define GWLP_USERDATA (-21)
344- #endif
345- #ifndef GWLP_ID
346- #define GWLP_ID (-12)
347- #endif
348-
349- #ifndef DWLP_MSGRESULT
350- #define DWLP_MSGRESULT 0
351- #endif
352-
353- typedef long LONG_PTR;
354- typedef unsigned long ULONG_PTR;
355- typedef ULONG_PTR DWORD_PTR;
356-
357- #ifndef HandleToUlong
358- #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
359- #endif
360- #ifndef HandleToLong
361- #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
362- #endif
363- #ifndef LongToHandle
364- #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
365- #endif
366- #ifndef PtrToUlong
367- #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
368- #endif
369- #ifndef PtrToLong
370- #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
371- #endif
372- #ifndef PtrToUint
373- #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
374- #endif
375- #ifndef PtrToInt
376- #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
377- #endif
378- #ifndef PtrToUshort
379- #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
380- #endif
381- #ifndef PtrToShort
382- #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
383- #endif
384- #ifndef IntToPtr
385- #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
386- #endif
387- #ifndef UIntToPtr
388- #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
389- #endif
390- #ifndef LongToPtr
391- #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
392- #endif
393- #ifndef ULongToPtr
394- #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
395- #endif
396-
397-#endif // !defined(_WIN64) && (_ATL_VER < 0x0700)
398-#endif // !_ATL_NO_OLD_HEADERS_WIN64
399-
400-
401-///////////////////////////////////////////////////////////////////////////////
402-// Global support for SecureHelper functions
403-
404-#ifndef _TRUNCATE
405- #define _TRUNCATE ((size_t)-1)
406-#endif
407-
408-#ifndef _ERRCODE_DEFINED
409- #define _ERRCODE_DEFINED
410- typedef int errno_t;
411-#endif
412-
413-#ifndef _SECURECRT_ERRCODE_VALUES_DEFINED
414- #define _SECURECRT_ERRCODE_VALUES_DEFINED
415- #define EINVAL 22
416- #define STRUNCATE 80
417-#endif
418-
419-#ifndef _countof
420- #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
421-#endif
422-
423-
424-///////////////////////////////////////////////////////////////////////////////
425-// Miscellaneous global support
426-
427-// define useful macros from winuser.h
428-#ifndef IS_INTRESOURCE
429- #define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0)
430-#endif // IS_INTRESOURCE
431-
432-// protect template members from windowsx.h macros
433-#ifdef _INC_WINDOWSX
434- #undef SubclassWindow
435-#endif // _INC_WINDOWSX
436-
437-// define useful macros from windowsx.h
438-#ifndef GET_X_LPARAM
439- #define GET_X_LPARAM(lParam) ((int)(short)LOWORD(lParam))
440-#endif
441-#ifndef GET_Y_LPARAM
442- #define GET_Y_LPARAM(lParam) ((int)(short)HIWORD(lParam))
443-#endif
444-
445-// Dummy structs for compiling with /CLR
446-#if (_MSC_VER >= 1300) && defined(_MANAGED)
447- __if_not_exists(_IMAGELIST::_IMAGELIST) { struct _IMAGELIST { }; }
448- __if_not_exists(_TREEITEM::_TREEITEM) { struct _TREEITEM { }; }
449- __if_not_exists(_PSP::_PSP) { struct _PSP { }; }
450-#endif
451-
452-// Define ATLVERIFY macro for ATL3
453-#if (_ATL_VER < 0x0700)
454- #ifndef ATLVERIFY
455- #ifdef _DEBUG
456- #define ATLVERIFY(expr) ATLASSERT(expr)
457- #else
458- #define ATLVERIFY(expr) (expr)
459- #endif // DEBUG
460- #endif // ATLVERIFY
461-#endif // (_ATL_VER < 0x0700)
462-
463-// Forward declaration for ATL3 fix
464-#if (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE)
465- namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); };
466-#endif
467-
468-
469-namespace WTL
470-{
471-
472-#if (_ATL_VER >= 0x0700)
473- DECLARE_TRACE_CATEGORY(atlTraceUI);
474- #ifdef _DEBUG
475- __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI"));
476- #endif // _DEBUG
477-#else // !(_ATL_VER >= 0x0700)
478- enum wtlTraceFlags
479- {
480- atlTraceUI = 0x10000000
481- };
482-#endif // !(_ATL_VER >= 0x0700)
483-
484-// Windows version helper
485-inline bool AtlIsOldWindows()
486-{
487- OSVERSIONINFO ovi = { 0 };
488- ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
489- BOOL bRet = ::GetVersionEx(&ovi);
490- return (!bRet || !((ovi.dwMajorVersion >= 5) || (ovi.dwMajorVersion == 4 && ovi.dwMinorVersion >= 90)));
491-}
492-
493-// default GUI font helper
494-inline HFONT AtlGetDefaultGuiFont()
495-{
496-#ifndef _WIN32_WCE
497- return (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
498-#else // CE specific
499- return (HFONT)::GetStockObject(SYSTEM_FONT);
500-#endif // _WIN32_WCE
501-}
502-
503-// bold font helper (NOTE: Caller owns the font, and should destroy it when done using it)
504-inline HFONT AtlCreateBoldFont(HFONT hFont = NULL)
505-{
506- if(hFont == NULL)
507- hFont = AtlGetDefaultGuiFont();
508- ATLASSERT(hFont != NULL);
509- HFONT hFontBold = NULL;
510- LOGFONT lf = { 0 };
511- if(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT))
512- {
513- lf.lfWeight = FW_BOLD;
514- hFontBold = ::CreateFontIndirect(&lf);
515- ATLASSERT(hFontBold != NULL);
516- }
517- else
518- {
519- ATLASSERT(FALSE);
520- }
521- return hFontBold;
522-}
523-
524-// Common Controls initialization helper
525-inline BOOL AtlInitCommonControls(DWORD dwFlags)
526-{
527- INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags };
528- BOOL bRet = ::InitCommonControlsEx(&iccx);
529- ATLASSERT(bRet);
530- return bRet;
531-}
532-
533-
534-///////////////////////////////////////////////////////////////////////////////
535-// RunTimeHelper - helper functions for Windows version and structure sizes
536-
537-// Not for Windows CE
538-#if defined(_WIN32_WCE) && !defined(_WTL_NO_RUNTIME_STRUCT_SIZE)
539- #define _WTL_NO_RUNTIME_STRUCT_SIZE
540-#endif
541-
542-#ifndef _WTL_NO_RUNTIME_STRUCT_SIZE
543-
544-#ifndef _SIZEOF_STRUCT
545- #define _SIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member))
546-#endif
547-
548-#if (_WIN32_WINNT >= 0x0600) && !defined(REBARBANDINFO_V6_SIZE)
549- #define REBARBANDINFO_V6_SIZE _SIZEOF_STRUCT(REBARBANDINFO, cxHeader)
550-#endif // (_WIN32_WINNT >= 0x0600) && !defined(REBARBANDINFO_V6_SIZE)
551-
552-#if (_WIN32_WINNT >= 0x0600) && !defined(LVGROUP_V5_SIZE)
553- #define LVGROUP_V5_SIZE _SIZEOF_STRUCT(LVGROUP, uAlign)
554-#endif // (_WIN32_WINNT >= 0x0600) && !defined(LVGROUP_V5_SIZE)
555-
556-#if (_WIN32_WINNT >= 0x0600) && !defined(LVTILEINFO_V5_SIZE)
557- #define LVTILEINFO_V5_SIZE _SIZEOF_STRUCT(LVTILEINFO, puColumns)
558-#endif // (_WIN32_WINNT >= 0x0600) && !defined(LVTILEINFO_V5_SIZE)
559-
560-#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE)
561- #define MCHITTESTINFO_V1_SIZE _SIZEOF_STRUCT(MCHITTESTINFO, st)
562-#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE)
563-
564-#if !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE)
565- #define NONCLIENTMETRICS_V1_SIZE _SIZEOF_STRUCT(NONCLIENTMETRICS, lfMessageFont)
566-#endif // !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE)
567-
568-#endif // !_WTL_NO_RUNTIME_STRUCT_SIZE
569-
570-namespace RunTimeHelper
571-{
572-#ifndef _WIN32_WCE
573- inline bool IsCommCtrl6()
574- {
575- DWORD dwMajor = 0, dwMinor = 0;
576- HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor);
577- return (SUCCEEDED(hRet) && (dwMajor >= 6));
578- }
579-
580- inline bool IsVista()
581- {
582- OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) };
583- BOOL bRet = ::GetVersionEx(&ovi);
584- return ((bRet != FALSE) && (ovi.dwMajorVersion >= 6));
585- }
586-#endif // !_WIN32_WCE
587-
588- inline int SizeOf_REBARBANDINFO()
589- {
590- int nSize = sizeof(REBARBANDINFO);
591-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
592- if(!(IsVista() && IsCommCtrl6()))
593- nSize = REBARBANDINFO_V6_SIZE;
594-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
595- return nSize;
596- }
597-
598-#if (_WIN32_WINNT >= 0x501)
599- inline int SizeOf_LVGROUP()
600- {
601- int nSize = sizeof(LVGROUP);
602-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
603- if(!IsVista())
604- nSize = LVGROUP_V5_SIZE;
605-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
606- return nSize;
607- }
608-
609- inline int SizeOf_LVTILEINFO()
610- {
611- int nSize = sizeof(LVTILEINFO);
612-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
613- if(!IsVista())
614- nSize = LVTILEINFO_V5_SIZE;
615-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
616- return nSize;
617- }
618-#endif // (_WIN32_WINNT >= 0x501)
619-
620- inline int SizeOf_MCHITTESTINFO()
621- {
622- int nSize = sizeof(MCHITTESTINFO);
623-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)
624- if(!(IsVista() && IsCommCtrl6()))
625- nSize = MCHITTESTINFO_V1_SIZE;
626-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)
627- return nSize;
628- }
629-
630-#ifndef _WIN32_WCE
631- inline int SizeOf_NONCLIENTMETRICS()
632- {
633- int nSize = sizeof(NONCLIENTMETRICS);
634-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (WINVER >= 0x0600)
635- if(!IsVista())
636- nSize = NONCLIENTMETRICS_V1_SIZE;
637-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (WINVER >= 0x0600)
638- return nSize;
639- }
640-#endif // !_WIN32_WCE
641-};
642-
643-
644-///////////////////////////////////////////////////////////////////////////////
645-// ModuleHelper - helper functions for ATL3 and ATL7 module classes
646-
647-namespace ModuleHelper
648-{
649- inline HINSTANCE GetModuleInstance()
650- {
651-#if (_ATL_VER >= 0x0700)
652- return ATL::_AtlBaseModule.GetModuleInstance();
653-#else // !(_ATL_VER >= 0x0700)
654- return ATL::_pModule->GetModuleInstance();
655-#endif // !(_ATL_VER >= 0x0700)
656- }
657-
658- inline HINSTANCE GetResourceInstance()
659- {
660-#if (_ATL_VER >= 0x0700)
661- return ATL::_AtlBaseModule.GetResourceInstance();
662-#else // !(_ATL_VER >= 0x0700)
663- return ATL::_pModule->GetResourceInstance();
664-#endif // !(_ATL_VER >= 0x0700)
665- }
666-
667- inline void AddCreateWndData(ATL::_AtlCreateWndData* pData, void* pObject)
668- {
669-#if (_ATL_VER >= 0x0700)
670- ATL::_AtlWinModule.AddCreateWndData(pData, pObject);
671-#else // !(_ATL_VER >= 0x0700)
672- ATL::_pModule->AddCreateWndData(pData, pObject);
673-#endif // !(_ATL_VER >= 0x0700)
674- }
675-
676- inline void* ExtractCreateWndData()
677- {
678-#if (_ATL_VER >= 0x0700)
679- return ATL::_AtlWinModule.ExtractCreateWndData();
680-#else // !(_ATL_VER >= 0x0700)
681- return ATL::_pModule->ExtractCreateWndData();
682-#endif // !(_ATL_VER >= 0x0700)
683- }
684-};
685-
686-
687-///////////////////////////////////////////////////////////////////////////////
688-// SecureHelper - helper functions for VS2005 secure CRT
689-
690-namespace SecureHelper
691-{
692- inline void strcpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc)
693- {
694-#if _SECURE_ATL
695- ATL::Checked::strcpy_s(lpstrDest, cchDest, lpstrSrc);
696-#else
697- if(cchDest > (size_t)lstrlenA(lpstrSrc))
698- ATLVERIFY(lstrcpyA(lpstrDest, lpstrSrc) != NULL);
699- else
700- ATLASSERT(FALSE);
701-#endif
702- }
703-
704- inline void strcpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc)
705- {
706-#if _SECURE_ATL
707- ATL::Checked::wcscpy_s(lpstrDest, cchDest, lpstrSrc);
708-#else
709- if(cchDest > (size_t)lstrlenW(lpstrSrc))
710- ATLVERIFY(lstrcpyW(lpstrDest, lpstrSrc) != NULL);
711- else
712- ATLASSERT(FALSE);
713-#endif
714- }
715-
716- inline void strcpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc)
717- {
718-#ifdef _UNICODE
719- strcpyW_x(lpstrDest, cchDest, lpstrSrc);
720-#else
721- strcpyA_x(lpstrDest, cchDest, lpstrSrc);
722-#endif
723- }
724-
725- inline errno_t strncpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc, size_t cchCount)
726- {
727-#if _SECURE_ATL
728- return ATL::Checked::strncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount);
729-#else
730- errno_t nRet = 0;
731- if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL)
732- {
733- nRet = EINVAL;
734- }
735- else if(cchCount == _TRUNCATE)
736- {
737- cchCount = min(cchDest - 1, size_t(lstrlenA(lpstrSrc)));
738- nRet = STRUNCATE;
739- }
740- else if(cchDest <= cchCount)
741- {
742- lpstrDest[0] = 0;
743- nRet = EINVAL;
744- }
745- if(nRet == 0 || nRet == STRUNCATE)
746- nRet = (lstrcpynA(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL;
747- ATLASSERT(nRet == 0 || nRet == STRUNCATE);
748- return nRet;
749-#endif
750- }
751-
752- inline errno_t strncpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc, size_t cchCount)
753- {
754-#if _SECURE_ATL
755- return ATL::Checked::wcsncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount);
756-#else
757- errno_t nRet = 0;
758- if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL)
759- {
760- nRet = EINVAL;
761- }
762- else if(cchCount == _TRUNCATE)
763- {
764- cchCount = min(cchDest - 1, size_t(lstrlenW(lpstrSrc)));
765- nRet = STRUNCATE;
766- }
767- else if(cchDest <= cchCount)
768- {
769- lpstrDest[0] = 0;
770- nRet = EINVAL;
771- }
772- if(nRet == 0 || nRet == STRUNCATE)
773- nRet = (lstrcpynW(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL;
774- ATLASSERT(nRet == 0 || nRet == STRUNCATE);
775- return nRet;
776-#endif
777- }
778-
779- inline errno_t strncpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc, size_t cchCount)
780- {
781-#ifdef _UNICODE
782- return strncpyW_x(lpstrDest, cchDest, lpstrSrc, cchCount);
783-#else
784- return strncpyA_x(lpstrDest, cchDest, lpstrSrc, cchCount);
785-#endif
786- }
787-
788- inline void strcatA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc)
789- {
790-#if _SECURE_ATL
791- ATL::Checked::strcat_s(lpstrDest, cchDest, lpstrSrc);
792-#else
793- if(cchDest > (size_t)lstrlenA(lpstrSrc))
794- ATLVERIFY(lstrcatA(lpstrDest, lpstrSrc) != NULL);
795- else
796- ATLASSERT(FALSE);
797-#endif
798- }
799-
800- inline void strcatW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc)
801- {
802-#if _SECURE_ATL
803- ATL::Checked::wcscat_s(lpstrDest, cchDest, lpstrSrc);
804-#else
805- if(cchDest > (size_t)lstrlenW(lpstrSrc))
806- ATLVERIFY(lstrcatW(lpstrDest, lpstrSrc) != NULL);
807- else
808- ATLASSERT(FALSE);
809-#endif
810- }
811-
812- inline void strcat_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc)
813- {
814-#ifdef _UNICODE
815- strcatW_x(lpstrDest, cchDest, lpstrSrc);
816-#else
817- strcatA_x(lpstrDest, cchDest, lpstrSrc);
818-#endif
819- }
820-
821- inline void memcpy_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc)
822- {
823-#if _SECURE_ATL
824- ATL::Checked::memcpy_s(pDest, cbDest, pSrc, cbSrc);
825-#else
826- if(cbDest >= cbSrc)
827- memcpy(pDest, pSrc, cbSrc);
828- else
829- ATLASSERT(FALSE);
830-#endif
831- }
832-
833- inline void memmove_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc)
834- {
835-#if _SECURE_ATL
836- ATL::Checked::memmove_s(pDest, cbDest, pSrc, cbSrc);
837-#else
838- if(cbDest >= cbSrc)
839- memmove(pDest, pSrc, cbSrc);
840- else
841- ATLASSERT(FALSE);
842-#endif
843- }
844-
845- inline int vsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args)
846- {
847-#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE)
848- return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args);
849-#else
850- cchBuff; // Avoid unused argument warning
851-#pragma warning(disable: 4996)
852- return _vstprintf(lpstrBuff, lpstrFormat, args);
853-#pragma warning(default: 4996)
854-#endif
855- }
856-
857- inline int wvsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args)
858- {
859-#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE)
860- return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args);
861-#else
862- cchBuff; // Avoid unused argument warning
863- return ::wvsprintf(lpstrBuff, lpstrFormat, args);
864-#endif
865- }
866-
867- inline int sprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...)
868- {
869- va_list args;
870- va_start(args, lpstrFormat);
871- int nRes = vsprintf_x(lpstrBuff, cchBuff, lpstrFormat, args);
872- va_end(args);
873- return nRes;
874- }
875-
876- inline int wsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...)
877- {
878- va_list args;
879- va_start(args, lpstrFormat);
880- int nRes = wvsprintf_x(lpstrBuff, cchBuff, lpstrFormat, args);
881- va_end(args);
882- return nRes;
883- }
884-}; // namespace SecureHelper
885-
886-
887-///////////////////////////////////////////////////////////////////////////////
888-// CMessageFilter - Interface for message filter support
889-
890-class CMessageFilter
891-{
892-public:
893- virtual BOOL PreTranslateMessage(MSG* pMsg) = 0;
894-};
895-
896-
897-///////////////////////////////////////////////////////////////////////////////
898-// CIdleHandler - Interface for idle processing
899-
900-class CIdleHandler
901-{
902-public:
903- virtual BOOL OnIdle() = 0;
904-};
905-
906-#ifndef _ATL_NO_OLD_NAMES
907- // for compatilibility with old names only
908- typedef CIdleHandler CUpdateUIObject;
909- #define DoUpdate OnIdle
910-#endif // !_ATL_NO_OLD_NAMES
911-
912-
913-///////////////////////////////////////////////////////////////////////////////
914-// CMessageLoop - message loop implementation
915-
916-class CMessageLoop
917-{
918-public:
919- ATL::CSimpleArray<CMessageFilter*> m_aMsgFilter;
920- ATL::CSimpleArray<CIdleHandler*> m_aIdleHandler;
921- MSG m_msg;
922-
923-// Message filter operations
924- BOOL AddMessageFilter(CMessageFilter* pMessageFilter)
925- {
926- return m_aMsgFilter.Add(pMessageFilter);
927- }
928-
929- BOOL RemoveMessageFilter(CMessageFilter* pMessageFilter)
930- {
931- return m_aMsgFilter.Remove(pMessageFilter);
932- }
933-
934-// Idle handler operations
935- BOOL AddIdleHandler(CIdleHandler* pIdleHandler)
936- {
937- return m_aIdleHandler.Add(pIdleHandler);
938- }
939-
940- BOOL RemoveIdleHandler(CIdleHandler* pIdleHandler)
941- {
942- return m_aIdleHandler.Remove(pIdleHandler);
943- }
944-
945-#ifndef _ATL_NO_OLD_NAMES
946- // for compatilibility with old names only
947- BOOL AddUpdateUI(CIdleHandler* pIdleHandler)
948- {
949- ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and AddUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n"));
950- return AddIdleHandler(pIdleHandler);
951- }
952-
953- BOOL RemoveUpdateUI(CIdleHandler* pIdleHandler)
954- {
955- ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and RemoveUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n"));
956- return RemoveIdleHandler(pIdleHandler);
957- }
958-#endif // !_ATL_NO_OLD_NAMES
959-
960-// message loop
961- int Run()
962- {
963- BOOL bDoIdle = TRUE;
964- int nIdleCount = 0;
965- BOOL bRet;
966-
967- for(;;)
968- {
969- while(bDoIdle && !::PeekMessage(&m_msg, NULL, 0, 0, PM_NOREMOVE))
970- {
971- if(!OnIdle(nIdleCount++))
972- bDoIdle = FALSE;
973- }
974-
975- bRet = ::GetMessage(&m_msg, NULL, 0, 0);
976-
977- if(bRet == -1)
978- {
979- ATLTRACE2(atlTraceUI, 0, _T("::GetMessage returned -1 (error)\n"));
980- continue; // error, don't process
981- }
982- else if(!bRet)
983- {
984- ATLTRACE2(atlTraceUI, 0, _T("CMessageLoop::Run - exiting\n"));
985- break; // WM_QUIT, exit message loop
986- }
987-
988- if(!PreTranslateMessage(&m_msg))
989- {
990- ::TranslateMessage(&m_msg);
991- ::DispatchMessage(&m_msg);
992- }
993-
994- if(IsIdleMessage(&m_msg))
995- {
996- bDoIdle = TRUE;
997- nIdleCount = 0;
998- }
999- }
1000-
1001- return (int)m_msg.wParam;
1002- }
1003-
1004- static BOOL IsIdleMessage(MSG* pMsg)
1005- {
1006- // These messages should NOT cause idle processing
1007- switch(pMsg->message)
1008- {
1009- case WM_MOUSEMOVE:
1010-#ifndef _WIN32_WCE
1011- case WM_NCMOUSEMOVE:
1012-#endif // !_WIN32_WCE
1013- case WM_PAINT:
1014- case 0x0118: // WM_SYSTIMER (caret blink)
1015- return FALSE;
1016- }
1017-
1018- return TRUE;
1019- }
1020-
1021-// Overrideables
1022- // Override to change message filtering
1023- virtual BOOL PreTranslateMessage(MSG* pMsg)
1024- {
1025- // loop backwards
1026- for(int i = m_aMsgFilter.GetSize() - 1; i >= 0; i--)
1027- {
1028- CMessageFilter* pMessageFilter = m_aMsgFilter[i];
1029- if(pMessageFilter != NULL && pMessageFilter->PreTranslateMessage(pMsg))
1030- return TRUE;
1031- }
1032- return FALSE; // not translated
1033- }
1034-
1035- // override to change idle processing
1036- virtual BOOL OnIdle(int /*nIdleCount*/)
1037- {
1038- for(int i = 0; i < m_aIdleHandler.GetSize(); i++)
1039- {
1040- CIdleHandler* pIdleHandler = m_aIdleHandler[i];
1041- if(pIdleHandler != NULL)
1042- pIdleHandler->OnIdle();
1043- }
1044- return FALSE; // don't continue
1045- }
1046-};
1047-
1048-
1049-///////////////////////////////////////////////////////////////////////////////
1050-// CStaticDataInitCriticalSectionLock and CWindowCreateCriticalSectionLock
1051-// internal classes to manage critical sections for both ATL3 and ATL7
1052-
1053-class CStaticDataInitCriticalSectionLock
1054-{
1055-public:
1056-#if (_ATL_VER >= 0x0700)
1057- ATL::CComCritSecLock<ATL::CComCriticalSection> m_cslock;
1058-
1059- CStaticDataInitCriticalSectionLock() : m_cslock(ATL::_pAtlModule->m_csStaticDataInitAndTypeInfo, false)
1060- { }
1061-#endif // (_ATL_VER >= 0x0700)
1062-
1063- HRESULT Lock()
1064- {
1065-#if (_ATL_VER >= 0x0700)
1066- return m_cslock.Lock();
1067-#else // !(_ATL_VER >= 0x0700)
1068- ::EnterCriticalSection(&ATL::_pModule->m_csStaticDataInit);
1069- return S_OK;
1070-#endif // !(_ATL_VER >= 0x0700)
1071- }
1072-
1073- void Unlock()
1074- {
1075-#if (_ATL_VER >= 0x0700)
1076- m_cslock.Unlock();
1077-#else // !(_ATL_VER >= 0x0700)
1078- ::LeaveCriticalSection(&ATL::_pModule->m_csStaticDataInit);
1079-#endif // !(_ATL_VER >= 0x0700)
1080- }
1081-};
1082-
1083-
1084-class CWindowCreateCriticalSectionLock
1085-{
1086-public:
1087-#if (_ATL_VER >= 0x0700)
1088- ATL::CComCritSecLock<ATL::CComCriticalSection> m_cslock;
1089-
1090- CWindowCreateCriticalSectionLock() : m_cslock(ATL::_AtlWinModule.m_csWindowCreate, false)
1091- { }
1092-#endif // (_ATL_VER >= 0x0700)
1093-
1094- HRESULT Lock()
1095- {
1096-#if (_ATL_VER >= 0x0700)
1097- return m_cslock.Lock();
1098-#else // !(_ATL_VER >= 0x0700)
1099- ::EnterCriticalSection(&ATL::_pModule->m_csWindowCreate);
1100- return S_OK;
1101-#endif // !(_ATL_VER >= 0x0700)
1102- }
1103-
1104- void Unlock()
1105- {
1106-#if (_ATL_VER >= 0x0700)
1107- m_cslock.Unlock();
1108-#else // !(_ATL_VER >= 0x0700)
1109- ::LeaveCriticalSection(&ATL::_pModule->m_csWindowCreate);
1110-#endif // !(_ATL_VER >= 0x0700)
1111- }
1112-};
1113-
1114-
1115-///////////////////////////////////////////////////////////////////////////////
1116-// CTempBuffer - helper class for stack allocations for ATL3
1117-
1118-#ifndef _WTL_STACK_ALLOC_THRESHOLD
1119- #define _WTL_STACK_ALLOC_THRESHOLD 512
1120-#endif
1121-
1122-#if (_ATL_VER >= 0x0700)
1123-
1124-using ATL::CTempBuffer;
1125-
1126-#else // !(_ATL_VER >= 0x0700)
1127-
1128-#ifndef SIZE_MAX
1129- #ifdef _WIN64
1130- #define SIZE_MAX _UI64_MAX
1131- #else
1132- #define SIZE_MAX UINT_MAX
1133- #endif
1134-#endif
1135-
1136-#pragma warning(disable: 4284) // warning for operator ->
1137-
1138-template<typename T, int t_nFixedBytes = 128>
1139-class CTempBuffer
1140-{
1141-public:
1142- CTempBuffer() : m_p(NULL)
1143- {
1144- }
1145-
1146- CTempBuffer(size_t nElements) : m_p(NULL)
1147- {
1148- Allocate(nElements);
1149- }
1150-
1151- ~CTempBuffer()
1152- {
1153- if(m_p != reinterpret_cast<T*>(m_abFixedBuffer))
1154- free(m_p);
1155- }
1156-
1157- operator T*() const
1158- {
1159- return m_p;
1160- }
1161-
1162- T* operator ->() const
1163- {
1164- ATLASSERT(m_p != NULL);
1165- return m_p;
1166- }
1167-
1168- T* Allocate(size_t nElements)
1169- {
1170- ATLASSERT(nElements <= (SIZE_MAX / sizeof(T)));
1171- return AllocateBytes(nElements * sizeof(T));
1172- }
1173-
1174- T* AllocateBytes(size_t nBytes)
1175- {
1176- ATLASSERT(m_p == NULL);
1177- if(nBytes > t_nFixedBytes)
1178- m_p = static_cast<T*>(malloc(nBytes));
1179- else
1180- m_p = reinterpret_cast<T*>(m_abFixedBuffer);
1181-
1182- return m_p;
1183- }
1184-
1185-private:
1186- T* m_p;
1187- BYTE m_abFixedBuffer[t_nFixedBytes];
1188-};
1189-
1190-#pragma warning(default: 4284)
1191-
1192-#endif // !(_ATL_VER >= 0x0700)
1193-
1194-
1195-///////////////////////////////////////////////////////////////////////////////
1196-// CAppModule - module class for an application
1197-
1198-class CAppModule : public ATL::CComModule
1199-{
1200-public:
1201- DWORD m_dwMainThreadID;
1202- ATL::CSimpleMap<DWORD, CMessageLoop*>* m_pMsgLoopMap;
1203- ATL::CSimpleArray<HWND>* m_pSettingChangeNotify;
1204-
1205-// Overrides of CComModule::Init and Term
1206- HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL)
1207- {
1208- HRESULT hRet = CComModule::Init(pObjMap, hInstance, pLibID);
1209- if(FAILED(hRet))
1210- return hRet;
1211-
1212- m_dwMainThreadID = ::GetCurrentThreadId();
1213- typedef ATL::CSimpleMap<DWORD, CMessageLoop*> _mapClass;
1214- m_pMsgLoopMap = NULL;
1215- ATLTRY(m_pMsgLoopMap = new _mapClass);
1216- if(m_pMsgLoopMap == NULL)
1217- return E_OUTOFMEMORY;
1218- m_pSettingChangeNotify = NULL;
1219-
1220- return hRet;
1221- }
1222-
1223- void Term()
1224- {
1225- TermSettingChangeNotify();
1226- delete m_pMsgLoopMap;
1227- CComModule::Term();
1228- }
1229-
1230-// Message loop map methods
1231- BOOL AddMessageLoop(CMessageLoop* pMsgLoop)
1232- {
1233- CStaticDataInitCriticalSectionLock lock;
1234- if(FAILED(lock.Lock()))
1235- {
1236- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::AddMessageLoop.\n"));
1237- ATLASSERT(FALSE);
1238- return FALSE;
1239- }
1240-
1241- ATLASSERT(pMsgLoop != NULL);
1242- ATLASSERT(m_pMsgLoopMap->Lookup(::GetCurrentThreadId()) == NULL); // not in map yet
1243-
1244- BOOL bRet = m_pMsgLoopMap->Add(::GetCurrentThreadId(), pMsgLoop);
1245-
1246- lock.Unlock();
1247-
1248- return bRet;
1249- }
1250-
1251- BOOL RemoveMessageLoop()
1252- {
1253- CStaticDataInitCriticalSectionLock lock;
1254- if(FAILED(lock.Lock()))
1255- {
1256- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::RemoveMessageLoop.\n"));
1257- ATLASSERT(FALSE);
1258- return FALSE;
1259- }
1260-
1261- BOOL bRet = m_pMsgLoopMap->Remove(::GetCurrentThreadId());
1262-
1263- lock.Unlock();
1264-
1265- return bRet;
1266- }
1267-
1268- CMessageLoop* GetMessageLoop(DWORD dwThreadID = ::GetCurrentThreadId()) const
1269- {
1270- CStaticDataInitCriticalSectionLock lock;
1271- if(FAILED(lock.Lock()))
1272- {
1273- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::GetMessageLoop.\n"));
1274- ATLASSERT(FALSE);
1275- return NULL;
1276- }
1277-
1278- CMessageLoop* pLoop = m_pMsgLoopMap->Lookup(dwThreadID);
1279-
1280- lock.Unlock();
1281-
1282- return pLoop;
1283- }
1284-
1285-// Setting change notify methods
1286- // Note: Call this from the main thread for MSDI apps
1287- BOOL InitSettingChangeNotify(DLGPROC pfnDlgProc = _SettingChangeDlgProc)
1288- {
1289- CStaticDataInitCriticalSectionLock lock;
1290- if(FAILED(lock.Lock()))
1291- {
1292- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::InitSettingChangeNotify.\n"));
1293- ATLASSERT(FALSE);
1294- return FALSE;
1295- }
1296-
1297- if(m_pSettingChangeNotify == NULL)
1298- {
1299- typedef ATL::CSimpleArray<HWND> _notifyClass;
1300- ATLTRY(m_pSettingChangeNotify = new _notifyClass);
1301- ATLASSERT(m_pSettingChangeNotify != NULL);
1302- }
1303-
1304- BOOL bRet = (m_pSettingChangeNotify != NULL);
1305- if(bRet && m_pSettingChangeNotify->GetSize() == 0)
1306- {
1307- // init everything
1308- _ATL_EMPTY_DLGTEMPLATE templ;
1309- HWND hNtfWnd = ::CreateDialogIndirect(GetModuleInstance(), &templ, NULL, pfnDlgProc);
1310- ATLASSERT(::IsWindow(hNtfWnd));
1311- if(::IsWindow(hNtfWnd))
1312- {
1313-// need conditional code because types don't match in winuser.h
1314-#ifdef _WIN64
1315- ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, (LONG_PTR)this);
1316-#else
1317- ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, PtrToLong(this));
1318-#endif
1319- bRet = m_pSettingChangeNotify->Add(hNtfWnd);
1320- }
1321- else
1322- {
1323- bRet = FALSE;
1324- }
1325- }
1326-
1327- lock.Unlock();
1328-
1329- return bRet;
1330- }
1331-
1332- void TermSettingChangeNotify()
1333- {
1334- CStaticDataInitCriticalSectionLock lock;
1335- if(FAILED(lock.Lock()))
1336- {
1337- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::TermSettingChangeNotify.\n"));
1338- ATLASSERT(FALSE);
1339- return;
1340- }
1341-
1342- if(m_pSettingChangeNotify != NULL && m_pSettingChangeNotify->GetSize() > 0)
1343- ::DestroyWindow((*m_pSettingChangeNotify)[0]);
1344- delete m_pSettingChangeNotify;
1345- m_pSettingChangeNotify = NULL;
1346-
1347- lock.Unlock();
1348- }
1349-
1350- BOOL AddSettingChangeNotify(HWND hWnd)
1351- {
1352- CStaticDataInitCriticalSectionLock lock;
1353- if(FAILED(lock.Lock()))
1354- {
1355- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::AddSettingChangeNotify.\n"));
1356- ATLASSERT(FALSE);
1357- return FALSE;
1358- }
1359-
1360- ATLASSERT(::IsWindow(hWnd));
1361- BOOL bRet = FALSE;
1362- if(InitSettingChangeNotify() != FALSE)
1363- bRet = m_pSettingChangeNotify->Add(hWnd);
1364-
1365- lock.Unlock();
1366-
1367- return bRet;
1368- }
1369-
1370- BOOL RemoveSettingChangeNotify(HWND hWnd)
1371- {
1372- CStaticDataInitCriticalSectionLock lock;
1373- if(FAILED(lock.Lock()))
1374- {
1375- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::RemoveSettingChangeNotify.\n"));
1376- ATLASSERT(FALSE);
1377- return FALSE;
1378- }
1379-
1380- BOOL bRet = FALSE;
1381- if(m_pSettingChangeNotify != NULL)
1382- bRet = m_pSettingChangeNotify->Remove(hWnd);
1383-
1384- lock.Unlock();
1385-
1386- return bRet;
1387- }
1388-
1389-// Implementation - setting change notify dialog template and dialog procedure
1390- struct _ATL_EMPTY_DLGTEMPLATE : DLGTEMPLATE
1391- {
1392- _ATL_EMPTY_DLGTEMPLATE()
1393- {
1394- memset(this, 0, sizeof(_ATL_EMPTY_DLGTEMPLATE));
1395- style = WS_POPUP;
1396- }
1397- WORD wMenu, wClass, wTitle;
1398- };
1399-
1400-#ifdef _WIN64
1401- static INT_PTR CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1402-#else
1403- static BOOL CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1404-#endif
1405- {
1406- if(uMsg == WM_SETTINGCHANGE)
1407- {
1408-// need conditional code because types don't match in winuser.h
1409-#ifdef _WIN64
1410- CAppModule* pModule = (CAppModule*)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
1411-#else
1412- CAppModule* pModule = (CAppModule*)LongToPtr(::GetWindowLongPtr(hWnd, GWLP_USERDATA));
1413-#endif
1414- ATLASSERT(pModule != NULL);
1415- ATLASSERT(pModule->m_pSettingChangeNotify != NULL);
1416- const UINT uTimeout = 1500; // ms
1417- for(int i = 1; i < pModule->m_pSettingChangeNotify->GetSize(); i++)
1418- {
1419-#if !defined(_WIN32_WCE)
1420- ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_ABORTIFHUNG, uTimeout, NULL);
1421-#elif(_WIN32_WCE >= 400) // CE specific
1422- ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_NORMAL, uTimeout, NULL);
1423-#else // _WIN32_WCE < 400 specific
1424- uTimeout;
1425- ::SendMessage((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam);
1426-#endif
1427- }
1428- return TRUE;
1429- }
1430- return FALSE;
1431- }
1432-};
1433-
1434-
1435-///////////////////////////////////////////////////////////////////////////////
1436-// CServerAppModule - module class for a COM server application
1437-
1438-class CServerAppModule : public CAppModule
1439-{
1440-public:
1441- HANDLE m_hEventShutdown;
1442- bool m_bActivity;
1443- DWORD m_dwTimeOut;
1444- DWORD m_dwPause;
1445-
1446-// Override of CAppModule::Init
1447- HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL)
1448- {
1449- m_dwTimeOut = 5000;
1450- m_dwPause = 1000;
1451- return CAppModule::Init(pObjMap, hInstance, pLibID);
1452- }
1453-
1454- void Term()
1455- {
1456- if(m_hEventShutdown != NULL && ::CloseHandle(m_hEventShutdown))
1457- m_hEventShutdown = NULL;
1458- CAppModule::Term();
1459- }
1460-
1461-// COM Server methods
1462- LONG Unlock()
1463- {
1464- LONG lRet = CComModule::Unlock();
1465- if(lRet == 0)
1466- {
1467- m_bActivity = true;
1468- ::SetEvent(m_hEventShutdown); // tell monitor that we transitioned to zero
1469- }
1470- return lRet;
1471- }
1472-
1473- void MonitorShutdown()
1474- {
1475- for(;;)
1476- {
1477- ::WaitForSingleObject(m_hEventShutdown, INFINITE);
1478- DWORD dwWait = 0;
1479- do
1480- {
1481- m_bActivity = false;
1482- dwWait = ::WaitForSingleObject(m_hEventShutdown, m_dwTimeOut);
1483- }
1484- while(dwWait == WAIT_OBJECT_0);
1485- // timed out
1486- if(!m_bActivity && m_nLockCnt == 0) // if no activity let's really bail
1487- {
1488-#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) && defined(_ATL_FREE_THREADED) && !defined(_WIN32_WCE)
1489- ::CoSuspendClassObjects();
1490- if(!m_bActivity && m_nLockCnt == 0)
1491-#endif
1492- break;
1493- }
1494- }
1495- // This handle should be valid now. If it isn't,
1496- // check if _Module.Term was called first (it shouldn't)
1497- if(::CloseHandle(m_hEventShutdown))
1498- m_hEventShutdown = NULL;
1499- ::PostThreadMessage(m_dwMainThreadID, WM_QUIT, 0, 0);
1500- }
1501-
1502- bool StartMonitor()
1503- {
1504- m_hEventShutdown = ::CreateEvent(NULL, false, false, NULL);
1505- if(m_hEventShutdown == NULL)
1506- return false;
1507- DWORD dwThreadID = 0;
1508-#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE)
1509- HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))MonitorProc, this, 0, (UINT*)&dwThreadID);
1510-#else
1511- HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
1512-#endif
1513- bool bRet = (hThread != NULL);
1514- if(bRet)
1515- ::CloseHandle(hThread);
1516- return bRet;
1517- }
1518-
1519- static DWORD WINAPI MonitorProc(void* pv)
1520- {
1521- CServerAppModule* p = (CServerAppModule*)pv;
1522- p->MonitorShutdown();
1523- return 0;
1524- }
1525-
1526-#if (_ATL_VER < 0x0700)
1527- // search for an occurence of string p2 in string p1
1528- static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
1529- {
1530- while(p1 != NULL && *p1 != NULL)
1531- {
1532- LPCTSTR p = p2;
1533- while(p != NULL && *p != NULL)
1534- {
1535- if(*p1 == *p)
1536- return ::CharNext(p1);
1537- p = ::CharNext(p);
1538- }
1539- p1 = ::CharNext(p1);
1540- }
1541- return NULL;
1542- }
1543-#endif // (_ATL_VER < 0x0700)
1544-};
1545-
1546-
1547-///////////////////////////////////////////////////////////////////////////////
1548-// CString forward reference (enables CString use in atluser.h and atlgdi.h)
1549-
1550-#if defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING)
1551- #define _WTL_USE_CSTRING
1552-#endif // defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING)
1553-
1554-#ifdef _WTL_USE_CSTRING
1555- class CString; // forward declaration (include atlmisc.h for the whole class)
1556-#endif // _WTL_USE_CSTRING
1557-
1558-// CString namespace
1559-#ifndef _CSTRING_NS
1560- #ifdef __ATLSTR_H__
1561- #define _CSTRING_NS ATL
1562- #else
1563- #define _CSTRING_NS WTL
1564- #endif
1565-#endif // _CSTRING_NS
1566-
1567-// Type classes namespace
1568-#ifndef _WTYPES_NS
1569- #ifdef __ATLTYPES_H__
1570- #define _WTYPES_NS
1571- #else
1572- #define _WTYPES_NS WTL
1573- #endif
1574-#endif // _WTYPES_NS
1575-
1576-}; // namespace WTL
1577-
1578-
1579-///////////////////////////////////////////////////////////////////////////////
1580-// General DLL version helpers (excluded from atlbase.h if _ATL_DLL is defined)
1581-
1582-#if (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE)
1583-
1584-namespace ATL
1585-{
1586-
1587-inline HRESULT AtlGetDllVersion(HINSTANCE hInstDLL, DLLVERSIONINFO* pDllVersionInfo)
1588-{
1589- ATLASSERT(pDllVersionInfo != NULL);
1590- if(pDllVersionInfo == NULL)
1591- return E_INVALIDARG;
1592-
1593- // We must get this function explicitly because some DLLs don't implement it.
1594- DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion");
1595- if(pfnDllGetVersion == NULL)
1596- return E_NOTIMPL;
1597-
1598- return (*pfnDllGetVersion)(pDllVersionInfo);
1599-}
1600-
1601-inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersionInfo)
1602-{
1603- HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName);
1604- if(hInstDLL == NULL)
1605- return E_FAIL;
1606- HRESULT hRet = AtlGetDllVersion(hInstDLL, pDllVersionInfo);
1607- ::FreeLibrary(hInstDLL);
1608- return hRet;
1609-}
1610-
1611-// Common Control Versions:
1612-// Win95/WinNT 4.0 maj=4 min=00
1613-// IE 3.x maj=4 min=70
1614-// IE 4.0 maj=4 min=71
1615-inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
1616-{
1617- ATLASSERT(pdwMajor != NULL && pdwMinor != NULL);
1618- if(pdwMajor == NULL || pdwMinor == NULL)
1619- return E_INVALIDARG;
1620-
1621- DLLVERSIONINFO dvi;
1622- ::ZeroMemory(&dvi, sizeof(dvi));
1623- dvi.cbSize = sizeof(dvi);
1624- HRESULT hRet = AtlGetDllVersion(_T("comctl32.dll"), &dvi);
1625-
1626- if(SUCCEEDED(hRet))
1627- {
1628- *pdwMajor = dvi.dwMajorVersion;
1629- *pdwMinor = dvi.dwMinorVersion;
1630- }
1631- else if(hRet == E_NOTIMPL)
1632- {
1633- // If DllGetVersion is not there, then the DLL is a version
1634- // previous to the one shipped with IE 3.x
1635- *pdwMajor = 4;
1636- *pdwMinor = 0;
1637- hRet = S_OK;
1638- }
1639-
1640- return hRet;
1641-}
1642-
1643-// Shell Versions:
1644-// Win95/WinNT 4.0 maj=4 min=00
1645-// IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00
1646-// IE 4.0 with Web Integrated Desktop maj=4 min=71
1647-// IE 4.01 with Web Integrated Desktop maj=4 min=72
1648-inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
1649-{
1650- ATLASSERT(pdwMajor != NULL && pdwMinor != NULL);
1651- if(pdwMajor == NULL || pdwMinor == NULL)
1652- return E_INVALIDARG;
1653-
1654- DLLVERSIONINFO dvi;
1655- ::ZeroMemory(&dvi, sizeof(dvi));
1656- dvi.cbSize = sizeof(dvi);
1657- HRESULT hRet = AtlGetDllVersion(_T("shell32.dll"), &dvi);
1658-
1659- if(SUCCEEDED(hRet))
1660- {
1661- *pdwMajor = dvi.dwMajorVersion;
1662- *pdwMinor = dvi.dwMinorVersion;
1663- }
1664- else if(hRet == E_NOTIMPL)
1665- {
1666- // If DllGetVersion is not there, then the DLL is a version
1667- // previous to the one shipped with IE 4.x
1668- *pdwMajor = 4;
1669- *pdwMinor = 0;
1670- hRet = S_OK;
1671- }
1672-
1673- return hRet;
1674-}
1675-
1676-}; // namespace ATL
1677-
1678-#endif // (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE)
1679-
1680-
1681-// These are always included
1682-#include "atlwinx.h"
1683-#include "atluser.h"
1684-#include "atlgdi.h"
1685-
1686-#ifndef _WTL_NO_AUTOMATIC_NAMESPACE
1687-using namespace WTL;
1688-#endif // !_WTL_NO_AUTOMATIC_NAMESPACE
1689-
1690-#endif // __ATLAPP_H__
--- a/include/WTL/Include/atlcrack.h
+++ /dev/null
@@ -1,2380 +0,0 @@
1-// Windows Template Library - WTL version 8.1
2-// Copyright (C) Microsoft Corporation. All rights reserved.
3-//
4-// This file is a part of the Windows Template Library.
5-// The use and distribution terms for this software are covered by the
6-// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
7-// which can be found in the file CPL.TXT at the root of this distribution.
8-// By using this software in any fashion, you are agreeing to be bound by
9-// the terms of this license. You must not remove this notice, or
10-// any other, from this software.
11-
12-#ifndef __ATLCRACK_H__
13-#define __ATLCRACK_H__
14-
15-#pragma once
16-
17-
18-///////////////////////////////////////////////////////////////////////////////
19-// Message map macro for cracked handlers
20-
21-// Note about message maps with cracked handlers:
22-// For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX.
23-// For ATL 7.0 or higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl derived classes,
24-// but must use BEGIN_MSG_MAP_EX for classes that don't derive from CWindowImpl/CDialogImpl.
25-
26-#define BEGIN_MSG_MAP_EX(theClass) \
27-public: \
28- BOOL m_bMsgHandled; \
29- /* "handled" management for cracked handlers */ \
30- BOOL IsMsgHandled() const \
31- { \
32- return m_bMsgHandled; \
33- } \
34- void SetMsgHandled(BOOL bHandled) \
35- { \
36- m_bMsgHandled = bHandled; \
37- } \
38- BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
39- { \
40- BOOL bOldMsgHandled = m_bMsgHandled; \
41- BOOL bRet = _ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
42- m_bMsgHandled = bOldMsgHandled; \
43- return bRet; \
44- } \
45- BOOL _ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) \
46- { \
47- BOOL bHandled = TRUE; \
48- hWnd; \
49- uMsg; \
50- wParam; \
51- lParam; \
52- lResult; \
53- bHandled; \
54- switch(dwMsgMapID) \
55- { \
56- case 0:
57-
58-
59-///////////////////////////////////////////////////////////////////////////////
60-// Standard Windows message macros
61-
62-// int OnCreate(LPCREATESTRUCT lpCreateStruct)
63-#define MSG_WM_CREATE(func) \
64- if (uMsg == WM_CREATE) \
65- { \
66- SetMsgHandled(TRUE); \
67- lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
68- if(IsMsgHandled()) \
69- return TRUE; \
70- }
71-
72-// BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
73-#define MSG_WM_INITDIALOG(func) \
74- if (uMsg == WM_INITDIALOG) \
75- { \
76- SetMsgHandled(TRUE); \
77- lResult = (LRESULT)func((HWND)wParam, lParam); \
78- if(IsMsgHandled()) \
79- return TRUE; \
80- }
81-
82-// BOOL OnCopyData(CWindow wnd, PCOPYDATASTRUCT pCopyDataStruct)
83-#define MSG_WM_COPYDATA(func) \
84- if (uMsg == WM_COPYDATA) \
85- { \
86- SetMsgHandled(TRUE); \
87- lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \
88- if(IsMsgHandled()) \
89- return TRUE; \
90- }
91-
92-// void OnDestroy()
93-#define MSG_WM_DESTROY(func) \
94- if (uMsg == WM_DESTROY) \
95- { \
96- SetMsgHandled(TRUE); \
97- func(); \
98- lResult = 0; \
99- if(IsMsgHandled()) \
100- return TRUE; \
101- }
102-
103-// void OnMove(CPoint ptPos)
104-#define MSG_WM_MOVE(func) \
105- if (uMsg == WM_MOVE) \
106- { \
107- SetMsgHandled(TRUE); \
108- func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
109- lResult = 0; \
110- if(IsMsgHandled()) \
111- return TRUE; \
112- }
113-
114-// void OnSize(UINT nType, CSize size)
115-#define MSG_WM_SIZE(func) \
116- if (uMsg == WM_SIZE) \
117- { \
118- SetMsgHandled(TRUE); \
119- func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
120- lResult = 0; \
121- if(IsMsgHandled()) \
122- return TRUE; \
123- }
124-
125-// void OnActivate(UINT nState, BOOL bMinimized, CWindow wndOther)
126-#define MSG_WM_ACTIVATE(func) \
127- if (uMsg == WM_ACTIVATE) \
128- { \
129- SetMsgHandled(TRUE); \
130- func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \
131- lResult = 0; \
132- if(IsMsgHandled()) \
133- return TRUE; \
134- }
135-
136-// void OnSetFocus(CWindow wndOld)
137-#define MSG_WM_SETFOCUS(func) \
138- if (uMsg == WM_SETFOCUS) \
139- { \
140- SetMsgHandled(TRUE); \
141- func((HWND)wParam); \
142- lResult = 0; \
143- if(IsMsgHandled()) \
144- return TRUE; \
145- }
146-
147-// void OnKillFocus(CWindow wndFocus)
148-#define MSG_WM_KILLFOCUS(func) \
149- if (uMsg == WM_KILLFOCUS) \
150- { \
151- SetMsgHandled(TRUE); \
152- func((HWND)wParam); \
153- lResult = 0; \
154- if(IsMsgHandled()) \
155- return TRUE; \
156- }
157-
158-// void OnEnable(BOOL bEnable)
159-#define MSG_WM_ENABLE(func) \
160- if (uMsg == WM_ENABLE) \
161- { \
162- SetMsgHandled(TRUE); \
163- func((BOOL)wParam); \
164- lResult = 0; \
165- if(IsMsgHandled()) \
166- return TRUE; \
167- }
168-
169-// void OnPaint(CDCHandle dc)
170-#define MSG_WM_PAINT(func) \
171- if (uMsg == WM_PAINT) \
172- { \
173- SetMsgHandled(TRUE); \
174- func((HDC)wParam); \
175- lResult = 0; \
176- if(IsMsgHandled()) \
177- return TRUE; \
178- }
179-
180-// void OnClose()
181-#define MSG_WM_CLOSE(func) \
182- if (uMsg == WM_CLOSE) \
183- { \
184- SetMsgHandled(TRUE); \
185- func(); \
186- lResult = 0; \
187- if(IsMsgHandled()) \
188- return TRUE; \
189- }
190-
191-// BOOL OnQueryEndSession(UINT nSource, UINT uLogOff)
192-#define MSG_WM_QUERYENDSESSION(func) \
193- if (uMsg == WM_QUERYENDSESSION) \
194- { \
195- SetMsgHandled(TRUE); \
196- lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \
197- if(IsMsgHandled()) \
198- return TRUE; \
199- }
200-
201-// BOOL OnQueryOpen()
202-#define MSG_WM_QUERYOPEN(func) \
203- if (uMsg == WM_QUERYOPEN) \
204- { \
205- SetMsgHandled(TRUE); \
206- lResult = (LRESULT)func(); \
207- if(IsMsgHandled()) \
208- return TRUE; \
209- }
210-
211-// BOOL OnEraseBkgnd(CDCHandle dc)
212-#define MSG_WM_ERASEBKGND(func) \
213- if (uMsg == WM_ERASEBKGND) \
214- { \
215- SetMsgHandled(TRUE); \
216- lResult = (LRESULT)func((HDC)wParam); \
217- if(IsMsgHandled()) \
218- return TRUE; \
219- }
220-
221-// void OnSysColorChange()
222-#define MSG_WM_SYSCOLORCHANGE(func) \
223- if (uMsg == WM_SYSCOLORCHANGE) \
224- { \
225- SetMsgHandled(TRUE); \
226- func(); \
227- lResult = 0; \
228- if(IsMsgHandled()) \
229- return TRUE; \
230- }
231-
232-// void OnEndSession(BOOL bEnding, UINT uLogOff)
233-#define MSG_WM_ENDSESSION(func) \
234- if (uMsg == WM_ENDSESSION) \
235- { \
236- SetMsgHandled(TRUE); \
237- func((BOOL)wParam, (UINT)lParam); \
238- lResult = 0; \
239- if(IsMsgHandled()) \
240- return TRUE; \
241- }
242-
243-// void OnShowWindow(BOOL bShow, UINT nStatus)
244-#define MSG_WM_SHOWWINDOW(func) \
245- if (uMsg == WM_SHOWWINDOW) \
246- { \
247- SetMsgHandled(TRUE); \
248- func((BOOL)wParam, (int)lParam); \
249- lResult = 0; \
250- if(IsMsgHandled()) \
251- return TRUE; \
252- }
253-
254-// HBRUSH OnCtlColorEdit(CDCHandle dc, CEdit edit)
255-#define MSG_WM_CTLCOLOREDIT(func) \
256- if (uMsg == WM_CTLCOLOREDIT) \
257- { \
258- SetMsgHandled(TRUE); \
259- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
260- if(IsMsgHandled()) \
261- return TRUE; \
262- }
263-
264-// HBRUSH OnCtlColorListBox(CDCHandle dc, CListBox listBox)
265-#define MSG_WM_CTLCOLORLISTBOX(func) \
266- if (uMsg == WM_CTLCOLORLISTBOX) \
267- { \
268- SetMsgHandled(TRUE); \
269- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
270- if(IsMsgHandled()) \
271- return TRUE; \
272- }
273-
274-// HBRUSH OnCtlColorBtn(CDCHandle dc, CButton button)
275-#define MSG_WM_CTLCOLORBTN(func) \
276- if (uMsg == WM_CTLCOLORBTN) \
277- { \
278- SetMsgHandled(TRUE); \
279- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
280- if(IsMsgHandled()) \
281- return TRUE; \
282- }
283-
284-// HBRUSH OnCtlColorDlg(CDCHandle dc, CWindow wnd)
285-#define MSG_WM_CTLCOLORDLG(func) \
286- if (uMsg == WM_CTLCOLORDLG) \
287- { \
288- SetMsgHandled(TRUE); \
289- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
290- if(IsMsgHandled()) \
291- return TRUE; \
292- }
293-
294-// HBRUSH OnCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
295-#define MSG_WM_CTLCOLORSCROLLBAR(func) \
296- if (uMsg == WM_CTLCOLORSCROLLBAR) \
297- { \
298- SetMsgHandled(TRUE); \
299- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
300- if(IsMsgHandled()) \
301- return TRUE; \
302- }
303-
304-// HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic)
305-#define MSG_WM_CTLCOLORSTATIC(func) \
306- if (uMsg == WM_CTLCOLORSTATIC) \
307- { \
308- SetMsgHandled(TRUE); \
309- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
310- if(IsMsgHandled()) \
311- return TRUE; \
312- }
313-
314-// void OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
315-#define MSG_WM_SETTINGCHANGE(func) \
316- if (uMsg == WM_SETTINGCHANGE) \
317- { \
318- SetMsgHandled(TRUE); \
319- func((UINT)wParam, (LPCTSTR)lParam); \
320- lResult = 0; \
321- if(IsMsgHandled()) \
322- return TRUE; \
323- }
324-
325-// void OnDevModeChange(LPCTSTR lpDeviceName)
326-#define MSG_WM_DEVMODECHANGE(func) \
327- if (uMsg == WM_DEVMODECHANGE) \
328- { \
329- SetMsgHandled(TRUE); \
330- func((LPCTSTR)lParam); \
331- lResult = 0; \
332- if(IsMsgHandled()) \
333- return TRUE; \
334- }
335-
336-// void OnActivateApp(BOOL bActive, DWORD dwThreadID)
337-#define MSG_WM_ACTIVATEAPP(func) \
338- if (uMsg == WM_ACTIVATEAPP) \
339- { \
340- SetMsgHandled(TRUE); \
341- func((BOOL)wParam, (DWORD)lParam); \
342- lResult = 0; \
343- if(IsMsgHandled()) \
344- return TRUE; \
345- }
346-
347-// void OnFontChange()
348-#define MSG_WM_FONTCHANGE(func) \
349- if (uMsg == WM_FONTCHANGE) \
350- { \
351- SetMsgHandled(TRUE); \
352- func(); \
353- lResult = 0; \
354- if(IsMsgHandled()) \
355- return TRUE; \
356- }
357-
358-// void OnTimeChange()
359-#define MSG_WM_TIMECHANGE(func) \
360- if (uMsg == WM_TIMECHANGE) \
361- { \
362- SetMsgHandled(TRUE); \
363- func(); \
364- lResult = 0; \
365- if(IsMsgHandled()) \
366- return TRUE; \
367- }
368-
369-// void OnCancelMode()
370-#define MSG_WM_CANCELMODE(func) \
371- if (uMsg == WM_CANCELMODE) \
372- { \
373- SetMsgHandled(TRUE); \
374- func(); \
375- lResult = 0; \
376- if(IsMsgHandled()) \
377- return TRUE; \
378- }
379-
380-// BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message)
381-#define MSG_WM_SETCURSOR(func) \
382- if (uMsg == WM_SETCURSOR) \
383- { \
384- SetMsgHandled(TRUE); \
385- lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
386- if(IsMsgHandled()) \
387- return TRUE; \
388- }
389-
390-// int OnMouseActivate(CWindow wndTopLevel, UINT nHitTest, UINT message)
391-#define MSG_WM_MOUSEACTIVATE(func) \
392- if (uMsg == WM_MOUSEACTIVATE) \
393- { \
394- SetMsgHandled(TRUE); \
395- lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
396- if(IsMsgHandled()) \
397- return TRUE; \
398- }
399-
400-// void OnChildActivate()
401-#define MSG_WM_CHILDACTIVATE(func) \
402- if (uMsg == WM_CHILDACTIVATE) \
403- { \
404- SetMsgHandled(TRUE); \
405- func(); \
406- lResult = 0; \
407- if(IsMsgHandled()) \
408- return TRUE; \
409- }
410-
411-// void OnGetMinMaxInfo(LPMINMAXINFO lpMMI)
412-#define MSG_WM_GETMINMAXINFO(func) \
413- if (uMsg == WM_GETMINMAXINFO) \
414- { \
415- SetMsgHandled(TRUE); \
416- func((LPMINMAXINFO)lParam); \
417- lResult = 0; \
418- if(IsMsgHandled()) \
419- return TRUE; \
420- }
421-
422-// void OnIconEraseBkgnd(CDCHandle dc)
423-#define MSG_WM_ICONERASEBKGND(func) \
424- if (uMsg == WM_ICONERASEBKGND) \
425- { \
426- SetMsgHandled(TRUE); \
427- func((HDC)wParam); \
428- lResult = 0; \
429- if(IsMsgHandled()) \
430- return TRUE; \
431- }
432-
433-// void OnSpoolerStatus(UINT nStatus, UINT nJobs)
434-#define MSG_WM_SPOOLERSTATUS(func) \
435- if (uMsg == WM_SPOOLERSTATUS) \
436- { \
437- SetMsgHandled(TRUE); \
438- func((UINT)wParam, (UINT)LOWORD(lParam)); \
439- lResult = 0; \
440- if(IsMsgHandled()) \
441- return TRUE; \
442- }
443-
444-// void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
445-#define MSG_WM_DRAWITEM(func) \
446- if (uMsg == WM_DRAWITEM) \
447- { \
448- SetMsgHandled(TRUE); \
449- func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
450- lResult = TRUE; \
451- if(IsMsgHandled()) \
452- return TRUE; \
453- }
454-
455-// void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
456-#define MSG_WM_MEASUREITEM(func) \
457- if (uMsg == WM_MEASUREITEM) \
458- { \
459- SetMsgHandled(TRUE); \
460- func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
461- lResult = TRUE; \
462- if(IsMsgHandled()) \
463- return TRUE; \
464- }
465-
466-// void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
467-#define MSG_WM_DELETEITEM(func) \
468- if (uMsg == WM_DELETEITEM) \
469- { \
470- SetMsgHandled(TRUE); \
471- func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
472- lResult = TRUE; \
473- if(IsMsgHandled()) \
474- return TRUE; \
475- }
476-
477-//int OnCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
478-#define MSG_WM_CHARTOITEM(func) \
479- if (uMsg == WM_CHARTOITEM) \
480- { \
481- SetMsgHandled(TRUE); \
482- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
483- if(IsMsgHandled()) \
484- return TRUE; \
485- }
486-
487-// int OnVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
488-#define MSG_WM_VKEYTOITEM(func) \
489- if (uMsg == WM_VKEYTOITEM) \
490- { \
491- SetMsgHandled(TRUE); \
492- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
493- if(IsMsgHandled()) \
494- return TRUE; \
495- }
496-
497-// HCURSOR OnQueryDragIcon()
498-#define MSG_WM_QUERYDRAGICON(func) \
499- if (uMsg == WM_QUERYDRAGICON) \
500- { \
501- SetMsgHandled(TRUE); \
502- lResult = (LRESULT)func(); \
503- if(IsMsgHandled()) \
504- return TRUE; \
505- }
506-
507-// int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
508-#define MSG_WM_COMPAREITEM(func) \
509- if (uMsg == WM_COMPAREITEM) \
510- { \
511- SetMsgHandled(TRUE); \
512- lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
513- if(IsMsgHandled()) \
514- return TRUE; \
515- }
516-
517-// void OnCompacting(UINT nCpuTime)
518-#define MSG_WM_COMPACTING(func) \
519- if (uMsg == WM_COMPACTING) \
520- { \
521- SetMsgHandled(TRUE); \
522- func((UINT)wParam); \
523- lResult = 0; \
524- if(IsMsgHandled()) \
525- return TRUE; \
526- }
527-
528-// BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct)
529-#define MSG_WM_NCCREATE(func) \
530- if (uMsg == WM_NCCREATE) \
531- { \
532- SetMsgHandled(TRUE); \
533- lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
534- if(IsMsgHandled()) \
535- return TRUE; \
536- }
537-
538-// void OnNcDestroy()
539-#define MSG_WM_NCDESTROY(func) \
540- if (uMsg == WM_NCDESTROY) \
541- { \
542- SetMsgHandled(TRUE); \
543- func(); \
544- lResult = 0; \
545- if(IsMsgHandled()) \
546- return TRUE; \
547- }
548-
549-// LRESULT OnNcCalcSize(BOOL bCalcValidRects, LPARAM lParam)
550-#define MSG_WM_NCCALCSIZE(func) \
551- if (uMsg == WM_NCCALCSIZE) \
552- { \
553- SetMsgHandled(TRUE); \
554- lResult = func((BOOL)wParam, lParam); \
555- if(IsMsgHandled()) \
556- return TRUE; \
557- }
558-
559-// UINT OnNcHitTest(CPoint point)
560-#define MSG_WM_NCHITTEST(func) \
561- if (uMsg == WM_NCHITTEST) \
562- { \
563- SetMsgHandled(TRUE); \
564- lResult = (LRESULT)func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
565- if(IsMsgHandled()) \
566- return TRUE; \
567- }
568-
569-// void OnNcPaint(CRgn rgn)
570-#define MSG_WM_NCPAINT(func) \
571- if (uMsg == WM_NCPAINT) \
572- { \
573- SetMsgHandled(TRUE); \
574- func((HRGN)wParam); \
575- lResult = 0; \
576- if(IsMsgHandled()) \
577- return TRUE; \
578- }
579-
580-// BOOL OnNcActivate(BOOL bActive)
581-#define MSG_WM_NCACTIVATE(func) \
582- if (uMsg == WM_NCACTIVATE) \
583- { \
584- SetMsgHandled(TRUE); \
585- lResult = (LRESULT)func((BOOL)wParam); \
586- if(IsMsgHandled()) \
587- return TRUE; \
588- }
589-
590-// UINT OnGetDlgCode(LPMSG lpMsg)
591-#define MSG_WM_GETDLGCODE(func) \
592- if (uMsg == WM_GETDLGCODE) \
593- { \
594- SetMsgHandled(TRUE); \
595- lResult = (LRESULT)func((LPMSG)lParam); \
596- if(IsMsgHandled()) \
597- return TRUE; \
598- }
599-
600-// void OnNcMouseMove(UINT nHitTest, CPoint point)
601-#define MSG_WM_NCMOUSEMOVE(func) \
602- if (uMsg == WM_NCMOUSEMOVE) \
603- { \
604- SetMsgHandled(TRUE); \
605- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
606- lResult = 0; \
607- if(IsMsgHandled()) \
608- return TRUE; \
609- }
610-
611-// void OnNcLButtonDown(UINT nHitTest, CPoint point)
612-#define MSG_WM_NCLBUTTONDOWN(func) \
613- if (uMsg == WM_NCLBUTTONDOWN) \
614- { \
615- SetMsgHandled(TRUE); \
616- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
617- lResult = 0; \
618- if(IsMsgHandled()) \
619- return TRUE; \
620- }
621-
622-// void OnNcLButtonUp(UINT nHitTest, CPoint point)
623-#define MSG_WM_NCLBUTTONUP(func) \
624- if (uMsg == WM_NCLBUTTONUP) \
625- { \
626- SetMsgHandled(TRUE); \
627- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
628- lResult = 0; \
629- if(IsMsgHandled()) \
630- return TRUE; \
631- }
632-
633-// void OnNcLButtonDblClk(UINT nHitTest, CPoint point)
634-#define MSG_WM_NCLBUTTONDBLCLK(func) \
635- if (uMsg == WM_NCLBUTTONDBLCLK) \
636- { \
637- SetMsgHandled(TRUE); \
638- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
639- lResult = 0; \
640- if(IsMsgHandled()) \
641- return TRUE; \
642- }
643-
644-// void OnNcRButtonDown(UINT nHitTest, CPoint point)
645-#define MSG_WM_NCRBUTTONDOWN(func) \
646- if (uMsg == WM_NCRBUTTONDOWN) \
647- { \
648- SetMsgHandled(TRUE); \
649- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
650- lResult = 0; \
651- if(IsMsgHandled()) \
652- return TRUE; \
653- }
654-
655-// void OnNcRButtonUp(UINT nHitTest, CPoint point)
656-#define MSG_WM_NCRBUTTONUP(func) \
657- if (uMsg == WM_NCRBUTTONUP) \
658- { \
659- SetMsgHandled(TRUE); \
660- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
661- lResult = 0; \
662- if(IsMsgHandled()) \
663- return TRUE; \
664- }
665-
666-// void OnNcRButtonDblClk(UINT nHitTest, CPoint point)
667-#define MSG_WM_NCRBUTTONDBLCLK(func) \
668- if (uMsg == WM_NCRBUTTONDBLCLK) \
669- { \
670- SetMsgHandled(TRUE); \
671- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
672- lResult = 0; \
673- if(IsMsgHandled()) \
674- return TRUE; \
675- }
676-
677-// void OnNcMButtonDown(UINT nHitTest, CPoint point)
678-#define MSG_WM_NCMBUTTONDOWN(func) \
679- if (uMsg == WM_NCMBUTTONDOWN) \
680- { \
681- SetMsgHandled(TRUE); \
682- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
683- lResult = 0; \
684- if(IsMsgHandled()) \
685- return TRUE; \
686- }
687-
688-// void OnNcMButtonUp(UINT nHitTest, CPoint point)
689-#define MSG_WM_NCMBUTTONUP(func) \
690- if (uMsg == WM_NCMBUTTONUP) \
691- { \
692- SetMsgHandled(TRUE); \
693- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
694- lResult = 0; \
695- if(IsMsgHandled()) \
696- return TRUE; \
697- }
698-
699-// void OnNcMButtonDblClk(UINT nHitTest, CPoint point)
700-#define MSG_WM_NCMBUTTONDBLCLK(func) \
701- if (uMsg == WM_NCMBUTTONDBLCLK) \
702- { \
703- SetMsgHandled(TRUE); \
704- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
705- lResult = 0; \
706- if(IsMsgHandled()) \
707- return TRUE; \
708- }
709-
710-// void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
711-#define MSG_WM_KEYDOWN(func) \
712- if (uMsg == WM_KEYDOWN) \
713- { \
714- SetMsgHandled(TRUE); \
715- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
716- lResult = 0; \
717- if(IsMsgHandled()) \
718- return TRUE; \
719- }
720-
721-// void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
722-#define MSG_WM_KEYUP(func) \
723- if (uMsg == WM_KEYUP) \
724- { \
725- SetMsgHandled(TRUE); \
726- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
727- lResult = 0; \
728- if(IsMsgHandled()) \
729- return TRUE; \
730- }
731-
732-// void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
733-#define MSG_WM_CHAR(func) \
734- if (uMsg == WM_CHAR) \
735- { \
736- SetMsgHandled(TRUE); \
737- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
738- lResult = 0; \
739- if(IsMsgHandled()) \
740- return TRUE; \
741- }
742-
743-// void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
744-#define MSG_WM_DEADCHAR(func) \
745- if (uMsg == WM_DEADCHAR) \
746- { \
747- SetMsgHandled(TRUE); \
748- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
749- lResult = 0; \
750- if(IsMsgHandled()) \
751- return TRUE; \
752- }
753-
754-// void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
755-#define MSG_WM_SYSKEYDOWN(func) \
756- if (uMsg == WM_SYSKEYDOWN) \
757- { \
758- SetMsgHandled(TRUE); \
759- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
760- lResult = 0; \
761- if(IsMsgHandled()) \
762- return TRUE; \
763- }
764-
765-// void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
766-#define MSG_WM_SYSKEYUP(func) \
767- if (uMsg == WM_SYSKEYUP) \
768- { \
769- SetMsgHandled(TRUE); \
770- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
771- lResult = 0; \
772- if(IsMsgHandled()) \
773- return TRUE; \
774- }
775-
776-// void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags)
777-#define MSG_WM_SYSCHAR(func) \
778- if (uMsg == WM_SYSCHAR) \
779- { \
780- SetMsgHandled(TRUE); \
781- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
782- lResult = 0; \
783- if(IsMsgHandled()) \
784- return TRUE; \
785- }
786-
787-// void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
788-#define MSG_WM_SYSDEADCHAR(func) \
789- if (uMsg == WM_SYSDEADCHAR) \
790- { \
791- SetMsgHandled(TRUE); \
792- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
793- lResult = 0; \
794- if(IsMsgHandled()) \
795- return TRUE; \
796- }
797-
798-// void OnSysCommand(UINT nID, LPARAM lParam)
799-#define MSG_WM_SYSCOMMAND(func) \
800- if (uMsg == WM_SYSCOMMAND) \
801- { \
802- SetMsgHandled(TRUE); \
803- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
804- lResult = 0; \
805- if(IsMsgHandled()) \
806- return TRUE; \
807- }
808-
809-// void OnTCard(UINT idAction, DWORD dwActionData)
810-#define MSG_WM_TCARD(func) \
811- if (uMsg == WM_TCARD) \
812- { \
813- SetMsgHandled(TRUE); \
814- func((UINT)wParam, (DWORD)lParam); \
815- lResult = 0; \
816- if(IsMsgHandled()) \
817- return TRUE; \
818- }
819-
820-// void OnTimer(UINT_PTR nIDEvent)
821-#define MSG_WM_TIMER(func) \
822- if (uMsg == WM_TIMER) \
823- { \
824- SetMsgHandled(TRUE); \
825- func((UINT_PTR)wParam); \
826- lResult = 0; \
827- if(IsMsgHandled()) \
828- return TRUE; \
829- }
830-
831-// void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
832-#define MSG_WM_HSCROLL(func) \
833- if (uMsg == WM_HSCROLL) \
834- { \
835- SetMsgHandled(TRUE); \
836- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
837- lResult = 0; \
838- if(IsMsgHandled()) \
839- return TRUE; \
840- }
841-
842-// void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
843-#define MSG_WM_VSCROLL(func) \
844- if (uMsg == WM_VSCROLL) \
845- { \
846- SetMsgHandled(TRUE); \
847- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
848- lResult = 0; \
849- if(IsMsgHandled()) \
850- return TRUE; \
851- }
852-
853-// void OnInitMenu(CMenu menu)
854-#define MSG_WM_INITMENU(func) \
855- if (uMsg == WM_INITMENU) \
856- { \
857- SetMsgHandled(TRUE); \
858- func((HMENU)wParam); \
859- lResult = 0; \
860- if(IsMsgHandled()) \
861- return TRUE; \
862- }
863-
864-// void OnInitMenuPopup(CMenu menuPopup, UINT nIndex, BOOL bSysMenu)
865-#define MSG_WM_INITMENUPOPUP(func) \
866- if (uMsg == WM_INITMENUPOPUP) \
867- { \
868- SetMsgHandled(TRUE); \
869- func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \
870- lResult = 0; \
871- if(IsMsgHandled()) \
872- return TRUE; \
873- }
874-
875-// void OnMenuSelect(UINT nItemID, UINT nFlags, CMenu menu)
876-#define MSG_WM_MENUSELECT(func) \
877- if (uMsg == WM_MENUSELECT) \
878- { \
879- SetMsgHandled(TRUE); \
880- func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
881- lResult = 0; \
882- if(IsMsgHandled()) \
883- return TRUE; \
884- }
885-
886-// LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu menu)
887-#define MSG_WM_MENUCHAR(func) \
888- if (uMsg == WM_MENUCHAR) \
889- { \
890- SetMsgHandled(TRUE); \
891- lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
892- if(IsMsgHandled()) \
893- return TRUE; \
894- }
895-
896-// LRESULT OnNotify(int idCtrl, LPNMHDR pnmh)
897-#define MSG_WM_NOTIFY(func) \
898- if (uMsg == WM_NOTIFY) \
899- { \
900- SetMsgHandled(TRUE); \
901- lResult = func((int)wParam, (LPNMHDR)lParam); \
902- if(IsMsgHandled()) \
903- return TRUE; \
904- }
905-
906-// void OnEnterIdle(UINT nWhy, CWindow wndWho)
907-#define MSG_WM_ENTERIDLE(func) \
908- if (uMsg == WM_ENTERIDLE) \
909- { \
910- SetMsgHandled(TRUE); \
911- func((UINT)wParam, (HWND)lParam); \
912- lResult = 0; \
913- if(IsMsgHandled()) \
914- return TRUE; \
915- }
916-
917-// void OnMouseMove(UINT nFlags, CPoint point)
918-#define MSG_WM_MOUSEMOVE(func) \
919- if (uMsg == WM_MOUSEMOVE) \
920- { \
921- SetMsgHandled(TRUE); \
922- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
923- lResult = 0; \
924- if(IsMsgHandled()) \
925- return TRUE; \
926- }
927-
928-// BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
929-#define MSG_WM_MOUSEWHEEL(func) \
930- if (uMsg == WM_MOUSEWHEEL) \
931- { \
932- SetMsgHandled(TRUE); \
933- lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
934- if(IsMsgHandled()) \
935- return TRUE; \
936- }
937-
938-// void OnLButtonDown(UINT nFlags, CPoint point)
939-#define MSG_WM_LBUTTONDOWN(func) \
940- if (uMsg == WM_LBUTTONDOWN) \
941- { \
942- SetMsgHandled(TRUE); \
943- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
944- lResult = 0; \
945- if(IsMsgHandled()) \
946- return TRUE; \
947- }
948-
949-// void OnLButtonUp(UINT nFlags, CPoint point)
950-#define MSG_WM_LBUTTONUP(func) \
951- if (uMsg == WM_LBUTTONUP) \
952- { \
953- SetMsgHandled(TRUE); \
954- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
955- lResult = 0; \
956- if(IsMsgHandled()) \
957- return TRUE; \
958- }
959-
960-// void OnLButtonDblClk(UINT nFlags, CPoint point)
961-#define MSG_WM_LBUTTONDBLCLK(func) \
962- if (uMsg == WM_LBUTTONDBLCLK) \
963- { \
964- SetMsgHandled(TRUE); \
965- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
966- lResult = 0; \
967- if(IsMsgHandled()) \
968- return TRUE; \
969- }
970-
971-// void OnRButtonDown(UINT nFlags, CPoint point)
972-#define MSG_WM_RBUTTONDOWN(func) \
973- if (uMsg == WM_RBUTTONDOWN) \
974- { \
975- SetMsgHandled(TRUE); \
976- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
977- lResult = 0; \
978- if(IsMsgHandled()) \
979- return TRUE; \
980- }
981-
982-// void OnRButtonUp(UINT nFlags, CPoint point)
983-#define MSG_WM_RBUTTONUP(func) \
984- if (uMsg == WM_RBUTTONUP) \
985- { \
986- SetMsgHandled(TRUE); \
987- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
988- lResult = 0; \
989- if(IsMsgHandled()) \
990- return TRUE; \
991- }
992-
993-// void OnRButtonDblClk(UINT nFlags, CPoint point)
994-#define MSG_WM_RBUTTONDBLCLK(func) \
995- if (uMsg == WM_RBUTTONDBLCLK) \
996- { \
997- SetMsgHandled(TRUE); \
998- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
999- lResult = 0; \
1000- if(IsMsgHandled()) \
1001- return TRUE; \
1002- }
1003-
1004-// void OnMButtonDown(UINT nFlags, CPoint point)
1005-#define MSG_WM_MBUTTONDOWN(func) \
1006- if (uMsg == WM_MBUTTONDOWN) \
1007- { \
1008- SetMsgHandled(TRUE); \
1009- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1010- lResult = 0; \
1011- if(IsMsgHandled()) \
1012- return TRUE; \
1013- }
1014-
1015-// void OnMButtonUp(UINT nFlags, CPoint point)
1016-#define MSG_WM_MBUTTONUP(func) \
1017- if (uMsg == WM_MBUTTONUP) \
1018- { \
1019- SetMsgHandled(TRUE); \
1020- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1021- lResult = 0; \
1022- if(IsMsgHandled()) \
1023- return TRUE; \
1024- }
1025-
1026-// void OnMButtonDblClk(UINT nFlags, CPoint point)
1027-#define MSG_WM_MBUTTONDBLCLK(func) \
1028- if (uMsg == WM_MBUTTONDBLCLK) \
1029- { \
1030- SetMsgHandled(TRUE); \
1031- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1032- lResult = 0; \
1033- if(IsMsgHandled()) \
1034- return TRUE; \
1035- }
1036-
1037-// void OnParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1038-#define MSG_WM_PARENTNOTIFY(func) \
1039- if (uMsg == WM_PARENTNOTIFY) \
1040- { \
1041- SetMsgHandled(TRUE); \
1042- func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1043- lResult = 0; \
1044- if(IsMsgHandled()) \
1045- return TRUE; \
1046- }
1047-
1048-// void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate)
1049-#define MSG_WM_MDIACTIVATE(func) \
1050- if (uMsg == WM_MDIACTIVATE) \
1051- { \
1052- SetMsgHandled(TRUE); \
1053- func((HWND)wParam, (HWND)lParam); \
1054- lResult = 0; \
1055- if(IsMsgHandled()) \
1056- return TRUE; \
1057- }
1058-
1059-// void OnRenderFormat(UINT nFormat)
1060-#define MSG_WM_RENDERFORMAT(func) \
1061- if (uMsg == WM_RENDERFORMAT) \
1062- { \
1063- SetMsgHandled(TRUE); \
1064- func((UINT)wParam); \
1065- lResult = 0; \
1066- if(IsMsgHandled()) \
1067- return TRUE; \
1068- }
1069-
1070-// void OnRenderAllFormats()
1071-#define MSG_WM_RENDERALLFORMATS(func) \
1072- if (uMsg == WM_RENDERALLFORMATS) \
1073- { \
1074- SetMsgHandled(TRUE); \
1075- func(); \
1076- lResult = 0; \
1077- if(IsMsgHandled()) \
1078- return TRUE; \
1079- }
1080-
1081-// void OnDestroyClipboard()
1082-#define MSG_WM_DESTROYCLIPBOARD(func) \
1083- if (uMsg == WM_DESTROYCLIPBOARD) \
1084- { \
1085- SetMsgHandled(TRUE); \
1086- func(); \
1087- lResult = 0; \
1088- if(IsMsgHandled()) \
1089- return TRUE; \
1090- }
1091-
1092-// void OnDrawClipboard()
1093-#define MSG_WM_DRAWCLIPBOARD(func) \
1094- if (uMsg == WM_DRAWCLIPBOARD) \
1095- { \
1096- SetMsgHandled(TRUE); \
1097- func(); \
1098- lResult = 0; \
1099- if(IsMsgHandled()) \
1100- return TRUE; \
1101- }
1102-
1103-// void OnPaintClipboard(CWindow wndViewer, const LPPAINTSTRUCT lpPaintStruct)
1104-#define MSG_WM_PAINTCLIPBOARD(func) \
1105- if (uMsg == WM_PAINTCLIPBOARD) \
1106- { \
1107- SetMsgHandled(TRUE); \
1108- func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \
1109- ::GlobalUnlock((HGLOBAL)lParam); \
1110- lResult = 0; \
1111- if(IsMsgHandled()) \
1112- return TRUE; \
1113- }
1114-
1115-// void OnVScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
1116-#define MSG_WM_VSCROLLCLIPBOARD(func) \
1117- if (uMsg == WM_VSCROLLCLIPBOARD) \
1118- { \
1119- SetMsgHandled(TRUE); \
1120- func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1121- lResult = 0; \
1122- if(IsMsgHandled()) \
1123- return TRUE; \
1124- }
1125-
1126-// void OnContextMenu(CWindow wnd, CPoint point)
1127-#define MSG_WM_CONTEXTMENU(func) \
1128- if (uMsg == WM_CONTEXTMENU) \
1129- { \
1130- SetMsgHandled(TRUE); \
1131- func((HWND)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1132- lResult = 0; \
1133- if(IsMsgHandled()) \
1134- return TRUE; \
1135- }
1136-
1137-// void OnSizeClipboard(CWindow wndViewer, const LPRECT lpRect)
1138-#define MSG_WM_SIZECLIPBOARD(func) \
1139- if (uMsg == WM_SIZECLIPBOARD) \
1140- { \
1141- SetMsgHandled(TRUE); \
1142- func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \
1143- ::GlobalUnlock((HGLOBAL)lParam); \
1144- lResult = 0; \
1145- if(IsMsgHandled()) \
1146- return TRUE; \
1147- }
1148-
1149-// void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString)
1150-#define MSG_WM_ASKCBFORMATNAME(func) \
1151- if (uMsg == WM_ASKCBFORMATNAME) \
1152- { \
1153- SetMsgHandled(TRUE); \
1154- func((DWORD)wParam, (LPTSTR)lParam); \
1155- lResult = 0; \
1156- if(IsMsgHandled()) \
1157- return TRUE; \
1158- }
1159-
1160-// void OnChangeCbChain(CWindow wndRemove, CWindow wndAfter)
1161-#define MSG_WM_CHANGECBCHAIN(func) \
1162- if (uMsg == WM_CHANGECBCHAIN) \
1163- { \
1164- SetMsgHandled(TRUE); \
1165- func((HWND)wParam, (HWND)lParam); \
1166- lResult = 0; \
1167- if(IsMsgHandled()) \
1168- return TRUE; \
1169- }
1170-
1171-// void OnHScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
1172-#define MSG_WM_HSCROLLCLIPBOARD(func) \
1173- if (uMsg == WM_HSCROLLCLIPBOARD) \
1174- { \
1175- SetMsgHandled(TRUE); \
1176- func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1177- lResult = 0; \
1178- if(IsMsgHandled()) \
1179- return TRUE; \
1180- }
1181-
1182-// BOOL OnQueryNewPalette()
1183-#define MSG_WM_QUERYNEWPALETTE(func) \
1184- if (uMsg == WM_QUERYNEWPALETTE) \
1185- { \
1186- SetMsgHandled(TRUE); \
1187- lResult = (LRESULT)func(); \
1188- if(IsMsgHandled()) \
1189- return TRUE; \
1190- }
1191-
1192-// void OnPaletteChanged(CWindow wndFocus)
1193-#define MSG_WM_PALETTECHANGED(func) \
1194- if (uMsg == WM_PALETTECHANGED) \
1195- { \
1196- SetMsgHandled(TRUE); \
1197- func((HWND)wParam); \
1198- lResult = 0; \
1199- if(IsMsgHandled()) \
1200- return TRUE; \
1201- }
1202-
1203-// void OnPaletteIsChanging(CWindow wndPalChg)
1204-#define MSG_WM_PALETTEISCHANGING(func) \
1205- if (uMsg == WM_PALETTEISCHANGING) \
1206- { \
1207- SetMsgHandled(TRUE); \
1208- func((HWND)wParam); \
1209- lResult = 0; \
1210- if(IsMsgHandled()) \
1211- return TRUE; \
1212- }
1213-
1214-// void OnDropFiles(HDROP hDropInfo)
1215-#define MSG_WM_DROPFILES(func) \
1216- if (uMsg == WM_DROPFILES) \
1217- { \
1218- SetMsgHandled(TRUE); \
1219- func((HDROP)wParam); \
1220- lResult = 0; \
1221- if(IsMsgHandled()) \
1222- return TRUE; \
1223- }
1224-
1225-// void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
1226-#define MSG_WM_WINDOWPOSCHANGING(func) \
1227- if (uMsg == WM_WINDOWPOSCHANGING) \
1228- { \
1229- SetMsgHandled(TRUE); \
1230- func((LPWINDOWPOS)lParam); \
1231- lResult = 0; \
1232- if(IsMsgHandled()) \
1233- return TRUE; \
1234- }
1235-
1236-// void OnWindowPosChanged(LPWINDOWPOS lpWndPos)
1237-#define MSG_WM_WINDOWPOSCHANGED(func) \
1238- if (uMsg == WM_WINDOWPOSCHANGED) \
1239- { \
1240- SetMsgHandled(TRUE); \
1241- func((LPWINDOWPOS)lParam); \
1242- lResult = 0; \
1243- if(IsMsgHandled()) \
1244- return TRUE; \
1245- }
1246-
1247-// void OnExitMenuLoop(BOOL fIsTrackPopupMenu)
1248-#define MSG_WM_EXITMENULOOP(func) \
1249- if (uMsg == WM_EXITMENULOOP) \
1250- { \
1251- SetMsgHandled(TRUE); \
1252- func((BOOL)wParam); \
1253- lResult = 0; \
1254- if(IsMsgHandled()) \
1255- return TRUE; \
1256- }
1257-
1258-// void OnEnterMenuLoop(BOOL fIsTrackPopupMenu)
1259-#define MSG_WM_ENTERMENULOOP(func) \
1260- if (uMsg == WM_ENTERMENULOOP) \
1261- { \
1262- SetMsgHandled(TRUE); \
1263- func((BOOL)wParam); \
1264- lResult = 0; \
1265- if(IsMsgHandled()) \
1266- return TRUE; \
1267- }
1268-
1269-// void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
1270-#define MSG_WM_STYLECHANGED(func) \
1271- if (uMsg == WM_STYLECHANGED) \
1272- { \
1273- SetMsgHandled(TRUE); \
1274- func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
1275- lResult = 0; \
1276- if(IsMsgHandled()) \
1277- return TRUE; \
1278- }
1279-
1280-// void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
1281-#define MSG_WM_STYLECHANGING(func) \
1282- if (uMsg == WM_STYLECHANGING) \
1283- { \
1284- SetMsgHandled(TRUE); \
1285- func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
1286- lResult = 0; \
1287- if(IsMsgHandled()) \
1288- return TRUE; \
1289- }
1290-
1291-// void OnSizing(UINT fwSide, LPRECT pRect)
1292-#define MSG_WM_SIZING(func) \
1293- if (uMsg == WM_SIZING) \
1294- { \
1295- SetMsgHandled(TRUE); \
1296- func((UINT)wParam, (LPRECT)lParam); \
1297- lResult = TRUE; \
1298- if(IsMsgHandled()) \
1299- return TRUE; \
1300- }
1301-
1302-// void OnMoving(UINT fwSide, LPRECT pRect)
1303-#define MSG_WM_MOVING(func) \
1304- if (uMsg == WM_MOVING) \
1305- { \
1306- SetMsgHandled(TRUE); \
1307- func((UINT)wParam, (LPRECT)lParam); \
1308- lResult = TRUE; \
1309- if(IsMsgHandled()) \
1310- return TRUE; \
1311- }
1312-
1313-// void OnCaptureChanged(CWindow wnd)
1314-#define MSG_WM_CAPTURECHANGED(func) \
1315- if (uMsg == WM_CAPTURECHANGED) \
1316- { \
1317- SetMsgHandled(TRUE); \
1318- func((HWND)lParam); \
1319- lResult = 0; \
1320- if(IsMsgHandled()) \
1321- return TRUE; \
1322- }
1323-
1324-// BOOL OnDeviceChange(UINT nEventType, DWORD dwData)
1325-#define MSG_WM_DEVICECHANGE(func) \
1326- if (uMsg == WM_DEVICECHANGE) \
1327- { \
1328- SetMsgHandled(TRUE); \
1329- lResult = (LRESULT)func((UINT)wParam, (DWORD)lParam); \
1330- if(IsMsgHandled()) \
1331- return TRUE; \
1332- }
1333-
1334-// void OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1335-#define MSG_WM_COMMAND(func) \
1336- if (uMsg == WM_COMMAND) \
1337- { \
1338- SetMsgHandled(TRUE); \
1339- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1340- lResult = 0; \
1341- if(IsMsgHandled()) \
1342- return TRUE; \
1343- }
1344-
1345-// void OnDisplayChange(UINT uBitsPerPixel, CSize sizeScreen)
1346-#define MSG_WM_DISPLAYCHANGE(func) \
1347- if (uMsg == WM_DISPLAYCHANGE) \
1348- { \
1349- SetMsgHandled(TRUE); \
1350- func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1351- lResult = 0; \
1352- if(IsMsgHandled()) \
1353- return TRUE; \
1354- }
1355-
1356-// void OnEnterSizeMove()
1357-#define MSG_WM_ENTERSIZEMOVE(func) \
1358- if (uMsg == WM_ENTERSIZEMOVE) \
1359- { \
1360- SetMsgHandled(TRUE); \
1361- func(); \
1362- lResult = 0; \
1363- if(IsMsgHandled()) \
1364- return TRUE; \
1365- }
1366-
1367-// void OnExitSizeMove()
1368-#define MSG_WM_EXITSIZEMOVE(func) \
1369- if (uMsg == WM_EXITSIZEMOVE) \
1370- { \
1371- SetMsgHandled(TRUE); \
1372- func(); \
1373- lResult = 0; \
1374- if(IsMsgHandled()) \
1375- return TRUE; \
1376- }
1377-
1378-// HFONT OnGetFont()
1379-#define MSG_WM_GETFONT(func) \
1380- if (uMsg == WM_GETFONT) \
1381- { \
1382- SetMsgHandled(TRUE); \
1383- lResult = (LRESULT)func(); \
1384- if(IsMsgHandled()) \
1385- return TRUE; \
1386- }
1387-
1388-// LRESULT OnGetHotKey()
1389-#define MSG_WM_GETHOTKEY(func) \
1390- if (uMsg == WM_GETHOTKEY) \
1391- { \
1392- SetMsgHandled(TRUE); \
1393- lResult = func(); \
1394- if(IsMsgHandled()) \
1395- return TRUE; \
1396- }
1397-
1398-// HICON OnGetIcon()
1399-#define MSG_WM_GETICON(func) \
1400- if (uMsg == WM_GETICON) \
1401- { \
1402- SetMsgHandled(TRUE); \
1403- lResult = (LRESULT)func((UINT)wParam); \
1404- if(IsMsgHandled()) \
1405- return TRUE; \
1406- }
1407-
1408-// int OnGetText(int cchTextMax, LPTSTR lpszText)
1409-#define MSG_WM_GETTEXT(func) \
1410- if (uMsg == WM_GETTEXT) \
1411- { \
1412- SetMsgHandled(TRUE); \
1413- lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \
1414- if(IsMsgHandled()) \
1415- return TRUE; \
1416- }
1417-
1418-// int OnGetTextLength()
1419-#define MSG_WM_GETTEXTLENGTH(func) \
1420- if (uMsg == WM_GETTEXTLENGTH) \
1421- { \
1422- SetMsgHandled(TRUE); \
1423- lResult = (LRESULT)func(); \
1424- if(IsMsgHandled()) \
1425- return TRUE; \
1426- }
1427-
1428-// void OnHelp(LPHELPINFO lpHelpInfo)
1429-#define MSG_WM_HELP(func) \
1430- if (uMsg == WM_HELP) \
1431- { \
1432- SetMsgHandled(TRUE); \
1433- func((LPHELPINFO)lParam); \
1434- lResult = TRUE; \
1435- if(IsMsgHandled()) \
1436- return TRUE; \
1437- }
1438-
1439-// void OnHotKey(int nHotKeyID, UINT uModifiers, UINT uVirtKey)
1440-#define MSG_WM_HOTKEY(func) \
1441- if (uMsg == WM_HOTKEY) \
1442- { \
1443- SetMsgHandled(TRUE); \
1444- func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1445- lResult = 0; \
1446- if(IsMsgHandled()) \
1447- return TRUE; \
1448- }
1449-
1450-// void OnInputLangChange(DWORD dwCharSet, HKL hKbdLayout)
1451-#define MSG_WM_INPUTLANGCHANGE(func) \
1452- if (uMsg == WM_INPUTLANGCHANGE) \
1453- { \
1454- SetMsgHandled(TRUE); \
1455- func((DWORD)wParam, (HKL)lParam); \
1456- lResult = TRUE; \
1457- if(IsMsgHandled()) \
1458- return TRUE; \
1459- }
1460-
1461-// void OnInputLangChangeRequest(BOOL bSysCharSet, HKL hKbdLayout)
1462-#define MSG_WM_INPUTLANGCHANGEREQUEST(func) \
1463- if (uMsg == WM_INPUTLANGCHANGEREQUEST) \
1464- { \
1465- SetMsgHandled(TRUE); \
1466- func((BOOL)wParam, (HKL)lParam); \
1467- lResult = 0; \
1468- if(IsMsgHandled()) \
1469- return TRUE; \
1470- }
1471-
1472-// void OnNextDlgCtl(BOOL bHandle, WPARAM wCtlFocus)
1473-#define MSG_WM_NEXTDLGCTL(func) \
1474- if (uMsg == WM_NEXTDLGCTL) \
1475- { \
1476- SetMsgHandled(TRUE); \
1477- func((BOOL)LOWORD(lParam), wParam); \
1478- lResult = 0; \
1479- if(IsMsgHandled()) \
1480- return TRUE; \
1481- }
1482-
1483-// void OnNextMenu(int nVirtKey, LPMDINEXTMENU lpMdiNextMenu)
1484-#define MSG_WM_NEXTMENU(func) \
1485- if (uMsg == WM_NEXTMENU) \
1486- { \
1487- SetMsgHandled(TRUE); \
1488- func((int)wParam, (LPMDINEXTMENU)lParam); \
1489- lResult = 0; \
1490- if(IsMsgHandled()) \
1491- return TRUE; \
1492- }
1493-
1494-// int OnNotifyFormat(CWindow wndFrom, int nCommand)
1495-#define MSG_WM_NOTIFYFORMAT(func) \
1496- if (uMsg == WM_NOTIFYFORMAT) \
1497- { \
1498- SetMsgHandled(TRUE); \
1499- lResult = (LRESULT)func((HWND)wParam, (int)lParam); \
1500- if(IsMsgHandled()) \
1501- return TRUE; \
1502- }
1503-
1504-// BOOL OnPowerBroadcast(DWORD dwPowerEvent, DWORD dwData)
1505-#define MSG_WM_POWERBROADCAST(func) \
1506- if (uMsg == WM_POWERBROADCAST) \
1507- { \
1508- SetMsgHandled(TRUE); \
1509- lResult = (LRESULT)func((DWORD)wParam, (DWORD)lParam); \
1510- if(IsMsgHandled()) \
1511- return TRUE; \
1512- }
1513-
1514-// void OnPrint(CDCHandle dc, UINT uFlags)
1515-#define MSG_WM_PRINT(func) \
1516- if (uMsg == WM_PRINT) \
1517- { \
1518- SetMsgHandled(TRUE); \
1519- func((HDC)wParam, (UINT)lParam); \
1520- lResult = 0; \
1521- if(IsMsgHandled()) \
1522- return TRUE; \
1523- }
1524-
1525-// void OnPrintClient(CDCHandle dc, UINT uFlags)
1526-#define MSG_WM_PRINTCLIENT(func) \
1527- if (uMsg == WM_PRINTCLIENT) \
1528- { \
1529- SetMsgHandled(TRUE); \
1530- func((HDC)wParam, (UINT)lParam); \
1531- lResult = 0; \
1532- if(IsMsgHandled()) \
1533- return TRUE; \
1534- }
1535-
1536-// void OnRasDialEvent(RASCONNSTATE rasconnstate, DWORD dwError)
1537-#define MSG_WM_RASDIALEVENT(func) \
1538- if (uMsg == WM_RASDIALEVENT) \
1539- { \
1540- SetMsgHandled(TRUE); \
1541- func((RASCONNSTATE)wParam, (DWORD)lParam); \
1542- lResult = TRUE; \
1543- if(IsMsgHandled()) \
1544- return TRUE; \
1545- }
1546-
1547-// void OnSetFont(CFont font, BOOL bRedraw)
1548-#define MSG_WM_SETFONT(func) \
1549- if (uMsg == WM_SETFONT) \
1550- { \
1551- SetMsgHandled(TRUE); \
1552- func((HFONT)wParam, (BOOL)LOWORD(lParam)); \
1553- lResult = 0; \
1554- if(IsMsgHandled()) \
1555- return TRUE; \
1556- }
1557-
1558-// int OnSetHotKey(int nVirtKey, UINT uFlags)
1559-#define MSG_WM_SETHOTKEY(func) \
1560- if (uMsg == WM_SETHOTKEY) \
1561- { \
1562- SetMsgHandled(TRUE); \
1563- lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \
1564- if(IsMsgHandled()) \
1565- return TRUE; \
1566- }
1567-
1568-// HICON OnSetIcon(UINT uType, HICON hIcon)
1569-#define MSG_WM_SETICON(func) \
1570- if (uMsg == WM_SETICON) \
1571- { \
1572- SetMsgHandled(TRUE); \
1573- lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \
1574- if(IsMsgHandled()) \
1575- return TRUE; \
1576- }
1577-
1578-// void OnSetRedraw(BOOL bRedraw)
1579-#define MSG_WM_SETREDRAW(func) \
1580- if (uMsg == WM_SETREDRAW) \
1581- { \
1582- SetMsgHandled(TRUE); \
1583- func((BOOL)wParam); \
1584- lResult = 0; \
1585- if(IsMsgHandled()) \
1586- return TRUE; \
1587- }
1588-
1589-// int OnSetText(LPCTSTR lpstrText)
1590-#define MSG_WM_SETTEXT(func) \
1591- if (uMsg == WM_SETTEXT) \
1592- { \
1593- SetMsgHandled(TRUE); \
1594- lResult = (LRESULT)func((LPCTSTR)lParam); \
1595- if(IsMsgHandled()) \
1596- return TRUE; \
1597- }
1598-
1599-// void OnUserChanged()
1600-#define MSG_WM_USERCHANGED(func) \
1601- if (uMsg == WM_USERCHANGED) \
1602- { \
1603- SetMsgHandled(TRUE); \
1604- func(); \
1605- lResult = 0; \
1606- if(IsMsgHandled()) \
1607- return TRUE; \
1608- }
1609-
1610-///////////////////////////////////////////////////////////////////////////////
1611-// New NT4 & NT5 messages
1612-
1613-#if(_WIN32_WINNT >= 0x0400)
1614-
1615-// void OnMouseHover(WPARAM wParam, CPoint ptPos)
1616-#define MSG_WM_MOUSEHOVER(func) \
1617- if (uMsg == WM_MOUSEHOVER) \
1618- { \
1619- SetMsgHandled(TRUE); \
1620- func(wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1621- lResult = 0; \
1622- if(IsMsgHandled()) \
1623- return TRUE; \
1624- }
1625-
1626-// void OnMouseLeave()
1627-#define MSG_WM_MOUSELEAVE(func) \
1628- if (uMsg == WM_MOUSELEAVE) \
1629- { \
1630- SetMsgHandled(TRUE); \
1631- func(); \
1632- lResult = 0; \
1633- if(IsMsgHandled()) \
1634- return TRUE; \
1635- }
1636-
1637-#endif /* _WIN32_WINNT >= 0x0400 */
1638-
1639-#if(WINVER >= 0x0500)
1640-
1641-// void OnMenuRButtonUp(WPARAM wParam, CMenu menu)
1642-#define MSG_WM_MENURBUTTONUP(func) \
1643- if (uMsg == WM_MENURBUTTONUP) \
1644- { \
1645- SetMsgHandled(TRUE); \
1646- func(wParam, (HMENU)lParam); \
1647- lResult = 0; \
1648- if(IsMsgHandled()) \
1649- return TRUE; \
1650- }
1651-
1652-// LRESULT OnMenuDrag(WPARAM wParam, CMenu menu)
1653-#define MSG_WM_MENUDRAG(func) \
1654- if (uMsg == WM_MENUDRAG) \
1655- { \
1656- SetMsgHandled(TRUE); \
1657- lResult = func(wParam, (HMENU)lParam); \
1658- if(IsMsgHandled()) \
1659- return TRUE; \
1660- }
1661-
1662-// LRESULT OnMenuGetObject(PMENUGETOBJECTINFO info)
1663-#define MSG_WM_MENUGETOBJECT(func) \
1664- if (uMsg == WM_MENUGETOBJECT) \
1665- { \
1666- SetMsgHandled(TRUE); \
1667- lResult = func((PMENUGETOBJECTINFO)lParam); \
1668- if(IsMsgHandled()) \
1669- return TRUE; \
1670- }
1671-
1672-// void OnUnInitMenuPopup(UINT nID, CMenu menu)
1673-#define MSG_WM_UNINITMENUPOPUP(func) \
1674- if (uMsg == WM_UNINITMENUPOPUP) \
1675- { \
1676- SetMsgHandled(TRUE); \
1677- func((UINT)HIWORD(lParam), (HMENU)wParam); \
1678- lResult = 0; \
1679- if(IsMsgHandled()) \
1680- return TRUE; \
1681- }
1682-
1683-// void OnMenuCommand(WPARAM nIndex, CMenu menu)
1684-#define MSG_WM_MENUCOMMAND(func) \
1685- if (uMsg == WM_MENUCOMMAND) \
1686- { \
1687- SetMsgHandled(TRUE); \
1688- func(wParam, (HMENU)lParam); \
1689- lResult = 0; \
1690- if(IsMsgHandled()) \
1691- return TRUE; \
1692- }
1693-
1694-#endif /* WINVER >= 0x0500 */
1695-
1696-#if(_WIN32_WINNT >= 0x0500)
1697-
1698-// BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys)
1699-#define MSG_WM_APPCOMMAND(func) \
1700- if (uMsg == WM_APPCOMMAND) \
1701- { \
1702- SetMsgHandled(TRUE); \
1703- lResult = (LRESULT)func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \
1704- if(IsMsgHandled()) \
1705- return TRUE; \
1706- }
1707-
1708-// void OnNCXButtonDown(int fwButton, short nHittest, CPoint ptPos)
1709-#define MSG_WM_NCXBUTTONDOWN(func) \
1710- if (uMsg == WM_NCXBUTTONDOWN) \
1711- { \
1712- SetMsgHandled(TRUE); \
1713- func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1714- lResult = 0; \
1715- if(IsMsgHandled()) \
1716- return TRUE; \
1717- }
1718-
1719-// void OnNCXButtonUp(int fwButton, short nHittest, CPoint ptPos)
1720-#define MSG_WM_NCXBUTTONUP(func) \
1721- if (uMsg == WM_NCXBUTTONUP) \
1722- { \
1723- SetMsgHandled(TRUE); \
1724- func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1725- lResult = 0; \
1726- if(IsMsgHandled()) \
1727- return TRUE; \
1728- }
1729-
1730-// void OnNCXButtonDblClk(int fwButton, short nHittest, CPoint ptPos)
1731-#define MSG_WM_NCXBUTTONDBLCLK(func) \
1732- if (uMsg == WM_NCXBUTTONDBLCLK) \
1733- { \
1734- SetMsgHandled(TRUE); \
1735- func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1736- lResult = 0; \
1737- if(IsMsgHandled()) \
1738- return TRUE; \
1739- }
1740-
1741-// void OnXButtonDown(int fwButton, int dwKeys, CPoint ptPos)
1742-#define MSG_WM_XBUTTONDOWN(func) \
1743- if (uMsg == WM_XBUTTONDOWN) \
1744- { \
1745- SetMsgHandled(TRUE); \
1746- func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1747- lResult = 0; \
1748- if(IsMsgHandled()) \
1749- return TRUE; \
1750- }
1751-
1752-// void OnXButtonUp(int fwButton, int dwKeys, CPoint ptPos)
1753-#define MSG_WM_XBUTTONUP(func) \
1754- if (uMsg == WM_XBUTTONUP) \
1755- { \
1756- SetMsgHandled(TRUE); \
1757- func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1758- lResult = 0; \
1759- if(IsMsgHandled()) \
1760- return TRUE; \
1761- }
1762-
1763-// void OnXButtonDblClk(int fwButton, int dwKeys, CPoint ptPos)
1764-#define MSG_WM_XBUTTONDBLCLK(func) \
1765- if (uMsg == WM_XBUTTONDBLCLK) \
1766- { \
1767- SetMsgHandled(TRUE); \
1768- func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1769- lResult = 0; \
1770- if(IsMsgHandled()) \
1771- return TRUE; \
1772- }
1773-
1774-// void OnChangeUIState(WORD nAction, WORD nState)
1775-#define MSG_WM_CHANGEUISTATE(func) \
1776- if (uMsg == WM_CHANGEUISTATE) \
1777- { \
1778- SetMsgHandled(TRUE); \
1779- func(LOWORD(wParam), HIWORD(wParam)); \
1780- lResult = 0; \
1781- if(IsMsgHandled()) \
1782- return TRUE; \
1783- }
1784-
1785-// void OnUpdateUIState(WORD nAction, WORD nState)
1786-#define MSG_WM_UPDATEUISTATE(func) \
1787- if (uMsg == WM_UPDATEUISTATE) \
1788- { \
1789- SetMsgHandled(TRUE); \
1790- func(LOWORD(wParam), HIWORD(wParam)); \
1791- lResult = 0; \
1792- if(IsMsgHandled()) \
1793- return TRUE; \
1794- }
1795-
1796-// LRESULT OnQueryUIState()
1797-#define MSG_WM_QUERYUISTATE(func) \
1798- if (uMsg == WM_QUERYUISTATE) \
1799- { \
1800- SetMsgHandled(TRUE); \
1801- lResult = func(); \
1802- if(IsMsgHandled()) \
1803- return TRUE; \
1804- }
1805-
1806-#endif // (_WIN32_WINNT >= 0x0500)
1807-
1808-#if(_WIN32_WINNT >= 0x0501)
1809-
1810-// void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput)
1811-#define MSG_WM_INPUT(func) \
1812- if (uMsg == WM_INPUT) \
1813- { \
1814- SetMsgHandled(TRUE); \
1815- func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \
1816- lResult = 0; \
1817- if(IsMsgHandled()) \
1818- return TRUE; \
1819- }
1820-
1821-// void OnUniChar(TCHAR nChar, UINT nRepCnt, UINT nFlags)
1822-#define MSG_WM_UNICHAR(func) \
1823- if (uMsg == WM_UNICHAR) \
1824- { \
1825- SetMsgHandled(TRUE); \
1826- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
1827- if(IsMsgHandled()) \
1828- { \
1829- lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \
1830- return TRUE; \
1831- } \
1832- }
1833-
1834-// void OnWTSSessionChange(WPARAM nStatusCode, PWTSSESSION_NOTIFICATION nSessionID)
1835-#define MSG_WM_WTSSESSION_CHANGE(func) \
1836- if (uMsg == WM_WTSSESSION_CHANGE) \
1837- { \
1838- SetMsgHandled(TRUE); \
1839- func(wParam, (PWTSSESSION_NOTIFICATION)lParam); \
1840- lResult = 0; \
1841- if(IsMsgHandled()) \
1842- return TRUE; \
1843- }
1844-
1845-// OnThemeChanged()
1846-#define MSG_WM_THEMECHANGED(func) \
1847- if (uMsg == WM_THEMECHANGED) \
1848- { \
1849- SetMsgHandled(TRUE); \
1850- func(); \
1851- lResult = 0; \
1852- if(IsMsgHandled()) \
1853- return TRUE; \
1854- }
1855-
1856-#endif /* _WIN32_WINNT >= 0x0501 */
1857-
1858-///////////////////////////////////////////////////////////////////////////////
1859-// ATL defined messages
1860-
1861-// BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
1862-#define MSG_WM_FORWARDMSG(func) \
1863- if (uMsg == WM_FORWARDMSG) \
1864- { \
1865- SetMsgHandled(TRUE); \
1866- lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \
1867- if(IsMsgHandled()) \
1868- return TRUE; \
1869- }
1870-
1871-///////////////////////////////////////////////////////////////////////////////
1872-// Dialog specific messages
1873-
1874-// LRESULT OnDMGetDefID()
1875-#define MSG_DM_GETDEFID(func) \
1876- if (uMsg == DM_GETDEFID) \
1877- { \
1878- SetMsgHandled(TRUE); \
1879- lResult = func(); \
1880- if(IsMsgHandled()) \
1881- return TRUE; \
1882- }
1883-
1884-// void OnDMSetDefID(UINT DefID)
1885-#define MSG_DM_SETDEFID(func) \
1886- if (uMsg == DM_SETDEFID) \
1887- { \
1888- SetMsgHandled(TRUE); \
1889- func((UINT)wParam); \
1890- lResult = TRUE; \
1891- if(IsMsgHandled()) \
1892- return TRUE; \
1893- }
1894-
1895-// void OnDMReposition()
1896-#define MSG_DM_REPOSITION(func) \
1897- if (uMsg == DM_REPOSITION) \
1898- { \
1899- SetMsgHandled(TRUE); \
1900- func(); \
1901- lResult = 0; \
1902- if(IsMsgHandled()) \
1903- return TRUE; \
1904- }
1905-
1906-///////////////////////////////////////////////////////////////////////////////
1907-// Reflected messages
1908-
1909-// void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1910-#define MSG_OCM_COMMAND(func) \
1911- if (uMsg == OCM_COMMAND) \
1912- { \
1913- SetMsgHandled(TRUE); \
1914- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1915- lResult = 0; \
1916- if(IsMsgHandled()) \
1917- return TRUE; \
1918- }
1919-
1920-// LRESULT OnReflectedNotify(int idCtrl, LPNMHDR pnmh)
1921-#define MSG_OCM_NOTIFY(func) \
1922- if (uMsg == OCM_NOTIFY) \
1923- { \
1924- SetMsgHandled(TRUE); \
1925- lResult = func((int)wParam, (LPNMHDR)lParam); \
1926- if(IsMsgHandled()) \
1927- return TRUE; \
1928- }
1929-
1930-// void OnReflectedParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1931-#define MSG_OCM_PARENTNOTIFY(func) \
1932- if (uMsg == OCM_PARENTNOTIFY) \
1933- { \
1934- SetMsgHandled(TRUE); \
1935- func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1936- lResult = 0; \
1937- if(IsMsgHandled()) \
1938- return TRUE; \
1939- }
1940-
1941-// void OnReflectedDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
1942-#define MSG_OCM_DRAWITEM(func) \
1943- if (uMsg == OCM_DRAWITEM) \
1944- { \
1945- SetMsgHandled(TRUE); \
1946- func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
1947- lResult = TRUE; \
1948- if(IsMsgHandled()) \
1949- return TRUE; \
1950- }
1951-
1952-// void OnReflectedMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
1953-#define MSG_OCM_MEASUREITEM(func) \
1954- if (uMsg == OCM_MEASUREITEM) \
1955- { \
1956- SetMsgHandled(TRUE); \
1957- func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
1958- lResult = TRUE; \
1959- if(IsMsgHandled()) \
1960- return TRUE; \
1961- }
1962-
1963-// int OnReflectedCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
1964-#define MSG_OCM_COMPAREITEM(func) \
1965- if (uMsg == OCM_COMPAREITEM) \
1966- { \
1967- SetMsgHandled(TRUE); \
1968- lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
1969- if(IsMsgHandled()) \
1970- return TRUE; \
1971- }
1972-
1973-// void OnReflectedDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
1974-#define MSG_OCM_DELETEITEM(func) \
1975- if (uMsg == OCM_DELETEITEM) \
1976- { \
1977- SetMsgHandled(TRUE); \
1978- func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
1979- lResult = TRUE; \
1980- if(IsMsgHandled()) \
1981- return TRUE; \
1982- }
1983-
1984-// int OnReflectedVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
1985-#define MSG_OCM_VKEYTOITEM(func) \
1986- if (uMsg == OCM_VKEYTOITEM) \
1987- { \
1988- SetMsgHandled(TRUE); \
1989- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
1990- if(IsMsgHandled()) \
1991- return TRUE; \
1992- }
1993-
1994-//int OnReflectedCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
1995-#define MSG_OCM_CHARTOITEM(func) \
1996- if (uMsg == OCM_CHARTOITEM) \
1997- { \
1998- SetMsgHandled(TRUE); \
1999- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
2000- if(IsMsgHandled()) \
2001- return TRUE; \
2002- }
2003-
2004-// void OnReflectedHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
2005-#define MSG_OCM_HSCROLL(func) \
2006- if (uMsg == OCM_HSCROLL) \
2007- { \
2008- SetMsgHandled(TRUE); \
2009- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
2010- lResult = 0; \
2011- if(IsMsgHandled()) \
2012- return TRUE; \
2013- }
2014-
2015-// void OnReflectedVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
2016-#define MSG_OCM_VSCROLL(func) \
2017- if (uMsg == OCM_VSCROLL) \
2018- { \
2019- SetMsgHandled(TRUE); \
2020- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
2021- lResult = 0; \
2022- if(IsMsgHandled()) \
2023- return TRUE; \
2024- }
2025-
2026-// HBRUSH OnReflectedCtlColorEdit(CDCHandle dc, CEdit edit)
2027-#define MSG_OCM_CTLCOLOREDIT(func) \
2028- if (uMsg == OCM_CTLCOLOREDIT) \
2029- { \
2030- SetMsgHandled(TRUE); \
2031- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2032- if(IsMsgHandled()) \
2033- return TRUE; \
2034- }
2035-
2036-// HBRUSH OnReflectedCtlColorListBox(CDCHandle dc, CListBox listBox)
2037-#define MSG_OCM_CTLCOLORLISTBOX(func) \
2038- if (uMsg == OCM_CTLCOLORLISTBOX) \
2039- { \
2040- SetMsgHandled(TRUE); \
2041- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2042- if(IsMsgHandled()) \
2043- return TRUE; \
2044- }
2045-
2046-// HBRUSH OnReflectedCtlColorBtn(CDCHandle dc, CButton button)
2047-#define MSG_OCM_CTLCOLORBTN(func) \
2048- if (uMsg == OCM_CTLCOLORBTN) \
2049- { \
2050- SetMsgHandled(TRUE); \
2051- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2052- if(IsMsgHandled()) \
2053- return TRUE; \
2054- }
2055-
2056-// HBRUSH OnReflectedCtlColorDlg(CDCHandle dc, CWindow wnd)
2057-#define MSG_OCM_CTLCOLORDLG(func) \
2058- if (uMsg == OCM_CTLCOLORDLG) \
2059- { \
2060- SetMsgHandled(TRUE); \
2061- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2062- if(IsMsgHandled()) \
2063- return TRUE; \
2064- }
2065-
2066-// HBRUSH OnReflectedCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
2067-#define MSG_OCM_CTLCOLORSCROLLBAR(func) \
2068- if (uMsg == OCM_CTLCOLORSCROLLBAR) \
2069- { \
2070- SetMsgHandled(TRUE); \
2071- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2072- if(IsMsgHandled()) \
2073- return TRUE; \
2074- }
2075-
2076-// HBRUSH OnReflectedCtlColorStatic(CDCHandle dc, CStatic wndStatic)
2077-#define MSG_OCM_CTLCOLORSTATIC(func) \
2078- if (uMsg == OCM_CTLCOLORSTATIC) \
2079- { \
2080- SetMsgHandled(TRUE); \
2081- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2082- if(IsMsgHandled()) \
2083- return TRUE; \
2084- }
2085-
2086-///////////////////////////////////////////////////////////////////////////////
2087-// Edit specific messages
2088-
2089-// void OnClear()
2090-#define MSG_WM_CLEAR(func) \
2091- if (uMsg == WM_CLEAR) \
2092- { \
2093- SetMsgHandled(TRUE); \
2094- func(); \
2095- lResult = 0; \
2096- if(IsMsgHandled()) \
2097- return TRUE; \
2098- }
2099-
2100-// void OnCopy()
2101-#define MSG_WM_COPY(func) \
2102- if (uMsg == WM_COPY) \
2103- { \
2104- SetMsgHandled(TRUE); \
2105- func(); \
2106- lResult = 0; \
2107- if(IsMsgHandled()) \
2108- return TRUE; \
2109- }
2110-
2111-// void OnCut()
2112-#define MSG_WM_CUT(func) \
2113- if (uMsg == WM_CUT) \
2114- { \
2115- SetMsgHandled(TRUE); \
2116- func(); \
2117- lResult = 0; \
2118- if(IsMsgHandled()) \
2119- return TRUE; \
2120- }
2121-
2122-// void OnPaste()
2123-#define MSG_WM_PASTE(func) \
2124- if (uMsg == WM_PASTE) \
2125- { \
2126- SetMsgHandled(TRUE); \
2127- func(); \
2128- lResult = 0; \
2129- if(IsMsgHandled()) \
2130- return TRUE; \
2131- }
2132-
2133-// void OnUndo()
2134-#define MSG_WM_UNDO(func) \
2135- if (uMsg == WM_UNDO) \
2136- { \
2137- SetMsgHandled(TRUE); \
2138- func(); \
2139- lResult = 0; \
2140- if(IsMsgHandled()) \
2141- return TRUE; \
2142- }
2143-
2144-///////////////////////////////////////////////////////////////////////////////
2145-// Generic message handlers
2146-
2147-// LRESULT OnMessageHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2148-#define MESSAGE_HANDLER_EX(msg, func) \
2149- if(uMsg == msg) \
2150- { \
2151- SetMsgHandled(TRUE); \
2152- lResult = func(uMsg, wParam, lParam); \
2153- if(IsMsgHandled()) \
2154- return TRUE; \
2155- }
2156-
2157-// LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2158-#define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \
2159- if(uMsg >= msgFirst && uMsg <= msgLast) \
2160- { \
2161- SetMsgHandled(TRUE); \
2162- lResult = func(uMsg, wParam, lParam); \
2163- if(IsMsgHandled()) \
2164- return TRUE; \
2165- }
2166-
2167-///////////////////////////////////////////////////////////////////////////////
2168-// Commands and notifications
2169-
2170-// void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2171-#define COMMAND_HANDLER_EX(id, code, func) \
2172- if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
2173- { \
2174- SetMsgHandled(TRUE); \
2175- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2176- lResult = 0; \
2177- if(IsMsgHandled()) \
2178- return TRUE; \
2179- }
2180-
2181-// void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2182-#define COMMAND_ID_HANDLER_EX(id, func) \
2183- if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \
2184- { \
2185- SetMsgHandled(TRUE); \
2186- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2187- lResult = 0; \
2188- if(IsMsgHandled()) \
2189- return TRUE; \
2190- }
2191-
2192-// void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2193-#define COMMAND_CODE_HANDLER_EX(code, func) \
2194- if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \
2195- { \
2196- SetMsgHandled(TRUE); \
2197- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2198- lResult = 0; \
2199- if(IsMsgHandled()) \
2200- return TRUE; \
2201- }
2202-
2203-// LRESULT OnNotifyHandlerEX(LPNMHDR pnmh)
2204-#define NOTIFY_HANDLER_EX(id, cd, func) \
2205- if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
2206- { \
2207- SetMsgHandled(TRUE); \
2208- lResult = func((LPNMHDR)lParam); \
2209- if(IsMsgHandled()) \
2210- return TRUE; \
2211- }
2212-
2213-// LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh)
2214-#define NOTIFY_ID_HANDLER_EX(id, func) \
2215- if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
2216- { \
2217- SetMsgHandled(TRUE); \
2218- lResult = func((LPNMHDR)lParam); \
2219- if(IsMsgHandled()) \
2220- return TRUE; \
2221- }
2222-
2223-// LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh)
2224-#define NOTIFY_CODE_HANDLER_EX(cd, func) \
2225- if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
2226- { \
2227- SetMsgHandled(TRUE); \
2228- lResult = func((LPNMHDR)lParam); \
2229- if(IsMsgHandled()) \
2230- return TRUE; \
2231- }
2232-
2233-// void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2234-#define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2235- if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2236- { \
2237- SetMsgHandled(TRUE); \
2238- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2239- lResult = 0; \
2240- if(IsMsgHandled()) \
2241- return TRUE; \
2242- }
2243-
2244-// void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2245-#define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
2246- if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2247- { \
2248- SetMsgHandled(TRUE); \
2249- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2250- lResult = 0; \
2251- if(IsMsgHandled()) \
2252- return TRUE; \
2253- }
2254-
2255-// LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh)
2256-#define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2257- if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2258- { \
2259- SetMsgHandled(TRUE); \
2260- lResult = func((LPNMHDR)lParam); \
2261- if(IsMsgHandled()) \
2262- return TRUE; \
2263- }
2264-
2265-// LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2266-#define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2267- if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2268- { \
2269- SetMsgHandled(TRUE); \
2270- lResult = func((LPNMHDR)lParam); \
2271- if(IsMsgHandled()) \
2272- return TRUE; \
2273- }
2274-
2275-// LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2276-#define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \
2277- if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
2278- { \
2279- SetMsgHandled(TRUE); \
2280- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2281- lResult = 0; \
2282- if(IsMsgHandled()) \
2283- return TRUE; \
2284- }
2285-
2286-// LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2287-#define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \
2288- if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) \
2289- { \
2290- SetMsgHandled(TRUE); \
2291- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2292- lResult = 0; \
2293- if(IsMsgHandled()) \
2294- return TRUE; \
2295- }
2296-
2297-// LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2298-#define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \
2299- if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) \
2300- { \
2301- SetMsgHandled(TRUE); \
2302- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2303- lResult = 0; \
2304- if(IsMsgHandled()) \
2305- return TRUE; \
2306- }
2307-
2308-// LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh)
2309-#define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \
2310- if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
2311- { \
2312- SetMsgHandled(TRUE); \
2313- lResult = func((LPNMHDR)lParam); \
2314- if(IsMsgHandled()) \
2315- return TRUE; \
2316- }
2317-
2318-// LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh)
2319-#define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \
2320- if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
2321- { \
2322- SetMsgHandled(TRUE); \
2323- lResult = func((LPNMHDR)lParam); \
2324- if(IsMsgHandled()) \
2325- return TRUE; \
2326- }
2327-
2328-// LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh)
2329-#define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \
2330- if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
2331- { \
2332- SetMsgHandled(TRUE); \
2333- lResult = func((LPNMHDR)lParam); \
2334- if(IsMsgHandled()) \
2335- return TRUE; \
2336- }
2337-
2338-// void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2339-#define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2340- if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2341- { \
2342- SetMsgHandled(TRUE); \
2343- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2344- lResult = 0; \
2345- if(IsMsgHandled()) \
2346- return TRUE; \
2347- }
2348-
2349-// void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2350-#define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
2351- if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2352- { \
2353- SetMsgHandled(TRUE); \
2354- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2355- lResult = 0; \
2356- if(IsMsgHandled()) \
2357- return TRUE; \
2358- }
2359-
2360-// LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh)
2361-#define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2362- if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2363- { \
2364- SetMsgHandled(TRUE); \
2365- lResult = func((LPNMHDR)lParam); \
2366- if(IsMsgHandled()) \
2367- return TRUE; \
2368- }
2369-
2370-// LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2371-#define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2372- if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2373- { \
2374- SetMsgHandled(TRUE); \
2375- lResult = func((LPNMHDR)lParam); \
2376- if(IsMsgHandled()) \
2377- return TRUE; \
2378- }
2379-
2380-#endif // __ATLCRACK_H__
--- a/include/WTL/Include/atlctrls.h
+++ /dev/null
@@ -1,10039 +0,0 @@
1-// Windows Template Library - WTL version 8.1
2-// Copyright (C) Microsoft Corporation. All rights reserved.
3-//
4-// This file is a part of the Windows Template Library.
5-// The use and distribution terms for this software are covered by the
6-// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
7-// which can be found in the file CPL.TXT at the root of this distribution.
8-// By using this software in any fashion, you are agreeing to be bound by
9-// the terms of this license. You must not remove this notice, or
10-// any other, from this software.
11-
12-#ifndef __ATLCTRLS_H__
13-#define __ATLCTRLS_H__
14-
15-#pragma once
16-
17-#ifndef __cplusplus
18- #error ATL requires C++ compilation (use a .cpp suffix)
19-#endif
20-
21-#ifndef __ATLAPP_H__
22- #error atlctrls.h requires atlapp.h to be included first
23-#endif
24-
25-#ifndef __ATLWIN_H__
26- #error atlctrls.h requires atlwin.h to be included first
27-#endif
28-
29-#if (_WIN32_IE < 0x0300)
30- #error atlctrls.h requires IE Version 3.0 or higher
31-#endif
32-
33-#ifndef _WIN32_WCE
34- #include <richedit.h>
35- #include <richole.h>
36-#elif defined(WIN32_PLATFORM_WFSP) && !defined(_WINUSERM_H_)
37- #include <winuserm.h>
38-#endif // !_WIN32_WCE
39-
40-// protect template members from windowsx.h macros
41-#ifdef _INC_WINDOWSX
42- #undef GetNextSibling
43- #undef GetPrevSibling
44-#endif // _INC_WINDOWSX
45-
46-
47-///////////////////////////////////////////////////////////////////////////////
48-// Classes in this file:
49-//
50-// CStaticT<TBase> - CStatic
51-// CButtonT<TBase> - CButton
52-// CListBoxT<TBase> - CListBox
53-// CComboBoxT<TBase> - CComboBox
54-// CEditT<TBase> - CEdit
55-// CEditCommands<T>
56-// CScrollBarT<TBase> - CScrollBar
57-//
58-// CImageList
59-// CListViewCtrlT<TBase> - CListViewCtrl
60-// CTreeViewCtrlT<TBase> - CTreeViewCtrl
61-// CTreeItemT<TBase> - CTreeItem
62-// CTreeViewCtrlExT<TBase> - CTreeViewCtrlEx
63-// CHeaderCtrlT<TBase> - CHeaderCtrl
64-// CToolBarCtrlT<TBase> - CToolBarCtrl
65-// CStatusBarCtrlT<TBase> - CStatusBarCtrl
66-// CTabCtrlT<TBase> - CTabCtrl
67-// CToolInfo
68-// CToolTipCtrlT<TBase> - CToolTipCtrl
69-// CTrackBarCtrlT<TBase> - CTrackBarCtrl
70-// CUpDownCtrlT<TBase> - CUpDownCtrl
71-// CProgressBarCtrlT<TBase> - CProgressBarCtrl
72-// CHotKeyCtrlT<TBase> - CHotKeyCtrl
73-// CAnimateCtrlT<TBase> - CAnimateCtrl
74-// CRichEditCtrlT<TBase> - CRichEditCtrl
75-// CRichEditCommands<T>
76-// CDragListBoxT<TBase> - CDragListBox
77-// CDragListNotifyImpl<T>
78-// CReBarCtrlT<TBase> - CReBarCtrl
79-// CComboBoxExT<TBase> - CComboBoxEx
80-// CDateTimePickerCtrlT<TBase> - CDateTimePickerCtrl
81-// CMonthCalendarCtrlT<TBase> - CMonthCalendarCtrl
82-// CFlatScrollBarImpl<T>
83-// CFlatScrollBarT<TBase> - CFlatScrollBar
84-// CIPAddressCtrlT<TBase> - CIPAddressCtrl
85-// CPagerCtrlT<TBase> - CPagerCtrl
86-// CLinkCtrlT<TBase> - CLinkCtrl
87-//
88-// CCustomDraw<T>
89-//
90-// CCECommandBarCtrlT<TBase> - CCECommandBarCtrl
91-// CCECommandBandsCtrlT<TBase> - CCECommandBandsCtrl
92-
93-
94-namespace WTL
95-{
96-
97-// These are wrapper classes for Windows standard and common controls.
98-// To implement a window based on a control, use following:
99-// Example: Implementing a window based on a list box
100-//
101-// class CMyListBox : CWindowImpl<CMyListBox, CListBox>
102-// {
103-// public:
104-// BEGIN_MSG_MAP(CMyListBox)
105-// // put your message handler entries here
106-// END_MSG_MAP()
107-// };
108-
109-
110-
111-// --- Standard Windows controls ---
112-
113-///////////////////////////////////////////////////////////////////////////////
114-// CStatic - client side for a Windows STATIC control
115-
116-template <class TBase>
117-class CStaticT : public TBase
118-{
119-public:
120-// Constructors
121- CStaticT(HWND hWnd = NULL) : TBase(hWnd)
122- { }
123-
124- CStaticT< TBase >& operator =(HWND hWnd)
125- {
126- m_hWnd = hWnd;
127- return *this;
128- }
129-
130- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
131- DWORD dwStyle = 0, DWORD dwExStyle = 0,
132- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
133- {
134- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
135- }
136-
137-// Attributes
138- static LPCTSTR GetWndClassName()
139- {
140- return _T("STATIC");
141- }
142-
143-#ifndef _WIN32_WCE
144- HICON GetIcon() const
145- {
146- ATLASSERT(::IsWindow(m_hWnd));
147- return (HICON)::SendMessage(m_hWnd, STM_GETICON, 0, 0L);
148- }
149-
150- HICON SetIcon(HICON hIcon)
151- {
152- ATLASSERT(::IsWindow(m_hWnd));
153- return (HICON)::SendMessage(m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L);
154- }
155-
156- HENHMETAFILE GetEnhMetaFile() const
157- {
158- ATLASSERT(::IsWindow(m_hWnd));
159- return (HENHMETAFILE)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L);
160- }
161-
162- HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile)
163- {
164- ATLASSERT(::IsWindow(m_hWnd));
165- return (HENHMETAFILE)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile);
166- }
167-#else // CE specific
168- HICON GetIcon() const
169- {
170- ATLASSERT(::IsWindow(m_hWnd));
171- return (HICON)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ICON, 0L);
172- }
173-
174- HICON SetIcon(HICON hIcon)
175- {
176- ATLASSERT(::IsWindow(m_hWnd));
177- return (HICON)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
178- }
179-#endif // _WIN32_WCE
180-
181- CBitmapHandle GetBitmap() const
182- {
183- ATLASSERT(::IsWindow(m_hWnd));
184- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L));
185- }
186-
187- CBitmapHandle SetBitmap(HBITMAP hBitmap)
188- {
189- ATLASSERT(::IsWindow(m_hWnd));
190- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap));
191- }
192-
193- HCURSOR GetCursor() const
194- {
195- ATLASSERT(::IsWindow(m_hWnd));
196- return (HCURSOR)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L);
197- }
198-
199- HCURSOR SetCursor(HCURSOR hCursor)
200- {
201- ATLASSERT(::IsWindow(m_hWnd));
202- return (HCURSOR)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
203- }
204-};
205-
206-typedef CStaticT<ATL::CWindow> CStatic;
207-
208-
209-///////////////////////////////////////////////////////////////////////////////
210-// CButton - client side for a Windows BUTTON control
211-
212-template <class TBase>
213-class CButtonT : public TBase
214-{
215-public:
216-// Constructors
217- CButtonT(HWND hWnd = NULL) : TBase(hWnd)
218- { }
219-
220- CButtonT< TBase >& operator =(HWND hWnd)
221- {
222- m_hWnd = hWnd;
223- return *this;
224- }
225-
226- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
227- DWORD dwStyle = 0, DWORD dwExStyle = 0,
228- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
229- {
230- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
231- }
232-
233-// Attributes
234- static LPCTSTR GetWndClassName()
235- {
236- return _T("BUTTON");
237- }
238-
239- UINT GetState() const
240- {
241- ATLASSERT(::IsWindow(m_hWnd));
242- return (UINT)::SendMessage(m_hWnd, BM_GETSTATE, 0, 0L);
243- }
244-
245- void SetState(BOOL bHighlight)
246- {
247- ATLASSERT(::IsWindow(m_hWnd));
248- ::SendMessage(m_hWnd, BM_SETSTATE, bHighlight, 0L);
249- }
250-
251- int GetCheck() const
252- {
253- ATLASSERT(::IsWindow(m_hWnd));
254- return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0L);
255- }
256-
257- void SetCheck(int nCheck)
258- {
259- ATLASSERT(::IsWindow(m_hWnd));
260- ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0L);
261- }
262-
263- UINT GetButtonStyle() const
264- {
265- ATLASSERT(::IsWindow(m_hWnd));
266- return (UINT)::GetWindowLong(m_hWnd, GWL_STYLE) & 0xFFFF;
267- }
268-
269- void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE)
270- {
271- ATLASSERT(::IsWindow(m_hWnd));
272- ::SendMessage(m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw);
273- }
274-
275-#ifndef _WIN32_WCE
276- HICON GetIcon() const
277- {
278- ATLASSERT(::IsWindow(m_hWnd));
279- return (HICON)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L);
280- }
281-
282- HICON SetIcon(HICON hIcon)
283- {
284- ATLASSERT(::IsWindow(m_hWnd));
285- return (HICON)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
286- }
287-
288- CBitmapHandle GetBitmap() const
289- {
290- ATLASSERT(::IsWindow(m_hWnd));
291- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L));
292- }
293-
294- CBitmapHandle SetBitmap(HBITMAP hBitmap)
295- {
296- ATLASSERT(::IsWindow(m_hWnd));
297- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap));
298- }
299-#endif // !_WIN32_WCE
300-
301-#if (_WIN32_WINNT >= 0x0501)
302- BOOL GetIdealSize(LPSIZE lpSize) const
303- {
304- ATLASSERT(::IsWindow(m_hWnd));
305- return (BOOL)::SendMessage(m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize);
306- }
307-
308- BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const
309- {
310- ATLASSERT(::IsWindow(m_hWnd));
311- return (BOOL)::SendMessage(m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist);
312- }
313-
314- BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist)
315- {
316- ATLASSERT(::IsWindow(m_hWnd));
317- return (BOOL)::SendMessage(m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist);
318- }
319-
320- BOOL GetTextMargin(LPRECT lpRect) const
321- {
322- ATLASSERT(::IsWindow(m_hWnd));
323- return (BOOL)::SendMessage(m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect);
324- }
325-
326- BOOL SetTextMargin(LPRECT lpRect)
327- {
328- ATLASSERT(::IsWindow(m_hWnd));
329- return (BOOL)::SendMessage(m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect);
330- }
331-#endif // (_WIN32_WINNT >= 0x0501)
332-
333-#if (WINVER >= 0x0600)
334- void SetDontClick(BOOL bDontClick)
335- {
336- ATLASSERT(::IsWindow(m_hWnd));
337- ::SendMessage(m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L);
338- }
339-#endif // (WINVER >= 0x0600)
340-
341-#if (_WIN32_WINNT >= 0x0600)
342- BOOL SetDropDownState(BOOL bDropDown)
343- {
344- ATLASSERT(::IsWindow(m_hWnd));
345- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
346- return (BOOL)::SendMessage(m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L);
347- }
348-
349- BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const
350- {
351- ATLASSERT(::IsWindow(m_hWnd));
352- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
353- return (BOOL)::SendMessage(m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo);
354- }
355-
356- BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo)
357- {
358- ATLASSERT(::IsWindow(m_hWnd));
359- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
360- return (BOOL)::SendMessage(m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo);
361- }
362-
363- int GetNoteLength() const
364- {
365- ATLASSERT(::IsWindow(m_hWnd));
366- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
367- return (int)::SendMessage(m_hWnd, BCM_GETNOTELENGTH, 0, 0L);
368- }
369-
370- BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const
371- {
372- ATLASSERT(::IsWindow(m_hWnd));
373- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
374- return (BOOL)::SendMessage(m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText);
375- }
376-
377- BOOL SetNote(LPCWSTR lpstrNoteText)
378- {
379- ATLASSERT(::IsWindow(m_hWnd));
380- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
381- return (BOOL)::SendMessage(m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText);
382- }
383-
384- LRESULT SetElevationRequiredState(BOOL bSet)
385- {
386- ATLASSERT(::IsWindow(m_hWnd));
387- return ::SendMessage(m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet);
388- }
389-#endif // (_WIN32_WINNT >= 0x0600)
390-
391-// Operations
392- void Click()
393- {
394- ATLASSERT(::IsWindow(m_hWnd));
395- ::SendMessage(m_hWnd, BM_CLICK, 0, 0L);
396- }
397-};
398-
399-typedef CButtonT<ATL::CWindow> CButton;
400-
401-
402-///////////////////////////////////////////////////////////////////////////////
403-// CListBox - client side for a Windows LISTBOX control
404-
405-template <class TBase>
406-class CListBoxT : public TBase
407-{
408-public:
409-// Constructors
410- CListBoxT(HWND hWnd = NULL) : TBase(hWnd)
411- { }
412-
413- CListBoxT< TBase >& operator =(HWND hWnd)
414- {
415- m_hWnd = hWnd;
416- return *this;
417- }
418-
419- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
420- DWORD dwStyle = 0, DWORD dwExStyle = 0,
421- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
422- {
423- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
424- }
425-
426-// Attributes
427- static LPCTSTR GetWndClassName()
428- {
429- return _T("LISTBOX");
430- }
431-
432- // for entire listbox
433- int GetCount() const
434- {
435- ATLASSERT(::IsWindow(m_hWnd));
436- return (int)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0L);
437- }
438-
439-#ifndef _WIN32_WCE
440- int SetCount(int cItems)
441- {
442- ATLASSERT(::IsWindow(m_hWnd));
443- ATLASSERT(((GetStyle() & LBS_NODATA) != 0) && ((GetStyle() & LBS_HASSTRINGS) == 0));
444- return (int)::SendMessage(m_hWnd, LB_SETCOUNT, cItems, 0L);
445- }
446-#endif // !_WIN32_WCE
447-
448- int GetHorizontalExtent() const
449- {
450- ATLASSERT(::IsWindow(m_hWnd));
451- return (int)::SendMessage(m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L);
452- }
453-
454- void SetHorizontalExtent(int cxExtent)
455- {
456- ATLASSERT(::IsWindow(m_hWnd));
457- ::SendMessage(m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L);
458- }
459-
460- int GetTopIndex() const
461- {
462- ATLASSERT(::IsWindow(m_hWnd));
463- return (int)::SendMessage(m_hWnd, LB_GETTOPINDEX, 0, 0L);
464- }
465-
466- int SetTopIndex(int nIndex)
467- {
468- ATLASSERT(::IsWindow(m_hWnd));
469- return (int)::SendMessage(m_hWnd, LB_SETTOPINDEX, nIndex, 0L);
470- }
471-
472- LCID GetLocale() const
473- {
474- ATLASSERT(::IsWindow(m_hWnd));
475- return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0L);
476- }
477-
478- LCID SetLocale(LCID nNewLocale)
479- {
480- ATLASSERT(::IsWindow(m_hWnd));
481- return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L);
482- }
483-
484-#if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
485- DWORD GetListBoxInfo() const
486- {
487- ATLASSERT(::IsWindow(m_hWnd));
488-#if (_WIN32_WINNT >= 0x0501)
489- return (DWORD)::SendMessage(m_hWnd, LB_GETLISTBOXINFO, 0, 0L);
490-#else // !(_WIN32_WINNT >= 0x0501)
491- return ::GetListBoxInfo(m_hWnd);
492-#endif // !(_WIN32_WINNT >= 0x0501)
493- }
494-#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
495-
496- // for single-selection listboxes
497- int GetCurSel() const
498- {
499- ATLASSERT(::IsWindow(m_hWnd));
500- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0);
501- return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0L);
502- }
503-
504- int SetCurSel(int nSelect)
505- {
506- ATLASSERT(::IsWindow(m_hWnd));
507- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0);
508- return (int)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0L);
509- }
510-
511- // for multiple-selection listboxes
512- int GetSel(int nIndex) const // also works for single-selection
513- {
514- ATLASSERT(::IsWindow(m_hWnd));
515- return (int)::SendMessage(m_hWnd, LB_GETSEL, nIndex, 0L);
516- }
517-
518- int SetSel(int nIndex, BOOL bSelect = TRUE)
519- {
520- ATLASSERT(::IsWindow(m_hWnd));
521- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
522- return (int)::SendMessage(m_hWnd, LB_SETSEL, bSelect, nIndex);
523- }
524-
525- int GetSelCount() const
526- {
527- ATLASSERT(::IsWindow(m_hWnd));
528- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
529- return (int)::SendMessage(m_hWnd, LB_GETSELCOUNT, 0, 0L);
530- }
531-
532- int GetSelItems(int nMaxItems, LPINT rgIndex) const
533- {
534- ATLASSERT(::IsWindow(m_hWnd));
535- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
536- return (int)::SendMessage(m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex);
537- }
538-
539- int GetAnchorIndex() const
540- {
541- ATLASSERT(::IsWindow(m_hWnd));
542- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
543- return (int)::SendMessage(m_hWnd, LB_GETANCHORINDEX, 0, 0L);
544- }
545-
546- void SetAnchorIndex(int nIndex)
547- {
548- ATLASSERT(::IsWindow(m_hWnd));
549- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
550- ::SendMessage(m_hWnd, LB_SETANCHORINDEX, nIndex, 0L);
551- }
552-
553- int GetCaretIndex() const
554- {
555- ATLASSERT(::IsWindow(m_hWnd));
556- return (int)::SendMessage(m_hWnd, LB_GETCARETINDEX, 0, 0);
557- }
558-
559- int SetCaretIndex(int nIndex, BOOL bScroll = TRUE)
560- {
561- ATLASSERT(::IsWindow(m_hWnd));
562- return (int)::SendMessage(m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0));
563- }
564-
565- // for listbox items
566- DWORD_PTR GetItemData(int nIndex) const
567- {
568- ATLASSERT(::IsWindow(m_hWnd));
569- return (DWORD_PTR)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L);
570- }
571-
572- int SetItemData(int nIndex, DWORD_PTR dwItemData)
573- {
574- ATLASSERT(::IsWindow(m_hWnd));
575- return (int)::SendMessage(m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
576- }
577-
578- void* GetItemDataPtr(int nIndex) const
579- {
580- ATLASSERT(::IsWindow(m_hWnd));
581- return (void*)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L);
582- }
583-
584- int SetItemDataPtr(int nIndex, void* pData)
585- {
586- ATLASSERT(::IsWindow(m_hWnd));
587- return SetItemData(nIndex, (DWORD_PTR)pData);
588- }
589-
590- int GetItemRect(int nIndex, LPRECT lpRect) const
591- {
592- ATLASSERT(::IsWindow(m_hWnd));
593- return (int)::SendMessage(m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect);
594- }
595-
596- int GetText(int nIndex, LPTSTR lpszBuffer) const
597- {
598- ATLASSERT(::IsWindow(m_hWnd));
599- return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer);
600- }
601-
602-#ifndef _ATL_NO_COM
603-#ifdef _OLEAUTO_H_
604- BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const
605- {
606- USES_CONVERSION;
607- ATLASSERT(::IsWindow(m_hWnd));
608- ATLASSERT(bstrText == NULL);
609-
610- int nLen = GetTextLen(nIndex);
611- if(nLen == LB_ERR)
612- return FALSE;
613-
614- CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
615- LPTSTR lpstrText = buff.Allocate(nLen + 1);
616- if(lpstrText == NULL)
617- return FALSE;
618-
619- if(GetText(nIndex, lpstrText) == LB_ERR)
620- return FALSE;
621-
622- bstrText = ::SysAllocString(T2OLE(lpstrText));
623- return (bstrText != NULL) ? TRUE : FALSE;
624- }
625-#endif // _OLEAUTO_H_
626-#endif // !_ATL_NO_COM
627-
628-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
629- int GetText(int nIndex, _CSTRING_NS::CString& strText) const
630- {
631- ATLASSERT(::IsWindow(m_hWnd));
632- int cchLen = GetTextLen(nIndex);
633- if(cchLen == LB_ERR)
634- return LB_ERR;
635- int nRet = LB_ERR;
636- LPTSTR lpstr = strText.GetBufferSetLength(cchLen);
637- if(lpstr != NULL)
638- {
639- nRet = GetText(nIndex, lpstr);
640- strText.ReleaseBuffer();
641- }
642- return nRet;
643- }
644-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
645-
646- int GetTextLen(int nIndex) const
647- {
648- ATLASSERT(::IsWindow(m_hWnd));
649- return (int)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0L);
650- }
651-
652- int GetItemHeight(int nIndex) const
653- {
654- ATLASSERT(::IsWindow(m_hWnd));
655- return (int)::SendMessage(m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L);
656- }
657-
658- int SetItemHeight(int nIndex, UINT cyItemHeight)
659- {
660- ATLASSERT(::IsWindow(m_hWnd));
661- return (int)::SendMessage(m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
662- }
663-
664- // Settable only attributes
665- void SetColumnWidth(int cxWidth)
666- {
667- ATLASSERT(::IsWindow(m_hWnd));
668- ::SendMessage(m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L);
669- }
670-
671- BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
672- {
673- ATLASSERT(::IsWindow(m_hWnd));
674- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
675- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
676- }
677-
678- BOOL SetTabStops()
679- {
680- ATLASSERT(::IsWindow(m_hWnd));
681- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
682- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 0, 0L);
683- }
684-
685- BOOL SetTabStops(const int& cxEachStop) // takes an 'int'
686- {
687- ATLASSERT(::IsWindow(m_hWnd));
688- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
689- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
690- }
691-
692-// Operations
693- int InitStorage(int nItems, UINT nBytes)
694- {
695- ATLASSERT(::IsWindow(m_hWnd));
696- return (int)::SendMessage(m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes);
697- }
698-
699- void ResetContent()
700- {
701- ATLASSERT(::IsWindow(m_hWnd));
702- ::SendMessage(m_hWnd, LB_RESETCONTENT, 0, 0L);
703- }
704-
705- UINT ItemFromPoint(POINT pt, BOOL& bOutside) const
706- {
707- ATLASSERT(::IsWindow(m_hWnd));
708- DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
709- bOutside = (BOOL)HIWORD(dw);
710- return (UINT)LOWORD(dw);
711- }
712-
713- // manipulating listbox items
714- int AddString(LPCTSTR lpszItem)
715- {
716- ATLASSERT(::IsWindow(m_hWnd));
717- return (int)::SendMessage(m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem);
718- }
719-
720- int DeleteString(UINT nIndex)
721- {
722- ATLASSERT(::IsWindow(m_hWnd));
723- return (int)::SendMessage(m_hWnd, LB_DELETESTRING, nIndex, 0L);
724- }
725-
726- int InsertString(int nIndex, LPCTSTR lpszItem)
727- {
728- ATLASSERT(::IsWindow(m_hWnd));
729- return (int)::SendMessage(m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem);
730- }
731-
732-#ifndef _WIN32_WCE
733- int Dir(UINT attr, LPCTSTR lpszWildCard)
734- {
735- ATLASSERT(::IsWindow(m_hWnd));
736- return (int)::SendMessage(m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard);
737- }
738-
739- int AddFile(LPCTSTR lpstrFileName)
740- {
741- ATLASSERT(::IsWindow(m_hWnd));
742- return (int)::SendMessage(m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName);
743- }
744-#endif // !_WIN32_WCE
745-
746- // selection helpers
747- int FindString(int nStartAfter, LPCTSTR lpszItem) const
748- {
749- ATLASSERT(::IsWindow(m_hWnd));
750- return (int)::SendMessage(m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem);
751- }
752-
753- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
754- {
755- ATLASSERT(::IsWindow(m_hWnd));
756- return (int)::SendMessage(m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
757- }
758-
759- int SelectString(int nStartAfter, LPCTSTR lpszItem)
760- {
761- ATLASSERT(::IsWindow(m_hWnd));
762- return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem);
763- }
764-
765- int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem)
766- {
767- ATLASSERT(::IsWindow(m_hWnd));
768- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
769- ATLASSERT(nFirstItem <= nLastItem);
770- return bSelect ? (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem);
771- }
772-
773-#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages
774- DWORD GetInputMode(BOOL bCurrentMode = TRUE)
775- {
776- return SendMessage(LB_GETINPUTMODE, 0, (LPARAM)bCurrentMode);
777- }
778-
779- BOOL SetInputMode(DWORD dwMode)
780- {
781- return SendMessage(LB_SETINPUTMODE, 0, (LPARAM)dwMode);
782- }
783-#endif // WIN32_PLATFORM_WFSP
784-};
785-
786-typedef CListBoxT<ATL::CWindow> CListBox;
787-
788-
789-///////////////////////////////////////////////////////////////////////////////
790-// CComboBox - client side for a Windows COMBOBOX control
791-
792-#ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones
793-
794-template <class TBase>
795-class CComboBoxT : public TBase
796-{
797-public:
798-// Constructors
799- CComboBoxT(HWND hWnd = NULL) : TBase(hWnd)
800- { }
801-
802- CComboBoxT< TBase >& operator =(HWND hWnd)
803- {
804- m_hWnd = hWnd;
805- return *this;
806- }
807-
808- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
809- DWORD dwStyle = 0, DWORD dwExStyle = 0,
810- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
811- {
812- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
813- }
814-
815-// Attributes
816- static LPCTSTR GetWndClassName()
817- {
818- return _T("COMBOBOX");
819- }
820-
821- // for entire combo box
822- int GetCount() const
823- {
824- ATLASSERT(::IsWindow(m_hWnd));
825- return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0L);
826- }
827-
828- int GetCurSel() const
829- {
830- ATLASSERT(::IsWindow(m_hWnd));
831- return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0L);
832- }
833-
834- int SetCurSel(int nSelect)
835- {
836- ATLASSERT(::IsWindow(m_hWnd));
837- return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0L);
838- }
839-
840- LCID GetLocale() const
841- {
842- ATLASSERT(::IsWindow(m_hWnd));
843- return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0L);
844- }
845-
846- LCID SetLocale(LCID nNewLocale)
847- {
848- ATLASSERT(::IsWindow(m_hWnd));
849- return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L);
850- }
851-
852- int GetTopIndex() const
853- {
854- ATLASSERT(::IsWindow(m_hWnd));
855- return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0L);
856- }
857-
858- int SetTopIndex(int nIndex)
859- {
860- ATLASSERT(::IsWindow(m_hWnd));
861- return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0L);
862- }
863-
864- UINT GetHorizontalExtent() const
865- {
866- ATLASSERT(::IsWindow(m_hWnd));
867- return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L);
868- }
869-
870- void SetHorizontalExtent(UINT nExtent)
871- {
872- ATLASSERT(::IsWindow(m_hWnd));
873- ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L);
874- }
875-
876- int GetDroppedWidth() const
877- {
878- ATLASSERT(::IsWindow(m_hWnd));
879- return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L);
880- }
881-
882- int SetDroppedWidth(UINT nWidth)
883- {
884- ATLASSERT(::IsWindow(m_hWnd));
885- return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L);
886- }
887-
888-#if ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
889- BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const
890- {
891- ATLASSERT(::IsWindow(m_hWnd));
892-#if ((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
893- return (BOOL)::SendMessage(m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo);
894-#else // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
895- return ::GetComboBoxInfo(m_hWnd, pComboBoxInfo);
896-#endif // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
897- }
898-#endif // ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
899-
900- // for edit control
901- DWORD GetEditSel() const
902- {
903- ATLASSERT(::IsWindow(m_hWnd));
904- return (DWORD)::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0L);
905- }
906-
907- BOOL SetEditSel(int nStartChar, int nEndChar)
908- {
909- ATLASSERT(::IsWindow(m_hWnd));
910- return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar));
911- }
912-
913- // for combobox item
914- DWORD_PTR GetItemData(int nIndex) const
915- {
916- ATLASSERT(::IsWindow(m_hWnd));
917- return (DWORD_PTR)::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex, 0L);
918- }
919-
920- int SetItemData(int nIndex, DWORD_PTR dwItemData)
921- {
922- ATLASSERT(::IsWindow(m_hWnd));
923- return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
924- }
925-
926- void* GetItemDataPtr(int nIndex) const
927- {
928- ATLASSERT(::IsWindow(m_hWnd));
929- return (void*)GetItemData(nIndex);
930- }
931-
932- int SetItemDataPtr(int nIndex, void* pData)
933- {
934- ATLASSERT(::IsWindow(m_hWnd));
935- return SetItemData(nIndex, (DWORD_PTR)pData);
936- }
937-
938- int GetLBText(int nIndex, LPTSTR lpszText) const
939- {
940- ATLASSERT(::IsWindow(m_hWnd));
941- return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText);
942- }
943-
944-#ifndef _ATL_NO_COM
945- BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const
946- {
947- USES_CONVERSION;
948- ATLASSERT(::IsWindow(m_hWnd));
949- ATLASSERT(bstrText == NULL);
950-
951- int nLen = GetLBTextLen(nIndex);
952- if(nLen == CB_ERR)
953- return FALSE;
954-
955- CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
956- LPTSTR lpstrText = buff.Allocate(nLen + 1);
957- if(lpstrText == NULL)
958- return FALSE;
959-
960- if(GetLBText(nIndex, lpstrText) == CB_ERR)
961- return FALSE;
962-
963- bstrText = ::SysAllocString(T2OLE(lpstrText));
964- return (bstrText != NULL) ? TRUE : FALSE;
965- }
966-#endif // !_ATL_NO_COM
967-
968-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
969- int GetLBText(int nIndex, _CSTRING_NS::CString& strText) const
970- {
971- ATLASSERT(::IsWindow(m_hWnd));
972- int cchLen = GetLBTextLen(nIndex);
973- if(cchLen == CB_ERR)
974- return CB_ERR;
975- int nRet = CB_ERR;
976- LPTSTR lpstr = strText.GetBufferSetLength(cchLen);
977- if(lpstr != NULL)
978- {
979- nRet = GetLBText(nIndex, lpstr);
980- strText.ReleaseBuffer();
981- }
982- return nRet;
983- }
984-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
985-
986- int GetLBTextLen(int nIndex) const
987- {
988- ATLASSERT(::IsWindow(m_hWnd));
989- return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L);
990- }
991-
992- int GetItemHeight(int nIndex) const
993- {
994- ATLASSERT(::IsWindow(m_hWnd));
995- return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L);
996- }
997-
998- int SetItemHeight(int nIndex, UINT cyItemHeight)
999- {
1000- ATLASSERT(::IsWindow(m_hWnd));
1001- return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
1002- }
1003-
1004- BOOL GetExtendedUI() const
1005- {
1006- ATLASSERT(::IsWindow(m_hWnd));
1007- return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L);
1008- }
1009-
1010- int SetExtendedUI(BOOL bExtended = TRUE)
1011- {
1012- ATLASSERT(::IsWindow(m_hWnd));
1013- return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L);
1014- }
1015-
1016- void GetDroppedControlRect(LPRECT lprect) const
1017- {
1018- ATLASSERT(::IsWindow(m_hWnd));
1019- ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect);
1020- }
1021-
1022- BOOL GetDroppedState() const
1023- {
1024- ATLASSERT(::IsWindow(m_hWnd));
1025- return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L);
1026- }
1027-
1028-#if (_WIN32_WINNT >= 0x0501)
1029- int GetMinVisible() const
1030- {
1031- ATLASSERT(::IsWindow(m_hWnd));
1032- return (int)::SendMessage(m_hWnd, CB_GETMINVISIBLE, 0, 0L);
1033- }
1034-
1035- BOOL SetMinVisible(int nMinVisible)
1036- {
1037- ATLASSERT(::IsWindow(m_hWnd));
1038- return (BOOL)::SendMessage(m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L);
1039- }
1040-
1041- // Vista only
1042- BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const
1043- {
1044-#ifndef CB_GETCUEBANNER
1045- const UINT CB_GETCUEBANNER = (CBM_FIRST + 4);
1046-#endif
1047- ATLASSERT(::IsWindow(m_hWnd));
1048- return (BOOL)::SendMessage(m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText);
1049- }
1050-
1051- // Vista only
1052- BOOL SetCueBannerText(LPCWSTR lpcwText)
1053- {
1054-#ifndef CB_SETCUEBANNER
1055- const UINT CB_SETCUEBANNER = (CBM_FIRST + 3);
1056-#endif
1057- ATLASSERT(::IsWindow(m_hWnd));
1058- return (BOOL)::SendMessage(m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText);
1059- }
1060-#endif // (_WIN32_WINNT >= 0x0501)
1061-
1062-// Operations
1063- int InitStorage(int nItems, UINT nBytes)
1064- {
1065- ATLASSERT(::IsWindow(m_hWnd));
1066- return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes);
1067- }
1068-
1069- void ResetContent()
1070- {
1071- ATLASSERT(::IsWindow(m_hWnd));
1072- ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0L);
1073- }
1074-
1075- // for edit control
1076- BOOL LimitText(int nMaxChars)
1077- {
1078- ATLASSERT(::IsWindow(m_hWnd));
1079- return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0L);
1080- }
1081-
1082- // for drop-down combo boxes
1083- void ShowDropDown(BOOL bShowIt = TRUE)
1084- {
1085- ATLASSERT(::IsWindow(m_hWnd));
1086- ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L);
1087- }
1088-
1089- // manipulating listbox items
1090- int AddString(LPCTSTR lpszString)
1091- {
1092- ATLASSERT(::IsWindow(m_hWnd));
1093- return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString);
1094- }
1095-
1096- int DeleteString(UINT nIndex)
1097- {
1098- ATLASSERT(::IsWindow(m_hWnd));
1099- return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0L);
1100- }
1101-
1102- int InsertString(int nIndex, LPCTSTR lpszString)
1103- {
1104- ATLASSERT(::IsWindow(m_hWnd));
1105- return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString);
1106- }
1107-
1108-#ifndef _WIN32_WCE
1109- int Dir(UINT attr, LPCTSTR lpszWildCard)
1110- {
1111- ATLASSERT(::IsWindow(m_hWnd));
1112- return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard);
1113- }
1114-#endif // !_WIN32_WCE
1115-
1116- // selection helpers
1117- int FindString(int nStartAfter, LPCTSTR lpszString) const
1118- {
1119- ATLASSERT(::IsWindow(m_hWnd));
1120- return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString);
1121- }
1122-
1123- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
1124- {
1125- ATLASSERT(::IsWindow(m_hWnd));
1126- return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
1127- }
1128-
1129- int SelectString(int nStartAfter, LPCTSTR lpszString)
1130- {
1131- ATLASSERT(::IsWindow(m_hWnd));
1132- return (int)::SendMessage(m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString);
1133- }
1134-
1135- // Clipboard operations
1136- void Clear()
1137- {
1138- ATLASSERT(::IsWindow(m_hWnd));
1139- ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
1140- }
1141-
1142- void Copy()
1143- {
1144- ATLASSERT(::IsWindow(m_hWnd));
1145- ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
1146- }
1147-
1148- void Cut()
1149- {
1150- ATLASSERT(::IsWindow(m_hWnd));
1151- ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
1152- }
1153-
1154- void Paste()
1155- {
1156- ATLASSERT(::IsWindow(m_hWnd));
1157- ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
1158- }
1159-};
1160-
1161-typedef CComboBoxT<ATL::CWindow> CComboBox;
1162-
1163-#endif // !WIN32_PLATFORM_WFSP
1164-
1165-///////////////////////////////////////////////////////////////////////////////
1166-// CEdit - client side for a Windows EDIT control
1167-
1168-template <class TBase>
1169-class CEditT : public TBase
1170-{
1171-public:
1172-// Constructors
1173- CEditT(HWND hWnd = NULL) : TBase(hWnd)
1174- { }
1175-
1176- CEditT< TBase >& operator =(HWND hWnd)
1177- {
1178- m_hWnd = hWnd;
1179- return *this;
1180- }
1181-
1182- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
1183- DWORD dwStyle = 0, DWORD dwExStyle = 0,
1184- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
1185- {
1186- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
1187- }
1188-
1189-// Attributes
1190- static LPCTSTR GetWndClassName()
1191- {
1192- return _T("EDIT");
1193- }
1194-
1195- BOOL CanUndo() const
1196- {
1197- ATLASSERT(::IsWindow(m_hWnd));
1198- return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L);
1199- }
1200-
1201- int GetLineCount() const
1202- {
1203- ATLASSERT(::IsWindow(m_hWnd));
1204- return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L);
1205- }
1206-
1207- BOOL GetModify() const
1208- {
1209- ATLASSERT(::IsWindow(m_hWnd));
1210- return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L);
1211- }
1212-
1213- void SetModify(BOOL bModified = TRUE)
1214- {
1215- ATLASSERT(::IsWindow(m_hWnd));
1216- ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L);
1217- }
1218-
1219- void GetRect(LPRECT lpRect) const
1220- {
1221- ATLASSERT(::IsWindow(m_hWnd));
1222- ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect);
1223- }
1224-
1225- DWORD GetSel() const
1226- {
1227- ATLASSERT(::IsWindow(m_hWnd));
1228- return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L);
1229- }
1230-
1231- void GetSel(int& nStartChar, int& nEndChar) const
1232- {
1233- ATLASSERT(::IsWindow(m_hWnd));
1234- ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar);
1235- }
1236-
1237-#ifndef _WIN32_WCE
1238- HLOCAL GetHandle() const
1239- {
1240- ATLASSERT(::IsWindow(m_hWnd));
1241- return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0L);
1242- }
1243-
1244- void SetHandle(HLOCAL hBuffer)
1245- {
1246- ATLASSERT(::IsWindow(m_hWnd));
1247- ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L);
1248- }
1249-#endif // !_WIN32_WCE
1250-
1251- DWORD GetMargins() const
1252- {
1253- ATLASSERT(::IsWindow(m_hWnd));
1254- return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L);
1255- }
1256-
1257- void SetMargins(UINT nLeft, UINT nRight)
1258- {
1259- ATLASSERT(::IsWindow(m_hWnd));
1260- ::SendMessage(m_hWnd, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(nLeft, nRight));
1261- }
1262-
1263- UINT GetLimitText() const
1264- {
1265- ATLASSERT(::IsWindow(m_hWnd));
1266- return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L);
1267- }
1268-
1269- void SetLimitText(UINT nMax)
1270- {
1271- ATLASSERT(::IsWindow(m_hWnd));
1272- ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0L);
1273- }
1274-
1275- POINT PosFromChar(UINT nChar) const
1276- {
1277- ATLASSERT(::IsWindow(m_hWnd));
1278- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_POSFROMCHAR, nChar, 0);
1279- POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) };
1280- return point;
1281- }
1282-
1283- int CharFromPos(POINT pt, int* pLine = NULL) const
1284- {
1285- ATLASSERT(::IsWindow(m_hWnd));
1286- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y));
1287- if(pLine != NULL)
1288- *pLine = (int)(short)HIWORD(dwRet);
1289- return (int)(short)LOWORD(dwRet);
1290- }
1291-
1292- // NOTE: first word in lpszBuffer must contain the size of the buffer!
1293- int GetLine(int nIndex, LPTSTR lpszBuffer) const
1294- {
1295- ATLASSERT(::IsWindow(m_hWnd));
1296- return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
1297- }
1298-
1299- int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
1300- {
1301- ATLASSERT(::IsWindow(m_hWnd));
1302- *(LPWORD)lpszBuffer = (WORD)nMaxLength;
1303- return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
1304- }
1305-
1306- TCHAR GetPasswordChar() const
1307- {
1308- ATLASSERT(::IsWindow(m_hWnd));
1309- return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L);
1310- }
1311-
1312- void SetPasswordChar(TCHAR ch)
1313- {
1314- ATLASSERT(::IsWindow(m_hWnd));
1315- ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0L);
1316- }
1317-
1318-#ifndef _WIN32_WCE
1319- EDITWORDBREAKPROC GetWordBreakProc() const
1320- {
1321- ATLASSERT(::IsWindow(m_hWnd));
1322- return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L);
1323- }
1324-
1325- void SetWordBreakProc(EDITWORDBREAKPROC ewbprc)
1326- {
1327- ATLASSERT(::IsWindow(m_hWnd));
1328- ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc);
1329- }
1330-#endif // !_WIN32_WCE
1331-
1332- int GetFirstVisibleLine() const
1333- {
1334- ATLASSERT(::IsWindow(m_hWnd));
1335- return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L);
1336- }
1337-
1338-#ifndef _WIN32_WCE
1339- int GetThumb() const
1340- {
1341- ATLASSERT(::IsWindow(m_hWnd));
1342- ATLASSERT((GetStyle() & ES_MULTILINE) != 0);
1343- return (int)::SendMessage(m_hWnd, EM_GETTHUMB, 0, 0L);
1344- }
1345-#endif // !_WIN32_WCE
1346-
1347- BOOL SetReadOnly(BOOL bReadOnly = TRUE)
1348- {
1349- ATLASSERT(::IsWindow(m_hWnd));
1350- return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L);
1351- }
1352-
1353-#if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
1354- UINT GetImeStatus(UINT uStatus) const
1355- {
1356- ATLASSERT(::IsWindow(m_hWnd));
1357- return (UINT)::SendMessage(m_hWnd, EM_GETIMESTATUS, uStatus, 0L);
1358- }
1359-
1360- UINT SetImeStatus(UINT uStatus, UINT uData)
1361- {
1362- ATLASSERT(::IsWindow(m_hWnd));
1363- return (UINT)::SendMessage(m_hWnd, EM_SETIMESTATUS, uStatus, uData);
1364- }
1365-#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
1366-
1367-#if (_WIN32_WINNT >= 0x0501)
1368- BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const
1369- {
1370- ATLASSERT(::IsWindow(m_hWnd));
1371- return (BOOL)::SendMessage(m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText);
1372- }
1373-
1374- // bKeepWithFocus - Vista only
1375- BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE)
1376- {
1377- ATLASSERT(::IsWindow(m_hWnd));
1378- return (BOOL)::SendMessage(m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText));
1379- }
1380-#endif // (_WIN32_WINNT >= 0x0501)
1381-
1382-// Operations
1383- void EmptyUndoBuffer()
1384- {
1385- ATLASSERT(::IsWindow(m_hWnd));
1386- ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L);
1387- }
1388-
1389- BOOL FmtLines(BOOL bAddEOL)
1390- {
1391- ATLASSERT(::IsWindow(m_hWnd));
1392- return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0L);
1393- }
1394-
1395- void LimitText(int nChars = 0)
1396- {
1397- ATLASSERT(::IsWindow(m_hWnd));
1398- ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0L);
1399- }
1400-
1401- int LineFromChar(int nIndex = -1) const
1402- {
1403- ATLASSERT(::IsWindow(m_hWnd));
1404- return (int)::SendMessage(m_hWnd, EM_LINEFROMCHAR, nIndex, 0L);
1405- }
1406-
1407- int LineIndex(int nLine = -1) const
1408- {
1409- ATLASSERT(::IsWindow(m_hWnd));
1410- return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L);
1411- }
1412-
1413- int LineLength(int nLine = -1) const
1414- {
1415- ATLASSERT(::IsWindow(m_hWnd));
1416- return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L);
1417- }
1418-
1419- void LineScroll(int nLines, int nChars = 0)
1420- {
1421- ATLASSERT(::IsWindow(m_hWnd));
1422- ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines);
1423- }
1424-
1425- void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
1426- {
1427- ATLASSERT(::IsWindow(m_hWnd));
1428- ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);
1429- }
1430-
1431- void SetRect(LPCRECT lpRect)
1432- {
1433- ATLASSERT(::IsWindow(m_hWnd));
1434- ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect);
1435- }
1436-
1437- void SetRectNP(LPCRECT lpRect)
1438- {
1439- ATLASSERT(::IsWindow(m_hWnd));
1440- ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect);
1441- }
1442-
1443- void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE)
1444- {
1445- ATLASSERT(::IsWindow(m_hWnd));
1446- ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));
1447- if(!bNoScroll)
1448- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
1449- }
1450-
1451- void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE)
1452- {
1453- ATLASSERT(::IsWindow(m_hWnd));
1454- ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
1455- if(!bNoScroll)
1456- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
1457- }
1458-
1459- void SetSelAll(BOOL bNoScroll = FALSE)
1460- {
1461- SetSel(0, -1, bNoScroll);
1462- }
1463-
1464- void SetSelNone(BOOL bNoScroll = FALSE)
1465- {
1466- SetSel(-1, 0, bNoScroll);
1467- }
1468-
1469- BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
1470- {
1471- ATLASSERT(::IsWindow(m_hWnd));
1472- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
1473- }
1474-
1475- BOOL SetTabStops()
1476- {
1477- ATLASSERT(::IsWindow(m_hWnd));
1478- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L);
1479- }
1480-
1481- BOOL SetTabStops(const int& cxEachStop) // takes an 'int'
1482- {
1483- ATLASSERT(::IsWindow(m_hWnd));
1484- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
1485- }
1486-
1487- void ScrollCaret()
1488- {
1489- ATLASSERT(::IsWindow(m_hWnd));
1490- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
1491- }
1492-
1493- int Scroll(int nScrollAction)
1494- {
1495- ATLASSERT(::IsWindow(m_hWnd));
1496- ATLASSERT((GetStyle() & ES_MULTILINE) != 0);
1497- LRESULT lRet = ::SendMessage(m_hWnd, EM_SCROLL, nScrollAction, 0L);
1498- if(!(BOOL)HIWORD(lRet))
1499- return -1; // failed
1500- return (int)(short)LOWORD(lRet);
1501-
1502- }
1503-
1504- void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)
1505- {
1506- SetSel(nInsertAfterChar, nInsertAfterChar, bNoScroll);
1507- ReplaceSel(lpstrText, bCanUndo);
1508- }
1509-
1510- void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)
1511- {
1512- InsertText(GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo);
1513- }
1514-
1515-#if (_WIN32_WINNT >= 0x0501)
1516- BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip)
1517- {
1518- ATLASSERT(::IsWindow(m_hWnd));
1519- return (BOOL)::SendMessage(m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip);
1520- }
1521-
1522- BOOL HideBalloonTip()
1523- {
1524- ATLASSERT(::IsWindow(m_hWnd));
1525- return (BOOL)::SendMessage(m_hWnd, EM_HIDEBALLOONTIP, 0, 0L);
1526- }
1527-#endif // (_WIN32_WINNT >= 0x0501)
1528-
1529-#if (_WIN32_WINNT >= 0x0600)
1530- DWORD GetHilite() const
1531- {
1532- ATLASSERT(::IsWindow(m_hWnd));
1533- return (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L);
1534- }
1535-
1536- void GetHilite(int& nStartChar, int& nEndChar) const
1537- {
1538- ATLASSERT(::IsWindow(m_hWnd));
1539- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L);
1540- nStartChar = (int)(short)LOWORD(dwRet);
1541- nEndChar = (int)(short)HIWORD(dwRet);
1542- }
1543-
1544- void SetHilite(int nStartChar, int nEndChar)
1545- {
1546- ATLASSERT(::IsWindow(m_hWnd));
1547- ::SendMessage(m_hWnd, EM_SETHILITE, nStartChar, nEndChar);
1548- }
1549-#endif // (_WIN32_WINNT >= 0x0600)
1550-
1551- // Clipboard operations
1552- BOOL Undo()
1553- {
1554- ATLASSERT(::IsWindow(m_hWnd));
1555- return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L);
1556- }
1557-
1558- void Clear()
1559- {
1560- ATLASSERT(::IsWindow(m_hWnd));
1561- ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
1562- }
1563-
1564- void Copy()
1565- {
1566- ATLASSERT(::IsWindow(m_hWnd));
1567- ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
1568- }
1569-
1570- void Cut()
1571- {
1572- ATLASSERT(::IsWindow(m_hWnd));
1573- ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
1574- }
1575-
1576- void Paste()
1577- {
1578- ATLASSERT(::IsWindow(m_hWnd));
1579- ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
1580- }
1581-
1582-#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages
1583- DWORD GetExtendedStyle()
1584- {
1585- return SendMessage(EM_GETEXTENDEDSTYLE);
1586- }
1587-
1588- DWORD SetExtendedStyle(DWORD dwMask, DWORD dwExStyle)
1589- {
1590- return SendMessage(EM_SETEXTENDEDSTYLE, (WPARAM)dwMask, (LPARAM)dwExStyle);
1591- }
1592-
1593- DWORD GetInputMode(BOOL bCurrentMode = TRUE)
1594- {
1595- return SendMessage(EM_GETINPUTMODE, 0, (LPARAM)bCurrentMode);
1596- }
1597-
1598- BOOL SetInputMode(DWORD dwMode)
1599- {
1600- return SendMessage(EM_SETINPUTMODE, 0, (LPARAM)dwMode);
1601- }
1602-
1603- BOOL SetSymbols(LPCTSTR szSymbols)
1604- {
1605- return SendMessage(EM_SETSYMBOLS, 0, (LPARAM)szSymbols);
1606- }
1607-
1608- BOOL ResetSymbols()
1609- {
1610- return SendMessage(EM_SETSYMBOLS);
1611- }
1612-#endif // WIN32_PLATFORM_WFSP
1613-};
1614-
1615-typedef CEditT<ATL::CWindow> CEdit;
1616-
1617-
1618-///////////////////////////////////////////////////////////////////////////////
1619-// CEditCommands - message handlers for standard EDIT commands
1620-
1621-// Chain to CEditCommands message map. Your class must also derive from CEdit.
1622-// Example:
1623-// class CMyEdit : public CWindowImpl<CMyEdit, CEdit>,
1624-// public CEditCommands<CMyEdit>
1625-// {
1626-// public:
1627-// BEGIN_MSG_MAP(CMyEdit)
1628-// // your handlers...
1629-// CHAIN_MSG_MAP_ALT(CEditCommands<CMyEdit>, 1)
1630-// END_MSG_MAP()
1631-// // other stuff...
1632-// };
1633-
1634-template <class T>
1635-class CEditCommands
1636-{
1637-public:
1638- BEGIN_MSG_MAP(CEditCommands< T >)
1639- ALT_MSG_MAP(1)
1640- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
1641- COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll)
1642- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
1643- COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut)
1644- COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste)
1645- COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll)
1646- COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo)
1647- END_MSG_MAP()
1648-
1649- LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1650- {
1651- T* pT = static_cast<T*>(this);
1652- pT->Clear();
1653- return 0;
1654- }
1655-
1656- LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1657- {
1658- T* pT = static_cast<T*>(this);
1659- pT->SetSel(0, -1);
1660- pT->Clear();
1661- return 0;
1662- }
1663-
1664- LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1665- {
1666- T* pT = static_cast<T*>(this);
1667- pT->Copy();
1668- return 0;
1669- }
1670-
1671- LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1672- {
1673- T* pT = static_cast<T*>(this);
1674- pT->Cut();
1675- return 0;
1676- }
1677-
1678- LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1679- {
1680- T* pT = static_cast<T*>(this);
1681- pT->Paste();
1682- return 0;
1683- }
1684-
1685- LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1686- {
1687- T* pT = static_cast<T*>(this);
1688- pT->SetSel(0, -1);
1689- return 0;
1690- }
1691-
1692- LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
1693- {
1694- T* pT = static_cast<T*>(this);
1695- pT->Undo();
1696- return 0;
1697- }
1698-
1699-// State (update UI) helpers
1700- BOOL CanCut() const
1701- { return HasSelection(); }
1702-
1703- BOOL CanCopy() const
1704- { return HasSelection(); }
1705-
1706- BOOL CanClear() const
1707- { return HasSelection(); }
1708-
1709- BOOL CanSelectAll() const
1710- { return HasText(); }
1711-
1712- BOOL CanFind() const
1713- { return HasText(); }
1714-
1715- BOOL CanRepeat() const
1716- { return HasText(); }
1717-
1718- BOOL CanReplace() const
1719- { return HasText(); }
1720-
1721- BOOL CanClearAll() const
1722- { return HasText(); }
1723-
1724-// Implementation
1725- BOOL HasSelection() const
1726- {
1727- const T* pT = static_cast<const T*>(this);
1728- int nMin, nMax;
1729- ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nMin, (LPARAM)&nMax);
1730- return (nMin != nMax);
1731- }
1732-
1733- BOOL HasText() const
1734- {
1735- const T* pT = static_cast<const T*>(this);
1736- return (pT->GetWindowTextLength() > 0);
1737- }
1738-};
1739-
1740-
1741-///////////////////////////////////////////////////////////////////////////////
1742-// CScrollBar - client side for a Windows SCROLLBAR control
1743-
1744-template <class TBase>
1745-class CScrollBarT : public TBase
1746-{
1747-public:
1748-// Constructors
1749- CScrollBarT(HWND hWnd = NULL) : TBase(hWnd)
1750- { }
1751-
1752- CScrollBarT< TBase >& operator =(HWND hWnd)
1753- {
1754- m_hWnd = hWnd;
1755- return *this;
1756- }
1757-
1758- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
1759- DWORD dwStyle = 0, DWORD dwExStyle = 0,
1760- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
1761- {
1762- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
1763- }
1764-
1765-// Attributes
1766- static LPCTSTR GetWndClassName()
1767- {
1768- return _T("SCROLLBAR");
1769- }
1770-
1771-#ifndef _WIN32_WCE
1772- int GetScrollPos() const
1773- {
1774- ATLASSERT(::IsWindow(m_hWnd));
1775- return ::GetScrollPos(m_hWnd, SB_CTL);
1776- }
1777-#endif // !_WIN32_WCE
1778-
1779- int SetScrollPos(int nPos, BOOL bRedraw = TRUE)
1780- {
1781- ATLASSERT(::IsWindow(m_hWnd));
1782- return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw);
1783- }
1784-
1785-#ifndef _WIN32_WCE
1786- void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const
1787- {
1788- ATLASSERT(::IsWindow(m_hWnd));
1789- ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos);
1790- }
1791-#endif // !_WIN32_WCE
1792-
1793- void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
1794- {
1795- ATLASSERT(::IsWindow(m_hWnd));
1796- ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw);
1797- }
1798-
1799- BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const
1800- {
1801- ATLASSERT(::IsWindow(m_hWnd));
1802- return ::GetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo);
1803- }
1804-
1805- int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
1806- {
1807- ATLASSERT(::IsWindow(m_hWnd));
1808- return ::SetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo, bRedraw);
1809- }
1810-
1811-#ifndef _WIN32_WCE
1812- int GetScrollLimit() const
1813- {
1814- int nMin = 0, nMax = 0;
1815- ::GetScrollRange(m_hWnd, SB_CTL, &nMin, &nMax);
1816- SCROLLINFO info = { 0 };
1817- info.cbSize = sizeof(SCROLLINFO);
1818- info.fMask = SIF_PAGE;
1819- if(::GetScrollInfo(m_hWnd, SB_CTL, &info))
1820- nMax -= ((info.nPage - 1) > 0) ? (info.nPage - 1) : 0;
1821-
1822- return nMax;
1823- }
1824-
1825-#if (WINVER >= 0x0500)
1826- BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const
1827- {
1828- ATLASSERT(::IsWindow(m_hWnd));
1829-#if (_WIN32_WINNT >= 0x0501)
1830- return (BOOL)::SendMessage(m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo);
1831-#else // !(_WIN32_WINNT >= 0x0501)
1832- return ::GetScrollBarInfo(m_hWnd, OBJID_CLIENT, pScrollBarInfo);
1833-#endif // !(_WIN32_WINNT >= 0x0501)
1834- }
1835-#endif // (WINVER >= 0x0500)
1836-
1837-// Operations
1838- void ShowScrollBar(BOOL bShow = TRUE)
1839- {
1840- ATLASSERT(::IsWindow(m_hWnd));
1841- ::ShowScrollBar(m_hWnd, SB_CTL, bShow);
1842- }
1843-
1844- BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH)
1845- {
1846- ATLASSERT(::IsWindow(m_hWnd));
1847- return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags);
1848- }
1849-#endif // !_WIN32_WCE
1850-};
1851-
1852-typedef CScrollBarT<ATL::CWindow> CScrollBar;
1853-
1854-
1855-// --- Windows Common Controls ---
1856-
1857-///////////////////////////////////////////////////////////////////////////////
1858-// CImageList
1859-
1860-class CImageList
1861-{
1862-public:
1863- HIMAGELIST m_hImageList;
1864-
1865-// Constructor
1866- CImageList(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList)
1867- { }
1868-
1869-// Operators, etc.
1870- CImageList& operator =(HIMAGELIST hImageList)
1871- {
1872- m_hImageList = hImageList;
1873- return *this;
1874- }
1875-
1876- operator HIMAGELIST() const { return m_hImageList; }
1877-
1878- void Attach(HIMAGELIST hImageList)
1879- {
1880- ATLASSERT(m_hImageList == NULL);
1881- ATLASSERT(hImageList != NULL);
1882- m_hImageList = hImageList;
1883- }
1884-
1885- HIMAGELIST Detach()
1886- {
1887- HIMAGELIST hImageList = m_hImageList;
1888- m_hImageList = NULL;
1889- return hImageList;
1890- }
1891-
1892- bool IsNull() const { return (m_hImageList == NULL); }
1893-
1894-// Attributes
1895- int GetImageCount() const
1896- {
1897- ATLASSERT(m_hImageList != NULL);
1898- return ImageList_GetImageCount(m_hImageList);
1899- }
1900-
1901- COLORREF GetBkColor() const
1902- {
1903- ATLASSERT(m_hImageList != NULL);
1904- return ImageList_GetBkColor(m_hImageList);
1905- }
1906-
1907- COLORREF SetBkColor(COLORREF cr)
1908- {
1909- ATLASSERT(m_hImageList != NULL);
1910- return ImageList_SetBkColor(m_hImageList, cr);
1911- }
1912-
1913- BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const
1914- {
1915- ATLASSERT(m_hImageList != NULL);
1916- return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo);
1917- }
1918-
1919- HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const
1920- {
1921- ATLASSERT(m_hImageList != NULL);
1922- return ImageList_GetIcon(m_hImageList, nIndex, uFlags);
1923- }
1924-
1925- BOOL GetIconSize(int& cx, int& cy) const
1926- {
1927- ATLASSERT(m_hImageList != NULL);
1928- return ImageList_GetIconSize(m_hImageList, &cx, &cy);
1929- }
1930-
1931- BOOL GetIconSize(SIZE& size) const
1932- {
1933- ATLASSERT(m_hImageList != NULL);
1934- return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*)&size.cy);
1935- }
1936-
1937- BOOL SetIconSize(int cx, int cy)
1938- {
1939- ATLASSERT(m_hImageList != NULL);
1940- return ImageList_SetIconSize(m_hImageList, cx, cy);
1941- }
1942-
1943- BOOL SetIconSize(SIZE size)
1944- {
1945- ATLASSERT(m_hImageList != NULL);
1946- return ImageList_SetIconSize(m_hImageList, size.cx, size.cy);
1947- }
1948-
1949- BOOL SetImageCount(UINT uNewCount)
1950- {
1951- ATLASSERT(m_hImageList != NULL);
1952- return ImageList_SetImageCount(m_hImageList, uNewCount);
1953- }
1954-
1955- BOOL SetOverlayImage(int nImage, int nOverlay)
1956- {
1957- ATLASSERT(m_hImageList != NULL);
1958- return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay);
1959- }
1960-
1961-// Operations
1962- BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow)
1963- {
1964- ATLASSERT(m_hImageList == NULL);
1965- m_hImageList = ImageList_Create(cx, cy, nFlags, nInitial, nGrow);
1966- return (m_hImageList != NULL) ? TRUE : FALSE;
1967- }
1968-
1969- BOOL Create(ATL::_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMask)
1970- {
1971- ATLASSERT(m_hImageList == NULL);
1972- m_hImageList = ImageList_LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr, cx, nGrow, crMask);
1973- return (m_hImageList != NULL) ? TRUE : FALSE;
1974- }
1975-
1976- BOOL CreateFromImage(ATL::_U_STRINGorID image, int cx, int nGrow, COLORREF crMask, UINT uType, UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE)
1977- {
1978- ATLASSERT(m_hImageList == NULL);
1979- m_hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInstance(), image.m_lpstr, cx, nGrow, crMask, uType, uFlags);
1980- return (m_hImageList != NULL) ? TRUE : FALSE;
1981- }
1982-
1983- BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2, int nImage2, int dx, int dy)
1984- {
1985- ATLASSERT(m_hImageList == NULL);
1986- m_hImageList = ImageList_Merge(hImageList1, nImage1, hImageList2, nImage2, dx, dy);
1987- return (m_hImageList != NULL) ? TRUE : FALSE;
1988- }
1989-
1990-#ifndef _WIN32_WCE
1991-#ifdef __IStream_INTERFACE_DEFINED__
1992- BOOL CreateFromStream(LPSTREAM lpStream)
1993- {
1994- ATLASSERT(m_hImageList == NULL);
1995- m_hImageList = ImageList_Read(lpStream);
1996- return (m_hImageList != NULL) ? TRUE : FALSE;
1997- }
1998-#endif // __IStream_INTERFACE_DEFINED__
1999-#endif // !_WIN32_WCE
2000-
2001- BOOL Destroy()
2002- {
2003- if (m_hImageList == NULL)
2004- return FALSE;
2005- BOOL bRet = ImageList_Destroy(m_hImageList);
2006- if(bRet)
2007- m_hImageList = NULL;
2008- return bRet;
2009- }
2010-
2011- int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL)
2012- {
2013- ATLASSERT(m_hImageList != NULL);
2014- return ImageList_Add(m_hImageList, hBitmap, hBitmapMask);
2015- }
2016-
2017- int Add(HBITMAP hBitmap, COLORREF crMask)
2018- {
2019- ATLASSERT(m_hImageList != NULL);
2020- return ImageList_AddMasked(m_hImageList, hBitmap, crMask);
2021- }
2022-
2023- BOOL Remove(int nImage)
2024- {
2025- ATLASSERT(m_hImageList != NULL);
2026- return ImageList_Remove(m_hImageList, nImage);
2027- }
2028-
2029- BOOL RemoveAll()
2030- {
2031- ATLASSERT(m_hImageList != NULL);
2032- return ImageList_RemoveAll(m_hImageList);
2033- }
2034-
2035- BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask)
2036- {
2037- ATLASSERT(m_hImageList != NULL);
2038- return ImageList_Replace(m_hImageList, nImage, hBitmap, hBitmapMask);
2039- }
2040-
2041- int AddIcon(HICON hIcon)
2042- {
2043- ATLASSERT(m_hImageList != NULL);
2044- return ImageList_AddIcon(m_hImageList, hIcon);
2045- }
2046-
2047- int ReplaceIcon(int nImage, HICON hIcon)
2048- {
2049- ATLASSERT(m_hImageList != NULL);
2050- return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon);
2051- }
2052-
2053- HICON ExtractIcon(int nImage)
2054- {
2055- ATLASSERT(m_hImageList != NULL);
2056- return ImageList_ExtractIcon(NULL, m_hImageList, nImage);
2057- }
2058-
2059- BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle)
2060- {
2061- ATLASSERT(m_hImageList != NULL);
2062- ATLASSERT(hDC != NULL);
2063- return ImageList_Draw(m_hImageList, nImage, hDC, x, y, nStyle);
2064- }
2065-
2066- BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle)
2067- {
2068- ATLASSERT(m_hImageList != NULL);
2069- ATLASSERT(hDC != NULL);
2070- return ImageList_Draw(m_hImageList, nImage, hDC, pt.x, pt.y, nStyle);
2071- }
2072-
2073- BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
2074- {
2075- ATLASSERT(m_hImageList != NULL);
2076- ATLASSERT(hDC != NULL);
2077- return ImageList_DrawEx(m_hImageList, nImage, hDC, x, y, dx, dy, rgbBk, rgbFg, fStyle);
2078- }
2079-
2080- BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
2081- {
2082- ATLASSERT(m_hImageList != NULL);
2083- ATLASSERT(hDC != NULL);
2084- return ImageList_DrawEx(m_hImageList, nImage, hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, rgbBk, rgbFg, fStyle);
2085- }
2086-
2087- static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp)
2088- {
2089- return ImageList_DrawIndirect(pimldp);
2090- }
2091-
2092- BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE)
2093- {
2094- ATLASSERT(m_hImageList != NULL);
2095- return ImageList_Copy(m_hImageList, nDst, m_hImageList, nSrc, uFlags);
2096- }
2097-
2098-#ifdef __IStream_INTERFACE_DEFINED__
2099-#ifndef _WIN32_WCE
2100- static HIMAGELIST Read(LPSTREAM lpStream)
2101- {
2102- return ImageList_Read(lpStream);
2103- }
2104-
2105- BOOL Write(LPSTREAM lpStream)
2106- {
2107- ATLASSERT(m_hImageList != NULL);
2108- return ImageList_Write(m_hImageList, lpStream);
2109- }
2110-#endif // !_WIN32_WCE
2111-
2112-#if (_WIN32_WINNT >= 0x0501)
2113- static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv)
2114- {
2115- return ImageList_ReadEx(dwFlags, lpStream, riid, ppv);
2116- }
2117-
2118- HRESULT WriteEx(DWORD dwFlags, LPSTREAM lpStream)
2119- {
2120- ATLASSERT(m_hImageList != NULL);
2121- return ImageList_WriteEx(m_hImageList, dwFlags, lpStream);
2122- }
2123-#endif // (_WIN32_WINNT >= 0x0501)
2124-#endif // __IStream_INTERFACE_DEFINED__
2125-
2126- // Drag operations
2127- BOOL BeginDrag(int nImage, POINT ptHotSpot)
2128- {
2129- ATLASSERT(m_hImageList != NULL);
2130- return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, ptHotSpot.y);
2131- }
2132-
2133- BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot)
2134- {
2135- ATLASSERT(m_hImageList != NULL);
2136- return ImageList_BeginDrag(m_hImageList, nImage, xHotSpot, yHotSpot);
2137- }
2138-
2139- static void EndDrag()
2140- {
2141- ImageList_EndDrag();
2142- }
2143-
2144- static BOOL DragMove(POINT pt)
2145- {
2146- return ImageList_DragMove(pt.x, pt.y);
2147- }
2148-
2149- static BOOL DragMove(int x, int y)
2150- {
2151- return ImageList_DragMove(x, y);
2152- }
2153-
2154- BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot)
2155- {
2156- ATLASSERT(m_hImageList != NULL);
2157- return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSpot.x, ptHotSpot.y);
2158- }
2159-
2160- BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot)
2161- {
2162- ATLASSERT(m_hImageList != NULL);
2163- return ImageList_SetDragCursorImage(m_hImageList, nDrag, xHotSpot, yHotSpot);
2164- }
2165-
2166- static BOOL DragShowNolock(BOOL bShow = TRUE)
2167- {
2168- return ImageList_DragShowNolock(bShow);
2169- }
2170-
2171- static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot)
2172- {
2173- return CImageList(ImageList_GetDragImage(lpPoint, lpPointHotSpot));
2174- }
2175-
2176- static BOOL DragEnter(HWND hWnd, POINT point)
2177- {
2178- return ImageList_DragEnter(hWnd, point.x, point.y);
2179- }
2180-
2181- static BOOL DragEnter(HWND hWnd, int x, int y)
2182- {
2183- return ImageList_DragEnter(hWnd, x, y);
2184- }
2185-
2186- static BOOL DragLeave(HWND hWnd)
2187- {
2188- return ImageList_DragLeave(hWnd);
2189- }
2190-
2191-#if (_WIN32_IE >= 0x0400)
2192- CImageList Duplicate() const
2193- {
2194- ATLASSERT(m_hImageList != NULL);
2195- return CImageList(ImageList_Duplicate(m_hImageList));
2196- }
2197-
2198- static CImageList Duplicate(HIMAGELIST hImageList)
2199- {
2200- ATLASSERT(hImageList != NULL);
2201- return CImageList(ImageList_Duplicate(hImageList));
2202- }
2203-#endif // (_WIN32_IE >= 0x0400)
2204-};
2205-
2206-
2207-///////////////////////////////////////////////////////////////////////////////
2208-// CToolTipCtrl
2209-
2210-#ifndef _WIN32_WCE
2211-
2212-class CToolInfo : public TOOLINFO
2213-{
2214-public:
2215- CToolInfo(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
2216- {
2217- Init(nFlags, hWnd, nIDTool, lpRect, lpstrText, lUserParam);
2218- }
2219-
2220- operator LPTOOLINFO() { return this; }
2221-
2222- operator LPARAM() { return (LPARAM)this; }
2223-
2224- void Init(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
2225- {
2226- ATLASSERT(::IsWindow(hWnd));
2227- memset(this, 0, sizeof(TOOLINFO));
2228- cbSize = sizeof(TOOLINFO);
2229- uFlags = nFlags;
2230- if(nIDTool == 0)
2231- {
2232- hwnd = ::GetParent(hWnd);
2233- uFlags |= TTF_IDISHWND;
2234- uId = (UINT_PTR)hWnd;
2235- }
2236- else
2237- {
2238- hwnd = hWnd;
2239- uId = nIDTool;
2240- }
2241- if(lpRect != NULL)
2242- rect = *lpRect;
2243- hinst = ModuleHelper::GetResourceInstance();
2244- lpszText = lpstrText;
2245- lParam = lUserParam;
2246- }
2247-};
2248-
2249-template <class TBase>
2250-class CToolTipCtrlT : public TBase
2251-{
2252-public:
2253-// Constructors
2254- CToolTipCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2255- { }
2256-
2257- CToolTipCtrlT< TBase >& operator =(HWND hWnd)
2258- {
2259- m_hWnd = hWnd;
2260- return *this;
2261- }
2262-
2263- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
2264- DWORD dwStyle = 0, DWORD dwExStyle = 0,
2265- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
2266- {
2267- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2268- }
2269-
2270-// Attributes
2271- static LPCTSTR GetWndClassName()
2272- {
2273- return TOOLTIPS_CLASS;
2274- }
2275-
2276- void GetText(LPTOOLINFO lpToolInfo) const
2277- {
2278- ATLASSERT(::IsWindow(m_hWnd));
2279- ::SendMessage(m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo);
2280- }
2281-
2282- void GetText(LPTSTR lpstrText, HWND hWnd, UINT nIDTool = 0) const
2283- {
2284- ATLASSERT(::IsWindow(m_hWnd));
2285- ATLASSERT(hWnd != NULL);
2286- CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText);
2287- ::SendMessage(m_hWnd, TTM_GETTEXT, 0, ti);
2288- }
2289-
2290- BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const
2291- {
2292- ATLASSERT(::IsWindow(m_hWnd));
2293- return (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo);
2294- }
2295-
2296- BOOL GetToolInfo(HWND hWnd, UINT nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const
2297- {
2298- ATLASSERT(::IsWindow(m_hWnd));
2299- ATLASSERT(hWnd != NULL);
2300- ATLASSERT(puFlags != NULL);
2301- ATLASSERT(lpRect != NULL);
2302- CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText);
2303- BOOL bRet = (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, ti);
2304- if(bRet != FALSE)
2305- {
2306- *puFlags = ti.uFlags;
2307- *lpRect = ti.rect;
2308- }
2309- return bRet;
2310- }
2311-
2312- void SetToolInfo(LPTOOLINFO lpToolInfo)
2313- {
2314- ATLASSERT(::IsWindow(m_hWnd));
2315- ::SendMessage(m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo);
2316- }
2317-
2318- void SetToolRect(LPTOOLINFO lpToolInfo)
2319- {
2320- ATLASSERT(::IsWindow(m_hWnd));
2321- ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo);
2322- }
2323-
2324- void SetToolRect(HWND hWnd, UINT nIDTool, LPCRECT lpRect)
2325- {
2326- ATLASSERT(::IsWindow(m_hWnd));
2327- ATLASSERT(hWnd != NULL);
2328- ATLASSERT(nIDTool != 0);
2329-
2330- CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL);
2331- ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, ti);
2332- }
2333-
2334- int GetToolCount() const
2335- {
2336- ATLASSERT(::IsWindow(m_hWnd));
2337- return (int)::SendMessage(m_hWnd, TTM_GETTOOLCOUNT, 0, 0L);
2338- }
2339-
2340- int GetDelayTime(DWORD dwType) const
2341- {
2342- ATLASSERT(::IsWindow(m_hWnd));
2343- return (int)::SendMessage(m_hWnd, TTM_GETDELAYTIME, dwType, 0L);
2344- }
2345-
2346- void SetDelayTime(DWORD dwType, int nTime)
2347- {
2348- ATLASSERT(::IsWindow(m_hWnd));
2349- ::SendMessage(m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0));
2350- }
2351-
2352- void GetMargin(LPRECT lpRect) const
2353- {
2354- ATLASSERT(::IsWindow(m_hWnd));
2355- ::SendMessage(m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect);
2356- }
2357-
2358- void SetMargin(LPRECT lpRect)
2359- {
2360- ATLASSERT(::IsWindow(m_hWnd));
2361- ::SendMessage(m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect);
2362- }
2363-
2364- int GetMaxTipWidth() const
2365- {
2366- ATLASSERT(::IsWindow(m_hWnd));
2367- return (int)::SendMessage(m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L);
2368- }
2369-
2370- int SetMaxTipWidth(int nWidth)
2371- {
2372- ATLASSERT(::IsWindow(m_hWnd));
2373- return (int)::SendMessage(m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth);
2374- }
2375-
2376- COLORREF GetTipBkColor() const
2377- {
2378- ATLASSERT(::IsWindow(m_hWnd));
2379- return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L);
2380- }
2381-
2382- void SetTipBkColor(COLORREF clr)
2383- {
2384- ATLASSERT(::IsWindow(m_hWnd));
2385- ::SendMessage(m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L);
2386- }
2387-
2388- COLORREF GetTipTextColor() const
2389- {
2390- ATLASSERT(::IsWindow(m_hWnd));
2391- return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L);
2392- }
2393-
2394- void SetTipTextColor(COLORREF clr)
2395- {
2396- ATLASSERT(::IsWindow(m_hWnd));
2397- ::SendMessage(m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L);
2398- }
2399-
2400- BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const
2401- {
2402- ATLASSERT(::IsWindow(m_hWnd));
2403- return (BOOL)::SendMessage(m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo);
2404- }
2405-
2406-#if (_WIN32_IE >= 0x0500)
2407- SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const
2408- {
2409- ATLASSERT(::IsWindow(m_hWnd));
2410- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo);
2411- SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) };
2412- return size;
2413- }
2414-
2415- BOOL SetTitle(UINT uIcon, LPCTSTR lpstrTitle)
2416- {
2417- ATLASSERT(::IsWindow(m_hWnd));
2418- return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle);
2419- }
2420-#endif // (_WIN32_IE >= 0x0500)
2421-
2422-#if (_WIN32_WINNT >= 0x0501)
2423- void GetTitle(PTTGETTITLE pTTGetTitle) const
2424- {
2425- ATLASSERT(::IsWindow(m_hWnd));
2426- ::SendMessage(m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle);
2427- }
2428-
2429- void SetWindowTheme(LPCWSTR lpstrTheme)
2430- {
2431- ATLASSERT(::IsWindow(m_hWnd));
2432- ::SendMessage(m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme);
2433- }
2434-#endif // (_WIN32_WINNT >= 0x0501)
2435-
2436-// Operations
2437- void Activate(BOOL bActivate)
2438- {
2439- ATLASSERT(::IsWindow(m_hWnd));
2440- ::SendMessage(m_hWnd, TTM_ACTIVATE, bActivate, 0L);
2441- }
2442-
2443- BOOL AddTool(LPTOOLINFO lpToolInfo)
2444- {
2445- ATLASSERT(::IsWindow(m_hWnd));
2446- return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo);
2447- }
2448-
2449- BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT nIDTool = 0)
2450- {
2451- ATLASSERT(::IsWindow(m_hWnd));
2452- ATLASSERT(hWnd != NULL);
2453- // the toolrect and toolid must both be zero or both valid
2454- ATLASSERT((lpRectTool != NULL && nIDTool != 0) || (lpRectTool == NULL && nIDTool == 0));
2455-
2456- CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr);
2457- return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, ti);
2458- }
2459-
2460- void DelTool(LPTOOLINFO lpToolInfo)
2461- {
2462- ATLASSERT(::IsWindow(m_hWnd));
2463- ::SendMessage(m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo);
2464- }
2465-
2466- void DelTool(HWND hWnd, UINT nIDTool = 0)
2467- {
2468- ATLASSERT(::IsWindow(m_hWnd));
2469- ATLASSERT(hWnd != NULL);
2470-
2471- CToolInfo ti(0, hWnd, nIDTool, NULL, NULL);
2472- ::SendMessage(m_hWnd, TTM_DELTOOL, 0, ti);
2473- }
2474-
2475- BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const
2476- {
2477- ATLASSERT(::IsWindow(m_hWnd));
2478- return (BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo);
2479- }
2480-
2481- BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const
2482- {
2483- ATLASSERT(::IsWindow(m_hWnd));
2484- ATLASSERT(hWnd != NULL);
2485- ATLASSERT(lpToolInfo != NULL);
2486-
2487- TTHITTESTINFO hti = { 0 };
2488- hti.ti.cbSize = sizeof(TOOLINFO);
2489- hti.hwnd = hWnd;
2490- hti.pt.x = pt.x;
2491- hti.pt.y = pt.y;
2492- if((BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE)
2493- {
2494- *lpToolInfo = hti.ti;
2495- return TRUE;
2496- }
2497- return FALSE;
2498- }
2499-
2500- void RelayEvent(LPMSG lpMsg)
2501- {
2502- ATLASSERT(::IsWindow(m_hWnd));
2503- ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg);
2504- }
2505-
2506- void UpdateTipText(LPTOOLINFO lpToolInfo)
2507- {
2508- ATLASSERT(::IsWindow(m_hWnd));
2509- ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo);
2510- }
2511-
2512- void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT nIDTool = 0)
2513- {
2514- ATLASSERT(::IsWindow(m_hWnd));
2515- ATLASSERT(hWnd != NULL);
2516-
2517- CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr);
2518- ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, ti);
2519- }
2520-
2521- BOOL EnumTools(UINT nTool, LPTOOLINFO lpToolInfo) const
2522- {
2523- ATLASSERT(::IsWindow(m_hWnd));
2524- return (BOOL)::SendMessage(m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo);
2525- }
2526-
2527- void Pop()
2528- {
2529- ATLASSERT(::IsWindow(m_hWnd));
2530- ::SendMessage(m_hWnd, TTM_POP, 0, 0L);
2531- }
2532-
2533- void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate)
2534- {
2535- ATLASSERT(::IsWindow(m_hWnd));
2536- ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo);
2537- }
2538-
2539- void TrackPosition(int xPos, int yPos)
2540- {
2541- ATLASSERT(::IsWindow(m_hWnd));
2542- ::SendMessage(m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
2543- }
2544-
2545-#if (_WIN32_IE >= 0x0400)
2546- void Update()
2547- {
2548- ATLASSERT(::IsWindow(m_hWnd));
2549- ::SendMessage(m_hWnd, TTM_UPDATE, 0, 0L);
2550- }
2551-#endif // (_WIN32_IE >= 0x0400)
2552-
2553-#if (_WIN32_IE >= 0x0500)
2554- BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/)
2555- {
2556- ATLASSERT(::IsWindow(m_hWnd));
2557- return (BOOL)::SendMessage(m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect);
2558- }
2559-#endif // (_WIN32_IE >= 0x0500)
2560-
2561-#if (_WIN32_WINNT >= 0x0501)
2562- void Popup()
2563- {
2564- ATLASSERT(::IsWindow(m_hWnd));
2565- ::SendMessage(m_hWnd, TTM_POPUP, 0, 0L);
2566- }
2567-#endif // (_WIN32_WINNT >= 0x0501)
2568-};
2569-
2570-typedef CToolTipCtrlT<ATL::CWindow> CToolTipCtrl;
2571-
2572-#endif // !_WIN32_WCE
2573-
2574-
2575-///////////////////////////////////////////////////////////////////////////////
2576-// CHeaderCtrl
2577-
2578-template <class TBase>
2579-class CHeaderCtrlT : public TBase
2580-{
2581-public:
2582-// Constructors
2583- CHeaderCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2584- { }
2585-
2586- CHeaderCtrlT< TBase >& operator =(HWND hWnd)
2587- {
2588- m_hWnd = hWnd;
2589- return *this;
2590- }
2591-
2592- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
2593- DWORD dwStyle = 0, DWORD dwExStyle = 0,
2594- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
2595- {
2596- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2597- }
2598-
2599-// Attributes
2600- static LPCTSTR GetWndClassName()
2601- {
2602- return WC_HEADER;
2603- }
2604-
2605- int GetItemCount() const
2606- {
2607- ATLASSERT(::IsWindow(m_hWnd));
2608- return (int)::SendMessage(m_hWnd, HDM_GETITEMCOUNT, 0, 0L);
2609- }
2610-
2611- BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const
2612- {
2613- ATLASSERT(::IsWindow(m_hWnd));
2614- return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem);
2615- }
2616-
2617- BOOL SetItem(int nIndex, LPHDITEM pHeaderItem)
2618- {
2619- ATLASSERT(::IsWindow(m_hWnd));
2620- return (BOOL)::SendMessage(m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem);
2621- }
2622-
2623- CImageList GetImageList() const
2624- {
2625- ATLASSERT(::IsWindow(m_hWnd));
2626- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_GETIMAGELIST, 0, 0L));
2627- }
2628-
2629- CImageList SetImageList(HIMAGELIST hImageList)
2630- {
2631- ATLASSERT(::IsWindow(m_hWnd));
2632- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList));
2633- }
2634-
2635- BOOL GetOrderArray(int nSize, int* lpnArray) const
2636- {
2637- ATLASSERT(::IsWindow(m_hWnd));
2638- return (BOOL)::SendMessage(m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray);
2639- }
2640-
2641- BOOL SetOrderArray(int nSize, int* lpnArray)
2642- {
2643- ATLASSERT(::IsWindow(m_hWnd));
2644- return (BOOL)::SendMessage(m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray);
2645- }
2646-
2647- BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const
2648- {
2649- ATLASSERT(::IsWindow(m_hWnd));
2650- return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect);
2651- }
2652-
2653- int SetHotDivider(BOOL bPos, DWORD dwInputValue)
2654- {
2655- ATLASSERT(::IsWindow(m_hWnd));
2656- return (int)::SendMessage(m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue);
2657- }
2658-
2659-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
2660- BOOL GetUnicodeFormat() const
2661- {
2662- ATLASSERT(::IsWindow(m_hWnd));
2663- return (BOOL)::SendMessage(m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L);
2664- }
2665-
2666- BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
2667- {
2668- ATLASSERT(::IsWindow(m_hWnd));
2669- return (BOOL)::SendMessage(m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L);
2670- }
2671-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
2672-
2673-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
2674- int GetBitmapMargin() const
2675- {
2676- ATLASSERT(::IsWindow(m_hWnd));
2677- return (int)::SendMessage(m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L);
2678- }
2679-
2680- int SetBitmapMargin(int nWidth)
2681- {
2682- ATLASSERT(::IsWindow(m_hWnd));
2683- return (int)::SendMessage(m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L);
2684- }
2685-
2686- int SetFilterChangeTimeout(DWORD dwTimeOut)
2687- {
2688- ATLASSERT(::IsWindow(m_hWnd));
2689- return (int)::SendMessage(m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut);
2690- }
2691-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
2692-
2693-#if (_WIN32_WINNT >= 0x0600)
2694- BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const
2695- {
2696- ATLASSERT(::IsWindow(m_hWnd));
2697- return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect);
2698- }
2699-
2700- BOOL GetOverflowRect(LPRECT lpRect) const
2701- {
2702- ATLASSERT(::IsWindow(m_hWnd));
2703- return (BOOL)::SendMessage(m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect);
2704- }
2705-
2706- int GetFocusedItem() const
2707- {
2708- ATLASSERT(::IsWindow(m_hWnd));
2709- return (int)::SendMessage(m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L);
2710- }
2711-
2712- BOOL SetFocusedItem(int nIndex)
2713- {
2714- ATLASSERT(::IsWindow(m_hWnd));
2715- return (BOOL)::SendMessage(m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex);
2716- }
2717-#endif // (_WIN32_WINNT >= 0x0600)
2718-
2719-// Operations
2720- int InsertItem(int nIndex, LPHDITEM phdi)
2721- {
2722- ATLASSERT(::IsWindow(m_hWnd));
2723- return (int)::SendMessage(m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi);
2724- }
2725-
2726- int AddItem(LPHDITEM phdi)
2727- {
2728- return InsertItem(GetItemCount(), phdi);
2729- }
2730-
2731- BOOL DeleteItem(int nIndex)
2732- {
2733- ATLASSERT(::IsWindow(m_hWnd));
2734- return (BOOL)::SendMessage(m_hWnd, HDM_DELETEITEM, nIndex, 0L);
2735- }
2736-
2737- BOOL Layout(HD_LAYOUT* pHeaderLayout)
2738- {
2739- ATLASSERT(::IsWindow(m_hWnd));
2740- return (BOOL)::SendMessage(m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout);
2741- }
2742-
2743- int HitTest(LPHDHITTESTINFO lpHitTestInfo) const
2744- {
2745- ATLASSERT(::IsWindow(m_hWnd));
2746- return (int)::SendMessage(m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo);
2747- }
2748-
2749- int OrderToIndex(int nOrder)
2750- {
2751- ATLASSERT(::IsWindow(m_hWnd));
2752- return (int)::SendMessage(m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L);
2753- }
2754-
2755- CImageList CreateDragImage(int nIndex)
2756- {
2757- ATLASSERT(::IsWindow(m_hWnd));
2758- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L));
2759- }
2760-
2761-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
2762- int EditFilter(int nColumn, BOOL bDiscardChanges)
2763- {
2764- ATLASSERT(::IsWindow(m_hWnd));
2765- return (int)::SendMessage(m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0));
2766- }
2767-
2768- int ClearFilter(int nColumn)
2769- {
2770- ATLASSERT(::IsWindow(m_hWnd));
2771- return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, nColumn, 0L);
2772- }
2773-
2774- int ClearAllFilters()
2775- {
2776- ATLASSERT(::IsWindow(m_hWnd));
2777- return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L);
2778- }
2779-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
2780-};
2781-
2782-typedef CHeaderCtrlT<ATL::CWindow> CHeaderCtrl;
2783-
2784-
2785-///////////////////////////////////////////////////////////////////////////////
2786-// CListViewCtrl
2787-
2788-template <class TBase>
2789-class CListViewCtrlT : public TBase
2790-{
2791-public:
2792-// Constructors
2793- CListViewCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2794- { }
2795-
2796- CListViewCtrlT< TBase >& operator =(HWND hWnd)
2797- {
2798- m_hWnd = hWnd;
2799- return *this;
2800- }
2801-
2802- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
2803- DWORD dwStyle = 0, DWORD dwExStyle = 0,
2804- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
2805- {
2806- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2807- }
2808-
2809-// Attributes
2810- static LPCTSTR GetWndClassName()
2811- {
2812- return WC_LISTVIEW;
2813- }
2814-
2815- COLORREF GetBkColor() const
2816- {
2817- ATLASSERT(::IsWindow(m_hWnd));
2818- return (COLORREF)::SendMessage(m_hWnd, LVM_GETBKCOLOR, 0, 0L);
2819- }
2820-
2821- BOOL SetBkColor(COLORREF cr)
2822- {
2823- ATLASSERT(::IsWindow(m_hWnd));
2824- return (BOOL)::SendMessage(m_hWnd, LVM_SETBKCOLOR, 0, cr);
2825- }
2826-
2827- CImageList GetImageList(int nImageListType) const
2828- {
2829- ATLASSERT(::IsWindow(m_hWnd));
2830- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L));
2831- }
2832-
2833- CImageList SetImageList(HIMAGELIST hImageList, int nImageList)
2834- {
2835- ATLASSERT(::IsWindow(m_hWnd));
2836- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList));
2837- }
2838-
2839- int GetItemCount() const
2840- {
2841- ATLASSERT(::IsWindow(m_hWnd));
2842- return (int)::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L);
2843- }
2844-
2845- BOOL SetItemCount(int nItems)
2846- {
2847- ATLASSERT(::IsWindow(m_hWnd));
2848- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, 0L);
2849- }
2850-
2851- BOOL GetItem(LPLVITEM pItem) const
2852- {
2853- ATLASSERT(::IsWindow(m_hWnd));
2854- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem);
2855- }
2856-
2857- BOOL SetItem(const LVITEM* pItem)
2858- {
2859- ATLASSERT(::IsWindow(m_hWnd));
2860- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem);
2861- }
2862-
2863- BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
2864- int nImage, UINT nState, UINT nStateMask, LPARAM lParam)
2865- {
2866- ATLASSERT(::IsWindow(m_hWnd));
2867- LVITEM lvi = { 0 };
2868- lvi.mask = nMask;
2869- lvi.iItem = nItem;
2870- lvi.iSubItem = nSubItem;
2871- lvi.stateMask = nStateMask;
2872- lvi.state = nState;
2873- lvi.pszText = (LPTSTR) lpszItem;
2874- lvi.iImage = nImage;
2875- lvi.lParam = lParam;
2876- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi);
2877- }
2878-
2879- UINT GetItemState(int nItem, UINT nMask) const
2880- {
2881- ATLASSERT(::IsWindow(m_hWnd));
2882- return (UINT)::SendMessage(m_hWnd, LVM_GETITEMSTATE, nItem, nMask);
2883- }
2884-
2885- BOOL SetItemState(int nItem, UINT nState, UINT nStateMask)
2886- {
2887- ATLASSERT(::IsWindow(m_hWnd));
2888- LVITEM lvi = { 0 };
2889- lvi.state = nState;
2890- lvi.stateMask = nStateMask;
2891- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi);
2892- }
2893-
2894- BOOL SetItemState(int nItem, LPLVITEM pItem)
2895- {
2896- ATLASSERT(::IsWindow(m_hWnd));
2897- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem);
2898- }
2899-
2900-#ifndef _ATL_NO_COM
2901- BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const
2902- {
2903- USES_CONVERSION;
2904- ATLASSERT(::IsWindow(m_hWnd));
2905- ATLASSERT(bstrText == NULL);
2906- LVITEM lvi = { 0 };
2907- lvi.iSubItem = nSubItem;
2908-
2909- LPTSTR lpstrText = NULL;
2910- int nRes = 0;
2911- for(int nLen = 256; ; nLen *= 2)
2912- {
2913- ATLTRY(lpstrText = new TCHAR[nLen]);
2914- if(lpstrText == NULL)
2915- break;
2916- lpstrText[0] = NULL;
2917- lvi.cchTextMax = nLen;
2918- lvi.pszText = lpstrText;
2919- nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
2920- if(nRes < nLen - 1)
2921- break;
2922- delete [] lpstrText;
2923- lpstrText = NULL;
2924- }
2925-
2926- if(lpstrText != NULL)
2927- {
2928- if(nRes != 0)
2929- bstrText = ::SysAllocString(T2OLE(lpstrText));
2930- delete [] lpstrText;
2931- }
2932-
2933- return (bstrText != NULL) ? TRUE : FALSE;
2934- }
2935-#endif // !_ATL_NO_COM
2936-
2937-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
2938- int GetItemText(int nItem, int nSubItem, _CSTRING_NS::CString& strText) const
2939- {
2940- ATLASSERT(::IsWindow(m_hWnd));
2941- LVITEM lvi = { 0 };
2942- lvi.iSubItem = nSubItem;
2943-
2944- strText.Empty();
2945- int nRes = 0;
2946- for(int nLen = 256; ; nLen *= 2)
2947- {
2948- lvi.cchTextMax = nLen;
2949- lvi.pszText = strText.GetBufferSetLength(nLen);
2950- if(lvi.pszText == NULL)
2951- {
2952- nRes = 0;
2953- break;
2954- }
2955- nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
2956- if(nRes < nLen - 1)
2957- break;
2958- }
2959- strText.ReleaseBuffer();
2960- return nRes;
2961- }
2962-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
2963-
2964- int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const
2965- {
2966- ATLASSERT(::IsWindow(m_hWnd));
2967- LVITEM lvi = { 0 };
2968- lvi.iSubItem = nSubItem;
2969- lvi.cchTextMax = nLen;
2970- lvi.pszText = lpszText;
2971- return (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
2972- }
2973-
2974- BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText)
2975- {
2976- ATLASSERT(::IsWindow(m_hWnd));
2977- return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0);
2978- }
2979-
2980- DWORD_PTR GetItemData(int nItem) const
2981- {
2982- ATLASSERT(::IsWindow(m_hWnd));
2983- LVITEM lvi = { 0 };
2984- lvi.iItem = nItem;
2985- lvi.mask = LVIF_PARAM;
2986- BOOL bRet = (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi);
2987- return (DWORD_PTR)(bRet ? lvi.lParam : NULL);
2988- }
2989-
2990- BOOL SetItemData(int nItem, DWORD_PTR dwData)
2991- {
2992- ATLASSERT(::IsWindow(m_hWnd));
2993- return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData);
2994- }
2995-
2996- UINT GetCallbackMask() const
2997- {
2998- ATLASSERT(::IsWindow(m_hWnd));
2999- return (UINT)::SendMessage(m_hWnd, LVM_GETCALLBACKMASK, 0, 0L);
3000- }
3001-
3002- BOOL SetCallbackMask(UINT nMask)
3003- {
3004- ATLASSERT(::IsWindow(m_hWnd));
3005- return (BOOL)::SendMessage(m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L);
3006- }
3007-
3008- BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const
3009- {
3010- ATLASSERT(::IsWindow(m_hWnd));
3011- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint);
3012- }
3013-
3014- BOOL SetItemPosition(int nItem, POINT pt)
3015- {
3016- ATLASSERT(::IsWindow(m_hWnd));
3017- ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON));
3018- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt);
3019- }
3020-
3021- BOOL SetItemPosition(int nItem, int x, int y)
3022- {
3023- ATLASSERT(::IsWindow(m_hWnd));
3024- ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON));
3025- POINT pt = { x, y };
3026- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt);
3027- }
3028-
3029- int GetStringWidth(LPCTSTR lpsz) const
3030- {
3031- ATLASSERT(::IsWindow(m_hWnd));
3032- return (int)::SendMessage(m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz);
3033- }
3034-
3035- CEdit GetEditControl() const
3036- {
3037- ATLASSERT(::IsWindow(m_hWnd));
3038- return CEdit((HWND)::SendMessage(m_hWnd, LVM_GETEDITCONTROL, 0, 0L));
3039- }
3040-
3041- BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const
3042- {
3043- ATLASSERT(::IsWindow(m_hWnd));
3044- return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn);
3045- }
3046-
3047- BOOL SetColumn(int nCol, const LVCOLUMN* pColumn)
3048- {
3049- ATLASSERT(::IsWindow(m_hWnd));
3050- return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn);
3051- }
3052-
3053- int GetColumnWidth(int nCol) const
3054- {
3055- ATLASSERT(::IsWindow(m_hWnd));
3056- return (int)::SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L);
3057- }
3058-
3059- BOOL SetColumnWidth(int nCol, int cx)
3060- {
3061- ATLASSERT(::IsWindow(m_hWnd));
3062- return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0));
3063- }
3064-
3065- BOOL GetViewRect(LPRECT lpRect) const
3066- {
3067- ATLASSERT(::IsWindow(m_hWnd));
3068- return (BOOL)::SendMessage(m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect);
3069- }
3070-
3071- COLORREF GetTextColor() const
3072- {
3073- ATLASSERT(::IsWindow(m_hWnd));
3074- return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0, 0L);
3075- }
3076-
3077- BOOL SetTextColor(COLORREF cr)
3078- {
3079- ATLASSERT(::IsWindow(m_hWnd));
3080- return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr);
3081- }
3082-
3083- COLORREF GetTextBkColor() const
3084- {
3085- ATLASSERT(::IsWindow(m_hWnd));
3086- return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L);
3087- }
3088-
3089- BOOL SetTextBkColor(COLORREF cr)
3090- {
3091- ATLASSERT(::IsWindow(m_hWnd));
3092- return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr);
3093- }
3094-
3095- int GetTopIndex() const
3096- {
3097- ATLASSERT(::IsWindow(m_hWnd));
3098- return (int)::SendMessage(m_hWnd, LVM_GETTOPINDEX, 0, 0L);
3099- }
3100-
3101- int GetCountPerPage() const
3102- {
3103- ATLASSERT(::IsWindow(m_hWnd));
3104- return (int)::SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L);
3105- }
3106-
3107- BOOL GetOrigin(LPPOINT lpPoint) const
3108- {
3109- ATLASSERT(::IsWindow(m_hWnd));
3110- return (BOOL)::SendMessage(m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint);
3111- }
3112-
3113- UINT GetSelectedCount() const
3114- {
3115- ATLASSERT(::IsWindow(m_hWnd));
3116- return (UINT)::SendMessage(m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L);
3117- }
3118-
3119- BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const
3120- {
3121- ATLASSERT(::IsWindow(m_hWnd));
3122- lpRect->left = nCode;
3123- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect);
3124- }
3125-
3126-#ifndef _WIN32_WCE
3127- HCURSOR GetHotCursor() const
3128- {
3129- ATLASSERT(::IsWindow(m_hWnd));
3130- return (HCURSOR)::SendMessage(m_hWnd, LVM_GETHOTCURSOR, 0, 0L);
3131- }
3132-
3133- HCURSOR SetHotCursor(HCURSOR hHotCursor)
3134- {
3135- ATLASSERT(::IsWindow(m_hWnd));
3136- return (HCURSOR)::SendMessage(m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor);
3137- }
3138-
3139- int GetHotItem() const
3140- {
3141- ATLASSERT(::IsWindow(m_hWnd));
3142- return (int)::SendMessage(m_hWnd, LVM_GETHOTITEM, 0, 0L);
3143- }
3144-
3145- int SetHotItem(int nIndex)
3146- {
3147- ATLASSERT(::IsWindow(m_hWnd));
3148- return (int)::SendMessage(m_hWnd, LVM_SETHOTITEM, nIndex, 0L);
3149- }
3150-#endif // !_WIN32_WCE
3151-
3152- BOOL GetColumnOrderArray(int nCount, int* lpnArray) const
3153- {
3154- ATLASSERT(::IsWindow(m_hWnd));
3155- return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray);
3156- }
3157-
3158- BOOL SetColumnOrderArray(int nCount, int* lpnArray)
3159- {
3160- ATLASSERT(::IsWindow(m_hWnd));
3161- return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray);
3162- }
3163-
3164- CHeaderCtrl GetHeader() const
3165- {
3166- ATLASSERT(::IsWindow(m_hWnd));
3167- return CHeaderCtrl((HWND)::SendMessage(m_hWnd, LVM_GETHEADER, 0, 0L));
3168- }
3169-
3170- BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const
3171- {
3172- ATLASSERT(::IsWindow(m_hWnd));
3173- ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_REPORT);
3174- ATLASSERT(lpRect != NULL);
3175- lpRect->top = nSubItem;
3176- lpRect->left = nFlag;
3177- return (BOOL)::SendMessage(m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect);
3178- }
3179-
3180- DWORD SetIconSpacing(int cx, int cy)
3181- {
3182- ATLASSERT(::IsWindow(m_hWnd));
3183- ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_ICON);
3184- return (DWORD)::SendMessage(m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy));
3185- }
3186-
3187- int GetISearchString(LPTSTR lpstr) const
3188- {
3189- ATLASSERT(::IsWindow(m_hWnd));
3190- return (int)::SendMessage(m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr);
3191- }
3192-
3193- void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const
3194- {
3195- ATLASSERT(::IsWindow(m_hWnd));
3196- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L);
3197- sizeSpacing.cx = GET_X_LPARAM(dwRet);
3198- sizeSpacing.cy = GET_Y_LPARAM(dwRet);
3199- }
3200-
3201-#if (_WIN32_WCE >= 410)
3202- void SetItemSpacing(INT cySpacing)
3203- {
3204- ATLASSERT(::IsWindow(m_hWnd));
3205- ListView_SetItemSpacing(m_hWnd, cySpacing);
3206- }
3207-#endif // (_WIN32_WCE >= 410)
3208-
3209- // single-selection only
3210- int GetSelectedIndex() const
3211- {
3212- ATLASSERT(::IsWindow(m_hWnd));
3213- ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0);
3214- return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
3215- }
3216-
3217- BOOL GetSelectedItem(LPLVITEM pItem) const
3218- {
3219- ATLASSERT(::IsWindow(m_hWnd));
3220- ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0);
3221- ATLASSERT(pItem != NULL);
3222- pItem->iItem = (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
3223- if(pItem->iItem == -1)
3224- return FALSE;
3225- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem);
3226- }
3227-
3228- // extended list view styles
3229- DWORD GetExtendedListViewStyle() const
3230- {
3231- ATLASSERT(::IsWindow(m_hWnd));
3232- return (DWORD)::SendMessage(m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L);
3233- }
3234-
3235- // dwExMask = 0 means all styles
3236- DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0)
3237- {
3238- ATLASSERT(::IsWindow(m_hWnd));
3239- return (DWORD)::SendMessage(m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle);
3240- }
3241-
3242- // checkboxes only
3243- BOOL GetCheckState(int nIndex) const
3244- {
3245- ATLASSERT(::IsWindow(m_hWnd));
3246- ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0);
3247- UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK);
3248- return (uRet >> 12) - 1;
3249- }
3250-
3251- BOOL SetCheckState(int nItem, BOOL bCheck)
3252- {
3253- int nCheck = bCheck ? 2 : 1; // one based index
3254- return SetItemState(nItem, INDEXTOSTATEIMAGEMASK(nCheck), LVIS_STATEIMAGEMASK);
3255- }
3256-
3257- // view type
3258- DWORD GetViewType() const
3259- {
3260- ATLASSERT(::IsWindow(m_hWnd));
3261- return (GetStyle() & LVS_TYPEMASK);
3262- }
3263-
3264- DWORD SetViewType(DWORD dwType)
3265- {
3266- ATLASSERT(::IsWindow(m_hWnd));
3267- ATLASSERT(dwType == LVS_ICON || dwType == LVS_SMALLICON || dwType == LVS_LIST || dwType == LVS_REPORT);
3268- DWORD dwOldType = GetViewType();
3269- if(dwType != dwOldType)
3270- ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK));
3271- return dwOldType;
3272- }
3273-
3274-#if (_WIN32_IE >= 0x0400)
3275-#ifndef _WIN32_WCE
3276- BOOL GetBkImage(LPLVBKIMAGE plvbki) const
3277- {
3278- ATLASSERT(::IsWindow(m_hWnd));
3279- return (BOOL)::SendMessage(m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki);
3280- }
3281-
3282- BOOL SetBkImage(LPLVBKIMAGE plvbki)
3283- {
3284- ATLASSERT(::IsWindow(m_hWnd));
3285- return (BOOL)::SendMessage(m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki);
3286- }
3287-#endif // !_WIN32_WCE
3288-
3289- int GetSelectionMark() const
3290- {
3291- ATLASSERT(::IsWindow(m_hWnd));
3292- return (int)::SendMessage(m_hWnd, LVM_GETSELECTIONMARK, 0, 0L);
3293- }
3294-
3295- int SetSelectionMark(int nIndex)
3296- {
3297- ATLASSERT(::IsWindow(m_hWnd));
3298- return (int)::SendMessage(m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex);
3299- }
3300-
3301-#ifndef _WIN32_WCE
3302- BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const
3303- {
3304- ATLASSERT(::IsWindow(m_hWnd));
3305- return (BOOL)::SendMessage(m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect);
3306- }
3307-
3308- BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect)
3309- {
3310- ATLASSERT(::IsWindow(m_hWnd));
3311- return (BOOL)::SendMessage(m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect);
3312- }
3313-
3314- DWORD GetHoverTime() const
3315- {
3316- ATLASSERT(::IsWindow(m_hWnd));
3317- ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0);
3318- return (DWORD)::SendMessage(m_hWnd, LVM_GETHOVERTIME, 0, 0L);
3319- }
3320-
3321- DWORD SetHoverTime(DWORD dwHoverTime)
3322- {
3323- ATLASSERT(::IsWindow(m_hWnd));
3324- ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0);
3325- return (DWORD)::SendMessage(m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime);
3326- }
3327-
3328- BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const
3329- {
3330- ATLASSERT(::IsWindow(m_hWnd));
3331- return (BOOL)::SendMessage(m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas);
3332- }
3333-#endif // !_WIN32_WCE
3334-
3335- BOOL SetItemCountEx(int nItems, DWORD dwFlags)
3336- {
3337- ATLASSERT(::IsWindow(m_hWnd));
3338- ATLASSERT(((GetStyle() & LVS_OWNERDATA) != 0) && (((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((GetStyle() & LVS_TYPEMASK) == LVS_LIST)));
3339- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags);
3340- }
3341-
3342-#ifndef _WIN32_WCE
3343- CToolTipCtrl GetToolTips() const
3344- {
3345- ATLASSERT(::IsWindow(m_hWnd));
3346- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS, 0, 0L));
3347- }
3348-
3349- CToolTipCtrl SetToolTips(HWND hWndTT)
3350- {
3351- ATLASSERT(::IsWindow(m_hWnd));
3352- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L));
3353- }
3354-
3355- BOOL GetUnicodeFormat() const
3356- {
3357- ATLASSERT(::IsWindow(m_hWnd));
3358- return (BOOL)::SendMessage(m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L);
3359- }
3360-
3361- BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
3362- {
3363- ATLASSERT(::IsWindow(m_hWnd));
3364- return (BOOL)::SendMessage(m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L);
3365- }
3366-#endif // !_WIN32_WCE
3367-#endif // (_WIN32_IE >= 0x0400)
3368-
3369-#if (_WIN32_WINNT >= 0x0501)
3370- int GetSelectedColumn() const
3371- {
3372- ATLASSERT(::IsWindow(m_hWnd));
3373- return (int)::SendMessage(m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L);
3374- }
3375-
3376- void SetSelectedColumn(int nColumn)
3377- {
3378- ATLASSERT(::IsWindow(m_hWnd));
3379- ::SendMessage(m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L);
3380- }
3381-
3382- DWORD GetView() const
3383- {
3384- ATLASSERT(::IsWindow(m_hWnd));
3385- return (DWORD)::SendMessage(m_hWnd, LVM_GETVIEW, 0, 0L);
3386- }
3387-
3388- int SetView(DWORD dwView)
3389- {
3390- ATLASSERT(::IsWindow(m_hWnd));
3391- return (int)::SendMessage(m_hWnd, LVM_SETVIEW, dwView, 0L);
3392- }
3393-
3394- BOOL IsGroupViewEnabled() const
3395- {
3396- ATLASSERT(::IsWindow(m_hWnd));
3397- return (BOOL)::SendMessage(m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L);
3398- }
3399-
3400- int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const
3401- {
3402- ATLASSERT(::IsWindow(m_hWnd));
3403- return (int)::SendMessage(m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup);
3404- }
3405-
3406- int SetGroupInfo(int nGroupID, PLVGROUP pGroup)
3407- {
3408- ATLASSERT(::IsWindow(m_hWnd));
3409- return (int)::SendMessage(m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup);
3410- }
3411-
3412- void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const
3413- {
3414- ATLASSERT(::IsWindow(m_hWnd));
3415- ::SendMessage(m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics);
3416- }
3417-
3418- void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics)
3419- {
3420- ATLASSERT(::IsWindow(m_hWnd));
3421- ::SendMessage(m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics);
3422- }
3423-
3424- void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const
3425- {
3426- ATLASSERT(::IsWindow(m_hWnd));
3427- ::SendMessage(m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo);
3428- }
3429-
3430- BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo)
3431- {
3432- ATLASSERT(::IsWindow(m_hWnd));
3433- return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo);
3434- }
3435-
3436- void GetTileInfo(PLVTILEINFO pTileInfo) const
3437- {
3438- ATLASSERT(::IsWindow(m_hWnd));
3439- ::SendMessage(m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo);
3440- }
3441-
3442- BOOL SetTileInfo(PLVTILEINFO pTileInfo)
3443- {
3444- ATLASSERT(::IsWindow(m_hWnd));
3445- return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo);
3446- }
3447-
3448- BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const
3449- {
3450- ATLASSERT(::IsWindow(m_hWnd));
3451- return (BOOL)::SendMessage(m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark);
3452- }
3453-
3454- BOOL SetInsertMark(LPLVINSERTMARK pInsertMark)
3455- {
3456- ATLASSERT(::IsWindow(m_hWnd));
3457- return (BOOL)::SendMessage(m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark);
3458- }
3459-
3460- int GetInsertMarkRect(LPRECT lpRect) const
3461- {
3462- ATLASSERT(::IsWindow(m_hWnd));
3463- return (int)::SendMessage(m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect);
3464- }
3465-
3466- COLORREF GetInsertMarkColor() const
3467- {
3468- ATLASSERT(::IsWindow(m_hWnd));
3469- return (COLORREF)::SendMessage(m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L);
3470- }
3471-
3472- COLORREF SetInsertMarkColor(COLORREF clr)
3473- {
3474- ATLASSERT(::IsWindow(m_hWnd));
3475- return (COLORREF)::SendMessage(m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr);
3476- }
3477-
3478- COLORREF GetOutlineColor() const
3479- {
3480- ATLASSERT(::IsWindow(m_hWnd));
3481- return (COLORREF)::SendMessage(m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L);
3482- }
3483-
3484- COLORREF SetOutlineColor(COLORREF clr)
3485- {
3486- ATLASSERT(::IsWindow(m_hWnd));
3487- return (COLORREF)::SendMessage(m_hWnd, LVM_SETOUTLINECOLOR, 0, clr);
3488- }
3489-#endif // (_WIN32_WINNT >= 0x0501)
3490-
3491-#if (_WIN32_WINNT >= 0x0600)
3492- int GetGroupCount() const
3493- {
3494- ATLASSERT(::IsWindow(m_hWnd));
3495- return (int)::SendMessage(m_hWnd, LVM_GETGROUPCOUNT, 0, 0L);
3496- }
3497-
3498- BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const
3499- {
3500- ATLASSERT(::IsWindow(m_hWnd));
3501- return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup);
3502- }
3503-
3504- BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const
3505- {
3506- ATLASSERT(::IsWindow(m_hWnd));
3507- ATLASSERT(lpRect != NULL);
3508- if(lpRect != NULL)
3509- lpRect->top = nType;
3510- return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect);
3511- }
3512-
3513- UINT GetGroupState(int nGroupID, UINT uMask) const
3514- {
3515- ATLASSERT(::IsWindow(m_hWnd));
3516- return (UINT)::SendMessage(m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask);
3517- }
3518-
3519- int GetFocusedGroup() const
3520- {
3521- ATLASSERT(::IsWindow(m_hWnd));
3522- return (int)::SendMessage(m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L);
3523- }
3524-
3525- BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const
3526- {
3527- ATLASSERT(::IsWindow(m_hWnd));
3528- return (BOOL)::SendMessage(m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText);
3529- }
3530-
3531- BOOL GetFooterRect(LPRECT lpRect) const
3532- {
3533- ATLASSERT(::IsWindow(m_hWnd));
3534- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect);
3535- }
3536-
3537- BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const
3538- {
3539- ATLASSERT(::IsWindow(m_hWnd));
3540- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo);
3541- }
3542-
3543- BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const
3544- {
3545- ATLASSERT(::IsWindow(m_hWnd));
3546- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect);
3547- }
3548-
3549- BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const
3550- {
3551- ATLASSERT(::IsWindow(m_hWnd));
3552- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem);
3553- }
3554-
3555- BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType, LPRECT lpRect) const
3556- {
3557- ATLASSERT(::IsWindow(m_hWnd));
3558- ATLASSERT(pItemIndex != NULL);
3559- ATLASSERT(lpRect != NULL);
3560- if(lpRect != NULL)
3561- {
3562- lpRect->top = nSubItem;
3563- lpRect->left = nType;
3564- }
3565- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect);
3566- }
3567-
3568- BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask)
3569- {
3570- ATLASSERT(::IsWindow(m_hWnd));
3571- LVITEM lvi = { 0 };
3572- lvi.state = uState;
3573- lvi.stateMask = dwMask;
3574- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi);
3575- }
3576-
3577- BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const
3578- {
3579- ATLASSERT(::IsWindow(m_hWnd));
3580- return (BOOL)::SendMessage(m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0));
3581- }
3582-#endif // (_WIN32_WINNT >= 0x0600)
3583-
3584-// Operations
3585- int InsertColumn(int nCol, const LVCOLUMN* pColumn)
3586- {
3587- ATLASSERT(::IsWindow(m_hWnd));
3588- return (int)::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn);
3589- }
3590-
3591- int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT,
3592- int nWidth = -1, int nSubItem = -1, int iImage = -1, int iOrder = -1)
3593- {
3594- LVCOLUMN column = { 0 };
3595- column.mask = LVCF_TEXT|LVCF_FMT;
3596- column.pszText = (LPTSTR)lpszColumnHeading;
3597- column.fmt = nFormat;
3598- if (nWidth != -1)
3599- {
3600- column.mask |= LVCF_WIDTH;
3601- column.cx = nWidth;
3602- }
3603- if (nSubItem != -1)
3604- {
3605- column.mask |= LVCF_SUBITEM;
3606- column.iSubItem = nSubItem;
3607- }
3608- if (iImage != -1)
3609- {
3610- column.mask |= LVCF_IMAGE;
3611- column.iImage = iImage;
3612- }
3613- if (iOrder != -1)
3614- {
3615- column.mask |= LVCF_ORDER;
3616- column.iOrder = iOrder;
3617- }
3618- return InsertColumn(nCol, &column);
3619- }
3620-
3621- BOOL DeleteColumn(int nCol)
3622- {
3623- ATLASSERT(::IsWindow(m_hWnd));
3624- return (BOOL)::SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0L);
3625- }
3626-
3627- int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam)
3628- {
3629- ATLASSERT(::IsWindow(m_hWnd));
3630- LVITEM item = { 0 };
3631- item.mask = nMask;
3632- item.iItem = nItem;
3633- item.iSubItem = 0;
3634- item.pszText = (LPTSTR)lpszItem;
3635- item.state = nState;
3636- item.stateMask = nStateMask;
3637- item.iImage = nImage;
3638- item.lParam = lParam;
3639- return InsertItem(&item);
3640- }
3641-
3642- int InsertItem(const LVITEM* pItem)
3643- {
3644- ATLASSERT(::IsWindow(m_hWnd));
3645- return (int)::SendMessage(m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem);
3646- }
3647-
3648- int InsertItem(int nItem, LPCTSTR lpszItem)
3649- {
3650- ATLASSERT(::IsWindow(m_hWnd));
3651- return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0);
3652- }
3653-
3654- int InsertItem(int nItem, LPCTSTR lpszItem, int nImage)
3655- {
3656- ATLASSERT(::IsWindow(m_hWnd));
3657- return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0);
3658- }
3659-
3660- int GetNextItem(int nItem, int nFlags) const
3661- {
3662- ATLASSERT(::IsWindow(m_hWnd));
3663- return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0));
3664- }
3665-
3666- BOOL DeleteItem(int nItem)
3667- {
3668- ATLASSERT(::IsWindow(m_hWnd));
3669- return (BOOL)::SendMessage(m_hWnd, LVM_DELETEITEM, nItem, 0L);
3670- }
3671-
3672- BOOL DeleteAllItems()
3673- {
3674- ATLASSERT(::IsWindow(m_hWnd));
3675- return (BOOL)::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L);
3676- }
3677-
3678- int FindItem(LVFINDINFO* pFindInfo, int nStart) const
3679- {
3680- ATLASSERT(::IsWindow(m_hWnd));
3681- return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo);
3682- }
3683-
3684- int HitTest(LVHITTESTINFO* pHitTestInfo) const
3685- {
3686- ATLASSERT(::IsWindow(m_hWnd));
3687- return (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo);
3688- }
3689-
3690- int HitTest(POINT pt, UINT* pFlags) const
3691- {
3692- ATLASSERT(::IsWindow(m_hWnd));
3693- LVHITTESTINFO hti = { 0 };
3694- hti.pt = pt;
3695- int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti);
3696- if (pFlags != NULL)
3697- *pFlags = hti.flags;
3698- return nRes;
3699- }
3700-
3701- BOOL EnsureVisible(int nItem, BOOL bPartialOK)
3702- {
3703- ATLASSERT(::IsWindow(m_hWnd));
3704- return (BOOL)::SendMessage(m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0));
3705- }
3706-
3707- BOOL Scroll(SIZE size)
3708- {
3709- ATLASSERT(::IsWindow(m_hWnd));
3710- return (BOOL)::SendMessage(m_hWnd, LVM_SCROLL, size.cx, size.cy);
3711- }
3712-
3713- BOOL RedrawItems(int nFirst, int nLast)
3714- {
3715- ATLASSERT(::IsWindow(m_hWnd));
3716- return (BOOL)::SendMessage(m_hWnd, LVM_REDRAWITEMS, nFirst, nLast);
3717- }
3718-
3719- BOOL Arrange(UINT nCode)
3720- {
3721- ATLASSERT(::IsWindow(m_hWnd));
3722- return (BOOL)::SendMessage(m_hWnd, LVM_ARRANGE, nCode, 0L);
3723- }
3724-
3725- CEdit EditLabel(int nItem)
3726- {
3727- ATLASSERT(::IsWindow(m_hWnd));
3728- return CEdit((HWND)::SendMessage(m_hWnd, LVM_EDITLABEL, nItem, 0L));
3729- }
3730-
3731- BOOL Update(int nItem)
3732- {
3733- ATLASSERT(::IsWindow(m_hWnd));
3734- return (BOOL)::SendMessage(m_hWnd, LVM_UPDATE, nItem, 0L);
3735- }
3736-
3737- BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
3738- {
3739- ATLASSERT(::IsWindow(m_hWnd));
3740- return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare);
3741- }
3742-
3743- CImageList RemoveImageList(int nImageList)
3744- {
3745- ATLASSERT(::IsWindow(m_hWnd));
3746- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL));
3747- }
3748-
3749- CImageList CreateDragImage(int nItem, LPPOINT lpPoint)
3750- {
3751- ATLASSERT(::IsWindow(m_hWnd));
3752- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint));
3753- }
3754-
3755- DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1)
3756- {
3757- ATLASSERT(::IsWindow(m_hWnd));
3758- return (DWORD)::SendMessage(m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy));
3759- }
3760-
3761- int SubItemHitTest(LPLVHITTESTINFO lpInfo) const
3762- {
3763- ATLASSERT(::IsWindow(m_hWnd));
3764- return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo);
3765- }
3766-
3767- int AddColumn(LPCTSTR strItem, int nItem, int nSubItem = -1,
3768- int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
3769- int nFmt = LVCFMT_LEFT)
3770- {
3771- const int cxOffset = 15;
3772- ATLASSERT(::IsWindow(m_hWnd));
3773- LVCOLUMN lvc = { 0 };
3774- lvc.mask = nMask;
3775- lvc.fmt = nFmt;
3776- lvc.pszText = (LPTSTR)strItem;
3777- lvc.cx = GetStringWidth(lvc.pszText) + cxOffset;
3778- if(nMask & LVCF_SUBITEM)
3779- lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem;
3780- return InsertColumn(nItem, &lvc);
3781- }
3782-
3783- int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -1)
3784- {
3785- ATLASSERT(::IsWindow(m_hWnd));
3786- LVITEM lvItem = { 0 };
3787- lvItem.mask = LVIF_TEXT;
3788- lvItem.iItem = nItem;
3789- lvItem.iSubItem = nSubItem;
3790- lvItem.pszText = (LPTSTR)strItem;
3791- if(nImageIndex != -1)
3792- {
3793- lvItem.mask |= LVIF_IMAGE;
3794- lvItem.iImage = nImageIndex;
3795- }
3796- if(nSubItem == 0)
3797- return InsertItem(&lvItem);
3798- return SetItem(&lvItem) ? nItem : -1;
3799- }
3800-
3801-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
3802- BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
3803- {
3804- ATLASSERT(::IsWindow(m_hWnd));
3805- return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare);
3806- }
3807-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
3808-
3809-#if (_WIN32_WINNT >= 0x0501)
3810- int InsertGroup(int nItem, PLVGROUP pGroup)
3811- {
3812- ATLASSERT(::IsWindow(m_hWnd));
3813- return (int)::SendMessage(m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup);
3814- }
3815-
3816- int AddGroup(PLVGROUP pGroup)
3817- {
3818- return InsertGroup(-1, pGroup);
3819- }
3820-
3821- int RemoveGroup(int nGroupID)
3822- {
3823- ATLASSERT(::IsWindow(m_hWnd));
3824- return (int)::SendMessage(m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L);
3825- }
3826-
3827- void MoveGroup(int nGroupID, int nItem)
3828- {
3829- ATLASSERT(::IsWindow(m_hWnd));
3830- ::SendMessage(m_hWnd, LVM_MOVEGROUP, nGroupID, nItem);
3831- }
3832-
3833- void MoveItemToGroup(int nItem, int nGroupID)
3834- {
3835- ATLASSERT(::IsWindow(m_hWnd));
3836- ::SendMessage(m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID);
3837- }
3838-
3839- int EnableGroupView(BOOL bEnable)
3840- {
3841- ATLASSERT(::IsWindow(m_hWnd));
3842- return (int)::SendMessage(m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L);
3843- }
3844-
3845- int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL)
3846- {
3847- ATLASSERT(::IsWindow(m_hWnd));
3848- return (int)::SendMessage(m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid);
3849- }
3850-
3851- void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted)
3852- {
3853- ATLASSERT(::IsWindow(m_hWnd));
3854- ::SendMessage(m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L);
3855- }
3856-
3857- void RemoveAllGroups()
3858- {
3859- ATLASSERT(::IsWindow(m_hWnd));
3860- ::SendMessage(m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L);
3861- }
3862-
3863- BOOL HasGroup(int nGroupID)
3864- {
3865- ATLASSERT(::IsWindow(m_hWnd));
3866- return (BOOL)::SendMessage(m_hWnd, LVM_HASGROUP, nGroupID, 0L);
3867- }
3868-
3869- BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) const
3870- {
3871- ATLASSERT(::IsWindow(m_hWnd));
3872- return (BOOL)::SendMessage(m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark);
3873- }
3874-
3875- BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip)
3876- {
3877- ATLASSERT(::IsWindow(m_hWnd));
3878- return (BOOL)::SendMessage(m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip);
3879- }
3880-
3881- void CancelEditLabel()
3882- {
3883- ATLASSERT(::IsWindow(m_hWnd));
3884- ::SendMessage(m_hWnd, LVM_CANCELEDITLABEL, 0, 0L);
3885- }
3886-
3887- UINT MapIndexToID(int nIndex) const
3888- {
3889- ATLASSERT(::IsWindow(m_hWnd));
3890- return (UINT)::SendMessage(m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L);
3891- }
3892-
3893- int MapIDToIndex(UINT uID) const
3894- {
3895- ATLASSERT(::IsWindow(m_hWnd));
3896- return (int)::SendMessage(m_hWnd, LVM_MAPIDTOINDEX, uID, 0L);
3897- }
3898-#endif // (_WIN32_WINNT >= 0x0501)
3899-
3900-#if (_WIN32_WINNT >= 0x0600)
3901- int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const
3902- {
3903- ATLASSERT(::IsWindow(m_hWnd));
3904- return (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo);
3905- }
3906-
3907- int HitTestEx(POINT pt, UINT* pFlags) const
3908- {
3909- ATLASSERT(::IsWindow(m_hWnd));
3910- LVHITTESTINFO hti = { 0 };
3911- hti.pt = pt;
3912- int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti);
3913- if (pFlags != NULL)
3914- *pFlags = hti.flags;
3915- return nRes;
3916- }
3917-
3918- int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const
3919- {
3920- ATLASSERT(::IsWindow(m_hWnd));
3921- return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo);
3922- }
3923-#endif // (_WIN32_WINNT >= 0x0600)
3924-
3925- // single-selection only
3926- BOOL SelectItem(int nIndex)
3927- {
3928- ATLASSERT(::IsWindow(m_hWnd));
3929- ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0);
3930-
3931- BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
3932- if(bRet)
3933- bRet = EnsureVisible(nIndex, FALSE);
3934- return bRet;
3935- }
3936-};
3937-
3938-typedef CListViewCtrlT<ATL::CWindow> CListViewCtrl;
3939-
3940-
3941-///////////////////////////////////////////////////////////////////////////////
3942-// CTreeViewCtrl
3943-
3944-template <class TBase>
3945-class CTreeViewCtrlT : public TBase
3946-{
3947-public:
3948-// Constructors
3949- CTreeViewCtrlT(HWND hWnd = NULL) : TBase(hWnd)
3950- { }
3951-
3952- CTreeViewCtrlT< TBase >& operator =(HWND hWnd)
3953- {
3954- m_hWnd = hWnd;
3955- return *this;
3956- }
3957-
3958- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
3959- DWORD dwStyle = 0, DWORD dwExStyle = 0,
3960- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
3961- {
3962- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
3963- }
3964-
3965-// Attributes
3966- static LPCTSTR GetWndClassName()
3967- {
3968- return WC_TREEVIEW;
3969- }
3970-
3971- UINT GetCount() const
3972- {
3973- ATLASSERT(::IsWindow(m_hWnd));
3974- return (UINT)::SendMessage(m_hWnd, TVM_GETCOUNT, 0, 0L);
3975- }
3976-
3977- UINT GetIndent() const
3978- {
3979- ATLASSERT(::IsWindow(m_hWnd));
3980- return (UINT)::SendMessage(m_hWnd, TVM_GETINDENT, 0, 0L);
3981- }
3982-
3983- void SetIndent(UINT nIndent)
3984- {
3985- ATLASSERT(::IsWindow(m_hWnd));
3986- ::SendMessage(m_hWnd, TVM_SETINDENT, nIndent, 0L);
3987- }
3988-
3989- CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const
3990- {
3991- ATLASSERT(::IsWindow(m_hWnd));
3992- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L));
3993- }
3994-
3995- CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSIL_NORMAL)
3996- {
3997- ATLASSERT(::IsWindow(m_hWnd));
3998- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList));
3999- }
4000-
4001- BOOL GetItem(LPTVITEM pItem) const
4002- {
4003- ATLASSERT(::IsWindow(m_hWnd));
4004- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem);
4005- }
4006-
4007- BOOL SetItem(LPTVITEM pItem)
4008- {
4009- ATLASSERT(::IsWindow(m_hWnd));
4010- return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem);
4011- }
4012-
4013- BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage,
4014- int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam)
4015- {
4016- ATLASSERT(::IsWindow(m_hWnd));
4017- TVITEM item = { 0 };
4018- item.hItem = hItem;
4019- item.mask = nMask;
4020- item.pszText = (LPTSTR) lpszItem;
4021- item.iImage = nImage;
4022- item.iSelectedImage = nSelectedImage;
4023- item.state = nState;
4024- item.stateMask = nStateMask;
4025- item.lParam = lParam;
4026- return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)&item);
4027- }
4028-
4029- BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const
4030- {
4031- ATLASSERT(::IsWindow(m_hWnd));
4032- ATLASSERT(lpstrText != NULL);
4033-
4034- TVITEM item = { 0 };
4035- item.hItem = hItem;
4036- item.mask = TVIF_TEXT;
4037- item.pszText = lpstrText;
4038- item.cchTextMax = nLen;
4039-
4040- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4041- }
4042-
4043-#ifndef _ATL_NO_COM
4044- BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const
4045- {
4046- USES_CONVERSION;
4047- ATLASSERT(::IsWindow(m_hWnd));
4048- ATLASSERT(bstrText == NULL);
4049- TVITEM item = { 0 };
4050- item.hItem = hItem;
4051- item.mask = TVIF_TEXT;
4052-
4053- LPTSTR lpstrText = NULL;
4054- BOOL bRet = FALSE;
4055- for(int nLen = 256; ; nLen *= 2)
4056- {
4057- ATLTRY(lpstrText = new TCHAR[nLen]);
4058- if(lpstrText == NULL)
4059- break;
4060- lpstrText[0] = NULL;
4061- item.pszText = lpstrText;
4062- item.cchTextMax = nLen;
4063- bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4064- if(!bRet || (lstrlen(item.pszText) < nLen - 1))
4065- break;
4066- delete [] lpstrText;
4067- lpstrText = NULL;
4068- }
4069-
4070- if(lpstrText != NULL)
4071- {
4072- if(bRet)
4073- bstrText = ::SysAllocString(T2OLE(lpstrText));
4074- delete [] lpstrText;
4075- }
4076-
4077- return (bstrText != NULL) ? TRUE : FALSE;
4078- }
4079-#endif // !_ATL_NO_COM
4080-
4081-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
4082- BOOL GetItemText(HTREEITEM hItem, _CSTRING_NS::CString& strText) const
4083- {
4084- ATLASSERT(::IsWindow(m_hWnd));
4085- TVITEM item = { 0 };
4086- item.hItem = hItem;
4087- item.mask = TVIF_TEXT;
4088-
4089- strText.Empty();
4090- BOOL bRet = FALSE;
4091- for(int nLen = 256; ; nLen *= 2)
4092- {
4093- item.pszText = strText.GetBufferSetLength(nLen);
4094- if(item.pszText == NULL)
4095- {
4096- bRet = FALSE;
4097- break;
4098- }
4099- item.cchTextMax = nLen;
4100- bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4101- if(!bRet || (lstrlen(item.pszText) < nLen - 1))
4102- break;
4103- }
4104- strText.ReleaseBuffer();
4105- return bRet;
4106- }
4107-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
4108-
4109- BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem)
4110- {
4111- ATLASSERT(::IsWindow(m_hWnd));
4112- return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL);
4113- }
4114-
4115- BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const
4116- {
4117- ATLASSERT(::IsWindow(m_hWnd));
4118- TVITEM item = { 0 };
4119- item.hItem = hItem;
4120- item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
4121- BOOL bRes = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4122- if (bRes)
4123- {
4124- nImage = item.iImage;
4125- nSelectedImage = item.iSelectedImage;
4126- }
4127- return bRes;
4128- }
4129-
4130- BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage)
4131- {
4132- ATLASSERT(::IsWindow(m_hWnd));
4133- return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImage, nSelectedImage, 0, 0, NULL);
4134- }
4135-
4136- UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const
4137- {
4138- ATLASSERT(::IsWindow(m_hWnd));
4139-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
4140- return (((UINT)::SendMessage(m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask);
4141-#else // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE))
4142- TVITEM item = { 0 };
4143- item.hItem = hItem;
4144- item.mask = TVIF_STATE;
4145- item.state = 0;
4146- item.stateMask = nStateMask;
4147- ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4148- return (item.state & nStateMask);
4149-#endif // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE))
4150- }
4151-
4152- BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask)
4153- {
4154- ATLASSERT(::IsWindow(m_hWnd));
4155- return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask, NULL);
4156- }
4157-
4158- DWORD_PTR GetItemData(HTREEITEM hItem) const
4159- {
4160- ATLASSERT(::IsWindow(m_hWnd));
4161- TVITEM item = { 0 };
4162- item.hItem = hItem;
4163- item.mask = TVIF_PARAM;
4164- BOOL bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4165- return (DWORD_PTR)(bRet ? item.lParam : NULL);
4166- }
4167-
4168- BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData)
4169- {
4170- ATLASSERT(::IsWindow(m_hWnd));
4171- return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwData);
4172- }
4173-
4174- CEdit GetEditControl() const
4175- {
4176- ATLASSERT(::IsWindow(m_hWnd));
4177- return CEdit((HWND)::SendMessage(m_hWnd, TVM_GETEDITCONTROL, 0, 0L));
4178- }
4179-
4180- UINT GetVisibleCount() const
4181- {
4182- ATLASSERT(::IsWindow(m_hWnd));
4183- return (UINT)::SendMessage(m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L);
4184- }
4185-
4186- BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const
4187- {
4188- ATLASSERT(::IsWindow(m_hWnd));
4189- *(HTREEITEM*)lpRect = hItem;
4190- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect);
4191- }
4192-
4193- BOOL ItemHasChildren(HTREEITEM hItem) const
4194- {
4195- ATLASSERT(::IsWindow(m_hWnd));
4196- TVITEM item = { 0 };
4197- item.hItem = hItem;
4198- item.mask = TVIF_CHILDREN;
4199- ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
4200- return item.cChildren;
4201- }
4202-
4203-#ifndef _WIN32_WCE
4204- CToolTipCtrl GetToolTips() const
4205- {
4206- ATLASSERT(::IsWindow(m_hWnd));
4207- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_GETTOOLTIPS, 0, 0L));
4208- }
4209-
4210- CToolTipCtrl SetToolTips(HWND hWndTT)
4211- {
4212- ATLASSERT(::IsWindow(m_hWnd));
4213- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L));
4214- }
4215-#endif // !_WIN32_WCE
4216-
4217- int GetISearchString(LPTSTR lpstr) const
4218- {
4219- ATLASSERT(::IsWindow(m_hWnd));
4220- return (int)::SendMessage(m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr);
4221- }
4222-
4223- // checkboxes only
4224- BOOL GetCheckState(HTREEITEM hItem) const
4225- {
4226- ATLASSERT(::IsWindow(m_hWnd));
4227- ATLASSERT((GetStyle() & TVS_CHECKBOXES) != 0);
4228- UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK);
4229- return (uRet >> 12) - 1;
4230- }
4231-
4232- BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck)
4233- {
4234- int nCheck = bCheck ? 2 : 1; // one based index
4235- return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK);
4236- }
4237-
4238-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4239- COLORREF GetBkColor() const
4240- {
4241- ATLASSERT(::IsWindow(m_hWnd));
4242- return (COLORREF)::SendMessage(m_hWnd, TVM_GETBKCOLOR, 0, 0L);
4243- }
4244-
4245- COLORREF SetBkColor(COLORREF clr)
4246- {
4247- ATLASSERT(::IsWindow(m_hWnd));
4248- return (COLORREF)::SendMessage(m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr);
4249- }
4250-
4251- COLORREF GetInsertMarkColor() const
4252- {
4253- ATLASSERT(::IsWindow(m_hWnd));
4254- return (COLORREF)::SendMessage(m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L);
4255- }
4256-
4257- COLORREF SetInsertMarkColor(COLORREF clr)
4258- {
4259- ATLASSERT(::IsWindow(m_hWnd));
4260- return (COLORREF)::SendMessage(m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr);
4261- }
4262-
4263- int GetItemHeight() const
4264- {
4265- ATLASSERT(::IsWindow(m_hWnd));
4266- return (int)::SendMessage(m_hWnd, TVM_GETITEMHEIGHT, 0, 0L);
4267- }
4268-
4269- int SetItemHeight(int cyHeight)
4270- {
4271- ATLASSERT(::IsWindow(m_hWnd));
4272- return (int)::SendMessage(m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L);
4273- }
4274-
4275- int GetScrollTime() const
4276- {
4277- ATLASSERT(::IsWindow(m_hWnd));
4278- return (int)::SendMessage(m_hWnd, TVM_GETSCROLLTIME, 0, 0L);
4279- }
4280-
4281- int SetScrollTime(int nScrollTime)
4282- {
4283- ATLASSERT(::IsWindow(m_hWnd));
4284- return (int)::SendMessage(m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L);
4285- }
4286-
4287- COLORREF GetTextColor() const
4288- {
4289- ATLASSERT(::IsWindow(m_hWnd));
4290- return (COLORREF)::SendMessage(m_hWnd, TVM_GETTEXTCOLOR, 0, 0L);
4291- }
4292-
4293- COLORREF SetTextColor(COLORREF clr)
4294- {
4295- ATLASSERT(::IsWindow(m_hWnd));
4296- return (COLORREF)::SendMessage(m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr);
4297- }
4298-
4299- BOOL GetUnicodeFormat() const
4300- {
4301- ATLASSERT(::IsWindow(m_hWnd));
4302- return (BOOL)::SendMessage(m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L);
4303- }
4304-
4305- BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
4306- {
4307- ATLASSERT(::IsWindow(m_hWnd));
4308- return (BOOL)::SendMessage(m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L);
4309- }
4310-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4311-
4312-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
4313- COLORREF GetLineColor() const
4314- {
4315- ATLASSERT(::IsWindow(m_hWnd));
4316- return (COLORREF)::SendMessage(m_hWnd, TVM_GETLINECOLOR, 0, 0L);
4317- }
4318-
4319- COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/)
4320- {
4321- ATLASSERT(::IsWindow(m_hWnd));
4322- return (COLORREF)::SendMessage(m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew);
4323- }
4324-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
4325-
4326-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4327- BOOL GetItem(LPTVITEMEX pItem) const
4328- {
4329- ATLASSERT(::IsWindow(m_hWnd));
4330- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem);
4331- }
4332-
4333- BOOL SetItem(LPTVITEMEX pItem)
4334- {
4335- ATLASSERT(::IsWindow(m_hWnd));
4336- return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem);
4337- }
4338-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4339-
4340- DWORD GetExtendedStyle() const
4341- {
4342-#ifndef TVM_GETEXTENDEDSTYLE
4343- const UINT TVM_GETEXTENDEDSTYLE = (TV_FIRST + 45);
4344-#endif
4345- ATLASSERT(::IsWindow(m_hWnd));
4346- return (DWORD)::SendMessage(m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L);
4347- }
4348-
4349- DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask)
4350- {
4351-#ifndef TVM_SETEXTENDEDSTYLE
4352- const UINT TVM_SETEXTENDEDSTYLE = (TV_FIRST + 44);
4353-#endif
4354- ATLASSERT(::IsWindow(m_hWnd));
4355- return (DWORD)::SendMessage(m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle);
4356- }
4357-
4358-#if (_WIN32_WINNT >= 0x0600)
4359- BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime)
4360- {
4361- ATLASSERT(::IsWindow(m_hWnd));
4362- return (BOOL)::SendMessage(m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime);
4363- }
4364-
4365- DWORD GetSelectedCount() const
4366- {
4367- ATLASSERT(::IsWindow(m_hWnd));
4368- return (DWORD)::SendMessage(m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L);
4369- }
4370-
4371- BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect) const
4372- {
4373- ATLASSERT(::IsWindow(m_hWnd));
4374- TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID };
4375- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri);
4376- }
4377-#endif // (_WIN32_WINNT >= 0x0600)
4378-
4379-// Operations
4380- HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct)
4381- {
4382- ATLASSERT(::IsWindow(m_hWnd));
4383- return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct);
4384- }
4385-
4386- HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage,
4387- int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter)
4388- {
4389- ATLASSERT(::IsWindow(m_hWnd));
4390- return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter);
4391- }
4392-
4393- HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
4394- {
4395- ATLASSERT(::IsWindow(m_hWnd));
4396- return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter);
4397- }
4398-
4399- HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage,
4400- int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam,
4401- HTREEITEM hParent, HTREEITEM hInsertAfter)
4402- {
4403- ATLASSERT(::IsWindow(m_hWnd));
4404- TVINSERTSTRUCT tvis = { 0 };
4405- tvis.hParent = hParent;
4406- tvis.hInsertAfter = hInsertAfter;
4407- tvis.item.mask = nMask;
4408- tvis.item.pszText = (LPTSTR) lpszItem;
4409- tvis.item.iImage = nImage;
4410- tvis.item.iSelectedImage = nSelectedImage;
4411- tvis.item.state = nState;
4412- tvis.item.stateMask = nStateMask;
4413- tvis.item.lParam = lParam;
4414- return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis);
4415- }
4416-
4417- BOOL DeleteItem(HTREEITEM hItem)
4418- {
4419- ATLASSERT(::IsWindow(m_hWnd));
4420- return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem);
4421- }
4422-
4423- BOOL DeleteAllItems()
4424- {
4425- ATLASSERT(::IsWindow(m_hWnd));
4426- return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);
4427- }
4428-
4429- BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND)
4430- {
4431- ATLASSERT(::IsWindow(m_hWnd));
4432- return (BOOL)::SendMessage(m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem);
4433- }
4434-
4435- HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const
4436- {
4437- ATLASSERT(::IsWindow(m_hWnd));
4438- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem);
4439- }
4440-
4441- HTREEITEM GetChildItem(HTREEITEM hItem) const
4442- {
4443- ATLASSERT(::IsWindow(m_hWnd));
4444- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);
4445- }
4446-
4447- HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const
4448- {
4449- ATLASSERT(::IsWindow(m_hWnd));
4450- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
4451- }
4452-
4453- HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const
4454- {
4455- ATLASSERT(::IsWindow(m_hWnd));
4456- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem);
4457- }
4458-
4459- HTREEITEM GetParentItem(HTREEITEM hItem) const
4460- {
4461- ATLASSERT(::IsWindow(m_hWnd));
4462- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem);
4463- }
4464-
4465- HTREEITEM GetFirstVisibleItem() const
4466- {
4467- ATLASSERT(::IsWindow(m_hWnd));
4468- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L);
4469- }
4470-
4471- HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const
4472- {
4473- ATLASSERT(::IsWindow(m_hWnd));
4474- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem);
4475- }
4476-
4477- HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const
4478- {
4479- ATLASSERT(::IsWindow(m_hWnd));
4480- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem);
4481- }
4482-
4483- HTREEITEM GetSelectedItem() const
4484- {
4485- ATLASSERT(::IsWindow(m_hWnd));
4486- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L);
4487- }
4488-
4489- HTREEITEM GetDropHilightItem() const
4490- {
4491- ATLASSERT(::IsWindow(m_hWnd));
4492- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L);
4493- }
4494-
4495- HTREEITEM GetRootItem() const
4496- {
4497- ATLASSERT(::IsWindow(m_hWnd));
4498- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L);
4499- }
4500-
4501-#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
4502- HTREEITEM GetLastVisibleItem() const
4503- {
4504- ATLASSERT(::IsWindow(m_hWnd));
4505- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L);
4506- }
4507-#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
4508-
4509-#if (_WIN32_IE >= 0x0600)
4510- HTREEITEM GetNextSelectedItem() const
4511- {
4512- ATLASSERT(::IsWindow(m_hWnd));
4513- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L);
4514- }
4515-#endif // (_WIN32_IE >= 0x0600)
4516-
4517- BOOL Select(HTREEITEM hItem, UINT nCode)
4518- {
4519- ATLASSERT(::IsWindow(m_hWnd));
4520- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem);
4521- }
4522-
4523- BOOL SelectItem(HTREEITEM hItem)
4524- {
4525- ATLASSERT(::IsWindow(m_hWnd));
4526- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem);
4527- }
4528-
4529- BOOL SelectDropTarget(HTREEITEM hItem)
4530- {
4531- ATLASSERT(::IsWindow(m_hWnd));
4532- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem);
4533- }
4534-
4535- BOOL SelectSetFirstVisible(HTREEITEM hItem)
4536- {
4537- ATLASSERT(::IsWindow(m_hWnd));
4538- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem);
4539- }
4540-
4541- CEdit EditLabel(HTREEITEM hItem)
4542- {
4543- ATLASSERT(::IsWindow(m_hWnd));
4544- return CEdit((HWND)::SendMessage(m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem));
4545- }
4546-
4547- BOOL EndEditLabelNow(BOOL bCancel)
4548- {
4549- ATLASSERT(::IsWindow(m_hWnd));
4550- return (BOOL)::SendMessage(m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L);
4551- }
4552-
4553- HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const
4554- {
4555- ATLASSERT(::IsWindow(m_hWnd));
4556- return (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo);
4557- }
4558-
4559- HTREEITEM HitTest(POINT pt, UINT* pFlags) const
4560- {
4561- ATLASSERT(::IsWindow(m_hWnd));
4562- TVHITTESTINFO hti = { 0 };
4563- hti.pt = pt;
4564- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti);
4565- if (pFlags != NULL)
4566- *pFlags = hti.flags;
4567- return hTreeItem;
4568- }
4569-
4570- BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE)
4571- {
4572- ATLASSERT(::IsWindow(m_hWnd));
4573- return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem);
4574- }
4575-
4576- BOOL EnsureVisible(HTREEITEM hItem)
4577- {
4578- ATLASSERT(::IsWindow(m_hWnd));
4579- return (BOOL)::SendMessage(m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem);
4580- }
4581-
4582- BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE)
4583- {
4584- ATLASSERT(::IsWindow(m_hWnd));
4585- return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort);
4586- }
4587-
4588- CImageList RemoveImageList(int nImageList)
4589- {
4590- ATLASSERT(::IsWindow(m_hWnd));
4591- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL));
4592- }
4593-
4594- CImageList CreateDragImage(HTREEITEM hItem)
4595- {
4596- ATLASSERT(::IsWindow(m_hWnd));
4597- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem));
4598- }
4599-
4600-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4601- BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter)
4602- {
4603- ATLASSERT(::IsWindow(m_hWnd));
4604- return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem);
4605- }
4606-
4607- BOOL RemoveInsertMark()
4608- {
4609- ATLASSERT(::IsWindow(m_hWnd));
4610- return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, 0, 0L);
4611- }
4612-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4613-
4614-#if (_WIN32_WINNT >= 0x0501)
4615- HTREEITEM MapAccIDToHTREEITEM(UINT uID) const
4616- {
4617- ATLASSERT(::IsWindow(m_hWnd));
4618- return (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L);
4619- }
4620-
4621- UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const
4622- {
4623- ATLASSERT(::IsWindow(m_hWnd));
4624- return (UINT)::SendMessage(m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L);
4625- }
4626-#endif // (_WIN32_WINNT >= 0x0501)
4627-
4628-#if (_WIN32_WINNT >= 0x0600)
4629- void ShowInfoTip(HTREEITEM hItem)
4630- {
4631- ATLASSERT(::IsWindow(m_hWnd));
4632- ::SendMessage(m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem);
4633- }
4634-#endif // (_WIN32_WINNT >= 0x0600)
4635-};
4636-
4637-typedef CTreeViewCtrlT<ATL::CWindow> CTreeViewCtrl;
4638-
4639-
4640-///////////////////////////////////////////////////////////////////////////////
4641-// CTreeViewCtrlEx
4642-
4643-// forward declaration
4644-template <class TBase> class CTreeViewCtrlExT;
4645-
4646-// Note: TBase here is for CTreeViewCtrlExT, and not for CTreeItemT itself
4647-template <class TBase>
4648-class CTreeItemT
4649-{
4650-public:
4651- HTREEITEM m_hTreeItem;
4652- CTreeViewCtrlExT<TBase>* m_pTreeView;
4653-
4654-// Construction
4655- CTreeItemT(HTREEITEM hTreeItem = NULL, CTreeViewCtrlExT<TBase>* pTreeView = NULL) : m_hTreeItem(hTreeItem), m_pTreeView(pTreeView)
4656- { }
4657-
4658- CTreeItemT(const CTreeItemT<TBase>& posSrc)
4659- {
4660- *this = posSrc;
4661- }
4662-
4663- operator HTREEITEM() { return m_hTreeItem; }
4664-
4665- CTreeItemT<TBase>& operator =(const CTreeItemT<TBase>& itemSrc)
4666- {
4667- m_hTreeItem = itemSrc.m_hTreeItem;
4668- m_pTreeView = itemSrc.m_pTreeView;
4669- return *this;
4670- }
4671-
4672-// Attributes
4673- CTreeViewCtrlExT<TBase>* GetTreeView() const { return m_pTreeView; }
4674-
4675- BOOL operator !() const { return m_hTreeItem == NULL; }
4676-
4677- BOOL IsNull() const { return m_hTreeItem == NULL; }
4678-
4679- BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const;
4680- BOOL GetText(LPTSTR lpstrText, int nLen) const;
4681-#ifndef _ATL_NO_COM
4682- BOOL GetText(BSTR& bstrText) const;
4683-#endif // !_ATL_NO_COM
4684-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
4685- BOOL GetText(_CSTRING_NS::CString& strText) const;
4686-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
4687- BOOL SetText(LPCTSTR lpszItem);
4688- BOOL GetImage(int& nImage, int& nSelectedImage) const;
4689- BOOL SetImage(int nImage, int nSelectedImage);
4690- UINT GetState(UINT nStateMask) const;
4691- BOOL SetState(UINT nState, UINT nStateMask);
4692- DWORD_PTR GetData() const;
4693- BOOL SetData(DWORD_PTR dwData);
4694- BOOL SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam);
4695-
4696-// Operations
4697- CTreeItemT<TBase> InsertAfter(LPCTSTR lpstrItem, HTREEITEM hItemAfter, int nImageIndex)
4698- {
4699- return _Insert(lpstrItem, nImageIndex, hItemAfter);
4700- }
4701-
4702- CTreeItemT<TBase> AddHead(LPCTSTR lpstrItem, int nImageIndex)
4703- {
4704- return _Insert(lpstrItem, nImageIndex, TVI_FIRST);
4705- }
4706-
4707- CTreeItemT<TBase> AddTail(LPCTSTR lpstrItem, int nImageIndex)
4708- {
4709- return _Insert(lpstrItem, nImageIndex, TVI_LAST);
4710- }
4711-
4712- CTreeItemT<TBase> GetChild() const;
4713- CTreeItemT<TBase> GetNext(UINT nCode) const;
4714- CTreeItemT<TBase> GetNextSibling() const;
4715- CTreeItemT<TBase> GetPrevSibling() const;
4716- CTreeItemT<TBase> GetParent() const;
4717- CTreeItemT<TBase> GetFirstVisible() const;
4718- CTreeItemT<TBase> GetNextVisible() const;
4719- CTreeItemT<TBase> GetPrevVisible() const;
4720- CTreeItemT<TBase> GetSelected() const;
4721- CTreeItemT<TBase> GetDropHilight() const;
4722- CTreeItemT<TBase> GetRoot() const;
4723-#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
4724- CTreeItemT<TBase> GetLastVisible() const;
4725-#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
4726-#if (_WIN32_IE >= 0x0600)
4727- CTreeItemT<TBase> GetNextSelected() const;
4728-#endif // (_WIN32_IE >= 0x0600)
4729- BOOL HasChildren() const;
4730- BOOL Delete();
4731- BOOL Expand(UINT nCode = TVE_EXPAND);
4732- BOOL Select(UINT nCode);
4733- BOOL Select();
4734- BOOL SelectDropTarget();
4735- BOOL SelectSetFirstVisible();
4736- HWND EditLabel();
4737- HIMAGELIST CreateDragImage();
4738- BOOL SortChildren(BOOL bRecurse = FALSE);
4739- BOOL EnsureVisible();
4740- CTreeItemT<TBase> _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter);
4741- int GetImageIndex() const;
4742-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4743- BOOL SetInsertMark(BOOL bAfter);
4744-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
4745-#if (_WIN32_WINNT >= 0x0501)
4746- UINT MapHTREEITEMToAccID() const;
4747-#endif // (_WIN32_WINNT >= 0x0501)
4748-#if (_WIN32_WINNT >= 0x0600)
4749- void ShowInfoTip();
4750- BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const;
4751-#endif // (_WIN32_WINNT >= 0x0600)
4752-};
4753-
4754-typedef CTreeItemT<ATL::CWindow> CTreeItem;
4755-
4756-
4757-template <class TBase>
4758-class CTreeViewCtrlExT : public CTreeViewCtrlT< TBase >
4759-{
4760-public:
4761-// Constructors
4762- CTreeViewCtrlExT(HWND hWnd = NULL) : CTreeViewCtrlT< TBase >(hWnd)
4763- { }
4764-
4765- CTreeViewCtrlExT< TBase >& operator =(HWND hWnd)
4766- {
4767- m_hWnd = hWnd;
4768- return *this;
4769- }
4770-
4771-// Operations (overides that return CTreeItem)
4772- CTreeItemT<TBase> InsertItem(LPTVINSERTSTRUCT lpInsertStruct)
4773- {
4774- ATLASSERT(::IsWindow(m_hWnd));
4775- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct);
4776- return CTreeItemT<TBase>(hTreeItem, this);
4777- }
4778-
4779- CTreeItemT<TBase> InsertItem(LPCTSTR lpszItem, int nImage,
4780- int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter)
4781- {
4782- ATLASSERT(::IsWindow(m_hWnd));
4783- return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter);
4784- }
4785-
4786- CTreeItemT<TBase> InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
4787- {
4788- ATLASSERT(::IsWindow(m_hWnd));
4789- return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter);
4790- }
4791-
4792- CTreeItemT<TBase> GetNextItem(HTREEITEM hItem, UINT nCode) const
4793- {
4794- ATLASSERT(::IsWindow(m_hWnd));
4795- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem);
4796- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4797- }
4798-
4799- CTreeItemT<TBase> GetChildItem(HTREEITEM hItem) const
4800- {
4801- ATLASSERT(::IsWindow(m_hWnd));
4802- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);
4803- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4804- }
4805-
4806- CTreeItemT<TBase> GetNextSiblingItem(HTREEITEM hItem) const
4807- {
4808- ATLASSERT(::IsWindow(m_hWnd));
4809- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
4810- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4811- }
4812-
4813- CTreeItemT<TBase> GetPrevSiblingItem(HTREEITEM hItem) const
4814- {
4815- ATLASSERT(::IsWindow(m_hWnd));
4816- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem);
4817- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4818- }
4819-
4820- CTreeItemT<TBase> GetParentItem(HTREEITEM hItem) const
4821- {
4822- ATLASSERT(::IsWindow(m_hWnd));
4823- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem);
4824- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4825- }
4826-
4827- CTreeItemT<TBase> GetFirstVisibleItem() const
4828- {
4829- ATLASSERT(::IsWindow(m_hWnd));
4830- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L);
4831- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4832- }
4833-
4834- CTreeItemT<TBase> GetNextVisibleItem(HTREEITEM hItem) const
4835- {
4836- ATLASSERT(::IsWindow(m_hWnd));
4837- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem);
4838- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4839- }
4840-
4841- CTreeItemT<TBase> GetPrevVisibleItem(HTREEITEM hItem) const
4842- {
4843- ATLASSERT(::IsWindow(m_hWnd));
4844- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem);
4845- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4846- }
4847-
4848- CTreeItemT<TBase> GetSelectedItem() const
4849- {
4850- ATLASSERT(::IsWindow(m_hWnd));
4851- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L);
4852- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4853- }
4854-
4855- CTreeItemT<TBase> GetDropHilightItem() const
4856- {
4857- ATLASSERT(::IsWindow(m_hWnd));
4858- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L);
4859- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4860- }
4861-
4862- CTreeItemT<TBase> GetRootItem() const
4863- {
4864- ATLASSERT(::IsWindow(m_hWnd));
4865- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L);
4866- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4867- }
4868-
4869-#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
4870- CTreeItemT<TBase> GetLastVisibleItem() const
4871- {
4872- ATLASSERT(::IsWindow(m_hWnd));
4873- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L);
4874- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4875- }
4876-#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
4877-
4878-#if (_WIN32_IE >= 0x0600)
4879- CTreeItemT<TBase> GetNextSelectedItem() const
4880- {
4881- ATLASSERT(::IsWindow(m_hWnd));
4882- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L);
4883- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4884- }
4885-#endif // (_WIN32_IE >= 0x0600)
4886-
4887- CTreeItemT<TBase> HitTest(TVHITTESTINFO* pHitTestInfo) const
4888- {
4889- ATLASSERT(::IsWindow(m_hWnd));
4890- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo);
4891- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4892- }
4893-
4894- CTreeItemT<TBase> InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage,
4895- int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam,
4896- HTREEITEM hParent, HTREEITEM hInsertAfter)
4897- {
4898- ATLASSERT(::IsWindow(m_hWnd));
4899- TVINSERTSTRUCT tvis = { 0 };
4900- tvis.hParent = hParent;
4901- tvis.hInsertAfter = hInsertAfter;
4902- tvis.item.mask = nMask;
4903- tvis.item.pszText = (LPTSTR) lpszItem;
4904- tvis.item.iImage = nImage;
4905- tvis.item.iSelectedImage = nSelectedImage;
4906- tvis.item.state = nState;
4907- tvis.item.stateMask = nStateMask;
4908- tvis.item.lParam = lParam;
4909- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis);
4910- return CTreeItemT<TBase>(hTreeItem, this);
4911- }
4912-
4913- CTreeItemT<TBase> HitTest(POINT pt, UINT* pFlags) const
4914- {
4915- ATLASSERT(::IsWindow(m_hWnd));
4916- TVHITTESTINFO hti = { 0 };
4917- hti.pt = pt;
4918- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti);
4919- if (pFlags != NULL)
4920- *pFlags = hti.flags;
4921- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4922- }
4923-
4924-#if (_WIN32_WINNT >= 0x0501)
4925- CTreeItemT<TBase> MapAccIDToHTREEITEM(UINT uID) const
4926- {
4927- ATLASSERT(::IsWindow(m_hWnd));
4928- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L);
4929- return CTreeItemT<TBase>(hTreeItem, (CTreeViewCtrlExT<TBase>*)this);
4930- }
4931-#endif // (_WIN32_WINNT >= 0x0501)
4932-};
4933-
4934-typedef CTreeViewCtrlExT<ATL::CWindow> CTreeViewCtrlEx;
4935-
4936-
4937-// CTreeItem inline methods
4938-template <class TBase>
4939-inline BOOL CTreeItemT<TBase>::GetRect(LPRECT lpRect, BOOL bTextOnly) const
4940-{
4941- ATLASSERT(m_pTreeView != NULL);
4942- return m_pTreeView->GetItemRect(m_hTreeItem,lpRect,bTextOnly);
4943-}
4944-
4945-template <class TBase>
4946-inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNext(UINT nCode) const
4947-{
4948- ATLASSERT(m_pTreeView != NULL);
4949- return m_pTreeView->GetNextItem(m_hTreeItem,nCode);
4950-}
4951-
4952-template <class TBase>
4953-inline CTreeItemT<TBase> CTreeItemT<TBase>::GetChild() const
4954-{
4955- ATLASSERT(m_pTreeView != NULL);
4956- return m_pTreeView->GetChildItem(m_hTreeItem);
4957-}
4958-
4959-template <class TBase>
4960-inline CTreeItemT<TBase> CTreeItemT<TBase>::GetNextSibling() const
4961-{
4962- ATLASSERT(m_pTreeView != NULL);
4963- return m_pTreeView->GetNextSiblingItem(m_hTreeItem);
4964-}
4965-
4966-template <class TBase>
4967-inline CTreeItemT<TBase> CTreeItemT<TBase>::GetPrevSibling() const
4968-{
4969- ATLASSERT(m_pTreeView != NULL);
4970- return m_pTreeView->GetPrevSiblingItem(m_hTreeItem);
4971-}
4972-
4973-template <class TBase>
4974-inline CTreeItemT<TBase> CTreeItemT<TBase>::GetParent() const
4975-{
4976-