ReactOS 0.4.16-dev-1260-g901af6a
CAppBarManager Class Referenceabstract

#include <appbar.h>

Inheritance diagram for CAppBarManager:
Collaboration diagram for CAppBarManager:

Public Member Functions

 CAppBarManager ()
 
virtual ~CAppBarManager ()
 
LRESULT OnAppBarMessage (_Inout_ PCOPYDATASTRUCT pCopyData)
 

Protected Member Functions

PAPPBAR FindAppBar (_In_ HWND hwndAppBar) const
 
void EliminateAppBar (_In_ INT iItem)
 
void DestroyAppBarDPA ()
 
void AppBarSubtractRect (_In_ PAPPBAR pAppBar, _Inout_ PRECT prc)
 
BOOL AppBarOutsideOf (_In_ const APPBAR *pAppBar1, _In_ const APPBAR *pAppBar2)
 
void ComputeHiddenRect (_Inout_ PRECT prc, _In_ UINT uSide)
 
PAPPBAR_COMMAND GetAppBarMessage (_Inout_ PCOPYDATASTRUCT pCopyData)
 
void GetDockedRect (_Out_ PRECT prcDocked)
 
BOOL SetAutoHideBar (_In_ HWND hwndTarget, _In_ BOOL bSetOrReset, _In_ UINT uSide)
 
void OnAppBarActivationChange2 (_In_ HWND hwndNewAutoHide, _In_ UINT uSide)
 
BOOL OnAppBarNew (_In_ const APPBAR_COMMAND *pData)
 
void OnAppBarRemove (_In_ const APPBAR_COMMAND *pData)
 
void OnAppBarQueryPos (_Inout_ PAPPBAR_COMMAND pData)
 
void OnAppBarSetPos (_Inout_ PAPPBAR_COMMAND pData)
 
UINT OnAppBarGetState ()
 
BOOL OnAppBarGetTaskbarPos (_Inout_ PAPPBAR_COMMAND pData)
 
void OnAppBarActivationChange (_In_ const APPBAR_COMMAND *pData)
 
HWND OnAppBarGetAutoHideBar (_In_ UINT uSide)
 
BOOL OnAppBarSetAutoHideBar (_In_ const APPBAR_COMMAND *pData)
 
void OnAppBarSetState (_In_ UINT uState)
 
void OnAppBarNotifyAll (_In_opt_ HMONITOR hMon, _In_opt_ HWND hwndIgnore, _In_ DWORD dwNotify, _In_opt_ LPARAM lParam)
 
WORKAREA_TYPE RecomputeWorkArea (_In_ const RECT *prcTray, _In_ HMONITOR hMonitor, _Out_ PRECT prcWorkArea)
 
void RecomputeAllWorkareas ()
 
void StuckAppChange (_In_opt_ HWND hwndTarget, _In_opt_ const RECT *prcOld, _In_opt_ const RECT *prcNew, _In_ BOOL bTray)
 
void RedrawDesktop (_In_ HWND hwndDesktop, _Inout_ PRECT prc)
 
virtual BOOL IsAutoHideState () const =0
 
virtual BOOL IsHidingState () const =0
 
virtual BOOL IsAlwaysOnTop () const =0
 
virtual HMONITORGetMonitor ()=0
 
virtual HMONITORGetPreviousMonitor ()=0
 
virtual INT GetPosition () const =0
 
virtual const RECTGetTrayRect ()=0
 
virtual HWND GetTrayWnd () const =0
 
virtual HWND GetDesktopWnd () const =0
 
virtual void SetAutoHideState (_In_ BOOL bAutoHide)=0
 
virtual void UpdateAlwaysOnTop (_In_ BOOL bAlwaysOnTop)=0
 

Static Protected Member Functions

static BOOL CALLBACK MonitorEnumProc (_In_ HMONITOR hMonitor, _In_ HDC hDC, _In_ LPRECT prc, _Inout_ LPARAM lParam)
 

Protected Attributes

HDPA m_hAppBarDPA
 
HWND m_ahwndAutoHideBars [4]
 

Detailed Description

Definition at line 44 of file appbar.h.

Constructor & Destructor Documentation

◆ CAppBarManager()

CAppBarManager::CAppBarManager ( )

Definition at line 12 of file appbar.cpp.

15{
16}
HDPA m_hAppBarDPA
Definition: appbar.h:53
HWND m_ahwndAutoHideBars[4]
Definition: appbar.h:54
#define NULL
Definition: types.h:112

◆ ~CAppBarManager()

CAppBarManager::~CAppBarManager ( )
virtual

Definition at line 18 of file appbar.cpp.

19{
21}
void DestroyAppBarDPA()
Definition: appbar.cpp:45

Member Function Documentation

◆ AppBarOutsideOf()

BOOL CAppBarManager::AppBarOutsideOf ( _In_ const APPBAR pAppBar1,
_In_ const APPBAR pAppBar2 
)
protected

Definition at line 254 of file appbar.cpp.

