Using the Access Bar Callback Message

As mentioned earlier, an application can specify that a callback message must be sent to it. SHELLFUN defines this message as APPBAR_CALLBACK (although an application can specify any message). This callback message is used for processing notifications that are sent to the access bar when the state of the bar changes (for example, from ABS_ALWAYSONTOP), when a full-screen application starts or closes, and when an event occurs that might affect the bar's size or position. SHELLFUN uses the following code to process the access bar's callback message. (It's very similar to code used as an example in the Win32 SDK.)

void AppBarCallback (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
UINT uState;

switch (wParam)
{
case ABN_STATECHANGE:
// Check to see whether the access bar is still ABS_ALWAYSONTOP.
uState = SHAppBarMessage (ABM_GETSTATE, &g_appBar);

SetWindowPos (hWnd,
(ABS_ALWAYSONTOP & uState) ? HWND_TOPMOST : HWND_BOTTOM,
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
break;

case ABN_FULLSCREENAPP:
// A full-screen application has started, or the last
// full-screen application has closed. Reset the access bar's
// z-order appropriately.
uState = SHAppBarMessage (ABM_GETSTATE, &g_appBar);

if (lParam)
{
SetWindowPos (hWnd,
(ABS_ALWAYSONTOP & uState) ? HWND_TOPMOST : HWND_BOTTOM,
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
else
{
if (uState & ABS_ALWAYSONTOP)
SetWindowPos (hWnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}

case ABN_POSCHANGED:
// The taskbar or another access bar
// has changed its size or position.
AppBarPosChanged (g_appBar.uEdge, &g_appBar);
break;
}
}