ReactOS 0.4.16-dev-1170-ge326b06
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 HMONITOR hMon = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
442 MONITORINFO mi = { sizeof(mi) };
443 ::GetMonitorInfo(hMon, &mi);
444 RECT rc = mi.rcWork;
445
446 BOOL fAutoHide = FALSE;
447 if (m_fAutoHide)
448 {
449 fAutoHide = m_fAutoHide;
453 }
454
455 switch (uSide)
456 {
457 case ABE_TOP:
458 rc.bottom = rc.top + m_cyHeight;
459 break;
460 case ABE_BOTTOM:
461 rc.top = rc.bottom - m_cyHeight;
462 break;
463 case ABE_LEFT:
464 rc.right = rc.left + m_cxWidth;
465 break;
466 case ABE_RIGHT:
467 rc.left = rc.right - m_cxWidth;
468 break;
469 }
470
471 APPBARDATA abd = { sizeof(abd) };
472 abd.hWnd = hwnd;
473 AppBar_QuerySetPos(uSide, &rc, &abd, TRUE);
474
475 if (fAutoHide)
476 {
478 m_fHiding = TRUE;
479
483 }
484
485 return TRUE;
486 }
487
489 {
491 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
492 m_fOnTop = fOnTop;
493 }
494
496 {
497 if (!m_fAutoHide)
498 return;
499
500 RECT rc = m_rcAppBar;
501 switch (m_uSide)
502 {
503 case ABE_TOP:
504 rc.bottom = rc.top + 2;
505 break;
506 case ABE_BOTTOM:
507 rc.top = rc.bottom - 2;
508 break;
509 case ABE_LEFT:
510 rc.right = rc.left + 2;
511 break;
512 case ABE_RIGHT:
513 rc.left = rc.right - 2;
514 break;
515 }
516
517 m_fHiding = TRUE;
518 SlideWindow(hwnd, &rc);
519 }
520
522 {
525
527 }
528
530 {
531 if (m_fAutoHide)
532 {
534 }
535 }
536
538 {
539 if (m_fAutoHide && m_fHiding)
540 {
542 }
543 }
544
546 {
547 if (m_fAppBarRegd)
548 {
549 APPBARDATA abd = { sizeof(abd) };
550 abd.hWnd = hwnd;
551
552 RECT rc;
553 GetWindowRect(hwnd, &rc);
554 AppBar_QuerySetPos(m_uSide, &rc, &abd, TRUE);
555 }
556 }
557
559 {
560 APPBARDATA abd = { sizeof(abd) };
561 abd.hWnd = hwnd;
562 abd.rc = *lprc;
563 abd.uEdge = m_uSide;
564
565 INT cx = 0, cy = 0;
566 if (ABE_LEFT == abd.uEdge || ABE_RIGHT == abd.uEdge)
567 {
568 cx = abd.rc.right - abd.rc.left;
569 abd.rc.top = 0;
571 }
572 else
573 {
574 cy = abd.rc.bottom - abd.rc.top;
575 abd.rc.left = 0;
577 }
578
580
581 switch (abd.uEdge)
582 {
583 case ABE_LEFT:
584 abd.rc.right = abd.rc.left + cx;
585 break;
586 case ABE_RIGHT:
587 abd.rc.left = abd.rc.right - cx;
588 break;
589 case ABE_TOP:
590 abd.rc.bottom = abd.rc.top + cy;
591 break;
592 case ABE_BOTTOM:
593 abd.rc.top = abd.rc.bottom - cy;
594 break;
595 }
596
597 *lprc = abd.rc;
598 }
599
601 {
602 pabd->rc = *lprc;
603 pabd->uEdge = uEdge;
604 m_uSide = uEdge;
605
606 AppBar_QueryPos(pabd->hWnd, &pabd->rc);
607
609
610 if (fMove)
611 {
612 RECT rc = pabd->rc;
613 MoveWindow(pabd->hWnd, rc.left, rc.top,
614 rc.right - rc.left, rc.bottom - rc.top, TRUE);
615 }
616
617 if (!m_fAutoHide)
618 {
619 m_rcAppBar = pabd->rc;
620 }
621 }
622
624 {
625 RECT rc;
627
628 if (m_fAutoHide)
629 {
630 m_rcAppBar = rc;
631 switch (m_uSide)
632 {
633 case ABE_TOP:
635 break;
636 case ABE_BOTTOM:
638 break;
639 case ABE_LEFT:
641 break;
642 case ABE_RIGHT:
644 break;
645 }
646 }
647
648 RECT rcWindow;
649 GetWindowRect(pabd->hWnd, &rcWindow);
650 INT cx = rcWindow.right - rcWindow.left;
651 INT cy = rcWindow.bottom - rcWindow.top;
652 switch (m_uSide)
653 {
654 case ABE_TOP:
655 rc.bottom = rc.top + cy;
656 break;
657 case ABE_BOTTOM:
658 rc.top = rc.bottom - cy;
659 break;
660 case ABE_LEFT:
661 rc.right = rc.left + cx;
662 break;
663 case ABE_RIGHT:
664 rc.left = rc.right - cx;
665 break;
666 }
667 AppBar_QuerySetPos(m_uSide, &rc, pabd, TRUE);
668 }
669
671 {
672 m_hwnd = hwnd;
673 m_fOnTop = TRUE;
675
681
684
685 trace("OnCreate(%p) done\n", hwnd);
686 return TRUE;
687 }
688
689 void OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
690 {
691 APPBARDATA abd = { sizeof(abd) };
692 abd.hWnd = hwnd;
694
695 switch (state)
696 {
697 case WA_ACTIVE:
698 case WA_CLICKACTIVE:
701 break;
702
703 case WA_INACTIVE:
705 break;
706 }
707 }
708
710 {
711 APPBARDATA abd = { sizeof(abd) };
712 abd.hWnd = hwnd;
714
716 }
717
718 void OnSize(HWND hwnd, UINT state, int cx, int cy)
719 {
720 RECT rcWindow;
721
722 if (m_fMoving || (m_fAutoHide && m_fHiding))
723 return;
724
725 if (!m_fHiding)
726 {
727 if (!m_fAutoHide)
729
730 GetWindowRect(hwnd, &rcWindow);
731 m_rcAppBar = rcWindow;
732
733 if (m_uSide == ABE_TOP || m_uSide == ABE_BOTTOM)
734 {
735 m_cyHeight = m_cySave = rcWindow.bottom - rcWindow.top;
736 }
737 else
738 {
739 m_cxWidth = m_cxSave = rcWindow.right - rcWindow.left;
740 }
741 }
742
744 }
745
746 void OnMove(HWND hwnd, int x, int y)
747 {
748 if (m_fMoving || m_fAutoHide)
749 return;
750
751 if (!m_fHiding)
753 }
754
756 {
758
759 m_hwnd = NULL;
761 delete this;
762 }
763
765 {
766 POINT pt;
767 RECT rc;
768 HWND hwndActive;
769
770 switch (id)
771 {
772 case IDT_AUTOHIDE:
773 if (m_fAutoHide && !m_fHiding && !m_fMoving)
774 {
776 GetWindowRect(hwnd, &rc);
777 hwndActive = GetForegroundWindow();
778
779 if (!PtInRect(&rc, pt) &&
780 hwndActive != hwnd &&
781 hwndActive != NULL &&
782 GetWindowOwner(hwndActive) != hwnd)
783 {
784 KillTimer(hwnd, id);
786 }
787 }
788 break;
789
790 case IDT_AUTOUNHIDE:
791 KillTimer(hwnd, id);
792
793 if (m_fAutoHide && m_fHiding)
794 {
796 GetWindowRect(hwnd, &rc);
797 if (PtInRect(&rc, pt))
798 {
800 }
801 }
802 break;
803 }
804 }
805
807 {
809
811
812 if (m_uSide == ABE_TOP && uHitTest == HTBOTTOM)
813 return HTBOTTOM;
814
815 if (m_uSide == ABE_BOTTOM && uHitTest == HTTOP)
816 return HTTOP;
817
818 if (m_uSide == ABE_LEFT && uHitTest == HTRIGHT)
819 return HTRIGHT;
820
821 if (m_uSide == ABE_RIGHT && uHitTest == HTLEFT)
822 return HTLEFT;
823
824 return HTCLIENT;
825 }
826
827 void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
828 {
829 m_fMoving = TRUE;
833 }
834
835 void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
836 {
837 if (!m_fMoving)
838 return;
839
840 POINT pt;
844 {
846 }
847
848 INT cxScreen = GetSystemMetrics(SM_CXSCREEN);
849 INT cyScreen = GetSystemMetrics(SM_CYSCREEN);
850
851 DWORD dx, dy;
852 UINT ix, iy;
853 if (pt.x < cxScreen / 2)
854 {
855 dx = pt.x;
856 ix = ABE_LEFT;
857 }
858 else
859 {
860 dx = cxScreen - pt.x;
861 ix = ABE_RIGHT;
862 }
863
864 if (pt.y < cyScreen / 2)
865 {
866 dy = pt.y;
867 iy = ABE_TOP;
868 }
869 else
870 {
871 dy = cyScreen - pt.y;
872 iy = ABE_BOTTOM;
873 }
874
875 if (cxScreen * dy > cyScreen * dx)
876 {
877 m_rcDrag.top = 0;
878 m_rcDrag.bottom = cyScreen;
879 if (ix == ABE_LEFT)
880 {
882 m_rcDrag.left = 0;
884 }
885 else
886 {
888 m_rcDrag.right = cxScreen;
890 }
891 }
892 else
893 {
894 m_rcDrag.left = 0;
895 m_rcDrag.right = cxScreen;
896 if (iy == ABE_TOP)
897 {
899 m_rcDrag.top = 0;
901 }
902 else
903 {
905 m_rcDrag.bottom = cyScreen;
907 }
908 }
909
911
912 if (m_bDragged)
913 {
917 TRUE);
918 }
919 }
920
921 void OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags)
922 {
923 if (!m_fMoving)
924 return;
925
926 OnMouseMove(hwnd, x, y, keyFlags);
927
929
931
932 if (m_fAutoHide)
933 {
934 switch (m_uSide)
935 {
936 case ABE_TOP:
938 break;
939 case ABE_BOTTOM:
941 break;
942 case ABE_LEFT:
944 break;
945 case ABE_RIGHT:
947 break;
948 }
949 }
950
951 if (m_bDragged)
952 {
953 if (m_fAutoHide)
954 {
956 }
957 else
958 {
959 APPBARDATA abd = { sizeof(abd) };
960 abd.hWnd = hwnd;
962 }
963 }
964
966 }
967
969 {
970 SystemParametersInfoW(SPI_GETWORKAREA, 0, prc, 0);
971 }
972
973public:
974 void DoAction()
975 {
976#define INTERVAL 250
977 POINT pt;
978 RECT rc1, rc2, rcWork;
980
981 trace("DoAction\n");
983
984 GetWindowRect(s_hwnd1, &rc1);
986 GetWorkArea(&rcWork);
990 ok_long(rc1.bottom, s_rcWorkArea.top + 80);
992 ok_long(rc2.top, s_rcWorkArea.top + 80);
994 ok_long(rc2.bottom, s_rcWorkArea.top + 110);
995 ok_long(rcWork.left, s_rcWorkArea.left);
996 ok_long(rcWork.top, s_rcWorkArea.top + 110);
1000 Sleep(INTERVAL);
1001
1003 GetWorkArea(&rcWork);
1006 ok_long(rc2.right, s_rcWorkArea.right);
1007 ok_long(rc2.bottom, s_rcWorkArea.top + 30);
1008 ok_long(rcWork.left, s_rcWorkArea.left);
1009 ok_long(rcWork.top, s_rcWorkArea.top + 30);
1013 Sleep(INTERVAL);
1014
1016 GetWorkArea(&rcWork);
1019 ok_long(rc2.right, s_rcWorkArea.left + 30);
1020 ok_long(rcWork.left, s_rcWorkArea.left + 30);
1021 ok_long(rcWork.top, s_rcWorkArea.top);
1025 Sleep(INTERVAL);
1026
1028 GetWorkArea(&rcWork);
1031 ok_long(rc2.right, s_rcWorkArea.right);
1032 ok_long(rc2.bottom, s_rcWorkArea.top + 30);
1033 ok_long(rcWork.left, s_rcWorkArea.left);
1034 ok_long(rcWork.top, s_rcWorkArea.top + 30);
1038 Sleep(INTERVAL);
1039
1041 GetWorkArea(&rcWork);
1042 ok_long(rc2.left, s_rcWorkArea.right - 30);
1044 ok_long(rc2.right, s_rcWorkArea.right);
1045 ok_long(rcWork.left, s_rcWorkArea.left);
1046 ok_long(rcWork.top, s_rcWorkArea.top);
1047 ok_long(rcWork.right, s_rcWorkArea.right - 30);
1049 Sleep(INTERVAL);
1050
1052 pt.x = (rc2.left + rc2.right) / 2;
1053 pt.y = (rc2.top + rc2.bottom) / 2;
1054 MOVE(pt.x, pt.y);
1055 LEFT_DOWN();
1056 MOVE(pt.x + 64, pt.y + 64);
1057 Sleep(INTERVAL);
1058
1059 pt.x = s_rcWorkArea.left + 80;
1061 MOVE(pt.x, pt.y);
1062 LEFT_UP();
1063 Sleep(INTERVAL);
1064
1066 GetWorkArea(&rcWork);
1069 ok_long(rc2.right, s_rcWorkArea.left + 30);
1070 ok_long(rcWork.left, s_rcWorkArea.left + 30);
1071 ok_long(rcWork.top, s_rcWorkArea.top);
1074 Sleep(INTERVAL);
1075
1077 pt.x = (rc2.left + rc2.right) / 2;
1078 pt.y = (rc2.top + rc2.bottom) / 2;
1079 MOVE(pt.x, pt.y);
1080 LEFT_DOWN();
1081 MOVE(pt.x + 64, pt.y + 64);
1082 Sleep(INTERVAL);
1083
1084 pt.x = s_rcWorkArea.right - 80;
1086 MOVE(pt.x, pt.y);
1087 LEFT_UP();
1088 Sleep(INTERVAL);
1089
1091 GetWorkArea(&rcWork);
1092 ok_long(rc2.left, s_rcWorkArea.right - 30);
1094 ok_long(rc2.right, s_rcWorkArea.right);
1095 ok_long(rcWork.left, s_rcWorkArea.left);
1096 ok_long(rcWork.top, s_rcWorkArea.top);
1097 ok_long(rcWork.right, s_rcWorkArea.right - 30);
1099 Sleep(INTERVAL);
1100
1102 Sleep(INTERVAL);
1103
1104 GetWorkArea(&rcWork);
1105 ok_long(rcWork.left, s_rcWorkArea.left);
1106 ok_long(rcWork.top, s_rcWorkArea.top);
1109
1111 PostThreadMessage(dwTID, WM_QUIT, 0, 0);
1112#undef INTERVAL
1113 }
1114
1116 {
1117 Window *this_ = (Window *)args;
1118 this_->DoAction();
1119 return 0;
1120 }
1121};
1122
1124{
1126
1127 if (!Window::DoRegisterClass(hInstance))
1128 {
1129 skip("Window::DoRegisterClass failed\n");
1130 return;
1131 }
1132
1133 trace("SM_CMONITORS: %d\n", GetSystemMetrics(SM_CMONITORS));
1135 {
1136 skip("Multi-monitor not supported yet\n");
1137 return;
1138 }
1139
1140 SystemParametersInfo(SPI_GETWORKAREA, 0, &s_rcWorkArea, FALSE);
1141 trace("s_rcWorkArea: %ld, %ld, %ld, %ld\n",
1143
1144 HWND hwnd1 = Window::DoCreateMainWnd(hInstance, TEXT("Test1"), 80, 80,
1146 if (!hwnd1)
1147 {
1148 skip("CreateWindowExW failed\n");
1149 return;
1150 }
1151
1152 HWND hwnd2 = Window::DoCreateMainWnd(hInstance, TEXT("Test2"), 30, 30,
1154 if (!hwnd2)
1155 {
1156 skip("CreateWindowExW failed\n");
1157 return;
1158 }
1159
1160 s_hwnd1 = hwnd1;
1161 s_hwnd2 = hwnd2;
1162
1163 PostMessageW(hwnd1, WM_COMMAND, ID_ACTION, 0);
1164
1165 Window::DoMainLoop();
1166}
#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(_In_ DWORD dwMessage, _Inout_ PAPPBARDATA pData)
Definition: appbar.c:67
#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:97
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:88
WORD vk
Definition: input.c:77
static MONITORINFO mi
Definition: win.c:7338
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
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
_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:75
#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:73
#define ABM_NEW
Definition: shellapi.h:62
#define ABM_GETAUTOHIDEBAR
Definition: shellapi.h:69
#define ABN_POSCHANGED
Definition: shellapi.h:74
#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:220
LPARAM lParam
Definition: shellapi.h:223
HWND hWnd
Definition: shellapi.h:219
UINT uEdge
Definition: shellapi.h:221
HBRUSH hbrBackground
Definition: winuser.h:3181
HICON hIcon
Definition: winuser.h:3179
HINSTANCE hInstance
Definition: winuser.h:3178
HCURSOR hCursor
Definition: winuser.h:3180
LPCSTR lpszClassName
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3175
Definition: match.c:390
Definition: dsound.c:943
LPVOID lpCreateParams
Definition: winuser.h:2951
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:1744
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define GetModuleHandle
Definition: winbase.h:3859
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:304
_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:781
#define WM_PAINT
Definition: winuser.h:1631
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define CreateWindowEx
Definition: winuser.h:5775
#define GetMonitorInfo
Definition: winuser.h:5811
#define WM_CLOSE
Definition: winuser.h:1632
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define wvsprintf
Definition: winuser.h:5886
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5746
#define SM_CXDRAG
Definition: winuser.h:1039
#define WM_QUIT
Definition: winuser.h:1634
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:1619
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HTBOTTOM
Definition: winuser.h:2504
#define SWP_DRAWFRAME
Definition: winuser.h:1250
#define WM_SIZE
Definition: winuser.h:1622
#define DT_SINGLELINE
Definition: winuser.h:540
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WM_COMMAND
Definition: winuser.h:1751
#define IDC_ARROW
Definition: winuser.h:695
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3032
#define WM_NCHITTEST
Definition: winuser.h:1697
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SWP_NOSIZE
Definition: winuser.h:1256
#define WM_MOUSEMOVE
Definition: winuser.h:1786
#define RDW_UPDATENOW
Definition: winuser.h:1231
#define WA_INACTIVE
Definition: winuser.h:2633
#define WM_LBUTTONDOWN
Definition: winuser.h:1787
#define PostThreadMessage
Definition: winuser.h:5853
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:5791
#define IDI_APPLICATION
Definition: winuser.h:712
#define WM_ACTIVATE
Definition: winuser.h:1623
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define WM_RBUTTONDOWN
Definition: winuser.h:1790
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define GetMessage
Definition: winuser.h:5810
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
#define WM_TIMER
Definition: winuser.h:1753
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define HTRIGHT
Definition: winuser.h:2500
#define LoadIcon
Definition: winuser.h:5833
BOOL WINAPI UpdateWindow(_In_ HWND)
#define HTCLIENT
Definition: winuser.h:2486
#define SendMessage
Definition: winuser.h:5863
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define LoadCursor
Definition: winuser.h:5832
#define WM_LBUTTONUP
Definition: winuser.h:1788
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define GetWindowText
Definition: winuser.h:5818
#define DT_VCENTER
Definition: winuser.h:543
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WA_ACTIVE
Definition: winuser.h:2634
#define WM_MOVE
Definition: winuser.h:1621
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4477
#define WM_NCDESTROY
Definition: winuser.h:1695
#define HTTOP
Definition: winuser.h:2501
#define WA_CLICKACTIVE
Definition: winuser.h:2635
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GW_HWNDPREV
Definition: winuser.h:773
#define RegisterClass
Definition: winuser.h:5856
#define SM_CXSCREEN
Definition: winuser.h:970
#define WM_KEYDOWN
Definition: winuser.h:1726
#define DispatchMessage
Definition: winuser.h:5785
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:5878
#define HTLEFT
Definition: winuser.h:2498
#define SM_CYDRAG
Definition: winuser.h:1040
#define SM_CMONITORS
Definition: winuser.h:1051
#define VK_ESCAPE
Definition: winuser.h:2225
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1673
#define HWND_NOTOPMOST
Definition: winuser.h:1217
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: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
char TCHAR
Definition: xmlstorage.h:189
const char * LPCSTR
Definition: xmlstorage.h:183
const CHAR * LPCTSTR
Definition: xmlstorage.h:193