257{
258 if (pAppBar1->uEdge != pAppBar2->uEdge)
259 return FALSE;
260
261 switch (pAppBar2->uEdge)
262 {
263 case ABE_LEFT: return pAppBar1->rc.left >= pAppBar2->rc.left;
264 case ABE_TOP: return pAppBar1->rc.top >= pAppBar2->rc.top;
265 case ABE_RIGHT: return pAppBar1->rc.right <= pAppBar2->rc.right;
266 case ABE_BOTTOM: return pAppBar1->rc.bottom <= pAppBar2->rc.bottom;
267 default:
268 ASSERT(FALSE);
269 return FALSE;
270 }
271}
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
#define ABE_BOTTOM
Definition: shellapi.h:20
#define ABE_RIGHT
Definition: shellapi.h:19
#define ABE_TOP
Definition: shellapi.h:18
#define ABE_LEFT
Definition: shellapi.h:17

Referenced by OnAppBarQueryPos().

◆ AppBarSubtractRect()

void CAppBarManager::AppBarSubtractRect ( _In_ PAPPBAR  pAppBar,
_Inout_ PRECT  prc 
)
protected
Parameters
pAppBarThe target AppBar to subtract.
prcThe rectangle to be subtracted.

Definition at line 239 of file appbar.cpp.

240{
241 switch (pAppBar->uEdge)
242 {
243 case ABE_LEFT: prc->left = max(prc->left, pAppBar->rc.right); break;
244 case ABE_TOP: prc->top = max(prc->top, pAppBar->rc.bottom); break;
245 case ABE_RIGHT: prc->right = min(prc->right, pAppBar->rc.left); break;
246 case ABE_BOTTOM: prc->bottom = min(prc->bottom, pAppBar->rc.top); break;
247 default:
248 ASSERT(FALSE);
249 break;
250 }
251}
#define min(a, b)
Definition: monoChain.cc:55
_Out_ LPRECT prc
Definition: ntgdi.h:1658
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define max(a, b)
Definition: svc.c:63

Referenced by OnAppBarQueryPos(), and RecomputeWorkArea().

◆ ComputeHiddenRect()

void CAppBarManager::ComputeHiddenRect ( _Inout_ PRECT  prc,
_In_ UINT  uSide 
)
protected

Compute the position and size of the hidden TaskBar.

Parameters
prcThe rectangle before hiding TaskBar.
uSideThe side of TaskBar (ABE_...).

Definition at line 285 of file appbar.cpp.

286{
287 MONITORINFO mi = { sizeof(mi) };
288 HMONITOR hMonitor = ::MonitorFromRect(prc, MONITOR_DEFAULTTONULL);
289 if (!::GetMonitorInfoW(hMonitor, &mi))
290 return;
291 RECT rcMon = mi.rcMonitor;
292
293 INT cxy = Edge_IsVertical(uSide) ? (prc->bottom - prc->top) : (prc->right - prc->left);
294 switch (uSide)
295 {
296 case ABE_LEFT:
297 prc->right = rcMon.left + GetSystemMetrics(SM_CXFRAME) / 2;
298 prc->left = prc->right - cxy;
299 break;
300 case ABE_TOP:
301 prc->bottom = rcMon.top + GetSystemMetrics(SM_CYFRAME) / 2;
302 prc->top = prc->bottom - cxy;
303 break;
304 case ABE_RIGHT:
305 prc->left = rcMon.right - GetSystemMetrics(SM_CXFRAME) / 2;
306 prc->right = prc->left + cxy;
307 break;
308 case ABE_BOTTOM:
309 prc->top = rcMon.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
310 prc->bottom = prc->top + cxy;
311 break;
312 default:
313 ASSERT(FALSE);
314 break;
315 }
316}
static BOOL Edge_IsVertical(_In_ UINT uEdge)
Definition: appbar.h:31
static MONITORINFO mi
Definition: win.c:7338
HMONITOR WINAPI MonitorFromRect(LPCRECT, DWORD)
RECT rcMonitor
Definition: winuser.h:3861
int32_t INT
Definition: typedefs.h:58
#define SM_CXFRAME
Definition: winuser.h:1005
#define SM_CYFRAME
Definition: winuser.h:1007
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
int WINAPI GetSystemMetrics(_In_ int)

Referenced by GetDockedRect().

◆ DestroyAppBarDPA()

void CAppBarManager::DestroyAppBarDPA ( )
protected

Definition at line 45 of file appbar.cpp.

46{
47 if (!m_hAppBarDPA)
48 return;
49
51 while (--nItems >= 0)
52 {
54 }
55
58}
int nItems
Definition: appswitch.c:55
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define DPA_GetPtrCount(hdpa)
Definition: commctrl.h:4960
#define DPA_GetPtr
Definition: commctrl.h:5

Referenced by ~CAppBarManager().

◆ EliminateAppBar()

void CAppBarManager::EliminateAppBar ( _In_ INT  iItem)
protected

Definition at line 39 of file appbar.cpp.

40{
43}
LPVOID WINAPI DPA_DeletePtr(HDPA hdpa, INT i)
Definition: dpa.c:677

Referenced by OnAppBarNotifyAll(), and OnAppBarRemove().

