ReactOS 0.4.17-dev-357-ga8f14ff
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-2025 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#define ID_QUIT 999
22
23#define APPBAR_CALLBACK (WM_USER + 100)
24
25#define LEFT_DOWN() mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
26#define LEFT_UP() mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
27#define MOVE(x, y) SetCursorPos((x), (y))
28
29#define INTERVAL 250
30#define LONG_INTERVAL 2500
31
32static const TCHAR s_szName[] = TEXT("AppBarSample");
36static HWND s_hwnd1 = NULL;
37static HWND s_hwnd2 = NULL;
38
39#ifdef VERBOSE
40static LPCSTR MessageOfAppBar(DWORD dwMessage)
41{
42 static char s_buf[32];
43 switch (dwMessage)
44 {
45 case ABM_NEW: return "ABM_NEW";
46 case ABM_REMOVE: return "ABM_REMOVE";
47 case ABM_QUERYPOS: return "ABM_QUERYPOS";
48 case ABM_SETPOS: return "ABM_SETPOS";
49 case ABM_GETSTATE: return "ABM_GETSTATE";
50 case ABM_GETTASKBARPOS: return "ABM_GETTASKBARPOS";
51 case ABM_ACTIVATE: return "ABM_ACTIVATE";
52 case ABM_GETAUTOHIDEBAR: return "ABM_GETAUTOHIDEBAR";
53 case ABM_SETAUTOHIDEBAR: return "ABM_SETAUTOHIDEBAR";
54 case ABM_WINDOWPOSCHANGED: return "ABM_WINDOWPOSCHANGED";
55 }
56 wsprintfA(s_buf, "%lu", dwMessage);
57 return s_buf;
58}
59
60static UINT WINAPI
61SHAppBarMessageWrap(DWORD dwMessage, PAPPBARDATA pData)
62{
63 trace("SHAppBarMessage entered (dwMessage=%s, rc=(%ld, %ld, %ld, %ld))\n",
64 MessageOfAppBar(dwMessage),
65 pData->rc.left, pData->rc.top, pData->rc.right, pData->rc.bottom);
66 UINT ret = SHAppBarMessage(dwMessage, pData);
67 trace("SHAppBarMessage leaved (dwMessage=%s, rc=(%ld, %ld, %ld, %ld))\n",
68 MessageOfAppBar(dwMessage),
69 pData->rc.left, pData->rc.top, pData->rc.right, pData->rc.bottom);
70 return ret;
71}
72#define SHAppBarMessage SHAppBarMessageWrap
73
74#undef ARRAYSIZE
75#define ARRAYSIZE _countof
76
77#define MSGDUMP_PRINTF printf
78#include "msgdump.h"
79
80#endif // def VERBOSE
81
83{
84#define SLIDE_HIDE 400
85#define SLIDE_SHOW 150
86 RECT rcOld, rcNew = *prc;
87 GetWindowRect(hwnd, &rcOld);
88
89 BOOL fShow = (rcNew.bottom - rcNew.top > rcOld.bottom - rcOld.top) ||
90 (rcNew.right - rcNew.left > rcOld.right - rcOld.left);
91
92 INT dx = (rcNew.right - rcOld.right) + (rcNew.left - rcOld.left);
93 INT dy = (rcNew.bottom - rcOld.bottom) + (rcNew.top - rcOld.top);
94
95 LONG dt = SLIDE_HIDE;
96 if (fShow)
97 {
98 dt = SLIDE_SHOW;
99 rcOld = rcNew;
100 OffsetRect(&rcOld, -dx, -dy);
101 SetWindowPos(hwnd, NULL, rcOld.left, rcOld.top,
102 rcOld.right - rcOld.left, rcOld.bottom - rcOld.top,
104 }
105
109
110 LONG t, t0 = GetTickCount();
111 while ((t = GetTickCount()) < t0 + dt)
112 {
113 INT x = rcOld.left + dx * (t - t0) / dt;
114 INT y = rcOld.top + dy * (t - t0) / dt;
116
119 }
120
122 SetWindowPos(hwnd, NULL, rcNew.left, rcNew.top,
123 rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
125#undef SLIDE_HIDE
126#undef SLIDE_SHOW
127}
128
129class Window
130{
131public:
132 Window(INT cx, INT cy, BOOL fAutoHide = FALSE)
133 : m_hwnd(NULL)
134 , m_fAutoHide(fAutoHide)
135 , m_cxWidth(cx)
136 , m_cyHeight(cy)
137 {
138 }
139
140 virtual ~Window() { }
141
143 {
144 WNDCLASS wc;
145 ZeroMemory(&wc, sizeof(wc));
147 wc.hInstance = hInstance;
150 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
152 return !!RegisterClass(&wc);
153 }
154
158 BOOL fAutoHide = FALSE)
159 {
160 Window *this_ = new Window(cx, cy, fAutoHide);
161 HWND hwnd = CreateWindowEx(exstyle, s_szName, pszText, style,
163 NULL, NULL, hInstance, this_);
166 return hwnd;
167 }
168
170 {
172 }
173
174 virtual LRESULT CALLBACK
176 {
177#ifdef VERBOSE
178 MD_msgdump(hwnd, uMsg, wParam, lParam);
179#endif
180 switch (uMsg)
181 {
197
198 case APPBAR_CALLBACK:
200 break;
201
202 default:
203 return DefWindowProc(hwnd, uMsg, wParam, lParam);
204 }
205 return 0;
206 }
207
208 static LRESULT CALLBACK
210 {
211 Window *this_ = GetAppbarData(hwnd);
212 if (uMsg == WM_CREATE)
213 {
215 this_ = (Window *)pCS->lpCreateParams;
217 }
218 if (this_)
219 return this_->WindowProcDx(hwnd, uMsg, wParam, lParam);
220 return DefWindowProc(hwnd, uMsg, wParam, lParam);
221 }
222
223protected:
240
241 void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
242 {
244 switch (id)
245 {
246 case ID_ACTION:
248 break;
249 case ID_ACTION + 1:
251 if (!hThread)
252 {
253 skip("failed to create thread\n");
256 return;
257 }
259 break;
260 case ID_QUIT:
264 break;
265 }
266 }
267
269 {
270 PAINTSTRUCT ps;
271
272 TCHAR szText[64];
273 GetWindowText(hwnd, szText, 64);
274
275 RECT rc;
276 GetClientRect(hwnd, &rc);
277
278 if (HDC hdc = BeginPaint(hwnd, &ps))
279 {
280 DrawText(hdc, szText, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
281 EndPaint(hwnd, &ps);
282 }
283 }
284
285 void OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
286 {
289 }
290
291 void OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
292 {
293 if (vk == VK_ESCAPE)
295 }
296
298 {
299 static HWND s_hwndZOrder = NULL;
300
301 switch (wParam)
302 {
303 case ABN_STATECHANGE:
304 break;
305
308 if (lParam)
309 {
310 s_hwndZOrder = GetWindow(hwnd, GW_HWNDPREV);
311 SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
313 }
314 else
315 {
316 SetWindowPos(hwnd, m_fOnTop ? HWND_TOPMOST : s_hwndZOrder,
317 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
318 s_hwndZOrder = NULL;
319 }
320 break;
321
322 case ABN_POSCHANGED:
323 {
324 APPBARDATA abd = { sizeof(abd), hwnd };
325 AppBar_PosChanged(&abd);
326 }
327 break;
328 }
329 }
330
332 {
333 APPBARDATA abd = { sizeof(abd), hwnd, APPBAR_CALLBACK };
335 return m_fAppBarRegd;
336 }
337
339 {
340 APPBARDATA abd = { sizeof(abd), hwnd };
342 return !m_fAppBarRegd;
343 }
344
346 {
347 APPBARDATA abd = { sizeof(abd), hwnd };
348
350 return FALSE;
351 *prc = abd.rc;
352 return TRUE;
353 }
354
356 {
357 APPBARDATA abd = { sizeof(abd), hwnd };
358 abd.uEdge = uSide;
359
361 }
362
364 {
365 if (fHide)
366 return AppBar_AutoHide(hwnd);
367 else
368 return AppBar_NoAutoHide(hwnd);
369 }
370
372 {
373 APPBARDATA abd = { sizeof(abd), hwnd };
374 abd.uEdge = m_uSide;
375
376 HWND hwndAutoHide = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
377 if (hwndAutoHide)
378 return FALSE;
379
380 abd.lParam = TRUE;
382 return FALSE;
383
387
388 RECT rc = m_rcAppBar;
389 switch (m_uSide)
390 {
391 case ABE_TOP:
392 rc.bottom = rc.top + 2;
393 break;
394 case ABE_BOTTOM:
395 rc.top = rc.bottom - 2;
396 break;
397 case ABE_LEFT:
398 rc.right = rc.left + 2;
399 break;
400 case ABE_RIGHT:
401 rc.left = rc.right - 2;
402 break;
403 }
404
405 AppBar_QueryPos(hwnd, &rc);
406 abd.rc = rc;
408 rc = abd.rc;
409
410 m_fHiding = TRUE;
411 SlideWindow(hwnd, &rc);
412
414 return TRUE;
415 }
416
418 {
419 APPBARDATA abd = { sizeof(abd), hwnd };
420 abd.uEdge = m_uSide;
421 HWND hwndAutoHide = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
422 if (hwndAutoHide != hwnd)
423 return FALSE;
424
425 abd.lParam = FALSE;
427 return FALSE;
428
433 return TRUE;
434 }
435
437 {
438 HMONITOR hMon = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
439 MONITORINFO mi = { sizeof(mi) };
440 ::GetMonitorInfo(hMon, &mi);
441 RECT rc = mi.rcWork;
442
443 BOOL fAutoHide = FALSE;
444 if (m_fAutoHide)
445 {
446 fAutoHide = m_fAutoHide;
450 }
451
452 switch (uSide)
453 {
454 case ABE_TOP:
455 rc.bottom = rc.top + m_cyHeight;
456 break;
457 case ABE_BOTTOM:
458 rc.top = rc.bottom - m_cyHeight;
459 break;
460 case ABE_LEFT:
461 rc.right = rc.left + m_cxWidth;
462 break;
463 case ABE_RIGHT:
464 rc.left = rc.right - m_cxWidth;
465 break;
466 }
467
468 APPBARDATA abd = { sizeof(abd), hwnd };
469 AppBar_QuerySetPos(uSide, &rc, &abd, TRUE);
470
471 if (fAutoHide)
472 {
474 m_fHiding = TRUE;
475
479 }
480
481 return TRUE;
482 }
483
485 {
487 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
488 m_fOnTop = fOnTop;
489 }
490
492 {
493 if (!m_fAutoHide)
494 return;
495
496 RECT rc = m_rcAppBar;
497 switch (m_uSide)
498 {
499 case ABE_TOP:
500 rc.bottom = rc.top + 2;
501 break;
502 case ABE_BOTTOM:
503 rc.top = rc.bottom - 2;
504 break;
505 case ABE_LEFT:
506 rc.right = rc.left + 2;
507 break;
508 case ABE_RIGHT:
509 rc.left = rc.right - 2;
510 break;
511 }
512
513 m_fHiding = TRUE;
514 SlideWindow(hwnd, &rc);
515 }
516
518 {
521
523 }
524
526 {
527 if (m_fAutoHide)
528 {
530 }
531 }
532
534 {
535 if (m_fAutoHide && m_fHiding)
536 {
538 }
539 }
540
542 {
543 if (m_fAppBarRegd)
544 {
545 APPBARDATA abd = { sizeof(abd), hwnd };
546
547 RECT rc;
548 GetWindowRect(hwnd, &rc);
549 AppBar_QuerySetPos(m_uSide, &rc, &abd, TRUE);
550 }
551 }
552
554 {
555 APPBARDATA abd = { sizeof(abd), hwnd };
556 abd.rc = *lprc;
557 abd.uEdge = m_uSide;
558
559 INT cx = 0, cy = 0;
560 if (ABE_LEFT == abd.uEdge || ABE_RIGHT == abd.uEdge)
561 {
562 cx = abd.rc.right - abd.rc.left;
563 abd.rc.top = 0;
565 }
566 else
567 {
568 cy = abd.rc.bottom - abd.rc.top;
569 abd.rc.left = 0;
571 }
572
574
575 switch (abd.uEdge)
576 {
577 case ABE_LEFT:
578 abd.rc.right = abd.rc.left + cx;
579 break;
580 case ABE_RIGHT:
581 abd.rc.left = abd.rc.right - cx;
582 break;
583 case ABE_TOP:
584 abd.rc.bottom = abd.rc.top + cy;
585 break;
586 case ABE_BOTTOM:
587 abd.rc.top = abd.rc.bottom - cy;
588 break;
589 }
590
591 *lprc = abd.rc;
592 }
593
595 {
596 pabd->rc = *lprc;
597 pabd->uEdge = uEdge;
598 m_uSide = uEdge;
599
600 AppBar_QueryPos(pabd->hWnd, &pabd->rc);
601
603
604 if (fMove)
605 {
606 RECT rc = pabd->rc;
607 MoveWindow(pabd->hWnd, rc.left, rc.top,
608 rc.right - rc.left, rc.bottom - rc.top, TRUE);
609 }
610
611 if (!m_fAutoHide)
612 {
613 m_rcAppBar = pabd->rc;
614 }
615 }
616
618 {
619 RECT rc;
621
622 if (m_fAutoHide)
623 {
624 m_rcAppBar = rc;
625 switch (m_uSide)
626 {
627 case ABE_TOP:
629 break;
630 case ABE_BOTTOM:
632 break;
633 case ABE_LEFT:
635 break;
636 case ABE_RIGHT:
638 break;
639 }
640 }
641
642 RECT rcWindow;
643 GetWindowRect(pabd->hWnd, &rcWindow);
644 INT cx = rcWindow.right - rcWindow.left;
645 INT cy = rcWindow.bottom - rcWindow.top;
646 switch (m_uSide)
647 {
648 case ABE_TOP:
649 rc.bottom = rc.top + cy;
650 break;
651 case ABE_BOTTOM:
652 rc.top = rc.bottom - cy;
653 break;
654 case ABE_LEFT:
655 rc.right = rc.left + cx;
656 break;
657 case ABE_RIGHT:
658 rc.left = rc.right - cx;
659 break;
660 }
661 AppBar_QuerySetPos(m_uSide, &rc, pabd, TRUE);
662 }
663
665 {
666 m_hwnd = hwnd;
667 m_fOnTop = TRUE;
669
675
678
679 trace("OnCreate(%p) done\n", hwnd);
680 return TRUE;
681 }
682
683 void OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
684 {
685 APPBARDATA abd = { sizeof(abd), hwnd };
687
688 switch (state)
689 {
690 case WA_ACTIVE:
691 case WA_CLICKACTIVE:
694 break;
695
696 case WA_INACTIVE:
698 break;
699 }
700 }
701
703 {
704 APPBARDATA abd = { sizeof(abd), hwnd };
706
708 }
709
710 void OnSize(HWND hwnd, UINT state, int cx, int cy)
711 {
712 RECT rcWindow;
713
714 if (m_fMoving || (m_fAutoHide && m_fHiding))
715 return;
716
717 if (!m_fHiding)
718 {
719 if (!m_fAutoHide)
721
722 GetWindowRect(hwnd, &rcWindow);
723 m_rcAppBar = rcWindow;
724
725 if (m_uSide == ABE_TOP || m_uSide == ABE_BOTTOM)
726 m_cyHeight = m_cySave = rcWindow.bottom - rcWindow.top;
727 else
728 m_cxWidth = m_cxSave = rcWindow.right - rcWindow.left;
729 }
730
732 }
733
734 void OnMove(HWND hwnd, int x, int y)
735 {
736 if (m_fMoving || m_fAutoHide)
737 return;
738
739 if (!m_fHiding)
741 }
742
744 {
746
747 m_hwnd = NULL;
749 delete this;
750 }
751
753 {
754 POINT pt;
755 RECT rc;
756 HWND hwndActive;
757
758 switch (id)
759 {
760 case IDT_AUTOHIDE:
761 if (m_fAutoHide && !m_fHiding && !m_fMoving)
762 {
764 GetWindowRect(hwnd, &rc);
765 hwndActive = GetForegroundWindow();
766
767 if (!PtInRect(&rc, pt) &&
768 hwndActive != hwnd &&
769 hwndActive != NULL &&
770 GetWindowOwner(hwndActive) != hwnd)
771 {
772 KillTimer(hwnd, id);
774 }
775 }
776 break;
777
778 case IDT_AUTOUNHIDE:
779 KillTimer(hwnd, id);
780
781 if (m_fAutoHide && m_fHiding)
782 {
784 GetWindowRect(hwnd, &rc);
785 if (PtInRect(&rc, pt))
786 {
788 }
789 }
790 break;
791 }
792 }
793
795 {
797
799
800 if (m_uSide == ABE_TOP && uHitTest == HTBOTTOM)
801 return HTBOTTOM;
802
803 if (m_uSide == ABE_BOTTOM && uHitTest == HTTOP)
804 return HTTOP;
805
806 if (m_uSide == ABE_LEFT && uHitTest == HTRIGHT)
807 return HTRIGHT;
808
809 if (m_uSide == ABE_RIGHT && uHitTest == HTLEFT)
810 return HTLEFT;
811
812 return HTCLIENT;
813 }
814
815 void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
816 {
817 m_fMoving = TRUE;
821 }
822
823 void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
824 {
825 if (!m_fMoving)
826 return;
827
828 POINT pt;
832 {
834 }
835
836 INT cxScreen = GetSystemMetrics(SM_CXSCREEN);
837 INT cyScreen = GetSystemMetrics(SM_CYSCREEN);
838
839 DWORD dx, dy;
840 UINT ix, iy;
841 if (pt.x < cxScreen / 2)
842 {
843 dx = pt.x;
844 ix = ABE_LEFT;
845 }
846 else
847 {
848 dx = cxScreen - pt.x;
849 ix = ABE_RIGHT;
850 }
851
852 if (pt.y < cyScreen / 2)
853 {
854 dy = pt.y;
855 iy = ABE_TOP;
856 }
857 else
858 {
859 dy = cyScreen - pt.y;
860 iy = ABE_BOTTOM;
861 }
862
863 if (cxScreen * dy > cyScreen * dx)
864 {
865 m_rcDrag.top = 0;
866 m_rcDrag.bottom = cyScreen;
867 if (ix == ABE_LEFT)
868 {
870 m_rcDrag.left = 0;
872 }
873 else
874 {
876 m_rcDrag.right = cxScreen;
878 }
879 }
880 else
881 {
882 m_rcDrag.left = 0;
883 m_rcDrag.right = cxScreen;
884 if (iy == ABE_TOP)
885 {
887 m_rcDrag.top = 0;
889 }
890 else
891 {
893 m_rcDrag.bottom = cyScreen;
895 }
896 }
897
899
900 if (m_bDragged)
901 {
905 TRUE);
906 }
907 }
908
909 void OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags)
910 {
911 if (!m_fMoving)
912 return;
913
914 OnMouseMove(hwnd, x, y, keyFlags);
915
917
919
920 if (m_fAutoHide)
921 {
922 switch (m_uSide)
923 {
924 case ABE_TOP:
926 break;
927 case ABE_BOTTOM:
929 break;
930 case ABE_LEFT:
932 break;
933 case ABE_RIGHT:
935 break;
936 }
937 }
938
939 if (m_bDragged)
940 {
941 if (m_fAutoHide)
942 {
944 }
945 else
946 {
947 APPBARDATA abd = { sizeof(abd), hwnd };
949 }
950 }
951
953 }
954
956 {
957 SystemParametersInfoW(SPI_GETWORKAREA, 0, prc, 0);
958 }
959
960 void Quit()
961 {
964 }
965
966public:
967 void DoAction()
968 {
969 trace("DoAction\n");
970
971 TEST_Main();
975
976 Quit();
977 }
978
980 {
981 trace("TEST_Main\n");
983
984 POINT pt;
985 RECT rc1, rc2, rcWork;
986
988 ok_int(ret, TRUE);
990
991 GetWindowRect(s_hwnd1, &rc1);
993 GetWorkArea(&rcWork);
997 ok_long(rc1.bottom, s_rcWorkArea.top + 80);
999 ok_long(rc2.top, s_rcWorkArea.top + 80);
1000 ok_long(rc2.right, s_rcWorkArea.right);
1001 ok_long(rc2.bottom, s_rcWorkArea.top + 110);
1002 ok_long(rcWork.left, s_rcWorkArea.left);
1003 ok_long(rcWork.top, s_rcWorkArea.top + 110);
1008
1010 GetWorkArea(&rcWork);
1013 ok_long(rc2.right, s_rcWorkArea.right);
1014 ok_long(rc2.bottom, s_rcWorkArea.top + 30);
1015 ok_long(rcWork.left, s_rcWorkArea.left);
1016 ok_long(rcWork.top, s_rcWorkArea.top + 30);
1020 Sleep(INTERVAL);
1021
1023 GetWorkArea(&rcWork);
1026 ok_long(rc2.right, s_rcWorkArea.left + 30);
1027 ok_long(rcWork.left, s_rcWorkArea.left + 30);
1028 ok_long(rcWork.top, s_rcWorkArea.top);
1032 Sleep(INTERVAL);
1033
1035 GetWorkArea(&rcWork);
1038 ok_long(rc2.right, s_rcWorkArea.right);
1039 ok_long(rc2.bottom, s_rcWorkArea.top + 30);
1040 ok_long(rcWork.left, s_rcWorkArea.left);
1041 ok_long(rcWork.top, s_rcWorkArea.top + 30);
1045 Sleep(INTERVAL);
1046
1048 GetWorkArea(&rcWork);
1049 ok_long(rc2.left, s_rcWorkArea.right - 30);
1051 ok_long(rc2.right, s_rcWorkArea.right);
1052 ok_long(rcWork.left, s_rcWorkArea.left);
1053 ok_long(rcWork.top, s_rcWorkArea.top);
1054 ok_long(rcWork.right, s_rcWorkArea.right - 30);
1056 Sleep(INTERVAL);
1057
1059 pt.x = (rc2.left + rc2.right) / 2;
1060 pt.y = (rc2.top + rc2.bottom) / 2;
1061 MOVE(pt.x, pt.y);
1062 LEFT_DOWN();
1063 MOVE(pt.x + 64, pt.y + 64);
1064 Sleep(INTERVAL);
1065
1066 pt.x = s_rcWorkArea.left + 80;
1068 MOVE(pt.x, pt.y);
1069 LEFT_UP();
1070 Sleep(INTERVAL);
1071
1073 GetWorkArea(&rcWork);
1076 ok_long(rc2.right, s_rcWorkArea.left + 30);
1077 ok_long(rcWork.left, s_rcWorkArea.left + 30);
1078 ok_long(rcWork.top, s_rcWorkArea.top);
1081 Sleep(INTERVAL);
1082 }
1083
1085 {
1086 trace("TEST_Dragging\n");
1087
1088 RECT rc, rcWork;
1089 POINT pt;
1090
1091 GetWindowRect(s_hwnd2, &rc);
1092 pt.x = (rc.left + rc.right) / 2;
1093 pt.y = (rc.top + rc.bottom) / 2;
1094 MOVE(pt.x, pt.y);
1095 LEFT_DOWN();
1096 Sleep(INTERVAL);
1097
1099 pt.y = s_rcWorkArea.top;
1100 MOVE(pt.x, pt.y);
1101 Sleep(INTERVAL);
1102
1103 pt.x = s_rcWorkArea.right - 1;
1105 MOVE(pt.x, pt.y);
1106 LEFT_UP();
1108
1109 GetWindowRect(s_hwnd2, &rc);
1110 GetWorkArea(&rcWork);
1111 ok_long(rc.left, s_rcWorkArea.right - 30);
1114 ok_long(rcWork.left, s_rcWorkArea.left);
1115 ok_long(rcWork.top, s_rcWorkArea.top);
1116 ok_long(rcWork.right, s_rcWorkArea.right - 30);
1118 }
1119
1121 {
1122 trace("TEST_AutoHide\n");
1123
1124 RECT rc;
1125
1126 m_cxWidth = 80;
1127 m_cyHeight = 40;
1131 ok_ptr(hwndRet, s_hwnd2);
1133
1134 GetWindowRect(s_hwnd2, &rc);
1138 ok_long(rc.bottom, s_rcWorkArea.top + 2);
1139
1141 LEFT_DOWN();
1142 LEFT_UP();
1144
1145 GetWindowRect(s_hwnd2, &rc);
1149 ok_long(rc.bottom, s_rcWorkArea.top + 40);
1150
1152 LEFT_DOWN();
1153 LEFT_UP();
1155
1156 GetWindowRect(s_hwnd2, &rc);
1160 ok_long(rc.bottom, s_rcWorkArea.top + 2);
1161
1164
1165 GetWindowRect(s_hwnd2, &rc);
1169 ok_long(rc.bottom, s_rcWorkArea.top + 40);
1170
1175 ok_ptr(hwndRet, s_hwnd2);
1176
1177 GetWindowRect(s_hwnd2, &rc);
1178 ok_long(rc.left, s_rcWorkArea.right - 2);
1182
1185
1186 GetWindowRect(s_hwnd2, &rc);
1187 ok_long(rc.left, s_rcWorkArea.right - 2);
1191 }
1192
1194 {
1195 trace("TEST_FullScreen\n");
1198 MoveWindow(s_hwnd2, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
1201 MoveWindow(s_hwnd2, rc.left, rc.top, 100, 100, TRUE);
1202 }
1203
1205 {
1206 Window *this_ = (Window *)args;
1207 this_->DoAction();
1208 return 0;
1209 }
1210};
1211
1213{
1215
1216 // Check Taskbar
1217 HWND hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
1218 if (!IsWindowVisible(hTrayWnd))
1219 {
1220 skip("Taskbar not found\n");
1221 return;
1222 }
1223
1224 // Taskbar
1225 RECT rc;
1226 GetWindowRect(hTrayWnd, &rc);
1227 s_rcTaskBar = rc;
1228 trace("s_rcTaskBar: %ld, %ld, %ld, %ld\n", rc.left, rc.top, rc.right, rc.bottom);
1229
1230 // Work area
1231 SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);
1232 s_rcWorkArea = rc;
1233 trace("s_rcWorkArea: %ld, %ld, %ld, %ld\n", rc.left, rc.top, rc.right, rc.bottom);
1234
1235 // Primary monitor
1237 s_rcPrimaryMonitor = rc;
1238 trace("s_rcPrimaryMonitor: %ld, %ld, %ld, %ld\n", rc.left, rc.top, rc.right, rc.bottom);
1239
1243 {
1244 // Taskbar must be bottom in this testcase
1245 skip("Taskbar was not bottom\n");
1246 return;
1247 }
1248
1249 if (!Window::DoRegisterClass(hInstance))
1250 {
1251 skip("Window::DoRegisterClass failed\n");
1252 return;
1253 }
1254
1255 trace("SM_CMONITORS: %d\n", GetSystemMetrics(SM_CMONITORS));
1257 {
1258 skip("Multi-monitor not supported yet\n");
1259 return;
1260 }
1261
1262 HWND hwnd1 = Window::DoCreateMainWnd(hInstance, TEXT("Test1"), 80, 80,
1264 if (!hwnd1)
1265 {
1266 skip("CreateWindowExW failed\n");
1267 return;
1268 }
1269
1270 HWND hwnd2 = Window::DoCreateMainWnd(hInstance, TEXT("Test2"), 30, 30,
1272 if (!hwnd2)
1273 {
1274 skip("CreateWindowExW failed\n");
1275 return;
1276 }
1277
1278 s_hwnd1 = hwnd1;
1279 s_hwnd2 = hwnd2;
1280
1281 PostMessageW(hwnd1, WM_COMMAND, ID_ACTION, 0);
1282
1283 // message loop
1284 MSG msg;
1285 while (GetMessage(&msg, NULL, 0, 0))
1286 {
1289 }
1290}
#define MD_msgdump(hwnd, uMsg, wParam, lParam)
#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
static RECT s_rcPrimaryMonitor
static RECT s_rcTaskBar
#define INTERVAL
#define ID_QUIT
static HWND s_hwnd2
#define LONG_INTERVAL
static HWND s_hwnd1
#define IDT_AUTOHIDE
#define APPBAR_CALLBACK
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 ok_int(expression, result)
Definition: atltest.h:134
#define ok_ptr(expression, result)
Definition: atltest.h:108
#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
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
unsigned short vk
Definition: console.c:118
_ACRTIMP __msvcrt_long __cdecl labs(__msvcrt_long)
Definition: math.c:680
UINT_PTR WINAPI SHAppBarMessage(_In_ DWORD dwMessage, _Inout_ PAPPBARDATA pData)
Definition: appbar.c:67
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
char TCHAR
Definition: tchar.h:1402
#define TEXT(s)
Definition: k32.h:28
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static MONITORINFO mi
Definition: win.c:9400
static int priority
Definition: timer.c:163
LPCSTR LPCTSTR
Definition: ms-dtyp.idl:130
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define BOOL
Definition: nt_native.h:43
#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
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define DefWindowProc
Definition: ros2win.h:31
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:70
#define ABE_BOTTOM
Definition: shellapi.h:20
#define ABM_GETTASKBARPOS
Definition: shellapi.h:66
#define ABM_GETSTATE
Definition: shellapi.h:65
#define ABM_SETAUTOHIDEBAR
Definition: shellapi.h:69
#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:64
#define ABM_ACTIVATE
Definition: shellapi.h:67
#define ABE_LEFT
Definition: shellapi.h:17
#define ABM_REMOVE
Definition: shellapi.h:62
#define ABN_STATECHANGE
Definition: shellapi.h:72
#define ABM_NEW
Definition: shellapi.h:61
#define ABM_GETAUTOHIDEBAR
Definition: shellapi.h:68
#define ABN_POSCHANGED
Definition: shellapi.h:73
#define ABM_QUERYPOS
Definition: shellapi.h:63
Definition: window.c:28
void OnSize(HWND hwnd, UINT state, int cx, int cy)
BOOL m_fAppBarRegd
BOOL AppBar_GetTaskBarPos(HWND hwnd, PRECT prc)
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)
void TEST_Main()
static Window * GetAppbarData(HWND hwnd)
BOOL m_fAutoHide
void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
BOOL m_bGotFullScreen
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 TEST_AutoHide()
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)
void TEST_FullScreen()
virtual LRESULT CALLBACK WindowProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND AppBar_GetAutoHideBar(HWND hwnd, UINT uSide)
void TEST_Dragging()
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)
LPARAM lParam
Definition: shellapi.h:222
HWND hWnd
Definition: shellapi.h:218
UINT uEdge
Definition: shellapi.h:220
HBRUSH hbrBackground
Definition: winuser.h:3278
HICON hIcon
Definition: winuser.h:3276
HINSTANCE hInstance
Definition: winuser.h:3275
HCURSOR hCursor
Definition: winuser.h:3277
LPCSTR lpszClassName
Definition: winuser.h:3280
WNDPROC lpfnWndProc
Definition: winuser.h:3272
Definition: match.c:390
LPVOID lpCreateParams
Definition: winuser.h:3048
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
#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
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT
Definition: typedefs.h:58
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1145
#define GetModuleHandle
Definition: winbase.h:3548
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:302
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#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:781
#define WM_PAINT
Definition: winuser.h:1648
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define CreateWindowEx
Definition: winuser.h:5921
#define GetMonitorInfo
Definition: winuser.h:5957
#define WM_CLOSE
Definition: winuser.h:1649
#define SWP_NOACTIVATE
Definition: winuser.h:1253
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5892
#define SM_CXDRAG
Definition: winuser.h:1039
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:971
#define DT_CENTER
Definition: winuser.h:527
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define HWND_TOPMOST
Definition: winuser.h:1219
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_CREATE
Definition: winuser.h:1636
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HTBOTTOM
Definition: winuser.h:2529
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SWP_DRAWFRAME
Definition: winuser.h:1250
#define WM_SIZE
Definition: winuser.h:1639
#define DT_SINGLELINE
Definition: winuser.h:540
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WM_COMMAND
Definition: winuser.h:1768
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define IDC_ARROW
Definition: winuser.h:695
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3064
#define WM_NCHITTEST
Definition: winuser.h:1714
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SWP_NOSIZE
Definition: winuser.h:1256
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define RDW_UPDATENOW
Definition: winuser.h:1231
#define WA_INACTIVE
Definition: winuser.h:2664
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
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:5937
#define IDI_APPLICATION
Definition: winuser.h:712
#define WM_ACTIVATE
Definition: winuser.h:1640
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define WM_RBUTTONDOWN
Definition: winuser.h:1807
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define GetMessage
Definition: winuser.h:5956
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
#define WM_TIMER
Definition: winuser.h:1770
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define HTRIGHT
Definition: winuser.h:2525
#define LoadIcon
Definition: winuser.h:5979
BOOL WINAPI UpdateWindow(_In_ HWND)
#define HTCLIENT
Definition: winuser.h:2511
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define LoadCursor
Definition: winuser.h:5978
#define WM_LBUTTONUP
Definition: winuser.h:1805
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define GetWindowText
Definition: winuser.h:5964
#define DT_VCENTER
Definition: winuser.h:543
#define PostMessage
Definition: winuser.h:5998
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WA_ACTIVE
Definition: winuser.h:2665
#define WM_MOVE
Definition: winuser.h:1638
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4620
#define WM_NCDESTROY
Definition: winuser.h:1712
#define HTTOP
Definition: winuser.h:2526
#define WA_CLICKACTIVE
Definition: winuser.h:2666
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GW_HWNDPREV
Definition: winuser.h:773
#define RegisterClass
Definition: winuser.h:6002
#define SM_CXSCREEN
Definition: winuser.h:970
#define WM_KEYDOWN
Definition: winuser.h:1743
#define DispatchMessage
Definition: winuser.h:5931
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SWP_NOZORDER
Definition: winuser.h:1258
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SystemParametersInfo
Definition: winuser.h:6024
#define HTLEFT
Definition: winuser.h:2523
#define SM_CYDRAG
Definition: winuser.h:1040
#define SM_CMONITORS
Definition: winuser.h:1051
#define VK_ESCAPE
Definition: winuser.h:2250
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1690
#define HWND_NOTOPMOST
Definition: winuser.h:1217
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
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:1225
#define HWND_BOTTOM
Definition: winuser.h:1216
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define COLOR_3DFACE
Definition: winuser.h:940