ReactOS 0.4.17-dev-1343-g8fe3cee
atlwin.h
Go to the documentation of this file.
1/*
2 * ReactOS ATL
3 *
4 * Copyright 2009 Andrew Hill <ash77@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#pragma once
22
23#if defined(__GNUC__) || defined(__clang__)
24#define GCCU(x) x __attribute__((unused))
25#define Unused(x)
26#else
27#define GCCU(x) (x)
28#define Unused(x) (x);
29#endif // __GNUC__
30
31#if !defined(_WIN64)
32#ifdef SetWindowLongPtr
33#undef SetWindowLongPtr
34inline LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLong)
35{
36 return SetWindowLong(hWnd, nIndex, (LONG)dwNewLong);
37}
38#endif
39
40#ifdef GetWindowLongPtr
41#undef GetWindowLongPtr
42inline LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex)
43{
44 return (LONG_PTR)GetWindowLong(hWnd, nIndex);
45}
46#endif
47#endif // !_WIN64
48
49#pragma push_macro("SubclassWindow")
50#undef SubclassWindow
51
52#ifdef __RATL__
53 #ifndef _Post_z_
54 #define _Post_z_
55 #endif
56#endif
57
58namespace ATL
59{
60
61#ifndef GET_X_LPARAM
62#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
63#endif
64#ifndef GET_Y_LPARAM
65#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
66#endif
67
68
71
72template <DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0>
74{
75public:
76 static DWORD GetWndStyle(DWORD dwStyle)
77 {
78 if (dwStyle == 0)
79 return t_dwStyle;
80 return dwStyle;
81 }
82
83 static DWORD GetWndExStyle(DWORD dwExStyle)
84 {
85 if (dwExStyle == 0)
86 return t_dwExStyle;
87 return dwExStyle;
88 }
89};
90
94
95template <DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0, class TWinTraits = CControlWinTraits>
97{
98public:
99 static DWORD GetWndStyle(DWORD dwStyle)
100 {
101 return dwStyle | t_dwStyle | TWinTraits::GetWndStyle(dwStyle);
102 }
103
104 static DWORD GetWndExStyle(DWORD dwExStyle)
105 {
106 return dwExStyle | t_dwExStyle | TWinTraits::GetWndExStyle(dwExStyle);
107 }
108};
109
111{
112public:
114public:
116 {
117 m_hMenu = hMenu;
118 }
119
121 {
122 m_hMenu = (HMENU)(UINT_PTR)nID;
123 }
124};
125
127{
128public:
130public:
132 {
133 m_lpRect = lpRect;
134 }
135
137 {
138 m_lpRect = &rc;
139 }
140};
141
142struct _ATL_MSG : public MSG
143{
144public:
146public:
147 _ATL_MSG(HWND hWnd, UINT uMsg, WPARAM wParamIn, LPARAM lParamIn, BOOL bHandledIn = TRUE)
148 {
149 hwnd = hWnd;
150 message = uMsg;
151 wParam = wParamIn;
152 lParam = lParamIn;
153 time = 0;
154 pt.x = 0;
155 pt.y = 0;
156 bHandled = bHandledIn;
157 }
158};
159
160#if defined(_M_IX86)
161
162#pragma pack(push,1)
163struct thunkCode
164{
165 DWORD m_mov; /* mov dword ptr [esp+4], m_this */
166 DWORD m_this;
167 BYTE m_jmp; /* jmp relproc */
168 DWORD m_relproc;
169
170 void
171 Init(WNDPROC proc, void *pThis)
172 {
173 m_mov = 0x042444C7;
174 m_this = PtrToUlong(pThis);
175 m_jmp = 0xe9;
176 m_relproc = DWORD(reinterpret_cast<char*>(proc) - (reinterpret_cast<char*>(this) + sizeof(thunkCode)));
177 FlushInstructionCache(GetCurrentProcess(), this, sizeof(thunkCode));
178 }
179};
180#pragma pack(pop)
181
182#elif defined(_AMD64_)
183
184#pragma pack(push,1)
185struct thunkCode
186{
187 USHORT m_mov_rcx; /* mov rcx, m_this */
188 ULONG64 m_this;
189 USHORT m_mov_rax; /* mov rax, m_proc */
190 ULONG64 m_proc;
191 USHORT m_jmp; /* jmp rax */
192
193 void
194 Init(WNDPROC proc, void *pThis)
195 {
196 m_mov_rcx = 0xb948;
197 m_this = (ULONG64)pThis;
198 m_mov_rax = 0xb848;
199 m_proc = (ULONG64)proc;
200 m_jmp = 0xe0ff;
201 FlushInstructionCache(GetCurrentProcess(), this, sizeof(thunkCode));
202 }
203};
204#pragma pack(pop)
205
206#elif defined(_M_ARM)
207
208#pragma pack(push,4)
209struct thunkCode
210{
211 DWORD m_mov_r0; /* mov r0, m_this */
212 DWORD m_mov_pc; /* mov pc, m_proc */
213 DWORD m_this;
214 DWORD m_proc;
215
216 void
217 Init(WNDPROC proc, void *pThis)
218 {
219 m_mov_r0 = 0xE59F0000;
220 m_mov_pc = 0xE59FF000;
221 m_this = (DWORD)pThis;
222 m_proc = (DWORD)proc;
223 FlushInstructionCache(GetCurrentProcess(), this, sizeof(thunkCode));
224 }
225};
226#pragma pack(pop)
227
228#elif defined(_M_ARM64)
229
230#pragma pack(push,8)
231struct thunkCode
232{
233 DWORD m_ldr_x0; /* ldr x0, m_this */
234 DWORD m_ldr_x16; /* ldr x16, m_proc */
235 DWORD m_br_x16; /* br x16 */
236 DWORD m_pad; /* nop, keeps the literals 8 byte aligned */
237 ULONG64 m_this;
238 ULONG64 m_proc;
239
240 void
241 Init(WNDPROC proc, void *pThis)
242 {
243 m_ldr_x0 = 0x58000080;
244 m_ldr_x16 = 0x580000B0;
245 m_br_x16 = 0xD61F0200;
246 m_pad = 0xD503201F;
247 m_this = (ULONG64)pThis;
248 m_proc = (ULONG64)proc;
249 FlushInstructionCache(GetCurrentProcess(), this, sizeof(thunkCode));
250 }
251};
252#pragma pack(pop)
253
254#else
255#error ARCH not supported
256#endif
257
259{
260public:
261 thunkCode *m_pthunk;
263
264public:
266 {
267 m_pthunk = (thunkCode*)VirtualAlloc(NULL, sizeof(thunkCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
268 }
269
271 {
272 if (m_pthunk != NULL)
274 }
275
276 BOOL Init(WNDPROC proc, void *pThis)
277 {
278 if (m_pthunk == NULL)
279 return FALSE;
280 m_pthunk->Init(proc, pThis);
281 return TRUE;
282 }
283
285 {
286 return reinterpret_cast<WNDPROC>(m_pthunk);
287 }
288};
289
291{
292public:
293 virtual BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD dwMsgMapID) = 0;
294};
295
297{
298public:
301
302public:
304 {
305 m_hWnd = hWnd;
306 }
307
308 operator HWND() const
309 {
310 return m_hWnd;
311 }
312
314 {
315 return NULL;
316 }
317
319 {
321 return ::ArrangeIconicWindows(m_hWnd);
322 }
323
324 void Attach(HWND hWndNew)
325 {
326 m_hWnd = hWndNew;
327 }
328
330 {
332 return ::BeginPaint(m_hWnd, lpPaint);
333 }
334
336 {
338 return ::BringWindowToTop(m_hWnd);
339 }
340
342 {
344 if (hWndCenter == NULL)
345 hWndCenter = ::GetParent(m_hWnd);
346 if (hWndCenter == NULL)
347 return FALSE;
348 RECT wndCenterRect, wndRect;
349 if (!::GetWindowRect(hWndCenter, &wndCenterRect) || !::GetWindowRect(m_hWnd, &wndRect))
350 return FALSE;
351 int wndCenterWidth = wndCenterRect.right - wndCenterRect.left;
352 int wndCenterHeight = wndCenterRect.bottom - wndCenterRect.top;
353 int wndWidth = wndRect.right - wndRect.left;
354 int wndHeight = wndRect.bottom - wndRect.top;
355 int xPos = wndCenterRect.left + ((wndCenterWidth - wndWidth + 1) >> 1);
356 int yPos = wndCenterRect.top + ((wndCenterHeight - wndHeight + 1) >> 1);
357
358 if (!(::GetWindowLong(hWndCenter, GWL_STYLE) & WS_CHILD))
359 {
361 mi.cbSize = sizeof(mi);
362 HMONITOR hMonitor = MonitorFromWindow(hWndCenter, MONITOR_DEFAULTTOPRIMARY);
363 GetMonitorInfo(hMonitor, &mi);
364
365 if (xPos + wndWidth > mi.rcWork.right)
366 {
367 xPos = mi.rcWork.right - wndWidth;
368 }
369 else if (xPos < mi.rcWork.left)
370 {
371 xPos = mi.rcWork.left;
372 }
373
374 if (yPos + wndHeight > mi.rcWork.bottom)
375 {
376 yPos = mi.rcWork.bottom - wndHeight;
377 }
378 if (yPos < mi.rcWork.top)
379 {
380 yPos = mi.rcWork.top;
381 }
382 }
383 return ::MoveWindow(m_hWnd,
384 xPos,
385 yPos,
386 wndWidth, wndHeight, TRUE);
387 }
388
390 {
392 return ::ChangeClipboardChain(m_hWnd, hWndNewNext);
393 }
394
395 BOOL CheckDlgButton(int nIDButton, UINT nCheck)
396 {
398 return ::CheckDlgButton(m_hWnd, nIDButton, nCheck);
399 }
400
401 BOOL CheckRadioButton(int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
402 {
404 return ::CheckRadioButton(m_hWnd, nIDFirstButton, nIDLastButton, nIDCheckButton);
405 }
406
408 {
410 return ::ChildWindowFromPoint(m_hWnd, point);
411 }
412
414 {
416 return ::ChildWindowFromPointEx(m_hWnd, point, uFlags);
417 }
418
420 {
422 return ::ClientToScreen(m_hWnd, lpPoint);
423 }
424
426 {
427 if (lpRect == NULL)
428 return FALSE;
430 POINT leftTop = {lpRect->left, lpRect->top};
431 POINT rightBottom = {lpRect->right, lpRect->bottom};
432 BOOL success = ::ClientToScreen(m_hWnd, &leftTop) && ::ClientToScreen(m_hWnd, &rightBottom);
433 if (success)
434 {
435 lpRect->left = leftTop.x;
436 lpRect->top = leftTop.y;
437 lpRect->right = rightBottom.x;
438 lpRect->bottom = rightBottom.y;
439 }
440 return success;
441 }
442
443 HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
444 {
445 HWND hWnd;
447 hWnd = ::CreateWindowEx(dwExStyle,
448 lpstrWndClass,
449 szWindowName,
450 dwStyle,
451 rect.m_lpRect->left,
452 rect.m_lpRect->top,
453 rect.m_lpRect->right - rect.m_lpRect->left,
454 rect.m_lpRect->bottom - rect.m_lpRect->top,
456 MenuOrID.m_hMenu,
457 _AtlBaseModule.GetModuleInstance(),
458 lpCreateParam);
459 if (hWnd != NULL)
460 m_hWnd = hWnd;
461 return hWnd;
462 }
463
465 {
467 return ::CreateCaret(m_hWnd, pBitmap, 0, 0);
468 }
469
470 BOOL CreateGrayCaret(int nWidth, int nHeight)
471 {
473 return ::CreateCaret(m_hWnd, (HBITMAP)1, nWidth, nHeight);
474 }
475
476 BOOL CreateSolidCaret(int nWidth, int nHeight)
477 {
479 return ::CreateCaret(m_hWnd, (HBITMAP)0, nWidth, nHeight);
480 }
481
482 HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags)
483 {
485 return ::DeferWindowPos(hWinPosInfo, m_hWnd, hWndInsertAfter, x, y, cx, cy, uFlags);
486 }
487
489 {
491
493 return FALSE;
494
495 m_hWnd = NULL;
496 return TRUE;
497 }
498
500 {
501 HWND hWnd = m_hWnd;
502 m_hWnd = NULL;
503 return hWnd;
504 }
505
506 int DlgDirList(LPTSTR lpPathSpec, int nIDListBox, int nIDStaticPath, UINT nFileType)
507 {
509 return ::DlgDirList(m_hWnd, lpPathSpec, nIDListBox, nIDStaticPath, nFileType);
510 }
511
512 int DlgDirListComboBox(LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath, UINT nFileType)
513 {
515 return ::DlgDirListComboBox(m_hWnd, lpPathSpec, nIDComboBox, nIDStaticPath, nFileType);
516 }
517
518 BOOL DlgDirSelect(LPTSTR lpString, int nCount, int nIDListBox)
519 {
521 return ::DlgDirSelectEx(m_hWnd, lpString, nCount, nIDListBox);
522 }
523
524 BOOL DlgDirSelectComboBox(LPTSTR lpString, int nCount, int nIDComboBox)
525 {
527 return ::DlgDirSelectComboBoxEx(m_hWnd, lpString, nCount, nIDComboBox);
528 }
529
530 void DragAcceptFiles(BOOL bAccept = TRUE)
531 {
533// FIXME following line requires shellapi.h
534// ::DragAcceptFiles(m_hWnd, bAccept);
535 }
536
538 {
540 return ::DrawMenuBar(m_hWnd);
541 }
542
544 {
546 return ::EnableScrollBar(m_hWnd, uSBFlags, uArrowFlags);
547 }
548
550 {
552 return ::EnableWindow(m_hWnd, bEnable);
553 }
554
556 {
558 ::EndPaint(m_hWnd, lpPaint);
559 }
560
562 {
564 return ::FlashWindow(m_hWnd, bInvert);
565 }
566
568 {
570 return ::GetClientRect(m_hWnd, lpRect);
571 }
572
574 {
576 return ::GetDC(m_hWnd);
577 }
578
579 HDC GetDCEx(HRGN hRgnClip, DWORD flags)
580 {
582 return ::GetDCEx(m_hWnd, hRgnClip, flags);
583 }
584
585private:
586 typedef struct _IDHWNDPAIR {
587 int nID;
590
592 {
594 {
595 ((PIDHWNDPAIR)lParam)->hWnd = hWnd;
596 return FALSE;
597 }
599 return (((PIDHWNDPAIR)lParam)->hWnd == NULL);
600 }
601
602public:
604 {
606 IDHWNDPAIR idHWndPair;
607 idHWndPair.nID = nID;
608 idHWndPair.hWnd = NULL;
610 return idHWndPair.hWnd;
611 }
612
613 HRESULT GetDlgControl(int nID, REFIID iid, void** ppCtrl)
614 {
616 return E_FAIL;//FIXME stub
617 }
618
619 int GetDlgCtrlID() const
620 {
622 return ::GetDlgCtrlID(m_hWnd);
623 }
624
625 HRESULT GetDlgHost(int nID, REFIID iid, void** ppHost)
626 {
628 return E_FAIL;//FIXME stub
629 }
630
631 HWND GetDlgItem(_In_ int nID) const
632 {
634 return ::GetDlgItem(m_hWnd, nID);
635 }
636
638 _In_ int nID,
639 _Out_opt_ BOOL* lpTrans = NULL,
640 _In_ BOOL bSigned = TRUE) const
641 {
643 return ::GetDlgItemInt(m_hWnd, nID, lpTrans, bSigned);
644 }
645
647 _In_ int nID,
648 _Out_writes_to_(nMaxCount, return + 1) LPTSTR lpStr,
649 _In_ int nMaxCount) const
650 {
652 return ::GetDlgItemText(m_hWnd, nID, lpStr, nMaxCount);
653 }
654
655#ifdef __ATLSTR_H__
656 UINT GetDlgItemText(_In_ int nID, _Inout_ CSimpleString& strText) const
657 {
658 HWND item = GetDlgItem(nID);
659 if (!item)
660 {
661 strText.Empty();
662 return 0;
663 }
664 return CWindow(item).GetWindowText(strText);
665 }
666#endif
667
669 _In_ int nID,
671 {
672 HWND item = GetDlgItem(nID);
673 if (!item)
674 return FALSE;
675 return CWindow(item).GetWindowText(bstrText);
676 }
677
679 {
681 return ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
682 }
683
684 HFONT GetFont() const
685 {
687 return (HFONT)::SendMessage(m_hWnd, WM_GETFONT, 0, 0);
688 }
689
691 {
693 return (DWORD)::SendMessage(m_hWnd, WM_GETHOTKEY, 0, 0);
694 }
695
696 HICON GetIcon(BOOL bBigIcon = TRUE) const
697 {
699 return (HICON)::SendMessage(m_hWnd, WM_GETICON, (WPARAM)bBigIcon, 0);
700 }
701
703 {
705 return ::GetLastActivePopup(m_hWnd);
706 }
707
709 {
711 return ::GetMenu(m_hWnd);
712 }
713
714 HWND GetNextDlgGroupItem(HWND hWndCtl, BOOL bPrevious = FALSE) const
715 {
717 return ::GetNextDlgGroupItem(m_hWnd, hWndCtl, bPrevious);
718 }
719
720 HWND GetNextDlgTabItem(HWND hWndCtl, BOOL bPrevious = FALSE) const
721 {
723 return ::GetNextDlgTabItem(m_hWnd, hWndCtl, bPrevious);
724 }
725
727 {
729 return CWindow(::GetParent(m_hWnd));
730 }
731
732 BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo)
733 {
735 return ::GetScrollInfo(m_hWnd, nBar, lpScrollInfo);
736 }
737
739 {
741 return ::GetScrollPos(m_hWnd, nBar);
742 }
743
744 BOOL GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const
745 {
747 return ::GetScrollRange(m_hWnd, nBar, lpMinPos, lpMaxPos);
748 }
749
751 {
753 return ::GetWindowLong(m_hWnd, GWL_STYLE);
754 }
755
757 {
759 return ::GetSystemMenu(m_hWnd, bRevert);
760 }
761
763 {
765
767 HWND hWndTmp;
768 while ((hWndTmp = ::GetParent(hWndParent)) != NULL)
769 hWndParent = hWndTmp;
770
771 return hWndParent;
772 }
773
775 {
777 return NULL;//FIXME stub
778 }
779
781 {
783 return ::GetTopWindow(m_hWnd);
784 }
785
787 {
789 return ::GetUpdateRect(m_hWnd, lpRect, bErase);
790 }
791
792 int GetUpdateRgn(HRGN hRgn, BOOL bErase = FALSE)
793 {
795 return :: GetUpdateRgn(m_hWnd, hRgn, bErase);
796 }
797
798 HWND GetWindow(UINT nCmd) const
799 {
801 return ::GetWindow(m_hWnd, nCmd);
802 }
803
805 {
807 return ::GetWindowContextHelpId(m_hWnd);
808 }
809
811 {
813 return ::GetWindowDC(m_hWnd);
814 }
815
816 LONG GetWindowLong(int nIndex) const
817 {
819 return ::GetWindowLong(m_hWnd, nIndex);
820 }
821
822 LONG_PTR GetWindowLongPtr(int nIndex) const
823 {
825 return ::GetWindowLongPtr(m_hWnd, nIndex);
826 }
827
829 {
831 return ::GetWindowPlacement(m_hWnd, lpwndpl);
832 }
833
835 {
837 DWORD processID;
839 return processID;
840 }
841
843 {
845 return ::GetWindowRect(m_hWnd, lpRect);
846 }
847
849 {
851 return ::GetWindowRgn(m_hWnd, hRgn);
852 }
853
855 _Out_writes_to_(nMaxCount, return + 1) LPTSTR lpszStringBuf,
856 _In_ int nMaxCount) const
857 {
859 return ::GetWindowText(m_hWnd, lpszStringBuf, nMaxCount);
860 }
861
862#ifdef __ATLSTR_H__
863 int GetWindowText(_Inout_ CSimpleString& strText) const
864 {
865 int len = GetWindowTextLength();
866 len = GetWindowText(strText.GetBuffer(len + 1), len + 1);
867 strText.ReleaseBuffer(len);
868 return len;
869 }
870#endif
871
874 {
877 if (!::SysReAllocStringLen(&bstrText, NULL, length))
878 return FALSE;
879 if (::GetWindowTextW(m_hWnd, bstrText, length + 1))
880 return TRUE;
881 ::SysFreeString(bstrText);
882 bstrText = NULL;
883 return FALSE;
884 }
885
887 {
889 return ::GetWindowTextLength(m_hWnd);
890 }
891
893 {
895 return ::GetWindowThreadProcessId(m_hWnd, NULL);
896 }
897
898 WORD GetWindowWord(int nIndex) const
899 {
901 return (WORD)::GetWindowLong(m_hWnd, nIndex);
902 }
903
904 void GotoDlgCtrl(HWND hWndCtrl) const
905 {
908 }
909
911 {
913 return ::HideCaret(m_hWnd);
914 }
915
916 BOOL HiliteMenuItem(HMENU hMenu, UINT uHiliteItem, UINT uHilite)
917 {
919 return ::HiliteMenuItem(m_hWnd, hMenu, uHiliteItem, uHilite);
920 }
921
923 {
925 return ::InvalidateRect(m_hWnd, NULL, bErase);
926 }
927
929 {
931 return ::InvalidateRect(m_hWnd, lpRect, bErase);
932 }
933
934 void InvalidateRgn(HRGN hRgn, BOOL bErase = TRUE)
935 {
937 ::InvalidateRgn(m_hWnd, hRgn, bErase);
938 }
939
940 BOOL IsChild(const HWND hWnd) const
941 {
943 return ::IsChild(m_hWnd, hWnd);
944 }
945
947 {
949 return ::IsDialogMessage(m_hWnd, lpMsg);
950 }
951
952 UINT IsDlgButtonChecked(int nIDButton) const
953 {
955 return ::IsDlgButtonChecked(m_hWnd, nIDButton);
956 }
957
959 {
961 return ::IsIconic(m_hWnd);
962 }
963
965 {
967 TCHAR pszType[10]; // Use sizeof("#32770")+3 so that extra characters can be detected.
968 if (!RealGetWindowClass(::GetParent(m_hWnd), pszType, _countof(pszType)))
969 return FALSE;
970 return !_tcscmp(pszType, _T("#32770"));
971 }
972
974 {
975 return ::IsWindow(m_hWnd);
976 }
977
979 {
981 return ::IsWindowEnabled(m_hWnd);
982 }
983
985 {
987 return ::IsWindowVisible(m_hWnd);
988 }
989
991 {
993 return ::IsWindowUnicode(m_hWnd);
994 }
995
997 {
999 return ::IsZoomed(m_hWnd);
1000 }
1001
1003 {
1005 return ::KillTimer(m_hWnd, nIDEvent);
1006 }
1007
1009 {
1011 if (bLock)
1012 return ::LockWindowUpdate(m_hWnd);
1013 return ::LockWindowUpdate(NULL);
1014 }
1015
1016 int MapWindowPoints(HWND hWndTo, LPPOINT lpPoint, UINT nCount) const
1017 {
1019 return ::MapWindowPoints(m_hWnd, hWndTo, lpPoint, nCount);
1020 }
1021
1022 int MapWindowPoints(HWND hWndTo, LPRECT lpRect) const
1023 {
1025 return ::MapWindowPoints(m_hWnd, hWndTo, (LPPOINT)lpRect, sizeof(RECT) / sizeof(POINT));
1026 }
1027
1028 int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK)
1029 {
1031 return ::MessageBox(m_hWnd, lpszText, lpszCaption, nType);
1032 }
1033
1034 BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0)
1035 {
1038 if (nFlags != 0)
1039 return ::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, nFlags | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
1040 return TRUE;
1041 }
1042
1043 BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0)
1044 {
1047 if (nFlags != 0)
1048 return ::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, nFlags | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
1049 return TRUE;
1050 }
1051
1052 BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE)
1053 {
1055 return ::MoveWindow(m_hWnd, x, y, nWidth, nHeight, bRepaint);
1056 }
1057
1058 void NextDlgCtrl() const
1059 {
1062 }
1063
1065 {
1067 return ::OpenClipboard(m_hWnd);
1068 }
1069
1071 {
1073 return ::PostMessage(m_hWnd, message, wParam, lParam);
1074 }
1075
1076 void PrevDlgCtrl() const
1077 {
1080 }
1081
1083 {
1086 }
1087
1089 {
1092 }
1093
1095 {
1097 return ::RedrawWindow(m_hWnd, lpRectUpdate, hRgnUpdate, flags);
1098 }
1099
1101 {
1103 return ::ReleaseDC(m_hWnd, hDC);
1104 }
1105
1106 BOOL ResizeClient(int nWidth, int nHeight, BOOL bRedraw = FALSE)
1107 {
1109 RECT clientRect, wndRect;
1110 ::GetClientRect(m_hWnd, &clientRect);
1111 ::GetWindowRect(m_hWnd, &wndRect);
1112 return ::MoveWindow(m_hWnd, wndRect.left, wndRect.top,
1113 nWidth + (wndRect.right - wndRect.left) - (clientRect.right - clientRect.left),
1114 nHeight + (wndRect.bottom - wndRect.top) - (clientRect.bottom - clientRect.top),
1115 bRedraw);
1116 }
1117
1119 {
1121 return ::ScreenToClient(m_hWnd, lpPoint);
1122 }
1123
1124 BOOL ScrollWindow(int xAmount, int yAmount, LPCRECT lpRect = NULL, LPCRECT lpClipRect = NULL)
1125 {
1127 return ::ScrollWindow(m_hWnd, xAmount, yAmount, lpRect, lpClipRect);
1128 }
1129
1130 int ScrollWindowEx(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate, UINT flags)
1131 {
1133 return ::ScrollWindowEx(m_hWnd, dx, dy, lpRectScroll, lpRectClip, hRgnUpdate, lpRectUpdate, flags);
1134 }
1135
1137 {
1139 return ::SendDlgItemMessage(m_hWnd, nID, message, wParam, lParam);
1140 }
1141
1143 {
1145 return ::SendMessage(m_hWnd, message, wParam, lParam);
1146 }
1147
1149 {
1151 return ::SendMessage(hWnd, message, wParam, lParam);
1152 }
1153
1154private:
1156 {
1158 return TRUE;
1159 }
1160
1162 {
1165 return TRUE;
1166 }
1167
1168public:
1170 {
1172 MSG msg;
1173 msg.message = message;
1174 msg.wParam = wParam;
1175 msg.lParam = lParam;
1176 if (bDeep)
1178 else
1179 ::EnumChildWindows(m_hWnd, &SendMessageToDescendantsCallbackDeep, (LPARAM)&msg);
1180 }
1181
1183 {
1185 return ::SendNotifyMessage(m_hWnd, message, wParam, lParam);
1186 }
1187
1189 {
1191 return ::SetActiveWindow(m_hWnd);
1192 }
1193
1195 {
1197 return ::SetCapture(m_hWnd);
1198 }
1199
1201 {
1203 return ::SetClipboardViewer(m_hWnd);
1204 }
1205
1206 int SetDlgCtrlID(int nID)
1207 {
1209 return ::SetWindowLong(m_hWnd, GWL_ID, nID);
1210 }
1211
1212 BOOL SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE)
1213 {
1215 return ::SetDlgItemInt(m_hWnd, nID, nValue, bSigned);
1216 }
1217
1218 BOOL SetDlgItemText(int nID, LPCTSTR lpszString)
1219 {
1221 return ::SetDlgItemText(m_hWnd, nID, lpszString);
1222 }
1223
1225 {
1227 return ::SetFocus(m_hWnd);
1228 }
1229
1230 void SetFont(HFONT hFont, BOOL bRedraw = TRUE)
1231 {
1234 }
1235
1236 int SetHotKey(WORD wVirtualKeyCode, WORD wModifiers)
1237 {
1239 return (int)::SendMessage(m_hWnd, WM_SETHOTKEY, MAKEWORD(wVirtualKeyCode, wModifiers), 0);
1240 }
1241
1243 {
1245 return (HICON)::SendMessage(m_hWnd, WM_SETICON, (WPARAM)bBigIcon, (LPARAM)hIcon);
1246 }
1247
1249 {
1251 return ::SetMenu(m_hWnd, hMenu);
1252 }
1253
1254 HWND SetParent(HWND hWndNewParent)
1255 {
1257 return ::SetParent(m_hWnd, hWndNewParent);
1258 }
1259
1260 void SetRedraw(BOOL bRedraw = TRUE)
1261 {
1263 ::SendMessage(m_hWnd, WM_SETREDRAW, (WPARAM)bRedraw, 0);
1264 }
1265
1266 int SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
1267 {
1269 return ::SetScrollInfo(m_hWnd, nBar, lpScrollInfo, bRedraw);
1270 }
1271
1272 int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE)
1273 {
1275 return ::SetScrollPos(m_hWnd, nBar, nPos, bRedraw);
1276 }
1277
1278 BOOL SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
1279 {
1281 return ::SetScrollRange(m_hWnd, nBar, nMinPos, nMaxPos, bRedraw);
1282 }
1283
1284 UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void (CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD) = NULL)
1285 {
1287 return ::SetTimer(m_hWnd, nIDEvent, nElapse, reinterpret_cast<TIMERPROC>(lpfnTimer));
1288 }
1289
1291 {
1293 return ::SetWindowContextHelpId(m_hWnd, dwContextHelpId);
1294 }
1295
1296 LONG SetWindowLong(int nIndex, LONG dwNewLong)
1297 {
1299 return ::SetWindowLong(m_hWnd, nIndex, dwNewLong);
1300 }
1301
1302 LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong)
1303 {
1305 return ::SetWindowLongPtr(m_hWnd, nIndex, dwNewLong);
1306 }
1307
1309 {
1311 return ::SetWindowPlacement(m_hWnd, lpwndpl);
1312 }
1313
1314 BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
1315 {
1317 return ::SetWindowPos(m_hWnd, hWndInsertAfter, x, y, cx, cy, nFlags);
1318 }
1319
1320 int SetWindowRgn(HRGN hRgn, BOOL bRedraw = FALSE)
1321 {
1323 return ::SetWindowRgn(m_hWnd, hRgn, bRedraw);
1324 }
1325
1327 {
1329 return ::SetWindowText(m_hWnd, lpszString);
1330 }
1331
1332 WORD SetWindowWord(int nIndex, WORD wNewWord)
1333 {
1335 if (nIndex >= -4)
1336 return ::SetWindowLong(m_hWnd, nIndex - 2, MAKELONG(LOWORD(::GetWindowLong(m_hWnd, nIndex - 2)), wNewWord));
1337 else
1338 return ::SetWindowLong(m_hWnd, nIndex, MAKELONG(wNewWord, HIWORD(::GetWindowLong(m_hWnd, nIndex))));
1339 }
1340
1342 {
1344 return ::ShowCaret(m_hWnd);
1345 }
1346
1348 {
1350 return ::ShowOwnedPopups(m_hWnd, bShow);
1351 }
1352
1354 {
1356 return ::ShowScrollBar(m_hWnd, nBar, bShow);
1357 }
1358
1359 BOOL ShowWindow(int nCmdShow)
1360 {
1362 return ::ShowWindow(m_hWnd, nCmdShow);
1363 }
1364
1365 BOOL ShowWindowAsync(int nCmdShow)
1366 {
1368 return ::ShowWindowAsync(m_hWnd, nCmdShow);
1369 }
1370
1372 {
1374 return ::UpdateWindow(m_hWnd);
1375 }
1376
1378 {
1380 return ::ValidateRect(m_hWnd, lpRect);
1381 }
1382
1384 {
1386 return ::ValidateRgn(m_hWnd, hRgn);
1387 }
1388
1390 {
1392 return ::WinHelp(m_hWnd, lpszHelp, nCmd, dwData);
1393 }
1394};
1395
1397
1398template <class TBase = CWindow>
1399class CWindowImplRoot : public TBase, public CMessageMap
1400{
1401public:
1402 enum { WINSTATE_DESTROYED = 0x00000001 };
1403
1404public:
1408
1411 , m_dwState(0)
1412 {
1413 }
1414
1416 {
1417 }
1418};
1419
1420
1421template <class TBase = CWindow>
1423{
1424public:
1425 // + Hacks for gcc
1427 // - Hacks for gcc
1428
1430 {
1431 }
1433 {
1434 return DialogProc;
1435 }
1436
1438 {
1440 DLGPROC newDlgProc;
1441 DLGPROC GCCU(pOldProc);
1442
1443 pThis = reinterpret_cast<CDialogImplBaseT<TBase>*>(_AtlWinModule.ExtractCreateWndData());
1444 ATLASSERT(pThis != NULL);
1445 if (pThis == NULL)
1446 return 0;
1447
1448 pThis->m_thunk.Init((WNDPROC)pThis->GetDialogProc(), pThis);
1449 newDlgProc = reinterpret_cast<DLGPROC>(pThis->m_thunk.GetWNDPROC());
1450 pOldProc = reinterpret_cast<DLGPROC>(::SetWindowLongPtr(hWnd, DWLP_DLGPROC, reinterpret_cast<LONG_PTR>(newDlgProc)));
1451 Unused(pOldProc); // TODO: should generate trace message if overwriting another subclass
1452 pThis->m_hWnd = hWnd;
1453 return newDlgProc(hWnd, uMsg, wParam, lParam);
1454 }
1455
1457 {
1458 CDialogImplBaseT<TBase>* pThis = reinterpret_cast<CDialogImplBaseT<TBase>*>(hWnd);
1459 _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
1460 LRESULT lResult = 0;
1461 const _ATL_MSG *previousMessage;
1462 BOOL handled;
1463
1464 hWnd = pThis->m_hWnd;
1465 previousMessage = pThis->m_pCurrentMsg;
1466 pThis->m_pCurrentMsg = &msg;
1467
1468 handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
1469 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1470
1471 if (handled)
1472 {
1473 if ((pThis->m_dwState & WINSTATE_DESTROYED) == 0)
1474 {
1475 ::SetWindowLongPtr(pThis->m_hWnd, DWLP_MSGRESULT, lResult);
1476 }
1477 }
1478 else
1479 {
1480 if (uMsg == WM_NCDESTROY)
1481 {
1482 pThis->m_dwState |= WINSTATE_DESTROYED;
1483 }
1484 }
1485
1486 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1487 pThis->m_pCurrentMsg = previousMessage;
1488
1489 if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 0)
1490 {
1491 pThis->m_dwState &= ~WINSTATE_DESTROYED;
1492 pThis->m_hWnd = NULL;
1493 pThis->OnFinalMessage(hWnd);
1494 }
1495 return lResult;
1496 }
1497
1498 virtual void OnFinalMessage(HWND)
1499 {
1500 }
1501};
1502
1503
1504template <class T, class TBase = CWindow>
1505class CDialogImpl : public CDialogImplBaseT<TBase>
1506{
1507public:
1508 // + Hacks for gcc
1509 using CWindowImplRoot<TBase>::m_thunk;
1510 using CWindowImplRoot<TBase>::m_hWnd;
1511 // - Hacks for gcc
1512
1514 {
1515 BOOL result;
1516 HWND hWnd;
1517 T* pImpl;
1518
1520 if (result == FALSE)
1521 return NULL;
1522
1523 _AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
1524
1525 pImpl = static_cast<T*>(this);
1526 hWnd = ::CreateDialogParam(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(pImpl->IDD), hWndParent, T::StartDialogProc, dwInitParam);
1527 return hWnd;
1528 }
1529
1531 {
1532 BOOL result;
1533 T* pImpl;
1534
1536 if (result == FALSE)
1537 return -1;
1538
1539 _AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
1540
1541 pImpl = static_cast<T*>(this);
1542 return ::DialogBoxParam(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(pImpl->IDD), hWndParent, T::StartDialogProc, dwInitParam);
1543 }
1544
1545 BOOL EndDialog(_In_ int nRetCode)
1546 {
1547 return ::EndDialog(m_hWnd, nRetCode);
1548 }
1549
1551 {
1552 return ::DestroyWindow(m_hWnd);
1553 }
1554};
1555
1556template <class TBase = CWindow, class TWinTraits = CControlWinTraits>
1558{
1559public:
1560 // + Hacks for gcc
1562 using CWindowImplRoot<TBase>::m_thunk;
1563 using CWindowImplRoot<TBase>::m_hWnd;
1564 // - Hacks for gcc
1565
1567
1568public:
1570 {
1572 }
1573
1574 virtual void OnFinalMessage(HWND /* hWnd */)
1575 {
1576 }
1577
1579 {
1580 ATLASSERT(m_hWnd == NULL);
1582
1584 pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(this);
1585
1587 if (result == FALSE)
1588 return FALSE;
1589
1590 WNDPROC newWindowProc = m_thunk.GetWNDPROC();
1591 WNDPROC oldWindowProc = reinterpret_cast<WNDPROC>(
1592 ::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(newWindowProc)));
1593 if (oldWindowProc == NULL)
1594 return FALSE;
1595
1596 pThis->m_pfnSuperWindowProc = oldWindowProc;
1597 pThis->m_hWnd = hWnd;
1598 return TRUE;
1599 }
1600
1602 {
1603 ATLASSERT(m_hWnd != NULL);
1605
1607 pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(this);
1608
1609 HWND hwndOld = pThis->m_hWnd;
1610 WNDPROC oldWindowProc = m_thunk.GetWNDPROC();
1611 WNDPROC subclassedProc = reinterpret_cast<WNDPROC>(
1613 if (!bForce && oldWindowProc != subclassedProc)
1614 return NULL;
1615
1619 pThis->m_hWnd = NULL;
1620 return hwndOld;
1621 }
1622
1624 {
1625 return WindowProc;
1626 }
1627
1628 static DWORD GetWndStyle(DWORD dwStyle)
1629 {
1630 return TWinTraits::GetWndStyle(dwStyle);
1631 }
1632
1633 static DWORD GetWndExStyle(DWORD dwExStyle)
1634 {
1635 return TWinTraits::GetWndExStyle(dwExStyle);
1636 }
1637
1639 {
1641 pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(this);
1642 return ::CallWindowProc(m_pfnSuperWindowProc, pThis->m_hWnd, uMsg, wParam, lParam);
1643 }
1644
1646 {
1648 WNDPROC newWindowProc;
1649 WNDPROC GCCU(pOldProc);
1650
1651 pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(_AtlWinModule.ExtractCreateWndData());
1652 ATLASSERT(pThis != NULL);
1653 if (pThis == NULL)
1654 return 0;
1655
1656 pThis->m_thunk.Init(pThis->GetWindowProc(), pThis);
1657 newWindowProc = pThis->m_thunk.GetWNDPROC();
1658 pOldProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(newWindowProc)));
1659 Unused(pOldProc); // TODO: should generate trace message if overwriting another subclass
1660 pThis->m_hWnd = hWnd;
1661 return newWindowProc(hWnd, uMsg, wParam, lParam);
1662 }
1663
1665 {
1667 _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
1668 LRESULT lResult;
1669 const _ATL_MSG *previousMessage;
1670 BOOL handled;
1671 LONG_PTR saveWindowProc;
1672
1673 ATLASSERT(pThis != NULL);
1674 if (pThis == NULL)
1675 return 0;
1676
1677 ATLASSERT((pThis->m_dwState & WINSTATE_DESTROYED) == 0);
1678 ATLASSERT(pThis->m_hWnd != NULL);
1679 if ((pThis->m_dwState & WINSTATE_DESTROYED) != 0 || pThis->m_hWnd == NULL)
1680 return 0;
1681
1682 hWnd = pThis->m_hWnd;
1683 previousMessage = pThis->m_pCurrentMsg;
1684 pThis->m_pCurrentMsg = &msg;
1685
1686 handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
1687 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1688
1689 if (handled == FALSE)
1690 {
1691 if (uMsg == WM_NCDESTROY)
1692 {
1693 saveWindowProc = ::GetWindowLongPtr(hWnd, GWLP_WNDPROC);
1694 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1695 if (pThis->m_pfnSuperWindowProc != ::DefWindowProc && saveWindowProc == ::GetWindowLongPtr(hWnd, GWLP_WNDPROC))
1697 pThis->m_dwState |= WINSTATE_DESTROYED;
1698 }
1699 else
1700 {
1701 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1702 }
1703 }
1704 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1705 pThis->m_pCurrentMsg = previousMessage;
1706 if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 0)
1707 {
1708 pThis->m_dwState &= ~WINSTATE_DESTROYED;
1709 pThis->m_hWnd = NULL;
1710 pThis->OnFinalMessage(hWnd);
1711 }
1712 return lResult;
1713 }
1714
1715 HWND Create(HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle,
1716 _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam)
1717 {
1718 HWND hWnd;
1719
1720 ATLASSERT(m_hWnd == NULL);
1721 ATLASSERT(atom != 0);
1722 if (atom == 0)
1723 return NULL;
1724 if (m_thunk.Init(NULL, NULL) == FALSE)
1725 {
1727 return NULL;
1728 }
1729
1730 _AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
1731 if (MenuOrID.m_hMenu == NULL && (dwStyle & WS_CHILD) != 0)
1732 MenuOrID.m_hMenu = (HMENU)(UINT_PTR)this;
1733 if (rect.m_lpRect == NULL)
1734 rect.m_lpRect = &TBase::rcDefault;
1735
1736 hWnd = ::CreateWindowEx(dwExStyle, MAKEINTATOM(atom), szWindowName, dwStyle, rect.m_lpRect->left,
1737 rect.m_lpRect->top, rect.m_lpRect->right - rect.m_lpRect->left, rect.m_lpRect->bottom - rect.m_lpRect->top,
1738 hWndParent, MenuOrID.m_hMenu, _AtlBaseModule.GetModuleInstance(), lpCreateParam);
1739
1740 ATLASSERT(m_hWnd == hWnd);
1741
1742 return hWnd;
1743 }
1744};
1745
1746
1747template <class T, class TBase = CWindow, class TWinTraits = CControlWinTraits>
1748class CWindowImpl : public CWindowImplBaseT<TBase, TWinTraits>
1749{
1750public:
1751 // + Hacks for gcc
1752 using CWindowImplRoot<TBase>::m_hWnd;
1753 // - Hacks for gcc
1754
1756 {
1757 return NULL;
1758 }
1759
1760 HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0,
1761 DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
1762 {
1764 ATOM atom;
1765
1766 ATLASSERT(m_hWnd == NULL);
1767 pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(this);
1768
1769 if (T::GetWndClassInfo().m_lpszOrigName == NULL)
1770 T::GetWndClassInfo().m_lpszOrigName = pThis->GetWndClassName();
1771 atom = T::GetWndClassInfo().Register(&pThis->m_pfnSuperWindowProc);
1772
1773 if (szWindowName == NULL)
1774 szWindowName = T::GetWndCaption();
1775 dwStyle = T::GetWndStyle(dwStyle);
1776 dwExStyle = T::GetWndExStyle(dwExStyle);
1777
1778 return CWindowImplBaseT<TBase, TWinTraits>::Create(hWndParent, rect, szWindowName, dwStyle,
1779 dwExStyle, MenuOrID, atom, lpCreateParam);
1780 }
1781};
1782
1783template <class TBase = CWindow, class TWinTraits = CControlWinTraits>
1784class CContainedWindowT : public TBase
1785{
1786public:
1787 // + Hacks for gcc
1788 using TBase::m_hWnd;
1789 // - Hacks for gcc
1790
1797
1798public:
1800 {
1801 m_lpszClassName = TBase::GetWndClassName();
1804 m_dwMsgMapID = dwMsgMapID;
1806 }
1807
1808 CContainedWindowT(LPCTSTR lpszClassName, CMessageMap *pObject, DWORD dwMsgMapID = 0)
1809 {
1810 m_lpszClassName = lpszClassName;
1813 m_dwMsgMapID = dwMsgMapID;
1815 }
1816
1818 {
1819 return ::CallWindowProc(m_pfnSuperWindowProc, this->m_hWnd, uMsg, wParam, lParam);
1820 }
1821
1823 {
1824 ATLASSERT(m_hWnd == NULL);
1826
1828 pThis = reinterpret_cast<CContainedWindowT<TBase>*>(this);
1829
1830 BOOL result = m_thunk.Init(WindowProc, pThis);
1831 if (result == FALSE)
1832 return FALSE;
1833
1834 WNDPROC newWindowProc = m_thunk.GetWNDPROC();
1835 WNDPROC oldWindowProc = reinterpret_cast<WNDPROC>(
1836 ::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(newWindowProc)));
1837 if (oldWindowProc == NULL)
1838 return FALSE;
1839
1840 pThis->m_pfnSuperWindowProc = oldWindowProc;
1841 pThis->m_hWnd = hWnd;
1842 return TRUE;
1843 }
1844
1846 {
1847 ATLASSERT(m_hWnd != NULL);
1849
1851 pThis = reinterpret_cast<CContainedWindowT<TBase>*>(this);
1852 HWND hwndOld = pThis->m_hWnd;
1853
1854 WNDPROC subclassedProc = reinterpret_cast<WNDPROC>(
1856 if (!bForce && m_thunk.GetWNDPROC() != subclassedProc)
1857 return NULL;
1858
1862 pThis->m_hWnd = NULL;
1863 return hwndOld;
1864 }
1865
1867 {
1869 WNDPROC newWindowProc;
1870 WNDPROC GCCU(pOldProc);
1871
1872 pThis = reinterpret_cast<CContainedWindowT<TBase>*>(_AtlWinModule.ExtractCreateWndData());
1873 ATLASSERT(pThis != NULL);
1874 if (pThis == NULL)
1875 return 0;
1876 pThis->m_thunk.Init(WindowProc, pThis);
1877 newWindowProc = pThis->m_thunk.GetWNDPROC();
1878 pOldProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(newWindowProc)));
1879 Unused(pOldProc); // TODO: should generate trace message if overwriting another subclass
1880 pThis->m_hWnd = hWnd;
1881 return newWindowProc(hWnd, uMsg, wParam, lParam);
1882 }
1883
1885 {
1886 CContainedWindowT<TBase>* pThis = reinterpret_cast<CContainedWindowT<TBase>*>(hWnd);
1887 _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
1888 LRESULT lResult;
1889 const _ATL_MSG *previousMessage;
1890 BOOL handled;
1891 LONG_PTR saveWindowProc;
1892
1893 ATLASSERT(pThis != NULL && pThis->m_hWnd != NULL && pThis->m_pObject != NULL);
1894 if (pThis == NULL || pThis->m_hWnd == NULL || pThis->m_pObject == NULL)
1895 return 0;
1896
1897 hWnd = pThis->m_hWnd;
1898 previousMessage = pThis->m_pCurrentMsg;
1899 pThis->m_pCurrentMsg = &msg;
1900
1901 handled = pThis->m_pObject->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, pThis->m_dwMsgMapID);
1902 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1903
1904 pThis->m_pCurrentMsg = previousMessage;
1905 if (handled == FALSE)
1906 {
1907 if (uMsg == WM_NCDESTROY)
1908 {
1909 saveWindowProc = ::GetWindowLongPtr(hWnd, GWLP_WNDPROC);
1910 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1911 if (pThis->m_pfnSuperWindowProc != ::DefWindowProc && saveWindowProc == ::GetWindowLongPtr(hWnd, GWLP_WNDPROC))
1913 pThis->m_hWnd = NULL;
1914 }
1915 else
1916 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1917 }
1918 return lResult;
1919 }
1920
1921};
1923
1924#define BEGIN_MSG_MAP(theClass) \
1925public: \
1926 BOOL ProcessWindowMessage(HWND GCCU(hWnd), UINT GCCU(uMsg), WPARAM GCCU(wParam), LPARAM GCCU(lParam), LRESULT &GCCU(lResult), DWORD dwMsgMapID = 0) \
1927 { \
1928 BOOL GCCU(bHandled) = TRUE; \
1929 Unused(hWnd); \
1930 Unused(uMsg); \
1931 Unused(wParam); \
1932 Unused(lParam); \
1933 Unused(lResult); \
1934 Unused(bHandled); \
1935 switch(dwMsgMapID) \
1936 { \
1937 case 0:
1938
1939#define ALT_MSG_MAP(map) \
1940 break; \
1941 case map:
1942
1943#define END_MSG_MAP() \
1944 break; \
1945 default: \
1946 ATLASSERT(FALSE); \
1947 break; \
1948 } \
1949 return FALSE; \
1950 }
1951
1952#define MESSAGE_HANDLER(msg, func) \
1953 if (uMsg == msg) \
1954 { \
1955 bHandled = TRUE; \
1956 lResult = func(uMsg, wParam, lParam, bHandled); \
1957 if (bHandled) \
1958 return TRUE; \
1959 }
1960
1961#define MESSAGE_RANGE_HANDLER(msgFirst, msgLast, func) \
1962 if (uMsg >= msgFirst && uMsg <= msgLast) \
1963 { \
1964 bHandled = TRUE; \
1965 lResult = func(uMsg, wParam, lParam, bHandled); \
1966 if (bHandled) \
1967 return TRUE; \
1968 }
1969
1970#define COMMAND_HANDLER(id, code, func) \
1971 if (uMsg == WM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \
1972 { \
1973 bHandled = TRUE; \
1974 lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \
1975 if (bHandled) \
1976 return TRUE; \
1977 }
1978
1979#define COMMAND_ID_HANDLER(id, func) \
1980 if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \
1981 { \
1982 bHandled = TRUE; \
1983 lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \
1984 if (bHandled) \
1985 return TRUE; \
1986 }
1987
1988#define COMMAND_CODE_HANDLER(code, func) \
1989 if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \
1990 { \
1991 bHandled = TRUE; \
1992 lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \
1993 if (bHandled) \
1994 return TRUE; \
1995 }
1996
1997#define COMMAND_RANGE_HANDLER(idFirst, idLast, func) \
1998 if (uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
1999 { \
2000 bHandled = TRUE; \
2001 lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \
2002 if (bHandled) \
2003 return TRUE; \
2004 }
2005
2006#define NOTIFY_CODE_HANDLER(cd, func) \
2007 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
2008 { \
2009 bHandled = TRUE; \
2010 lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \
2011 if (bHandled) \
2012 return TRUE; \
2013 }
2014
2015#define NOTIFY_HANDLER(id, cd, func) \
2016 if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \
2017 { \
2018 bHandled = TRUE; \
2019 lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \
2020 if (bHandled) \
2021 return TRUE; \
2022 }
2023
2024#define CHAIN_MSG_MAP(theChainClass) \
2025 { \
2026 if (theChainClass::ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult)) \
2027 return TRUE; \
2028 }
2029
2030#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \
2031static ATL::CWndClassInfo& GetWndClassInfo() \
2032{ \
2033 static ATL::CWndClassInfo wc = \
2034 { \
2035 { sizeof(WNDCLASSEX), style, StartWindowProc, \
2036 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \
2037 NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \
2038 }; \
2039 return wc; \
2040}
2041
2043{
2050 TCHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2]; // == 4 characters + NULL + number of hexadecimal digits describing a pointer.
2051
2053 {
2054 if (m_wc.hInstance == NULL)
2055 m_wc.hInstance = _AtlBaseModule.GetModuleInstance();
2056 if (m_atom == 0)
2057 {
2058 if (m_bSystemCursor)
2060 else
2061 m_wc.hCursor = ::LoadCursor(_AtlBaseModule.GetResourceInstance(), m_lpszCursorID);
2062
2064 }
2065
2066 return m_atom;
2067 }
2068};
2069
2070}; // namespace ATL
2071
2072#pragma pop_macro("SubclassWindow")
2073
static HDC hDC
Definition: 3dtext.c:33
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
HFONT hFont
Definition: main.c:53
#define U(x)
Definition: wordpad.c:45
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1884
LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1817
CMessageMap * m_pObject
Definition: atlwin.h:1794
WNDPROC m_pfnSuperWindowProc
Definition: atlwin.h:1793
CContainedWindowT(LPCTSTR lpszClassName, CMessageMap *pObject, DWORD dwMsgMapID=0)
Definition: atlwin.h:1808
static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1866
CWndProcThunk m_thunk
Definition: atlwin.h:1791
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1822
LPCTSTR m_lpszClassName
Definition: atlwin.h:1792
HWND UnsubclassWindow(BOOL bForce=FALSE)
Definition: atlwin.h:1845
const _ATL_MSG * m_pCurrentMsg
Definition: atlwin.h:1796
CContainedWindowT(CMessageMap *pObject, DWORD dwMsgMapID=0)
Definition: atlwin.h:1799
static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1456
virtual void OnFinalMessage(HWND)
Definition: atlwin.h:1498
static INT_PTR CALLBACK StartDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1437
virtual ~CDialogImplBaseT()
Definition: atlwin.h:1429
virtual DLGPROC GetDialogProc()
Definition: atlwin.h:1432
BOOL EndDialog(_In_ int nRetCode)
Definition: atlwin.h:1545
BOOL DestroyWindow()
Definition: atlwin.h:1550
HWND Create(HWND hWndParent, LPARAM dwInitParam=0)
Definition: atlwin.h:1513
INT_PTR DoModal(HWND hWndParent=::GetActiveWindow(), LPARAM dwInitParam=0)
Definition: atlwin.h:1530
virtual BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD dwMsgMapID)=0
static DWORD GetWndExStyle(DWORD dwExStyle)
Definition: atlwin.h:104
static DWORD GetWndStyle(DWORD dwStyle)
Definition: atlwin.h:99
static DWORD GetWndExStyle(DWORD dwExStyle)
Definition: atlwin.h:83
static DWORD GetWndStyle(DWORD dwStyle)
Definition: atlwin.h:76
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1578
static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1645
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1664
virtual void OnFinalMessage(HWND)
Definition: atlwin.h:1574
HWND UnsubclassWindow(BOOL bForce=FALSE)
Definition: atlwin.h:1601
static DWORD GetWndExStyle(DWORD dwExStyle)
Definition: atlwin.h:1633
HWND Create(HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam)
Definition: atlwin.h:1715
static DWORD GetWndStyle(DWORD dwStyle)
Definition: atlwin.h:1628
LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1638
virtual WNDPROC GetWindowProc()
Definition: atlwin.h:1623
WNDPROC m_pfnSuperWindowProc
Definition: atlwin.h:1566
const _ATL_MSG * m_pCurrentMsg
Definition: atlwin.h:1406
CWndProcThunk m_thunk
Definition: atlwin.h:1405
virtual ~CWindowImplRoot()
Definition: atlwin.h:1415
HWND Create(HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:1760
static LPCTSTR GetWndCaption()
Definition: atlwin.h:1755
HWND SetParent(HWND hWndNewParent)
Definition: atlwin.h:1254
HWND SetClipboardViewer()
Definition: atlwin.h:1200
DWORD GetWindowContextHelpId() const
Definition: atlwin.h:804
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL)
Definition: atlwin.h:1284
DWORD GetStyle() const
Definition: atlwin.h:750
BOOL IsIconic() const
Definition: atlwin.h:958
BOOL CreateCaret(HBITMAP pBitmap)
Definition: atlwin.h:464
BOOL LockWindowUpdate(BOOL bLock=TRUE)
Definition: atlwin.h:1008
BOOL GetDlgItemText(_In_ int nID, _Inout_ _Outref_result_maybenull_ _Post_z_ BSTR &bstrText) const
Definition: atlwin.h:668
UINT IsDlgButtonChecked(int nIDButton) const
Definition: atlwin.h:952
BOOL ShowWindowAsync(int nCmdShow)
Definition: atlwin.h:1365
void SendMessageToDescendants(UINT message, WPARAM wParam=0, LPARAM lParam=0, BOOL bDeep=TRUE)
Definition: atlwin.h:1169
int ScrollWindowEx(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate, UINT flags)
Definition: atlwin.h:1130
int GetWindowTextLength() const
Definition: atlwin.h:886
BOOL DlgDirSelect(LPTSTR lpString, int nCount, int nIDListBox)
Definition: atlwin.h:518
int GetWindowText(_Out_writes_to_(nMaxCount, return+1) LPTSTR lpszStringBuf, _In_ int nMaxCount) const
Definition: atlwin.h:854
CWindow(HWND hWnd=NULL)
Definition: atlwin.h:303
DWORD GetExStyle() const
Definition: atlwin.h:678
struct ATL::CWindow::_IDHWNDPAIR * PIDHWNDPAIR
WORD SetWindowWord(int nIndex, WORD wNewWord)
Definition: atlwin.h:1332
BOOL SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw=TRUE)
Definition: atlwin.h:1278
BOOL ShowOwnedPopups(BOOL bShow=TRUE)
Definition: atlwin.h:1347
HMENU GetSystemMenu(BOOL bRevert)
Definition: atlwin.h:756
int SetWindowRgn(HRGN hRgn, BOOL bRedraw=FALSE)
Definition: atlwin.h:1320
BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
Definition: atlwin.h:1034
HFONT GetFont() const
Definition: atlwin.h:684
BOOL FlashWindow(BOOL bInvert)
Definition: atlwin.h:561
BOOL ResizeClient(int nWidth, int nHeight, BOOL bRedraw=FALSE)
Definition: atlwin.h:1106
HDC GetDC()
Definition: atlwin.h:573
int GetDlgCtrlID() const
Definition: atlwin.h:619
BOOL CheckDlgButton(int nIDButton, UINT nCheck)
Definition: atlwin.h:395
BOOL SetDlgItemText(int nID, LPCTSTR lpszString)
Definition: atlwin.h:1218
BOOL SetWindowContextHelpId(DWORD dwContextHelpId)
Definition: atlwin.h:1290
BOOL OpenClipboard()
Definition: atlwin.h:1064
HWND GetNextDlgTabItem(HWND hWndCtl, BOOL bPrevious=FALSE) const
Definition: atlwin.h:720
int DlgDirListComboBox(LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath, UINT nFileType)
Definition: atlwin.h:512
int MapWindowPoints(HWND hWndTo, LPRECT lpRect) const
Definition: atlwin.h:1022
HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:443
BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
Definition: atlwin.h:1314
HWND GetLastActivePopup() const
Definition: atlwin.h:702
int DlgDirList(LPTSTR lpPathSpec, int nIDListBox, int nIDStaticPath, UINT nFileType)
Definition: atlwin.h:506
BOOL GetWindowPlacement(WINDOWPLACEMENT *lpwndpl) const
Definition: atlwin.h:828
WORD GetWindowWord(int nIndex) const
Definition: atlwin.h:898
static BOOL CALLBACK SendMessageToDescendantsCallbackDeep(HWND hWnd, LPARAM lParam)
Definition: atlwin.h:1161
HWND ChildWindowFromPoint(POINT point) const
Definition: atlwin.h:407
BOOL BringWindowToTop()
Definition: atlwin.h:335
HWND ChildWindowFromPointEx(POINT point, UINT uFlags) const
Definition: atlwin.h:413
BOOL CenterWindow(HWND hWndCenter=NULL)
Definition: atlwin.h:341
BOOL CheckRadioButton(int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
Definition: atlwin.h:401
int SetHotKey(WORD wVirtualKeyCode, WORD wModifiers)
Definition: atlwin.h:1236
LRESULT SendDlgItemMessage(int nID, UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1136
BOOL ShowScrollBar(UINT nBar, BOOL bShow=TRUE)
Definition: atlwin.h:1353
void EndPaint(LPPAINTSTRUCT lpPaint)
Definition: atlwin.h:555
HWND SetFocus()
Definition: atlwin.h:1224
BOOL DrawMenuBar()
Definition: atlwin.h:537
HWND GetTopWindow() const
Definition: atlwin.h:780
HWND GetTopLevelParent() const
Definition: atlwin.h:762
BOOL ShowCaret()
Definition: atlwin.h:1341
HWND GetDlgItem(_In_ int nID) const
Definition: atlwin.h:631
BOOL DestroyWindow()
Definition: atlwin.h:488
HWND SetActiveWindow()
Definition: atlwin.h:1188
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1142
HDC GetWindowDC()
Definition: atlwin.h:810
int GetWindowRgn(HRGN hRgn)
Definition: atlwin.h:848
BOOL SetDlgItemInt(int nID, UINT nValue, BOOL bSigned=TRUE)
Definition: atlwin.h:1212
DWORD GetWindowThreadID()
Definition: atlwin.h:892
BOOL ScreenToClient(LPPOINT lpPoint) const
Definition: atlwin.h:1118
UINT GetDlgItemText(_In_ int nID, _Out_writes_to_(nMaxCount, return+1) LPTSTR lpStr, _In_ int nMaxCount) const
Definition: atlwin.h:646
HICON SetIcon(HICON hIcon, BOOL bBigIcon=TRUE)
Definition: atlwin.h:1242
HRESULT GetDlgControl(int nID, REFIID iid, void **ppCtrl)
Definition: atlwin.h:613
void SetFont(HFONT hFont, BOOL bRedraw=TRUE)
Definition: atlwin.h:1230
void Print(HDC hDC, DWORD dwFlags) const
Definition: atlwin.h:1082
void SetRedraw(BOOL bRedraw=TRUE)
Definition: atlwin.h:1260
BOOL DlgDirSelectComboBox(LPTSTR lpString, int nCount, int nIDComboBox)
Definition: atlwin.h:524
int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption=NULL, UINT nType=MB_OK)
Definition: atlwin.h:1028
BOOL SendNotifyMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1182
int MapWindowPoints(HWND hWndTo, LPPOINT lpPoint, UINT nCount) const
Definition: atlwin.h:1016
HMENU GetMenu() const
Definition: atlwin.h:708
BOOL SetWindowText(LPCTSTR lpszString)
Definition: atlwin.h:1326
HRESULT GetDlgHost(int nID, REFIID iid, void **ppHost)
Definition: atlwin.h:625
HWND GetTopLevelWindow() const
Definition: atlwin.h:774
HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags)
Definition: atlwin.h:482
BOOL ChangeClipboardChain(HWND hWndNewNext)
Definition: atlwin.h:389
BOOL RedrawWindow(LPCRECT lpRectUpdate=NULL, HRGN hRgnUpdate=NULL, UINT flags=RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE)
Definition: atlwin.h:1094
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:567
HWND Detach()
Definition: atlwin.h:499
BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase=FALSE)
Definition: atlwin.h:786
BOOL GetWindowRect(LPRECT lpRect) const
Definition: atlwin.h:842
HWND GetDescendantWindow(int nID) const
Definition: atlwin.h:603
HWND GetWindow(UINT nCmd) const
Definition: atlwin.h:798
BOOL IsZoomed() const
Definition: atlwin.h:996
BOOL HiliteMenuItem(HMENU hMenu, UINT uHiliteItem, UINT uHilite)
Definition: atlwin.h:916
BOOL SetMenu(HMENU hMenu)
Definition: atlwin.h:1248
static BOOL CALLBACK GetDescendantWindowCallback(HWND hWnd, LPARAM lParam)
Definition: atlwin.h:591
BOOL ScrollWindow(int xAmount, int yAmount, LPCRECT lpRect=NULL, LPCRECT lpClipRect=NULL)
Definition: atlwin.h:1124
BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint=TRUE)
Definition: atlwin.h:1052
BOOL ValidateRect(LPCRECT lpRect)
Definition: atlwin.h:1377
HDC BeginPaint(LPPAINTSTRUCT lpPaint)
Definition: atlwin.h:329
void DragAcceptFiles(BOOL bAccept=TRUE)
Definition: atlwin.h:530
LONG_PTR GetWindowLongPtr(int nIndex) const
Definition: atlwin.h:822
int GetUpdateRgn(HRGN hRgn, BOOL bErase=FALSE)
Definition: atlwin.h:792
BOOL GetScrollPos(int nBar)
Definition: atlwin.h:738
BOOL ClientToScreen(LPRECT lpRect) const
Definition: atlwin.h:425
int SetScrollPos(int nBar, int nPos, BOOL bRedraw=TRUE)
Definition: atlwin.h:1272
BOOL GetWindowText(_Inout_ _Outref_result_maybenull_ _Post_z_ BSTR &bstrText) const
Definition: atlwin.h:872
CWindow GetParent() const
Definition: atlwin.h:726
BOOL KillTimer(UINT_PTR nIDEvent)
Definition: atlwin.h:1002
BOOL EnableScrollBar(UINT uSBFlags, UINT uArrowFlags=ESB_ENABLE_BOTH)
Definition: atlwin.h:543
HWND SetCapture()
Definition: atlwin.h:1194
LONG SetWindowLong(int nIndex, LONG dwNewLong)
Definition: atlwin.h:1296
BOOL HideCaret()
Definition: atlwin.h:910
BOOL SetWindowPlacement(const WINDOWPLACEMENT *lpwndpl)
Definition: atlwin.h:1308
BOOL IsWindowVisible() const
Definition: atlwin.h:984
BOOL UpdateWindow()
Definition: atlwin.h:1371
int ReleaseDC(HDC hDC)
Definition: atlwin.h:1100
void InvalidateRgn(HRGN hRgn, BOOL bErase=TRUE)
Definition: atlwin.h:934
BOOL CreateSolidCaret(int nWidth, int nHeight)
Definition: atlwin.h:476
HWND m_hWnd
Definition: atlwin.h:299
int SetDlgCtrlID(int nID)
Definition: atlwin.h:1206
DWORD GetHotKey() const
Definition: atlwin.h:690
BOOL ShowWindow(int nCmdShow)
Definition: atlwin.h:1359
DWORD GetWindowProcessID()
Definition: atlwin.h:834
BOOL ClientToScreen(LPPOINT lpPoint) const
Definition: atlwin.h:419
static LRESULT SendMessage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1148
UINT ArrangeIconicWindows()
Definition: atlwin.h:318
BOOL IsWindowUnicode()
Definition: atlwin.h:990
BOOL CreateGrayCaret(int nWidth, int nHeight)
Definition: atlwin.h:470
HDC GetDCEx(HRGN hRgnClip, DWORD flags)
Definition: atlwin.h:579
LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong)
Definition: atlwin.h:1302
HICON GetIcon(BOOL bBigIcon=TRUE) const
Definition: atlwin.h:696
void PrintClient(HDC hDC, DWORD dwFlags) const
Definition: atlwin.h:1088
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:928
BOOL IsWindow() const
Definition: atlwin.h:973
LONG GetWindowLong(int nIndex) const
Definition: atlwin.h:816
int SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw=TRUE)
Definition: atlwin.h:1266
struct ATL::CWindow::_IDHWNDPAIR IDHWNDPAIR
static LPCTSTR GetWndClassName()
Definition: atlwin.h:313
BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
Definition: atlwin.h:1043
void Attach(HWND hWndNew)
Definition: atlwin.h:324
BOOL IsWindowEnabled() const
Definition: atlwin.h:978
BOOL PostMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1070
UINT GetDlgItemInt(_In_ int nID, _Out_opt_ BOOL *lpTrans=NULL, _In_ BOOL bSigned=TRUE) const
Definition: atlwin.h:637
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:922
void PrevDlgCtrl() const
Definition: atlwin.h:1076
BOOL WinHelp(LPCTSTR lpszHelp, UINT nCmd=HELP_CONTEXT, DWORD dwData=0)
Definition: atlwin.h:1389
BOOL IsParentDialog()
Definition: atlwin.h:964
static BOOL CALLBACK SendMessageToDescendantsCallback(HWND hWnd, LPARAM lParam)
Definition: atlwin.h:1155
void GotoDlgCtrl(HWND hWndCtrl) const
Definition: atlwin.h:904
BOOL EnableWindow(BOOL bEnable=TRUE)
Definition: atlwin.h:549
BOOL IsChild(const HWND hWnd) const
Definition: atlwin.h:940
static RECT rcDefault
Definition: atlwin.h:300
BOOL GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const
Definition: atlwin.h:744
HWND GetNextDlgGroupItem(HWND hWndCtl, BOOL bPrevious=FALSE) const
Definition: atlwin.h:714
BOOL ValidateRgn(HRGN hRgn)
Definition: atlwin.h:1383
void NextDlgCtrl() const
Definition: atlwin.h:1058
BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo)
Definition: atlwin.h:732
BOOL IsDialogMessage(LPMSG lpMsg)
Definition: atlwin.h:946
WNDPROC GetWNDPROC()
Definition: atlwin.h:284
_AtlCreateWndData cd
Definition: atlwin.h:262
thunkCode * m_pthunk
Definition: atlwin.h:261
BOOL Init(WNDPROC proc, void *pThis)
Definition: atlwin.h:276
HMENU m_hMenu
Definition: atlwin.h:113
_U_MENUorID(UINT nID)
Definition: atlwin.h:120
_U_MENUorID(HMENU hMenu)
Definition: atlwin.h:115
LPRECT m_lpRect
Definition: atlwin.h:129
_U_RECT(LPRECT lpRect)
Definition: atlwin.h:131
_U_RECT(RECT &rc)
Definition: atlwin.h:136
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_FAIL
Definition: ddrawi.h:102
#define DLGPROC
Definition: maze.c:62
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT uFlags
Definition: api.c:59
#define SetLastError(x)
Definition: compat.h:752
OLECHAR * BSTR
Definition: compat.h:2293
#define GetCurrentProcess()
Definition: compat.h:759
HANDLE HWND
Definition: compat.h:19
#define CALLBACK
Definition: compat.h:35
BOOL WINAPI FlushInstructionCache(IN HANDLE hProcess, IN LPCVOID lpBaseAddress, IN SIZE_T nSize)
Definition: proc.c:1358
#define pt(x, y)
Definition: drawing.c:79
#define PtrToUlong(u)
Definition: config.h:107
POINTL point
Definition: edittest.c:50
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
void __declspec(noinline) __cdecl _free_base(void *const block)
Definition: free_base.cpp:98
FxObject * pObject
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: sysinfo.c:13
char TCHAR
Definition: tchar.h:1402
#define _tcscmp
Definition: tchar.h:1424
#define GCCU(x)
Definition: atlwin.h:27
#define Unused(x)
Definition: atlwin.h:28
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
int * LPINT
Definition: minwindef.h:151
__u16 time
Definition: mkdosfs.c:8
unsigned __int64 ULONG64
Definition: imports.h:198
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static HRGN hRgn
Definition: mapping.c:32
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
static MONITORINFO mi
Definition: win.c:9400
static BOOL bInvert
Definition: win.c:60
LPSTR LPTSTR
Definition: ms-dtyp.idl:131
LPCSTR LPCTSTR
Definition: ms-dtyp.idl:130
HICON hIcon
Definition: msconfig.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
Definition: rosdlgs.h:6
CContainedWindowT< CWindow > CContainedWindow
Definition: atlwin.h:1922
_ATL_WNDCLASSINFOW CWndClassInfo
Definition: atlwin.h:70
CWinTraits< WS_OVERLAPPEDWINDOW|WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, WS_EX_MDICHILD > CMDIChildWinTraits
Definition: atlwin.h:93
CWinTraits< WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0 > CControlWinTraits
Definition: atlwin.h:91
CWinTraits< WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE > CFrameWinTraits
Definition: atlwin.h:92
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_
Definition: no_sal2.h:162
#define _Post_z_
Definition: no_sal2.h:508
#define _In_
Definition: no_sal2.h:158
#define _Outref_result_maybenull_
Definition: no_sal2.h:458
#define _Out_writes_to_(s, c)
Definition: no_sal2.h:188
#define MEM_RELEASE
Definition: nt_native.h:1319
#define DWORD
Definition: nt_native.h:44
#define MEM_COMMIT
Definition: nt_native.h:1316
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1311
static HANDLE ULONG_PTR dwData
Definition: pipe.c:111
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
int WINAPI SysReAllocStringLen(BSTR *old, const OLECHAR *str, unsigned int len)
Definition: oleaut.c:385
static HANDLE proc()
Definition: pdb.c:32
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define REFIID
Definition: guiddef.h:118
#define CreateWindowEx
Definition: winuser.h:5921
#define WM_GETHOTKEY
Definition: winuser.h:1681
#define GetMonitorInfo
Definition: winuser.h:5957
#define SetWindowLong
Definition: winuser.h:6019
#define RealGetWindowClass
Definition: winuser.h:6001
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define DWLP_DLGPROC
Definition: winuser.h:882
#define WM_SETHOTKEY
Definition: winuser.h:1680
#define GWL_ID
Definition: winuser.h:870
#define GetDlgItemText
Definition: winuser.h:5951
#define SWP_NOMOVE
Definition: winuser.h:1255
#define CreateDialogParam
Definition: winuser.h:5918
#define SWP_NOSIZE
Definition: winuser.h:1256
#define RDW_UPDATENOW
Definition: winuser.h:1231
#define RDW_ERASE
Definition: winuser.h:1222
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define WM_GETFONT
Definition: winuser.h:1679
#define WM_NEXTDLGCTL
Definition: winuser.h:1671
#define HELP_CONTEXT
Definition: winuser.h:2442
#define RegisterClassEx
Definition: winuser.h:6003
_In_ int nMaxCount
Definition: winuser.h:5034
#define WM_SETFONT
Definition: winuser.h:1678
#define SendMessage
Definition: winuser.h:6009
#define LoadCursor
Definition: winuser.h:5978
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define GetWindowLong
Definition: winuser.h:5962
#define MB_OK
Definition: winuser.h:801
#define GetWindowText
Definition: winuser.h:5964
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_NCDESTROY
Definition: winuser.h:1712
#define DWLP_MSGRESULT
Definition: winuser.h:881
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
#define SWP_NOZORDER
Definition: winuser.h:1258
#define WM_PRINT
Definition: winuser.h:1908
VOID(CALLBACK * TIMERPROC)(HWND, UINT, UINT_PTR, DWORD)
Definition: winuser.h:3005
#define GWL_STYLE
Definition: winuser.h:863
#define ESB_ENABLE_BOTH
Definition: winuser.h:563
#define RDW_INVALIDATE
Definition: winuser.h:1225
#define GWL_EXSTYLE
Definition: winuser.h:862
#define WM_SETREDRAW
Definition: winuser.h:1644
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define DefWindowProc
Definition: ros2win.h:31
#define T(num)
Definition: thunks.c:311
#define _countof(array)
Definition: sndvol32.h:70
_ATL_MSG(HWND hWnd, UINT uMsg, WPARAM wParamIn, LPARAM lParamIn, BOOL bHandledIn=TRUE)
Definition: atlwin.h:147
BOOL bHandled
Definition: atlwin.h:145
TCHAR m_szAutoName[sizeof("ATL:")+sizeof(void *) *2]
Definition: atlwin.h:2050
ATOM Register(WNDPROC *p)
Definition: atlwin.h:2052
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
HINSTANCE hInstance
Definition: winuser.h:3314
HCURSOR hCursor
Definition: winuser.h:3316
Definition: tftpd.h:60
DWORD cbSize
Definition: winuser.h:3892
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT_PTR
Definition: typedefs.h:64
#define MAKEWORD(a, b)
Definition: typedefs.h:248
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
#define _T(x)
Definition: vfdio.h:22
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:119
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
#define success(from, fromstr, to, tostr)
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define MAKEINTATOM(i)
Definition: winbase.h:1196
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
_In_ BOOL bEnable
Definition: winddi.h:3426
unsigned char BYTE
Definition: xxhash.c:193