◆ FindAppBar()

PAPPBAR CAppBarManager::FindAppBar ( _In_ HWND  hwndAppBar) const
protected

Definition at line 23 of file appbar.cpp.

24{
25 if (!m_hAppBarDPA)
26 return NULL;
27
29 while (--nItems >= 0)
30 {
32 if (pAppBar && hwndAppBar == pAppBar->hWnd)
33 return pAppBar;
34 }
35
36 return NULL;
37}
struct tagAPPBAR * PAPPBAR
HWND hWnd
Definition: appbar.h:12

Referenced by OnAppBarActivationChange(), OnAppBarNew(), OnAppBarQueryPos(), and OnAppBarSetPos().

◆ GetAppBarMessage()

PAPPBAR_COMMAND CAppBarManager::GetAppBarMessage ( _Inout_ PCOPYDATASTRUCT  pCopyData)
protected

Definition at line 483 of file appbar.cpp.

484{
485 PAPPBAR_COMMAND pData = (PAPPBAR_COMMAND)pCopyData->lpData;
486
487 if (pCopyData->cbData != sizeof(*pData) || pData->abd.cbSize != sizeof(pData->abd))
488 {
489 ERR("Invalid AppBar message\n");
490 return NULL;
491 }
492
493 return pData;
494}
#define ERR(fmt,...)
Definition: precomp.h:57
if(dx< 0)
Definition: linetemp.h:194
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
struct tagAPPBAR_COMMAND * PAPPBAR_COMMAND

Referenced by OnAppBarMessage().

◆ GetDesktopWnd()

virtual HWND CAppBarManager::GetDesktopWnd ( ) const
protectedpure virtual

Implemented in CTrayWindow.

Referenced by MonitorEnumProc(), and StuckAppChange().

◆ GetDockedRect()

void CAppBarManager::GetDockedRect ( _Out_ PRECT  prcDocked)
protected

Get rectangle of the tray window.

Parameters
prcDockedThe pointer to the rectangle to be received.

Definition at line 275 of file appbar.cpp.

276{
277 *prcDocked = *GetTrayRect();
279 ComputeHiddenRect(prcDocked, GetPosition());
280}
void ComputeHiddenRect(_Inout_ PRECT prc, _In_ UINT uSide)
Definition: appbar.cpp:285
virtual BOOL IsAutoHideState() const =0
virtual const RECT * GetTrayRect()=0
virtual INT GetPosition() const =0
virtual BOOL IsHidingState() const =0

Referenced by OnAppBarQueryPos().

◆ GetMonitor()

virtual HMONITOR & CAppBarManager::GetMonitor ( )
protectedpure virtual

Implemented in CTrayWindow.

Referenced by OnAppBarQueryPos().

◆ GetPosition()

virtual INT CAppBarManager::GetPosition ( ) const
protectedpure virtual

◆ GetPreviousMonitor()

virtual HMONITOR & CAppBarManager::GetPreviousMonitor ( )
protectedpure virtual

Implemented in CTrayWindow.

Referenced by StuckAppChange().

◆ GetTrayRect()

virtual const RECT * CAppBarManager::GetTrayRect ( )
protectedpure virtual

◆ GetTrayWnd()

virtual HWND CAppBarManager::GetTrayWnd ( ) const
protectedpure virtual

Implemented in CTrayWindow.

Referenced by OnAppBarActivationChange2().

◆ IsAlwaysOnTop()

virtual BOOL CAppBarManager::IsAlwaysOnTop ( ) const
protectedpure virtual

Implemented in CTrayWindow.

Referenced by OnAppBarGetState().

◆ IsAutoHideState()

virtual BOOL CAppBarManager::IsAutoHideState ( ) const
protectedpure virtual

◆ IsHidingState()

virtual BOOL CAppBarManager::IsHidingState ( ) const
protectedpure virtual

Implemented in CTrayWindow.

Referenced by GetDockedRect().

◆ MonitorEnumProc()

BOOL CALLBACK CAppBarManager::MonitorEnumProc ( _In_ HMONITOR  hMonitor,
_In_ HDC  hDC,
_In_ LPRECT  prc,
_Inout_ LPARAM  lParam 
)
staticprotected

Definition at line 430 of file appbar.cpp.

435{
438
439 RECT rcWorkArea;
440 if (pThis->RecomputeWorkArea(prc, hMonitor, &rcWorkArea) != WORKAREA_IS_NOT_MONITOR)
441 return TRUE;
442
443 HWND hwndDesktop = pThis->GetDesktopWnd();
444 ::SystemParametersInfoW(SPI_SETWORKAREA, 0, &rcWorkArea, hwndDesktop ? SPIF_SENDCHANGE : 0);
445 pThis->RedrawDesktop(hwndDesktop, &rcWorkArea);
446 return TRUE;
447}
static HDC hDC
Definition: 3dtext.c:33
@ WORKAREA_IS_NOT_MONITOR
Definition: appbar.h:40
virtual HWND GetDesktopWnd() const =0
WORKAREA_TYPE RecomputeWorkArea(_In_ const RECT *prcTray, _In_ HMONITOR hMonitor, _Out_ PRECT prcWorkArea)
Definition: appbar.cpp:395
void RedrawDesktop(_In_ HWND hwndDesktop, _Inout_ PRECT prc)
Definition: appbar.cpp:382
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define SPIF_SENDCHANGE
Definition: winuser.h:1591
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)

