<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      玩轉Windows桌面圖標

      [摘要]大家一定和我一樣對Windows的桌面十分不滿意吧。那就拿起手術刀(Delphi)給它動動手術。 首先要對付的是桌面圖標那一個個難看的、帶有背景色的文字,不僅看上去別扭,還遮住了漂亮的墻紙,一定要去...
      大家一定和我一樣對Windows的桌面十分不滿意吧。那就拿起手術刀(Delphi)給它動動手術。
      首先要對付的是桌面圖標那一個個難看的、帶有背景色的文字,不僅看上去別扭,還遮住了漂亮的墻紙,一定要去掉它,把它變成透明。其次就是圖標的位置,只會傻傻地呆在屏幕的左邊,還得我們一個個去拖,真累!給它來點新花樣,Please Follow Me!

      1、 新建一工程,在 uses 中加入 CommCtrl 單元,窗體上加一個按鈕;

      2、 聲明一個取得桌面句柄的函數:

      function TForm1.GetDesktopHand: THandle;

      begin

      Result:=FindWindow('progman',nil);

      Result:=GetWindow(Result,GW_Child);

      Result:=GetWindow(Result,GW_Child);

      end;


      3、 聲明一個設置圖標文字顏色的過程:

      procedure TForm1.SetTextColor(ForeClr, BackClr: TColor);

      var Hand: THandle;

      begin

      Hand:= GetDesktopHand;

      Listview_SetTextColor(Hand,ForeClr); // 設置文字前景色;

      Listview_SetTextBkColor(Hand,BackClr); // 設置文字背景色,crNone 為透明;

      Listview_RedrawItems(Hand,0,Listview_GetItemCount(Hand)); // 重畫;

      end;



      有了上面的兩個方法,你已經可以對桌面動小手術了。下面介紹圖標的排列方式。


      4、 以屏幕的中心為圓點作圓形排列:

      procedure TForm1.Circle(r: integer); // 形參 r 為半徑;

      var

      i, Count, CenterX, CenterY, TempR :integer;

      Hand: THandle;

      Radian: double;

      TempRect: TRect;

      DesktopHeight,DesktopWidth :integer;

      X, Y : Word;

      begin

      Hand:=GetDesktopHand;

      SystemParametersInfo(SPI_GetWorkArea,0,@TempRect,0); // 取得工作區域;

      DesktopWidth:=TempRect.Right - TempRect.Left; // 工作區的寬(即屏幕的寬);

      DesktopHeight:= TempRect.Bottom - TempRect.Top; // 工作區的高(即屏幕的高);

      CenterX:=DesktopWidth div 2; // 取得圓心 X 坐標;

      CenterY:=DesktopHeight div 2; // 圓心 Y 坐標;

      if CenterX>CenterY then

      TempR:=CenterY

      else

      TempR:=CenterX;

      if r>TempR then r:=TempR; // 半徑不能超過屏幕中心點到四邊的最短距離;

      Count:=Listview_GetItemCount(Hand); // 桌面上圖標個數;

      Radian:=2*3.14159/Count; // 相鄰圖標間的弧度; for i:=0 to Count-1 do

      begin

      // 第一個圖標排在正上方;

      X:=Integer(CenterX+Trunc(r*Sin(i*Radian))); // 圖標的X坐標;

      Y:=Integer(CenterY+Trunc(r*Cos(i*Radian))); // 圖標的Y坐標;

      SendMessage(Hand,LVM_SetItemPosition,i,MakeLparam(X, y)); // 設置坐標;

      end;

      end;



      5、 圖標右對齊:

      procedure AlignRight(Rec: Integer); // 形參 Rec 為一個圖標所占區域大小,一般為77;

      var Hand: THandle;

      h, I, j, DesktopHight, DesktopWidth :integer;

      TempRect : TRect;

      Begin

      Hand:=GetDesktopHand;

      SystemParametersInfo(SPI_GetWorkArea,0,@TempRect,0); // 取得工作區域;

      DesktopWidth:=TempRect.Right - TempRect.Left; // 工作區的寬(即屏幕的寬);

      DesktopHeight:= TempRect.Bottom - TempRect.Top; // 工作區的高(即屏幕的高);

      I:=0; // 圖標所排的列數

      J:=0;

      For h:=0 to Listview_GetItemCount(Hand)-1 do

      Begin

      Inc(j);

      If j*rec>DesktopHeight then // 排完一列;

      Begin

      Inc(i); // 換列

      J:=1;

      End;

      SendMessage(Hand,LVM_SetItemPosition,h,

      MakeLparam(DesktopWidth-Rec*(I+1),Rec*(j-1));

      End; // for 循環結束;

      End;



      6、 在按鈕的單擊事件中加入代碼:

      procedure TForm1.Button1Click(Sender: TObject);

      begin

      SetTextColor(clBlack,crNone); // 設置圖標文字顏色;

      Circle(200); // 把圖標排列成半徑為200的圓;

      // AlignRight(77); // 右對齊;

      end;



      編譯運行,單擊按鈕。哇塞!太棒了!你還可發揮你的想象力,對程序稍加改進,把圖標排成蛇形、橢圓形、環形等等。以上程序在 Win98+Delphi5下運行通過。 


      日韩精品一区二区三区高清