ReactOS 0.4.15-dev-7924-g5949c20
SHAppBarMessage.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: Test for SHAppBarMessage
5 * COPYRIGHT: Copyright 2020 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "shelltest.h"
9#include <windowsx.h>
10#include <shlwapi.h>
11#include <stdio.h>
12
13/* Based on https://github.com/katahiromz/AppBarSample */
14
15//#define VERBOSE
16
17#define IDT_AUTOHIDE 1
18#define IDT_AUTOUNHIDE 2
19
20#define ID_ACTION 100
21
22#define APPBAR_CALLBACK (WM_USER + 100)
23
24#define LEFT_DOWN() mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
25#define LEFT_UP() mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
26#define MOVE(x, y) SetCursorPos((x), (y))
27
28static const TCHAR s_szName[] = TEXT("AppBarSample");
30static HWND s_hwnd1 = NULL;
31static HWND s_hwnd2 = NULL;
32
33#ifdef VERBOSE
34static LPCSTR MessageOfAppBar(DWORD dwMessage)
35{
36 static char s_buf[32];
37 switch (dwMessage)
38 {
39 case ABM_NEW: return "ABM_NEW";
40 case ABM_REMOVE: return "ABM_REMOVE";
41 case ABM_QUERYPOS: return "ABM_QUERYPOS";
42 case ABM_SETPOS: return "ABM_SETPOS";
43 case ABM_GETSTATE: return "ABM_GETSTATE";
44 case ABM_GETTASKBARPOS: return "ABM_GETTASKBARPOS";
45 case ABM_ACTIVATE: return "ABM_ACTIVATE";
46 case ABM_GETAUTOHIDEBAR: return "ABM_GETAUTOHIDEBAR";
47 case ABM_SETAUTOHIDEBAR: return "ABM_SETAUTOHIDEBAR";
48 case ABM_WINDOWPOSCHANGED: return "ABM_WINDOWPOSCHANGED";
49 }
50 wsprintfA(s_buf, "%lu", dwMessage);
51 return s_buf;
52}
53
54static UINT WINAPI
55SHAppBarMessageWrap(DWORD dwMessage, PAPPBARDATA pData)
56{
57 trace("SHAppBarMessage entered (dwMessage=%s, rc=(%ld, %ld, %ld, %ld))\n",
58 MessageOfAppBar(dwMessage),
59 pData->rc.left, pData->rc.top, pData->rc.right, pData->rc.bottom);
60 UINT ret = SHAppBarMessage(dwMessage, pData);
61 trace("SHAppBarMessage leaved (dwMessage=%s, rc=(%ld, %ld, %ld, %ld))\n",
62 MessageOfAppBar(dwMessage),
63 pData->rc.left, pData->rc.top, pData->rc.right, pData->rc.bottom);
64 return ret;
65}
66#define SHAppBarMessage SHAppBarMessageWrap
67
68#undef ARRAYSIZE
69#define ARRAYSIZE _countof
70
71void appbar_tprintf(const TCHAR *fmt, ...)
72{
73 TCHAR szText[512];
74 va_list va;
75 va_start(va, fmt);
76 wvsprintf(szText, fmt, va);
77#ifdef UNICODE
78 printf("%ls", szText);
79#else
80 printf("%s", szText);
81#endif
82 va_end(va);
83}
84
85#define MSGDUMP_TPRINTF appbar_tprintf
86#include "msgdump.h"
87
88#endif // def VERBOSE
89
91{
92#define SLIDE_HIDE 400
93#define SLIDE_SHOW 150
94 RECT rcOld, rcNew = *prc;
95 GetWindowRect(hwnd, &rcOld);
96
97 BOOL fShow = (rcNew.bottom - rcNew.top > rcOld.bottom - rcOld.top) ||
98 (rcNew.right - rcNew.left > rcOld.right - rcOld.left);
99
100 INT dx = (rcNew.right - rcOld.right) + (rcNew.left - rcOld.left);
101 INT dy = (rcNew.bottom - rcOld.bottom) + (rcNew.top - rcOld.top);
102
103 LONG dt = SLIDE_HIDE;
104 if (fShow)
105 {
106 dt = SLIDE_SHOW;
107 rcOld = rcNew;
108 OffsetRect(&rcOld, -dx, -dy);
109 SetWindowPos(hwnd, NULL, rcOld.left, rcOld.top,
110 rcOld.right - rcOld.left, rcOld.bottom - rcOld.top,
112 }
113
117
118 LONG t, t0 = GetTickCount();
119 while ((t = GetTickCount()) < t0 + dt)
120 {
121 INT x = rcOld.left + dx * (t - t0) / dt;
122 INT y = rcOld.top + dy * (t - t0) / dt;
124
127 }
128
130 SetWindowPos(hwnd, NULL, rcNew.left, rcNew.top,
131 rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
133#undef SLIDE_HIDE
134#undef SLIDE_SHOW
135}
136
137class Window
138{
139public:
140 Window(INT cx, INT cy, BOOL fAutoHide = FALSE)
141 : m_hwnd(NULL)
142 , m_fAutoHide(fAutoHide)
143 , m_cxWidth(cx)
144 , m_cyHeight(cy)
145 {
146 }
147
148 virtual ~Window()
149 {
150 }
151
153 {
154 WNDCLASS wc;
155 ZeroMemory(&wc, sizeof(wc));
157 wc.hInstance = hInstance;
160 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
162 return !!RegisterClass(&wc);
163 }
164
168 BOOL fAutoHide = FALSE)
169 {
170 Window *this_ = new Window(cx, cy, fAutoHide);
171 HWND hwnd = CreateWindowEx(exstyle, s_szName, pszText, style,
173 NULL, NULL, hInstance, this_);
176 return hwnd;
177 }
178
180 {
181 MSG msg;
182 while (GetMessage(&msg, NULL, 0, 0))
183 {
186 }
187 return (INT)msg.wParam;
188 }
189
191 {
193 }
194
195 virtual LRESULT CALLBACK
197 {
198#ifdef VERBOSE
199 MD_msgdump(hwnd, uMsg, wParam, lParam);
200#endif
201 switch (uMsg)
202 {
218
219 case APPBAR_CALLBACK:
221 break;
222
223 default:
224 return DefWindowProc(hwnd, uMsg, wParam, lParam);
225 }
226 return 0;
227 }
228
229 static LRESULT CALLBACK
231 {
232 Window *this_ = GetAppbarData(hwnd);
233 if (uMsg == WM_CREATE)
234 {
236 this_ = (Window *)pCS->lpCreateParams;
238 }
239 if (this_)
240 return this_->WindowProcDx(hwnd, uMsg, wParam, lParam);
241 return DefWindowProc(hwnd, uMsg, wParam, lParam);
242 }
243
244protected:
260
261 void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
262 {
264 switch (id)
265 {
266 case ID_ACTION:
268 break;
269 case ID_ACTION + 1:
271 if (!hThread)
272 {
273 skip("failed to create thread\n");
276 return;
277 }
279 }
280 }
281
283 {
284 PAINTSTRUCT ps;
285
286 TCHAR szText[64];
287 GetWindowText(hwnd, szText, 64);
288
289 RECT rc;
290 GetClientRect(hwnd, &rc);
291
292 if (HDC hdc = BeginPaint(hwnd, &ps))
293 {
294 DrawText(hdc, szText, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
295 EndPaint(hwnd, &ps);
296 }
297 }
298
299 void OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
300 {
303 }
304
305 void OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
306 {
307 if (vk == VK_ESCAPE)
309 }
310
312 {
313 static HWND s_hwndZOrder = NULL;
314
315 switch (wParam)
316 {
317 case ABN_STATECHANGE:
318 break;
319
321 if (lParam)
322 {
323 s_hwndZOrder = GetWindow(hwnd, GW_HWNDPREV);
324 SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
326 }
327 else
328 {
329 SetWindowPos(hwnd, m_fOnTop ? HWND_TOPMOST : s_hwndZOrder,
330 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
331 s_hwndZOrder = NULL;
332 }
333 break;
334
335 case ABN_POSCHANGED:
336 {
337 APPBARDATA abd = { sizeof(abd) };
338 abd.hWnd = hwnd;
339 AppBar_PosChanged(&abd);
340 }
341 break;
342 }
343 }
344
346 {
347 APPBARDATA abd = { sizeof(abd) };
348 abd.hWnd = hwnd;
350
352 return m_fAppBarRegd;
353 }
354
356 {
357 APPBARDATA abd = { sizeof(abd) };
358 abd.hWnd = hwnd;
359
361 return !m_fAppBarRegd;
362 }
363
365 {
366 if (fHide)
367 return AppBar_AutoHide(hwnd);
368 else
369 return AppBar_NoAutoHide(hwnd);
370 }
371
373 {
374 APPBARDATA abd = { sizeof(abd) };
375 abd.hWnd = hwnd;
376 abd.uEdge = m_uSide;
377
378 HWND hwndAutoHide = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
379 if (hwndAutoHide)
380 return FALSE;
381
382 abd.lParam = TRUE;
384 return FALSE;
385
389
390 RECT rc = m_rcAppBar;
391 switch (m_uSide)
392 {
393 case ABE_TOP:
394 rc.bottom = rc.top + 2;
395 break;
396 case ABE_BOTTOM:
397 rc.top = rc.bottom - 2;
398 break;
399 case ABE_LEFT:
400 rc.right = rc.left + 2;
401 break;
402 case ABE_RIGHT:
403 rc.left = rc.right - 2;
404 break;
405 }
406
407 AppBar_QueryPos(hwnd, &rc);
408 abd.rc = rc;
410 rc = abd.rc;
411
412 m_fHiding = TRUE;
413 SlideWindow(hwnd, &rc);
414
416 return TRUE;
417 }
418
420 {
421 APPBARDATA abd = { sizeof(abd) };
422 abd.hWnd = hwnd;
423 abd.uEdge = m_uSide;
424 HWND hwndAutoHide = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
425 if (hwndAutoHide != hwnd)
426 return FALSE;
427
428 abd.lParam = FALSE;
430 return FALSE;
431
436 return TRUE;
437 }
438
440 {
441 RECT rc;
443
444 BOOL fAutoHide = FALSE;
445 if (m_fAutoHide)
446 {
447 fAutoHide = m_fAutoHide;
451 }
452
453 switch (uSide)
454 {
455 case ABE_TOP:
456 rc.bottom = rc.top + m_cyHeight;
457 break;
458 case ABE_BOTTOM:
459 rc.top = rc.bottom - m_cyHeight;
460 break;
461 case ABE_LEFT:
462 rc.right = rc.left + m_cxWidth;
463 break;
464 case ABE_RIGHT:
465 rc.left = rc.right - m_cxWidth;
466 break;
467 }
468
469 APPBARDATA abd = { sizeof(abd) };
470 abd.hWnd = hwnd;
471 AppBar_QuerySetPos(uSide, &rc, &abd, TRUE);
472
473 if (fAutoHide)
474 {
476 m_fHiding = TRUE;
477
481 }
482
483 return TRUE;
484 }
485
487 {
489 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
490 m_fOnTop = fOnTop;
491 }
492
494 {
495 if (!m_fAutoHide)
496 return;
497
498 RECT rc = m_rcAppBar;
499 switch (m_uSide)
500 {
501 case ABE_TOP:
502 rc.bottom = rc.top + 2;
503 break;
504 case ABE_BOTTOM:
505 rc.top = rc.bottom - 2;
506 break;
507 case ABE_LEFT:
508 rc.right = rc.left + 2;
509 break;
510 case ABE_RIGHT:
511 rc.left = rc.right - 2;
512 break;
513 }
514
515 m_fHiding = TRUE;
516 SlideWindow(hwnd, &rc);
517 }
518
520 {
523
525 }
526
528 {
529 if (m_fAutoHide)
530 {
532 }
533 }
534
536 {
537 if (m_fAutoHide && m_fHiding)
538 {
540 }
541 }
542
544 {
545 if (m_fAppBarRegd)
546 {
547 APPBARDATA abd = { sizeof(abd) };
548 abd.hWnd = hwnd;
549
550 RECT rc;
551 GetWindowRect(hwnd, &rc);
552 AppBar_QuerySetPos(m_uSide, &rc, &abd, TRUE);
553 }
554 }
555
557 {
558 APPBARDATA abd = { sizeof(abd) };
559 abd.hWnd = hwnd;
560 abd.rc = *lprc;
561 abd.uEdge = m_uSide;
562
563 INT cx = 0, cy = 0;
564 if (ABE_LEFT == abd.uEdge || ABE_RIGHT == abd.uEdge)
565 {
566 cx = abd.rc.right - abd.rc.left;
567 abd.rc.top = 0;
569 }
570 else
571 {
572 cy = abd.rc.bottom - abd.rc.top;
573 abd.rc.left = 0;
575 }
576
578
579 switch (abd.uEdge)
580 {
581 case ABE_LEFT:
582 abd.rc.right = abd.rc.left + cx;
583 break;
584 case ABE_RIGHT:
585 abd.rc.left = abd.rc.right - cx;
586 break;
587 case ABE_TOP:
588 abd.rc.bottom = abd.rc.top + cy;
589 break;
590 case ABE_BOTTOM:
591 abd.rc.top = abd.rc.bottom - cy;
592 break;
593 }
594
595 *lprc = abd.rc;
596 }
597
599 {
600 pabd->rc = *lprc;
601 pabd->uEdge = uEdge;
602 m_uSide = uEdge;
603
604 AppBar_QueryPos(pabd->hWnd, &pabd->rc);
605
607
608 if (fMove)
609 {
610 RECT rc = pabd->rc;
611 MoveWindow(pabd->hWnd, rc.left, rc.top,
612 rc.right - rc.left, rc.bottom - rc.top, TRUE);
613 }
614
615 if (!m_fAutoHide)
616 {
617 m_rcAppBar = pabd->rc;
618 }
619 }
620
622 {
623 RECT rc;
625
626 if (m_fAutoHide)
627 {
628 m_rcAppBar = rc;
629 switch (m_uSide)
630 {
631 case ABE_TOP:
633 break;
634 case ABE_BOTTOM:
636 break;
637 case ABE_LEFT:
639 break;
640 case ABE_RIGHT:
642 break;
643 }
644 }
645
646 RECT rcWindow;
647 GetWindowRect(pabd->hWnd, &rcWindow);
648 INT cx = rcWindow.right - rcWindow.left;
649 INT cy = rcWindow.bottom - rcWindow.top;
650 switch (m_uSide)
651 {
652 case ABE_TOP:
653 rc.bottom = rc.top + cy;
654 break;
655 case ABE_BOTTOM:
656 rc.top = rc.bottom - cy;
657 break;
658 case ABE_LEFT:
659 rc.right = rc.left + cx;
660 break;
661 case ABE_RIGHT:
662 rc.left = rc.right - cx;
663 break;
664 }
665 AppBar_QuerySetPos(m_uSide, &rc, pabd, TRUE);
666 }
667
669 {
670 m_hwnd = hwnd;
671 m_fOnTop = TRUE;
673
679
682
683 return TRUE;
684 }
685
686 void OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
687 {
688 APPBARDATA abd = { sizeof(abd) };
689 abd.hWnd = hwnd;
691
692 switch (state)
693 {
694 case WA_ACTIVE:
695 case WA_CLICKACTIVE:
698 break;
699
700 case WA_INACTIVE:
702 break;
703 }
704 }
705
707 {
708 APPBARDATA abd = { sizeof(abd) };
709 abd.hWnd = hwnd;
711
713 }
714
715 void OnSize(HWND hwnd, UINT state, int cx, int cy)
716 {
717 RECT rcWindow;
718
719 if (m_fMoving || (m_fAutoHide && m_fHiding))
720 return;
721
722 if (!m_fHiding)
723 {
724 if (!m_fAutoHide)
726
727 GetWindowRect(hwnd, &rcWindow);
728 m_rcAppBar = rcWindow;
729
730 if (m_uSide == ABE_TOP || m_uSide == ABE_BOTTOM)
731 {
732 m_cyHeight = m_cySave = rcWindow.bottom - rcWindow.top;
733 }
734 else
735 {
736 m_cxWidth = m_cxSave = rcWindow.right - rcWindow.left;
737 }
738 }
739
741 }
742
743 void OnMove(HWND hwnd, int x, int y)
744 {
745 if (m_fMoving || m_fAutoHide)
746 return;
747
748 if (!m_fHiding)
750 }
751
753 {
755
756 m_hwnd = NULL;
758 delete this;
759 }
760
762 {
763 POINT pt;
764 RECT rc;
765 HWND hwndActive;
766
767 switch (id)
768 {
769 case IDT_AUTOHIDE:
770 if (m_fAutoHide && !m_fHiding && !m_fMoving)
771 {
773 GetWindowRect(hwnd, &rc);
774 hwndActive = GetForegroundWindow();
775
776 if (!PtInRect(&rc, pt) &&
777 hwndActive != hwnd &&
778 hwndActive != NULL &&
779 GetWindowOwner(hwndActive) != hwnd)
780 {
781 KillTimer(hwnd, id);
783 }
784 }
785 break;
786
787 case IDT_AUTOUNHIDE:
788 KillTimer(hwnd, id);
789
790 if (m_fAutoHide && m_fHiding)
791 {
793 GetWindowRect(hwnd, &rc);
794 if (PtInRect(&rc, pt))
795 {
797 }
798 }
799 break;
800 }
801 }
802
804 {
806
808
809 if (m_uSide == ABE_TOP && uHitTest == HTBOTTOM)
810 return HTBOTTOM;
811
812 if (m_uSide == ABE_BOTTOM && uHitTest == HTTOP)
813 return HTTOP;
814
815 if (m_uSide == ABE_LEFT && uHitTest == HTRIGHT)
816 return HTRIGHT;
817
818 if (m_uSide == ABE_RIGHT && uHitTest == HTLEFT)
819 return HTLEFT;
820
821 return HTCLIENT;
822 }
823
824 void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
825 {
826 m_fMoving = TRUE;
830 }
831
832 void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
833 {
834 if (!m_fMoving)
835 return;
836
837 POINT pt;
841 {
843 }
844
845 INT cxScreen = GetSystemMetrics(SM_CXSCREEN);
846 INT cyScreen = GetSystemMetrics(SM_CYSCREEN);
847
848 DWORD dx, dy;
849 UINT ix, iy;
850 if (pt.x < cxScreen / 2)
851 {
852 dx = pt.x;
853 ix = ABE_LEFT;
854 }
855 else
856 {
857 dx = cxScreen - pt.x;
858 ix = ABE_RIGHT;
859 }
860
861 if (pt.y < cyScreen / 2)
862 {
863 dy = pt.y;
864 iy = ABE_TOP;
865 }
866 else
867 {
868 dy = cyScreen - pt.y;
869 iy = ABE_BOTTOM;
870 }
871
872 if (cxScreen * dy > cyScreen * dx)
873 {
874 m_rcDrag.top = 0;
875 m_rcDrag.bottom = cyScreen;
876 if (ix == ABE_LEFT)
877 {
879 m_rcDrag.left = 0;
881 }
882 else
883 {
885 m_rcDrag.right = cxScreen;
887 }
888 }
889 else
890 {
891 m_rcDrag.left = 0;
892 m_rcDrag.right = cxScreen;
893 if (iy == ABE_TOP)
894 {
896 m_rcDrag.top = 0;
898 }
899 else
900 {
902 m_rcDrag.bottom = cyScreen;
904 }
905 }
906
908
909 if (m_bDragged)
910 {
914 TRUE);
915 }
916 }
917
918 void OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags)
919 {
920 if (!m_fMoving)
921 return;
922
923 OnMouseMove(hwnd, x, y, keyFlags);
924
926
928
929 if (m_fAutoHide)
930 {
931 switch (m_uSide)
932 {
933 case ABE_TOP:
935 break;
936 case ABE_BOTTOM:
938 break;
939 case ABE_LEFT:
941 break;
942 case ABE_RIGHT:
944 break;
945 }
946 }
947
948 if (m_bDragged)
949 {
950 if (m_fAutoHide)
951 {
953 }
954 else
955 {
956 APPBARDATA abd = { sizeof(abd) };
957 abd.hWnd = hwnd;
959 }
960 }
961
963 }
964
966 {
967 SystemParametersInfoW(SPI_GETWORKAREA, 0, prc, 0);
968 }
969
970public:
971 void DoAction()
972 {
973#define INTERVAL 250
974 POINT pt;
975 RECT rc1, rc2, rcWork;
977
978 GetWindowRect(s_hwnd1, &rc1);
980 GetWorkArea(&rcWork);
984 ok_long(rc1.bottom, s_rcWorkArea.top + 80);
986 ok_long(rc2.top, s_rcWorkArea.top + 80);
988 ok_long(rc2.bottom, s_rcWorkArea.top + 110);
989 ok_long(rcWork.left, s_rcWorkArea.left);
990 ok_long(rcWork.top, s_rcWorkArea.top + 110);
995
997 GetWorkArea(&rcWork);
1000 ok_long(rc2.right, s_rcWorkArea.right);
1001 ok_long(rc2.bottom, s_rcWorkArea.top + 30);
1002 ok_long(rcWork.left, s_rcWorkArea.left);
1003 ok_long(rcWork.top, s_rcWorkArea.top + 30);
1007 Sleep(INTERVAL);
1008
1010 GetWorkArea(&rcWork);
1013 ok_long(rc2.right, s_rcWorkArea.left + 30);
1014 ok_long(rcWork.left, s_rcWorkArea.left + 30);
1015 ok_long(rcWork.top, s_rcWorkArea.top);
1019 Sleep(INTERVAL);
1020
1022 GetWorkArea(&rcWork);
1025 ok_long(rc2.right, s_rcWorkArea.right);
1026 ok_long(rc2.bottom, s_rcWorkArea.top + 30);
1027 ok_long(rcWork.left, s_rcWorkArea.left);
1028 ok_long(rcWork.top, s_rcWorkArea.top + 30);
1032 Sleep(INTERVAL);
1033
1035 GetWorkArea(&rcWork);
1036 ok_long(rc2.left, s_rcWorkArea.right - 30);
1038 ok_long(rc2.right, s_rcWorkArea.right);
1039 ok_long(rcWork.left, s_rcWorkArea.left);
1040 ok_long(rcWork.top, s_rcWorkArea.top);
1041 ok_long(rcWork.right, s_rcWorkArea.right - 30);
1043 Sleep(INTERVAL);
1044
1046 pt.x = (rc2.left + rc2.right) / 2;
1047 pt.y = (rc2.top + rc2.bottom) / 2;
1048 MOVE(pt.x, pt.y);
1049 LEFT_DOWN();
1050 MOVE(pt.x + 64, pt.y + 64);
1051 Sleep(INTERVAL);
1052
1053 pt.x = s_rcWorkArea.left + 80;
1055 MOVE(pt.x, pt.y);
1056 LEFT_UP();
1057 Sleep(INTERVAL);
1058
1060 GetWorkArea(&rcWork);
1063 ok_long(rc2.right, s_rcWorkArea.left + 30);
1064 ok_long(rcWork.left, s_rcWorkArea.left + 30);
1065 ok_long(rcWork.top, s_rcWorkArea.top);
1068 Sleep(INTERVAL);
1069
1071 pt.x = (rc2.left + rc2.right) / 2;
1072 pt.y = (rc2.top + rc2.bottom) / 2;
1073 MOVE(pt.x, pt.y);
1074 LEFT_DOWN();
1075 MOVE(pt.x + 64, pt.y + 64);
1076 Sleep(INTERVAL);
1077
1078 pt.x = s_rcWorkArea.right - 80;
1080 MOVE(pt.x, pt.y);
1081 LEFT_UP();
1082 Sleep(INTERVAL);
1083
1085 GetWorkArea(&rcWork);
1086 ok_long(rc2.left, s_rcWorkArea.right - 30);
1088 ok_long(rc2.right, s_rcWorkArea.right);
1089 ok_long(rcWork.left, s_rcWorkArea.left);
1090 ok_long(rcWork.top, s_rcWorkArea.top);
1091 ok_long(rcWork.right, s_rcWorkArea.right - 30);
1093 Sleep(INTERVAL);
1094
1096 Sleep(INTERVAL);
1097
1098 GetWorkArea(&rcWork);
1099 ok_long(rcWork.left, s_rcWorkArea.left);
1100 ok_long(rcWork.top, s_rcWorkArea.top);
1103
1104 PostMessage(s_hwnd2, WM_QUIT, 0, 0);
1105 PostThreadMessage(dwTID, WM_QUIT, 0, 0);
1106#undef INTERVAL
1107 }
1108
1110 {
1111 Window *this_ = (Window *)args;
1112 this_->DoAction();
1113 return 0;
1114 }
1115};
1116
1118{
1120
1121 if (!Window::DoRegisterClass(hInstance))
1122 {
1123 skip("Window::DoRegisterClass failed\n");
1124 return;
1125 }
1126
1127 SystemParametersInfo(SPI_GETWORKAREA, 0, &s_rcWorkArea, FALSE);
1128
1129 HWND hwnd1 = Window::DoCreateMainWnd(hInstance, TEXT("Test1"), 80, 80,
1131 if (!hwnd1)
1132 {
1133 skip("CreateWindowExW failed\n");
1134 return;
1135 }
1136
1137 HWND hwnd2 = Window::DoCreateMainWnd(hInstance, TEXT("Test2"), 30, 30,
1139 if (!hwnd2)
1140 {
1141 skip("CreateWindowExW failed\n");
1142 return;
1143 }
1144
1145 s_hwnd1 = hwnd1;
1146 s_hwnd2 = hwnd2;
1147
1148 PostMessage(hwnd1, WM_COMMAND, ID_ACTION, 0);
1149
1150 Window::DoMainLoop();
1151}
#define MOVE(x, y)
#define SLIDE_HIDE
#define LEFT_UP()
static const TCHAR s_szName[]
#define SLIDE_SHOW
#define LEFT_DOWN()
static RECT s_rcWorkArea
void SlideWindow(HWND hwnd, LPRECT prc)
#define IDT_AUTOUNHIDE
#define ID_ACTION
#define INTERVAL
static HWND s_hwnd2
static HWND s_hwnd1
#define IDT_AUTOHIDE
#define APPBAR_CALLBACK
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Arabic default style
Definition: afstyles.h:94
static int state
Definition: maze.c:121
#define ok_long(expression, result)
Definition: atltest.h:133
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR rc2[]
Definition: oid.c:1216
#define CloseHandle
Definition: compat.h:739
HANDLE HWND
Definition: compat.h:19
#define CALLBACK
Definition: compat.h:35
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:700
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
int WINAPI GetThreadPriority(IN HANDLE hThread)
Definition: thread.c:739
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
Definition: appbar.c:65
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:93
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble t
Definition: gl.h:2047
GLbitfield flags
Definition: glext.h:7161
_Check_return_ long __cdecl labs(_In_ long x)
#define TEXT(s)
Definition: k32.h:26
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
WORD vk
Definition: input.c:77
static int priority
Definition: timer.c:163
static __inline LRESULT MSGDUMP_API MD_msgdump(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: msgdump.h:4655
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define BOOL
Definition: nt_native.h:43
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_THICKFRAME
Definition: pedump.c:630
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define DefWindowProc
Definition: ros2win.h:31
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:71
#define ABE_BOTTOM
Definition: shellapi.h:20
#define ABM_GETTASKBARPOS
Definition: shellapi.h:67
#define ABM_GETSTATE
Definition: shellapi.h:66
#define ABM_SETAUTOHIDEBAR
Definition: shellapi.h:70
#define ABE_RIGHT
Definition: shellapi.h:19
#define ABE_TOP
Definition: shellapi.h:18
#define ABN_FULLSCREENAPP
Definition: shellapi.h:74
#define ABM_SETPOS
Definition: shellapi.h:65
#define ABM_ACTIVATE
Definition: shellapi.h:68
#define ABE_LEFT
Definition: shellapi.h:17
#define ABM_REMOVE
Definition: shellapi.h:63
#define ABN_STATECHANGE
Definition: shellapi.h:72
#define ABM_NEW
Definition: shellapi.h:62
#define ABM_GETAUTOHIDEBAR
Definition: shellapi.h:69
#define ABN_POSCHANGED
Definition: shellapi.h:73
#define ABM_QUERYPOS
Definition: shellapi.h:64
Definition: window.c:28
void OnSize(HWND hwnd, UINT state, int cx, int cy)
BOOL m_fAppBarRegd
void AppBar_Size(HWND hwnd)
BOOL AppBar_Register(HWND hwnd)
void AppBar_UnHide(HWND hwnd)
void AppBar_SetAlwaysOnTop(HWND hwnd, BOOL fOnTop)
POINT m_ptDragOn
BOOL AppBar_UnRegister(HWND hwnd)
void AppBar_SetAutoHideTimer(HWND hwnd)
void DoAction()
void OnTimer(HWND hwnd, UINT id)
static DWORD WINAPI ActionThreadFunc(LPVOID args)
void AppBar_QuerySetPos(UINT uEdge, LPRECT lprc, PAPPBARDATA pabd, BOOL fMove)
BOOL AppBar_SetAutoHide(HWND hwnd, BOOL fHide)
virtual ~Window()
UINT OnNCHitTest(HWND hwnd, int x, int y)
void OnMove(HWND hwnd, int x, int y)
void AppBar_PosChanged(PAPPBARDATA pabd)
static Window * GetAppbarData(HWND hwnd)
BOOL m_fAutoHide
void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
static INT DoMainLoop()
BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
void OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags)
void OnAppBarCallback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
void OnNCDestroy(HWND hwnd)
void AppBar_Hide(HWND hwnd)
void GetWorkArea(LPRECT prc) const
BOOL AppBar_SetSide(HWND hwnd, UINT uSide)
BOOL AppBar_NoAutoHide(HWND hwnd)
virtual LRESULT CALLBACK WindowProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
void OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
Window(INT cx, INT cy, BOOL fAutoHide=FALSE)
void OnWindowPosChanged(HWND hwnd, const LPWINDOWPOS lpwpos)
void OnPaint(HWND hwnd)
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
void OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
static BOOL DoRegisterClass(HINSTANCE hInstance)
void AppBar_QueryPos(HWND hwnd, LPRECT lprc)
static HWND DoCreateMainWnd(HINSTANCE hInstance, LPCTSTR pszText, INT cx, INT cy, DWORD style=WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN, DWORD exstyle=WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW|WS_EX_TOPMOST, BOOL fAutoHide=FALSE)
void OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
BOOL AppBar_AutoHide(HWND hwnd)
void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
void AppBar_SetAutoUnhideTimer(HWND hwnd)
UINT uCallbackMessage
Definition: shellapi.h:219
LPARAM lParam
Definition: shellapi.h:222
HWND hWnd
Definition: shellapi.h:218
UINT uEdge
Definition: shellapi.h:220
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
Definition: match.c:390
Definition: dsound.c:943
LPVOID lpCreateParams
Definition: winuser.h:2940
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_USERDATA
Definition: treelist.c:63
int iy
Definition: tritemp.h:491
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT
Definition: typedefs.h:58
int ret
#define ZeroMemory
Definition: winbase.h:1712
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define GetModuleHandle
Definition: winbase.h:3827
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:277
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, fn)
Definition: windowsx.h:240
#define GetWindowOwner(hwnd)
Definition: windowsx.h:314
#define FORWARD_WM_NCHITTEST(hwnd, x, y, fn)
Definition: windowsx.h:191
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:322
#define SetWindowRedraw(hwnd, fRedraw)
Definition: windowsx.h:534
#define SW_SHOWNORMAL
Definition: winuser.h:770
#define WM_PAINT
Definition: winuser.h:1620
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define CreateWindowEx
Definition: winuser.h:5755
#define WM_CLOSE
Definition: winuser.h:1621
#define SWP_NOACTIVATE
Definition: winuser.h:1242
#define wvsprintf
Definition: winuser.h:5866
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5726
#define SM_CXDRAG
Definition: winuser.h:1028
#define WM_QUIT
Definition: winuser.h:1623
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define SM_CYSCREEN
Definition: winuser.h:960
#define DT_CENTER
Definition: winuser.h:527
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define HWND_TOPMOST
Definition: winuser.h:1208
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_CREATE
Definition: winuser.h:1608
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HTBOTTOM
Definition: winuser.h:2493
#define SWP_DRAWFRAME
Definition: winuser.h:1239
#define WM_SIZE
Definition: winuser.h:1611
#define DT_SINGLELINE
Definition: winuser.h:540
#define SWP_NOMOVE
Definition: winuser.h:1244
#define WM_COMMAND
Definition: winuser.h:1740
#define IDC_ARROW
Definition: winuser.h:687
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2670
#define WM_NCHITTEST
Definition: winuser.h:1686
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SWP_NOSIZE
Definition: winuser.h:1245
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define RDW_UPDATENOW
Definition: winuser.h:1220
#define WA_INACTIVE
Definition: winuser.h:2622
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define PostThreadMessage
Definition: winuser.h:5833
int WINAPIV wsprintfA(_Out_ LPSTR, _In_ _Printf_format_string_ LPCSTR,...)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DrawText
Definition: winuser.h:5771
#define IDI_APPLICATION
Definition: winuser.h:704
#define WM_ACTIVATE
Definition: winuser.h:1612
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define GetMessage
Definition: winuser.h:5790
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RDW_ALLCHILDREN
Definition: winuser.h:1221
#define WM_TIMER
Definition: winuser.h:1742
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define HTRIGHT
Definition: winuser.h:2489
#define LoadIcon
Definition: winuser.h:5813
BOOL WINAPI UpdateWindow(_In_ HWND)
#define HTCLIENT
Definition: winuser.h:2475
#define SendMessage
Definition: winuser.h:5843
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define LoadCursor
Definition: winuser.h:5812
#define WM_LBUTTONUP
Definition: winuser.h:1777
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define GetWindowText
Definition: winuser.h:5798
#define DT_VCENTER
Definition: winuser.h:543
#define PostMessage
Definition: winuser.h:5832
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WA_ACTIVE
Definition: winuser.h:2623
#define WM_MOVE
Definition: winuser.h:1610
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4466
#define WM_NCDESTROY
Definition: winuser.h:1684
#define HTTOP
Definition: winuser.h:2490
#define WA_CLICKACTIVE
Definition: winuser.h:2624
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GW_HWNDPREV
Definition: winuser.h:762
#define RegisterClass
Definition: winuser.h:5836
#define SM_CXSCREEN
Definition: winuser.h:959
#define WM_KEYDOWN
Definition: winuser.h:1715
#define DispatchMessage
Definition: winuser.h:5765
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SWP_NOZORDER
Definition: winuser.h:1247
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SystemParametersInfo
Definition: winuser.h:5858
#define HTLEFT
Definition: winuser.h:2487
#define SM_CYDRAG
Definition: winuser.h:1029
#define VK_ESCAPE
Definition: winuser.h:2214
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1662
#define HWND_NOTOPMOST
Definition: winuser.h:1206
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define RDW_INVALIDATE
Definition: winuser.h:1214
#define HWND_BOTTOM
Definition: winuser.h:1205
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define COLOR_3DFACE
Definition: winuser.h:929
char TCHAR
Definition: xmlstorage.h:189
const char * LPCSTR
Definition: xmlstorage.h:183
const CHAR * LPCTSTR
Definition: xmlstorage.h:193