Referenced by RecomputeAllWorkareas().

◆ OnAppBarActivationChange()

void CAppBarManager::OnAppBarActivationChange ( _In_ const APPBAR_COMMAND pData)
protected

Definition at line 520 of file appbar.cpp.

521{
522 HWND hWnd = (HWND)UlongToHandle(pData->abd.hWnd32);
523 PAPPBAR pAppBar = FindAppBar(hWnd);
524 if (!pAppBar)
525 {
526 ERR("Not found: %p\n", hWnd);
527 return;
528 }
529
530 HWND hwndAppBar = pAppBar->hWnd;
531 for (UINT uSide = ABE_LEFT; uSide <= ABE_BOTTOM; ++uSide)
532 {
533 if (m_ahwndAutoHideBars[uSide] == hwndAppBar && uSide != pAppBar->uEdge)
534 return;
535 }
536
537 OnAppBarActivationChange2(hwndAppBar, pAppBar->uEdge);
538}
HWND hWnd
Definition: settings.c:17
#define UlongToHandle(ul)
Definition: basetsd.h:97
PAPPBAR FindAppBar(_In_ HWND hwndAppBar) const
Definition: appbar.cpp:23
void OnAppBarActivationChange2(_In_ HWND hwndNewAutoHide, _In_ UINT uSide)
Definition: appbar.cpp:475
HANDLE HWND
Definition: compat.h:19
unsigned int UINT
Definition: ndis.h:50
UINT uEdge
Definition: appbar.h:14

Referenced by OnAppBarMessage().

◆ OnAppBarActivationChange2()

void CAppBarManager::OnAppBarActivationChange2 ( _In_ HWND  hwndNewAutoHide,
_In_ UINT  uSide 
)
protected

Definition at line 475 of file appbar.cpp.

476{
477 HWND hwndAutoHideBar = OnAppBarGetAutoHideBar(uSide);
478 if (hwndAutoHideBar && hwndAutoHideBar != hwndNewAutoHide)
479 ::PostMessageW(GetTrayWnd(), TWM_SETZORDER, (WPARAM)hwndAutoHideBar, uSide);
480}
#define TWM_SETZORDER
Definition: precomp.h:135
virtual HWND GetTrayWnd() const =0
HWND OnAppBarGetAutoHideBar(_In_ UINT uSide)
Definition: appbar.cpp:541
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by CTrayWindow::OnActivate(), and OnAppBarActivationChange().

◆ OnAppBarGetAutoHideBar()

HWND CAppBarManager::OnAppBarGetAutoHideBar ( _In_ UINT  uSide)
protected

Definition at line 541 of file appbar.cpp.

542{
543 if (uSide >= _countof(m_ahwndAutoHideBars))
544 return NULL;
545
546 if (!::IsWindow(m_ahwndAutoHideBars[uSide]))
547 m_ahwndAutoHideBars[uSide] = NULL;
548 return m_ahwndAutoHideBars[uSide];
549}
#define _countof(array)
Definition: sndvol32.h:70
BOOL WINAPI IsWindow(_In_opt_ HWND)

Referenced by OnAppBarActivationChange2(), and OnAppBarMessage().

◆ OnAppBarGetState()

UINT CAppBarManager::OnAppBarGetState ( )
protected

Definition at line 497 of file appbar.cpp.

498{
499 return (IsAutoHideState() ? ABS_AUTOHIDE : 0) | (IsAlwaysOnTop() ? ABS_ALWAYSONTOP : 0);
500}
virtual BOOL IsAlwaysOnTop() const =0
#define ABS_ALWAYSONTOP
Definition: shellapi.h:22
#define ABS_AUTOHIDE
Definition: shellapi.h:21

Referenced by OnAppBarMessage().

◆ OnAppBarGetTaskbarPos()

BOOL CAppBarManager::OnAppBarGetTaskbarPos ( _Inout_ PAPPBAR_COMMAND  pData)
protected

Definition at line 503 of file appbar.cpp.

504{
506 if (!pOutput)
507 {
508 ERR("!pOutput: %d\n", pData->dwProcessId);
509 return FALSE;
510 }
511
512 pOutput->rc = *GetTrayRect();
513 pOutput->uEdge = GetPosition();
514
515 AppBar_UnLockOutput(pOutput);
516 return TRUE;
517}
static PAPPBARDATAINTEROP AppBar_LockOutput(_In_ PAPPBAR_COMMAND pData)
Definition: appbar.h:19
static VOID AppBar_UnLockOutput(_Out_ PAPPBARDATAINTEROP pOutput)
Definition: appbar.h:25

Referenced by OnAppBarMessage().

◆ OnAppBarMessage()

LRESULT CAppBarManager::OnAppBarMessage ( _Inout_ PCOPYDATASTRUCT  pCopyData)

