***************************************************************** * Neveprise Inc. Delphi FAQ * ***************************************************************** * Section: WinAPI Topic: Registering a taskbar * * Created: July 26th, 1999 Revised: July 26th, 1999 * * Updates: www.neveprise.de Info: support@neveprise.de * ***************************************************************** Q: How can I register my application as a taskbar? A: You simply can align a form to the top e.g. and set the FormStyle Property to fsStayOnTop, so that no app can hide yours. But There are at least two problems: a) some other apps or windows still can cover your taskbar's window when they have the same stay-on-top property set and b) it does not define new Desktop metrics, so if an application maximizes, it lays behind your form instead of aligning to it. So you have to register that form as an ordinary taskbar: procedure RegisterTaskBarH(FormHandle: THandle; Metrics: TRect; Align: byte; UnRegister:boolean); var AppStruct: TAppBarData; begin if UnRegister=false then begin //means you want to register a form with AppStruct do begin cbSize:= SizeOf(AppStruct); //set record's size hWnd:= FormHandle; //e.g. Form1.Handle uCallBackMessage:= WM_Activate; Rc:= Metrics; lParam:= WM_Activate; case Align of //where shall it be placed? top, bottom...? tbaTop: uEdge:= ABE_Top; tbaBottom: uEdge:= ABE_Bottom; tbaLeft: uEdge:= ABE_Left; tbaRight: uEdge:= ABE_Right; end; end; SHAppBarMessage(ABM_New,AppStruct); //add your form SHAppBarMessage(ABM_SetPos,AppStruct); //set it's position SHAppBarMessage(ABM_Activate,AppStruct); //activate it //and notify all other windows that your taskbar occupies a //special area (the metric bounds) on Desktop; thus they "know" //how far they can maximize etc. SHAppBarMessage(ABM_WindowPosChanged,AppStruct); //that's it! end else begin //or we want to release our app with AppStruct do begin //clear parameters Rc:=rect(0,0,0,0); cbSize:=SizeOf(AppStruct); hWnd:=FormHandle; uCallBackMessage:=WM_Close; end; SHAppBarMessage(ABM_SetPos,AppStruct); //..feed functions with "nil" SHAppBarMessage(ABM_Activate,AppStruct); SHAppBarMessage(ABM_WindowPosChanged,AppStruct); SHAppBarMessage(ABM_Remove,AppStruct); end; end; If your window shall be placed to the top of the Desktop, you would call the procedure this way: with Metrics do begin //type: TRect Left:= 0; Top:= 0; Bottom:= Screen.Width; Right:= Form1.Height; end; RegisterTaksBarH(Form1.Handle, Metrics, tbaTop, false); Blazko