这一段是在AppBar的程序里面要用的<br><br>Uses ShellApi, AppBar;<br><br>var g_uSide:longInt; // record which side my AppBar resides.<br>// AppBarPosChanged - adjusts the appbar's size and position.<br>// pabd - address of an APPBARDATA structure that contains information<br>// used to adjust the size and position<br>procedure AppBarPosChanged(var abd : APPBARDATA);<br>var<br> rc : TRECT;<br> rcWindow :TRECT;<br> iHeight :integer;<br> iWidth :Integer;<br>Begin<br> rc.top := 0;<br> rc.left := 0;<br> rc.right := GetSystemMetrics(SM_CXSCREEN);<br> rc.bottom := GetSystemMetrics(SM_CYSCREEN);<br><br> GetWindowRect(abd.hWnd, rcWindow);<br> iHeight := rcWindow.bottom - rcWindow.top;<br> iWidth := rcWindow.right - rcWindow.left;<br><br> case (g_uSide) of<br> ABE_TOP:<br> rc.bottom := rc.top + iHeight;<br> ABE_BOTTOM:<br> rc.top := rc.bottom - iHeight;<br> ABE_LEFT:<br> rc.right := rc.left + iWidth;<br> ABE_RIGHT:<br> rc.left := rc.right - iWidth;<br> end;<br><br> AppBarQuerySetPos(g_uSide, rc, abd);<br>end;<br><br>// 这个CallBack处理过程 handle住系统发来的AppBar通知消息<br>// AppBarCallback - processes notification messages sent by the system.<br>// hwndAccessBar - handle to the appbar<br>// uNotifyMsg - identifier of the notification message<br>// lParam - message parameter<br>procedure AppBarCallback(hwndAccessBar : HWND; uNotifyMsg : UINT; lParam : LongInt);<br>var<br> abd :APPBARDATA;<br> uState: LongInt;<br> hWndTmp : HWnd;<br>begin<br> abd.cbSize := sizeof(abd);<br> abd.hWnd := hwndAccessBar;<br><br> case (uNotifyMsg) of<br> ABN_STATECHANGE:<br> Begin<br><br> // Check to see if the taskbar's always-on-top state has<br> // changed and, if it has, change the appbar's state<br> // accordingly.<br> uState := SHAppBarMessage(ABM_GETSTATE, abd);<br> if (ABS_ALWAYSONTOP and uState)<>0 then<br> Begin<br> hWndTmp := HWND_TOPMOST<br> End<br> else<br> hWndTmp := HWND_BOTTOM;<br><br> SetWindowPos(hwndAccessBar,<br> hWndTmp,<br> 0, 0, 0, 0,<br> SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);<br> end;<br> ABN_FULLSCREENAPP:<br> Begin<br> // A full-screen application has started, or the last full-<br> // screen application has closed. Set the appbar's<br> // z-order appropriately.<br> if (lParam<>0) then<br> Begin<br> if (ABS_ALWAYSONTOP and uState)<>0 then<br> Begin<br> hWndTmp := HWND_TOPMOST<br> End<br> else<br> hWndTmp := HWND_BOTTOM;<br><br> SetWindowPos(hwndAccessBar, hWndTmp,<br> 0, 0, 0, 0,<br> SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);<br> End<br> else<br> Begin<br> uState := SHAppBarMessage(ABM_GETSTATE, abd);<br> if (uState and ABS_ALWAYSONTOP)<>0 then<br> begin<br> SetWindowPos(hwndAccessBar, HWND_TOPMOST,<br> 0, 0, 0, 0,<br> SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);<br> end;<br> End;<br> End;<br> ABN_POSCHANGED:<br> Begin<br> // The taskbar or another appbar has changed its<br> // size or position.<br> AppBarPosChanged(abd, g_uSide);<br> End<br> End;<br>End;<br><br>