Definition at line 571 of file appbar.cpp.

572{
574 if (!pData)
575 return 0;
576
577 switch (pData->dwMessage)
578 {
579 case ABM_NEW:
580 return OnAppBarNew(pData);
581 case ABM_REMOVE:
583 break;
584 case ABM_QUERYPOS:
586 break;
587 case ABM_SETPOS:
589 break;
590 case ABM_GETSTATE:
591 return OnAppBarGetState();
594 case ABM_ACTIVATE:
597 break;
599 return (LRESULT)OnAppBarGetAutoHideBar(pData->abd.uEdge);
602 case ABM_SETSTATE:
603 OnAppBarSetState((UINT)pData->abd.lParam64);
604 break;
605 default:
606 {
607 FIXME("0x%X\n", pData->dwMessage);
608 return FALSE;
609 }
610 }
611 return TRUE;
612}
#define FIXME(fmt,...)
Definition: precomp.h:53
BOOL OnAppBarGetTaskbarPos(_Inout_ PAPPBAR_COMMAND pData)
Definition: appbar.cpp:503
void OnAppBarRemove(_In_ const APPBAR_COMMAND *pData)
Definition: appbar.cpp:101
void OnAppBarSetState(_In_ UINT uState)
Definition: appbar.cpp:561
void OnAppBarActivationChange(_In_ const APPBAR_COMMAND *pData)
Definition: appbar.cpp:520
void OnAppBarSetPos(_Inout_ PAPPBAR_COMMAND pData)
Definition: appbar.cpp:182
BOOL OnAppBarSetAutoHideBar(_In_ const APPBAR_COMMAND *pData)
Definition: appbar.cpp:552
PAPPBAR_COMMAND GetAppBarMessage(_Inout_ PCOPYDATASTRUCT pCopyData)
Definition: appbar.cpp:483
void OnAppBarQueryPos(_Inout_ PAPPBAR_COMMAND pData)
Definition: appbar.cpp:124
BOOL OnAppBarNew(_In_ const APPBAR_COMMAND *pData)
Definition: appbar.cpp:61
UINT OnAppBarGetState()
Definition: appbar.cpp:497
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:70
#define ABM_GETTASKBARPOS
Definition: shellapi.h:66
#define ABM_GETSTATE
Definition: shellapi.h:65
#define ABM_SETAUTOHIDEBAR
Definition: shellapi.h:69
#define ABM_SETSTATE
Definition: shellapi.h:71
#define ABM_SETPOS
Definition: shellapi.h:64
#define ABM_ACTIVATE
Definition: shellapi.h:67
#define ABM_REMOVE
Definition: shellapi.h:62
#define ABM_NEW
Definition: shellapi.h:61
#define ABM_GETAUTOHIDEBAR
Definition: shellapi.h:68
#define ABM_QUERYPOS
Definition: shellapi.h:63
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by CTrayWindow::OnCopyData().

◆ OnAppBarNew()

BOOL CAppBarManager::OnAppBarNew ( _In_ const APPBAR_COMMAND pData)
protected

Definition at line 61 of file appbar.cpp.

62{
63 HWND hWnd = (HWND)UlongToHandle(pData->abd.hWnd32);
64
65 if (m_hAppBarDPA)
66 {
67 if (FindAppBar(hWnd))
68 {
69 ERR("Already exists: %p\n", hWnd);
70 return FALSE;
71 }
72 }
73 else
74 {
75 const UINT c_nGrow = 4;
76 m_hAppBarDPA = DPA_Create(c_nGrow);
77 if (!m_hAppBarDPA)
78 {
79 ERR("Out of memory\n");
80 return FALSE;
81 }
82 }
83
84 PAPPBAR pAppBar = (PAPPBAR)::LocalAlloc(LPTR, sizeof(*pAppBar));
85 if (pAppBar)
86 {
87 pAppBar->hWnd = hWnd;
88 pAppBar->uEdge = UINT_MAX;
89 pAppBar->uCallbackMessage = pData->abd.uCallbackMessage;
90 if (DPA_InsertPtr(m_hAppBarDPA, INT_MAX, pAppBar) >= 0)
91 return TRUE; // Success!
92
93 ::LocalFree(pAppBar);
94 }
95
96 ERR("Out of memory\n");
97 return FALSE;
98}
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
INT WINAPI DPA_InsertPtr(HDPA hdpa, INT i, LPVOID p)
Definition: dpa.c:591
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define INT_MAX
Definition: intsafe.h:150
#define UINT_MAX
Definition: intsafe.h:152
UINT uCallbackMessage
Definition: appbar.h:13
#define LPTR
Definition: winbase.h:414

Referenced by OnAppBarMessage().

◆ OnAppBarNotifyAll()

void CAppBarManager::OnAppBarNotifyAll ( _In_opt_ HMONITOR  hMon,
_In_opt_ HWND  hwndIgnore,
_In_ DWORD  dwNotify,
_In_opt_ LPARAM  lParam 
)
protected

Definition at line 207 of file appbar.cpp.

