隐藏任务栏图标等等7个功能的程序组合

这个程序所能完成的功能有
隐藏任务栏
隐藏开始按钮
隐藏任务栏图标
隐藏程序按钮
隐藏任务栏时钟
隐藏桌面图标
隐藏快速运行图标
在Delphi6和Winxp下调试通过!

unit Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Commctrl;

type
TfrmMain = class(TForm)
chk1: TCheckBox;
chk2: TCheckBox;
chk3: TCheckBox;
chk4: TCheckBox;
chk5: TCheckBox;
chk6: TCheckBox;
chk7: TCheckBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure CheckButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
wnd: Integer;
procedure SetDesktopIconColor(Forground, Background: TColor; Trans: Boolean);
procedure SetDeskTopIconArr(iWidth,iHeight:Integer);
procedure SetDefaultIconColors;
public
{ Public declarations }
end;

Const
//file://定义不同窗口的类名
sTrayWindow = 'Shell_TrayWnd';
sTrayNotify = 'TrayNotifyWnd';
sStartButton = 'Button';
sAppSwitchBar = 'ReBarWindow32';
sAppSwitch = 'MSTaskSwWClass';
sAppIcon = 'ToolbarWindow32';
sTrayClock = 'TrayClockWClass';
sDesktopIcon = 'ShellDll_DefView';
sProgman = 'Progman';

var
frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.FormCreate(Sender: TObject);
begin
chk1.Caption := '隐藏任务栏';
chk1.OnClick := CheckButtonClick;
chk2.Caption := '隐藏开始按钮';
chk2.OnClick := CheckButtonClick;
chk3.Caption := '隐藏任务栏图标';
chk3.OnClick := CheckButtonClick;
chk4.Caption := '隐藏程序按钮';
chk4.OnClick := CheckButtonClick;
chk5.Caption := '隐藏任务栏时钟';
chk5.OnClick := CheckButtonClick;
chk6.Caption := '隐藏桌面图标';
chk6.OnClick := CheckButtonClick;
chk7.Caption := '隐藏快速运行图标';
chk7.OnClick := CheckButtonClick;

Button1.Caption := '设置图标文本颜色';
Button2.Caption := '设置图标排列';

end;

procedure TfrmMain.CheckButtonClick(Sender: TObject);
var
i:Integer;
begin
//file://找到任务栏窗口的窗口句柄
wnd := FindWindow(sTrayWindow, nil);

if (TCheckBox(Sender).Name)= 'chk2' then
wnd := FindWindowEx(wnd, 0, sStartButton, nil);

if (TCheckBox(Sender).Name)= 'chk3' then
wnd := FindWindowEx(wnd, 0, sTrayNotify, nil);

if (TCheckBox(Sender).Name)= 'chk4' then begin
wnd := FindWindowEx(wnd, 0, sAppSwitchBar, nil);
wnd := FindWindowEx(wnd, 0, sAppSwitch, nil);
end;

if (TCheckBox(Sender).Name)= 'chk5' then begin
wnd := FindWindowEx(wnd, 0, sTrayNotify, nil);
wnd := FindWindowEx(wnd, 0, sTrayClock, nil);
end;

if (TCheckBox(Sender).Name)= 'chk6' then begin
wnd := FindWindow(sProgman, nil);
wnd := FindWindowEx(wnd, 0, sDesktopIcon, nil);
end;

if (TCheckBox(Sender).Name)= 'chk7' then begin
wnd := FindWindowEx(wnd, 0, sAppSwitchBar, nil);
wnd := FindWindowEx(wnd, 0, sAppIcon, nil);
end;

if TCheckBox(Sender).Checked then
begin
ShowWindow (wnd, SW_HIDE);
end
Else
begin
ShowWindow (wnd, SW_SHOW);
end;
end;

procedure TfrmMain.SetDesktopIconColor(Forground, Background: TColor;
Trans: Boolean);
var
Window: HWND;
begin
Window := FindWindow('Progman', 'Program Manager');
//file://找到桌面窗口
Window := FindWindowEx(Window, HWND(nil), 'SHELLDLL_DefView', '');
//file://找到放置桌面图标的ListView窗口
Window := FindWindowEx(Window, HWND(nil), 'SysListView32', '');

if Trans then //file://设置透明的文字背景色
ListView_SetTextBkColor(Window, $ffffffff) // back color
else //file://设置不透明的文字背景色
ListView_SetTextBkColor(Window, Background); // back color

ListView_SetTextColor(Window, Forground); // foreground color
//file://重新绘制桌面图标
ListView_RedrawItems(Window, 0, ListView_GetItemCount(Window) - 1);
UpdateWindow(Window); //file://重新绘制窗口
end;

procedure TfrmMain.SetDeskTopIconArr(iWidth, iHeight: Integer);
var
Window: HWND;
i,i1,i2,iCount:integer;
begin
Window := FindWindow('Progman', 'Program Manager');
Window := FindWindowEx(Window, HWND(nil), 'SHELLDLL_DefView', '');
Window := FindWindowEx(Window, HWND(nil), 'SysListView32', '');

//file://设置图标与边界的距离。
i1:=20;i2:=20;

//file://获得桌面图标的个数
iCount:=ListView_GetItemCount(Window)-1;
for i:=0 to iCount do begin
//file://设置图标位置
ListView_SetItemPosition(Window,i,i1,i2);
i1:=i1+iWidth;
if i1>(Screen.Width-32) then begin
i1:=20;
i2:=i2+iHeight;
end;
end;
ListView_RedrawItems(Window, 0, ListView_GetItemCount(Window) - 1);
UpdateWindow(Window);
end;

procedure TfrmMain.SetDefaultIconColors;
var
Kind: Integer;
Color: TColor;
begin
Kind := COLOR_DESKTOP;
Color := GetSysColor(COLOR_DESKTOP);
SetSysColors(1, Kind, Color);
end;

procedure TfrmMain.Button1Click(Sender: TObject);
begin
//file://你可以改变clWhite,clBlack为其它的颜色值看看
//file://图标文本颜色的变化
//这个好象没用啊!变不了的!
SetDesktopIconColor(clBlue, clRed, True);
end;

procedure TfrmMain.Button2Click(Sender: TObject);
begin
//file://设置图标的间距为100个像素
//不用,我的桌面图标好难排的。SetDeskTopIconArr(100,100);
end;

procedure TfrmMain.Button3Click(Sender: TObject);
var
Window: HWND;
begin
Window := FindWindow(sTrayWindow, nil);
//Window := FindWindow('Progman', 'Program Manager');
UpdateWindow(Window); //file://重新绘制窗口
end;

end.

文章分类目录:

添加新评论

Only text

  • 不允许HTML标记。
  • 自动断行和分段。

Plain text

  • 不允许HTML标记。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
CAPTCHA
请输入下面的验证码再提交评论,不区分大小写。
Image CAPTCHA
Enter the characters shown in the image.