***************************************************************** * Neveprise Inc. Delphi FAQ * ***************************************************************** * Section: Desktop Topic: Changing taskbar props * * Created: July 26th, 1999 Revised: July 27th, 1999 * * Updates: www.neveprise.de Info: support@neveprise.de * ***************************************************************** Q: How can I change the properties of the Windows taskbar? A: There is not very much to change, as far as I know. However, you can change the buttons / icons that represent running apps. This includes default width and gaps between'em. The other things to change are Window tracing (the animation effect happening when mini- or maximizing apps - normally you set this property under Settings|Taskbar) as well as hiding or disabling the startbutton (well, it is more a gag than usefull). The function below can also be used just to get info on these properties. To explain the function: the type TTaskBarCommand indicates what you want the function to do, Switch (boolean) defines if you want to enable or disble something, Metric (word) is used for setting width or gap, and the result is width or gap in pixels if you call the FUnction width tbGetIconGap or tbGetIconWidth. In all other cases, it returns a pseudo-boolean to tell if the function was successfull, e.g. 1 equals true, 0 equals false. interface type TTaskBarCommand = ( tbSetIconWidth, //metrics of app' icons tbSetIconGap, tbGetIconWidth, tbGetIconGap, tbSetWindowTracing, //animation on window resize tbGetWindowTracing, tbHideStartButton, //nice gag: hide the startbutton tbDisableStartButton ); implementation function TaskBarH(Command: TTaskBarCommand; Switch: boolean; Metric:word): word; var hWnd: THandle; Reg: TRegIniFile; //we use it cos one command does not work right...:-( mRect: TMinimizedMetrics; TAI: TAnimationInfo; Rgn: hRgn; //similar to TRect (^PRect) begin Result:=0; Reg:=TRegIniFile.Create(''); Reg.RootKey:=HKEY_CURRENT_USER; if Command=tbSetIconWidth then begin //we want to set default width of buttons mRect.cbSize:=SizeOf(mRect); //init record mRect.iWidth:=Metric; //fill the right parameter with info if SystemParametersInfo(SPI_SetMinimizedMetrics, SizeOf(mRect),@mRect,SPIF_UpdateIniFile)=true then Result:=1 else Result:=0; //and set end; if Command=tbSetIconGap then begin //we want to set distances between buttons mRect.cbSize:=SizeOf(mRect); //init record mRect.iHorzGap:=Metric; //fill it with our values mRect.iVertGap:=Metric; if SystemParametersInfo(SPI_SetMinimizedMetrics, SizeOf(mRect),@mRect,SPIF_UpdateIniFile)=true then Result:=1 else Result:=0; //and set'em end; if Command=tbGetIconWidth then begin //retrieves button;s width mRect.cbSize:=SizeOf(mRect); //init record SystemParametersInfo(SPI_GetMinimizedMetrics, SizeOf(mRect),@mRect,SPIF_SendWinIniChange); //fill it Result:=mRect.iWidth; //return result end; if Command=tbGetIconGap then begin //retrieve distance between buttons mRect.cbSize:=SizeOf(mRect); SystemParametersInfo(SPI_GetMinimizedMetrics, SizeOf(mRect),@mRect,SPIF_SendWinIniChange); Result:=mRect.iHorzGap; end; if Command=tbSetWindowTracing then begin //we want to set window animation //the following code is commented out, although it should work; but in fact it //does not, so we write into the Registry // TAI.cbSize:=SizeOf(TAI); // if Switch=true then TAI.iMinAnimate:=0 else TAI.iMinAnimate:=1; // TAI.cbSize:=SizeOf(TAI); // if SystemParametersInfo(SPI_GetAnimation,0,@TAI,SPIF_UpdateIniFile)=true then Result:=1 else Result:=0; Reg.WriteBool('\Control Panel\Desktop','DragFullWindows',Switch); //switch tells if on/off Result:=1; end; if Command=tbGetWindowTracing then begin //we want to know, if window animation is on TAI.cbSize:=SizeOf(TAi); //init record SystemParametersInfo(SPI_SetAnimation,0,@TAI,0); //fill TAI with values if TAI.iMinAnimate>0 then Result:=1 else Result:=0; //return pseudo-bool as result //above: if iMinAnimate>0 then animation is on end; if Command=tbHideStartButton then begin //we want to hide or show the start button (switch decides what we do) Rgn:= CreateRectRgn(0,0,0,0); //set button's dimensions: none if Switch=true then SetWindowRgn(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil),Rgn,true) //size the button to null else SetWindowRgn(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil),0,true); //no, we want it back end; if Command=tbDisableStartButton then begin //we want to enable or disable the start button (and switch decides) Rgn:= CreateRectRgn(0,0,0,0); //nil doesn't work, so we make a dummy if Switch=true then EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil),false) //we disable it else EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil),true); //we enable it end; Reg.free; end; Blazko