212{
213 TRACE("%p, %p, 0x%X, %p\n", hMon, hwndIgnore, dwNotify, lParam);
214
215 if (!m_hAppBarDPA)
216 return;
217
219 while (--nItems >= 0)
220 {
222 if (!pAppBar || pAppBar->hWnd == hwndIgnore)
223 continue;
224
225 HWND hwndAppBar = pAppBar->hWnd;
226 if (!::IsWindow(hwndAppBar))
227 {
229 continue;
230 }
231
232 if (!hMon || hMon == ::MonitorFromWindow(hwndAppBar, MONITOR_DEFAULTTONULL))
233 ::PostMessageW(hwndAppBar, pAppBar->uCallbackMessage, dwNotify, lParam);
234 }
235}
void EliminateAppBar(_In_ INT iItem)
Definition: appbar.cpp:39
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CTrayWindow::ExecContextMenuCmd(), and StuckAppChange().

◆ OnAppBarQueryPos()

void CAppBarManager::OnAppBarQueryPos ( _Inout_ PAPPBAR_COMMAND  pData)
protected

Definition at line 124 of file appbar.cpp.

125{
126 HWND hWnd = (HWND)UlongToHandle(pData->abd.hWnd32);
127 PAPPBAR pAppBar1 = FindAppBar(hWnd);
128 if (!pAppBar1)
129 {
130 ERR("Not found: %p\n", hWnd);
131 return;
132 }
133
135 if (!pOutput)
136 {
137 ERR("!pOutput: %d\n", pData->dwProcessId);
138 return;
139 }
140 pOutput->rc = pData->abd.rc;
141
142 if (::IsRectEmpty(&pOutput->rc))
143 ERR("IsRectEmpty\n");
144
145 HMONITOR hMon1 = ::MonitorFromRect(&pOutput->rc, MONITOR_DEFAULTTOPRIMARY);
146 ASSERT(hMon1 != NULL);
147
148 // Subtract tray rectangle from pOutput->rc if necessary
149 if (hMon1 == GetMonitor() && !IsAutoHideState())
150 {
151 APPBAR dummyAppBar;
152 dummyAppBar.uEdge = GetPosition();
153 GetDockedRect(&dummyAppBar.rc);
154 AppBarSubtractRect(&dummyAppBar, &pOutput->rc);
155 }
156
157 // Subtract area from pOutput->rc
158 UINT uEdge = pData->abd.uEdge;
160 while (--nItems >= 0)
161 {
163 if (!pAppBar2 || pAppBar1->hWnd == pAppBar2->hWnd)
164 continue;
165
166 if ((Edge_IsVertical(uEdge) || !Edge_IsVertical(pAppBar2->uEdge)) &&
167 (pAppBar1->uEdge != uEdge || !AppBarOutsideOf(pAppBar1, pAppBar2)))
168 {
169 if (pAppBar1->uEdge == uEdge || pAppBar2->uEdge != uEdge)
170 continue;
171 }
172
173 HMONITOR hMon2 = ::MonitorFromRect(&pAppBar2->rc, MONITOR_DEFAULTTONULL);
174 if (hMon1 == hMon2)
175 AppBarSubtractRect(pAppBar2, &pOutput->rc);
176 }
177
178 AppBar_UnLockOutput(pOutput);
179}
void AppBarSubtractRect(_In_ PAPPBAR pAppBar, _Inout_ PRECT prc)
Definition: appbar.cpp:239
BOOL AppBarOutsideOf(_In_ const APPBAR *pAppBar1, _In_ const APPBAR *pAppBar2)
Definition: appbar.cpp:254
void GetDockedRect(_Out_ PRECT prcDocked)
Definition: appbar.cpp:275
virtual HMONITOR & GetMonitor()=0
RECT rc
Definition: appbar.h:15
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)

Referenced by OnAppBarMessage(), and OnAppBarSetPos().

◆ OnAppBarRemove()

void CAppBarManager::OnAppBarRemove ( _In_ const APPBAR_COMMAND pData)
protected

Definition at line 101 of file appbar.cpp.

102{
103 if (!m_hAppBarDPA)
104 return;
105
106 HWND hWnd = (HWND)UlongToHandle(pData->abd.hWnd32);
108 while (--nItems >= 0)
109 {
111 if (!pAppBar)
112 continue;
113
114 if (pAppBar->hWnd == hWnd)
115 {
116 RECT rcOld = pAppBar->rc;
118 StuckAppChange(hWnd, &rcOld, NULL, FALSE);
119 }
120 }
121}
void StuckAppChange(_In_opt_ HWND hwndTarget, _In_opt_ const RECT *prcOld, _In_opt_ const RECT *prcNew, _In_ BOOL bTray)
Definition: appbar.cpp:324

Referenced by OnAppBarMessage().

◆ OnAppBarSetAutoHideBar()

BOOL CAppBarManager::OnAppBarSetAutoHideBar ( _In_ const APPBAR_COMMAND pData)
protected

Definition at line 552 of file appbar.cpp.

553{
554 if (pData->abd.uEdge >= _countof(m_ahwndAutoHideBars))
555 return FALSE;
556 HWND hwndTarget = (HWND)UlongToHandle(pData->abd.hWnd32);
557 return SetAutoHideBar(hwndTarget, (BOOL)pData->abd.lParam64, pData->abd.uEdge);
558}
BOOL SetAutoHideBar(_In_ HWND hwndTarget, _In_ BOOL bSetOrReset, _In_ UINT uSide)
Definition: appbar.cpp:454
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by OnAppBarMessage().

◆ OnAppBarSetPos()

void CAppBarManager::OnAppBarSetPos ( _Inout_ PAPPBAR_COMMAND  pData)
protected

Definition at line 182 of file appbar.cpp.

183{
184 HWND hWnd = (HWND)UlongToHandle(pData->abd.hWnd32);
185 PAPPBAR pAppBar = FindAppBar(hWnd);
186 if (!pAppBar)
187 return;
188
190
192 if (!pOutput)
193 return;
194
195 RECT rcOld = pAppBar->rc, rcNew = pData->abd.rc;
196 BOOL bChanged = !::EqualRect(&rcOld, &rcNew);
197
198 pAppBar->rc = rcNew;
199 pAppBar->uEdge = pData->abd.uEdge;
200
201 AppBar_UnLockOutput(pOutput);
202
203 if (bChanged)
204 StuckAppChange(hWnd, &rcOld, &rcNew, FALSE);
205}
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by OnAppBarMessage().

◆ OnAppBarSetState()

void CAppBarManager::OnAppBarSetState ( _In_ UINT  uState)
protected

Definition at line 561 of file appbar.cpp.

562{
563 if ((uState & ~(ABS_AUTOHIDE | ABS_ALWAYSONTOP)))
564 return;
565
566 SetAutoHideState(!!(uState & ABS_AUTOHIDE));
568}
virtual void UpdateAlwaysOnTop(_In_ BOOL bAlwaysOnTop)=0
virtual void SetAutoHideState(_In_ BOOL bAutoHide)=0

Referenced by OnAppBarMessage().

◆ RecomputeAllWorkareas()

void CAppBarManager::RecomputeAllWorkareas ( )
protected

Definition at line 449 of file appbar.cpp.

450{
452}
static BOOL CALLBACK MonitorEnumProc(_In_ HMONITOR hMonitor, _In_ HDC hDC, _In_ LPRECT prc, _Inout_ LPARAM lParam)
Definition: appbar.cpp:430
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI EnumDisplayMonitors(_In_opt_ HDC, _In_opt_ LPCRECT, _In_ MONITORENUMPROC, _In_ LPARAM)

Referenced by CTrayWindow::OnDisplayChange().

◆ RecomputeWorkArea()

WORKAREA_TYPE CAppBarManager::RecomputeWorkArea ( _In_ const RECT prcTray,
_In_ HMONITOR  hMonitor,
_Out_ PRECT  prcWorkArea 
)
protected

Re-compute the work area.

Parameters
prcTrayThe position and size of the tray window
hMonitorThe monitor of the work area to re-compute.
prcWorkAreaThe work area to be re-computed.

Definition at line 395 of file appbar.cpp.

399{
400 MONITORINFO mi = { sizeof(mi) };
401 if (!::GetMonitorInfoW(hMonitor, &mi))
403
404 if (IsAutoHideState())
405 *prcWorkArea = mi.rcMonitor;
406 else
407 ::SubtractRect(prcWorkArea, &mi.rcMonitor, prcTray);
408
409 if (m_hAppBarDPA)
410 {
412 while (--nItems >= 0)
413 {
415 if (pAppBar && hMonitor == ::MonitorFromRect(&pAppBar->rc, MONITOR_DEFAULTTONULL))
416 AppBarSubtractRect(pAppBar, prcWorkArea);
417 }
418 }
419
420 if (!::EqualRect(prcWorkArea, &mi.rcWork))
422
423 if (IsAutoHideState() || ::IsRectEmpty(prcTray))
425
427}
@ WORKAREA_SAME_AS_MONITOR
Definition: appbar.h:41
@ WORKAREA_NO_TRAY_AREA
Definition: appbar.h:39
BOOL WINAPI SubtractRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

Referenced by MonitorEnumProc(), and StuckAppChange().

◆ RedrawDesktop()

void CAppBarManager::RedrawDesktop ( _In_ HWND  hwndDesktop,
_Inout_ PRECT  prc 
)
protected

Definition at line 382 of file appbar.cpp.

383{
384 if (!hwndDesktop)
385 return;
386 ::MapWindowPoints(NULL, hwndDesktop, (POINT*)prc, sizeof(*prc) / sizeof(POINT));
388}
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define RDW_ERASE
Definition: winuser.h:1222
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
#define RDW_INVALIDATE
Definition: winuser.h:1225

Referenced by MonitorEnumProc(), and StuckAppChange().

◆ SetAutoHideBar()

BOOL CAppBarManager::SetAutoHideBar ( _In_ HWND  hwndTarget,
_In_ BOOL  bSetOrReset,
_In_ UINT  uSide 
)
protected

Definition at line 454 of file appbar.cpp.

455{
457 HWND *phwndAutoHide = &m_ahwndAutoHideBars[uSide];
458 if (!IsWindow(*phwndAutoHide))
459 *phwndAutoHide = NULL;
460
461 if (bSetOrReset) // Set?
462 {
463 if (!*phwndAutoHide)
464 *phwndAutoHide = hwndTarget;
465 return *phwndAutoHide == hwndTarget;
466 }
467 else // Reset
468 {
469 if (*phwndAutoHide == hwndTarget)
470 *phwndAutoHide = NULL;
471 return TRUE;
472 }
473}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10

Referenced by OnAppBarSetAutoHideBar().

◆ SetAutoHideState()

virtual void CAppBarManager::SetAutoHideState ( _In_ BOOL  bAutoHide)
protectedpure virtual

Implemented in CTrayWindow.

Referenced by OnAppBarSetState().

◆ StuckAppChange()

void CAppBarManager::StuckAppChange ( _In_opt_ HWND  hwndTarget,
_In_opt_ const RECT prcOld,
_In_opt_ const RECT prcNew,
_In_ BOOL  bTray 
)
protected

This function is called when AppBar and/or TaskBar is being moved, removed, and/or updated.

Parameters
hwndTargetThe target window. Optional.
prcOldThe old position and size. Optional.
prcNewThe new position and size. Optional.
bTrayTRUE if the tray is being moved.

Definition at line 324 of file appbar.cpp.

329{
330 RECT rcWorkArea1, rcWorkArea2;
331 HMONITOR hMon1 = NULL;
332 UINT flags = 0;
333 enum { SET_WORKAREA_1 = 1, SET_WORKAREA_2 = 2, NEED_SIZING = 4 }; // for flags
334
335 if (prcOld)
336 {
337 hMon1 = (bTray ? GetPreviousMonitor() : ::MonitorFromRect(prcOld, MONITOR_DEFAULTTONEAREST));
338 if (hMon1)
339 {
340 WORKAREA_TYPE type1 = RecomputeWorkArea(GetTrayRect(), hMon1, &rcWorkArea1);
341 if (type1 == WORKAREA_IS_NOT_MONITOR)
342 flags = SET_WORKAREA_1;
343 if (type1 == WORKAREA_SAME_AS_MONITOR)
344 flags = NEED_SIZING;
345 }
346 }
347
348 if (prcNew)
349 {
350 HMONITOR hMon2 = ::MonitorFromRect(prcNew, MONITOR_DEFAULTTONULL);
351 if (hMon2 && hMon2 != hMon1)
352 {
353 WORKAREA_TYPE type2 = RecomputeWorkArea(GetTrayRect(), hMon2, &rcWorkArea2);
354 if (type2 == WORKAREA_IS_NOT_MONITOR)
355 flags |= SET_WORKAREA_2;
356 else if (type2 == WORKAREA_SAME_AS_MONITOR && !flags)
357 flags = NEED_SIZING;
358 }
359 }
360
361 if (flags & SET_WORKAREA_1)
362 {
363 UINT fWinIni = ((flags == SET_WORKAREA_1 && GetDesktopWnd()) ? SPIF_SENDCHANGE : 0);
364 ::SystemParametersInfoW(SPI_SETWORKAREA, TRUE, &rcWorkArea1, fWinIni);
365 RedrawDesktop(GetDesktopWnd(), &rcWorkArea1);
366 }
367
368 if (flags & SET_WORKAREA_2)
369 {
370 UINT fWinIni = (GetDesktopWnd() ? SPIF_SENDCHANGE : 0);
371 ::SystemParametersInfoW(SPI_SETWORKAREA, TRUE, &rcWorkArea2, fWinIni);
372 RedrawDesktop(GetDesktopWnd(), &rcWorkArea2);
373 }
374
375 if (bTray || flags == NEED_SIZING)
377
378 // Post ABN_POSCHANGED messages to AppBar windows
380}
WORKAREA_TYPE
Definition: appbar.h:38
void OnAppBarNotifyAll(_In_opt_ HMONITOR hMon, _In_opt_ HWND hwndIgnore, _In_ DWORD dwNotify, _In_opt_ LPARAM lParam)
Definition: appbar.cpp:207
virtual HMONITOR & GetPreviousMonitor()=0
GLbitfield flags
Definition: glext.h:7161
#define ABN_POSCHANGED
Definition: shellapi.h:73
#define WM_SIZE
Definition: winuser.h:1630
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by OnAppBarRemove(), and OnAppBarSetPos().

◆ UpdateAlwaysOnTop()

virtual void CAppBarManager::UpdateAlwaysOnTop ( _In_ BOOL  bAlwaysOnTop)
protectedpure virtual

Implemented in CTrayWindow.

Referenced by OnAppBarSetState().

Member Data Documentation

◆ m_ahwndAutoHideBars

HWND CAppBarManager::m_ahwndAutoHideBars[4]
protected

◆ m_hAppBarDPA

HDPA CAppBarManager::m_hAppBarDPA
protected

The documentation for this class was generated from the following files: