1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button1Click(Sender: TObject);
var
ColorNo:integer;
Colors:COLORREF;
begin
//下列常量表示设置的是哪些显示元素,这些常量已定义在Windows单元中,不必再定义,直接使用即可
// COLOR_SCROLLBAR =0 //滚动条颜色
// COLOR_BACKGROUND =1 //无墙纸时的背景色
// COLOR_ACTIVECAPTION =2 //活动窗口标题颜色
// COLOR_INACTIVECAPTION =3 //非活动窗口标题颜色
// COLOR_MENU =4 //菜单
// COLOR_WINDOW =5 //Windows背景
// COLOR_WINDOWFRAME =6 //Window frame
// COLOR_MENUTEXT =7 //Window文字
// COLOR_WINDOWTEXT =8 //3D阴影(Win95)
// COLOR_CAPTIONTEXT =9 //窗口标题中的文字
// COLOR_ACTIVEBORDER =10 //活动窗口边框
// COLOR_INACTIVEBORDER =11 //非活动窗口边框
// COLOR_APPWORKSPACE =12 //MDI桌面的背景
// COLOR_HIGHLIGHT =13 //选择项背景
// COLOR_HIGHLIGHTTEXT =14 //选择菜单项
// COLOR_BTNFACE =15 //按钮
// COLOR_BTNSHADOW =16 //3D按钮阴影
// COLOR_GRAYTEXT =17 //Grey text,of zero if dithering is used.
// COLOR_BTNTEXT =18 //按钮文本
// COLOR_INACTIVECAPTIONTEXT=19 //非活动窗口文本
// COLOR_BTNHIGHLIGHT =20 //3D高亮按钮
// COLOR_2NDACTIVECAPTION =27 //只用于Win98:第2活动窗口颜色
// COLOR_2NDINACTIVECAPTION =28 //只用于Win98:第2非活动窗口颜色
COLORNO:=COLOR_WINDOW; //设置Windows背景
Colors:=RGB(199,237,204);
SetSysColors(1, ColorNo,Colors); //这个函数无论是否使用桌面主题,都能生效
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,registry;
const
FCIDM_SHVIEWSHELL = $7000;
FNoFolderOptions = 'NoFolderOptions';
FCIDM_MENU_VIEW_REFRESH = FCIDM_SHVIEWSHELL + $0103;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function EnumWindowsProc(AHWnd: HWND;LPARAM: lParam): boolean; stdcall;
var
WClassName : array[0..254] of char;
begin
Result := True;
GetClassName(AHWnd, @WClassName, 254);
if SameText(WClassName,'CabinetWClass') then
begin
PostMessage(AHWnd,$111, 28931, 0);
end;
end;
//function EnumWindowsProc(AHWnd: HWND;LPARAM: lParam): boolean; stdcall;
Procedure UpdateExplorer;
var
AHandle : THandle;
begin
EnumWindows(@EnumWindowsProc, 0);
AHandle := FindWindow('Progman',Nil);
if AHandle <> 0 then PostMessage(AHandle,$111, 28931, 0);
end;
procedure RefershDesk;
begin
PostMessage(HWND_BROADCAST, WM_COMMAND, FCIDM_MENU_VIEW_REFRESH, 0);
SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,0);
UpdateExplorer;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
reg:tregistry;
begin
reg:=tregistry.Create;
reg.RootKey:=HKEY_CURRENT_USER;
reg.OpenKey('\Control Panel\Colors',true);
reg.WriteString('window','199 237 204');
reg.CloseKey;
reg.Free;
RefershDesk;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
FCIDM_SHVIEWSHELL = $7000;
FNoFolderOptions = 'NoFolderOptions';
FCIDM_MENU_VIEW_REFRESH = FCIDM_SHVIEWSHELL + $0103;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{function EnumWindowsProc(AHWnd: HWND;LPARAM: lParam): boolean; stdcall;
procedure RefershDesk;
begin
PostMessage(HWND_BROADCAST, WM_COMMAND, FCIDM_MENU_VIEW_REFRESH, 0);
SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,0);
UpdateExplorer;
end; }
function EnumWindowsProc(AHWnd: HWND;LPARAM: lParam): boolean; stdcall;
var
WClassName : array[0..254] of char;
begin
Result := True;
GetClassName(AHWnd, @WClassName, 254);
if SameText(WClassName,'CabinetWClass') then
begin
PostMessage(AHWnd,$111, 28931, 0);
end;
end;
Procedure UpdateExplorer;
var
AHandle : THandle;
begin
EnumWindows(@EnumWindowsProc, 0);
AHandle := FindWindow('Progman',Nil);
if AHandle <> 0 then PostMessage(AHandle,$111, 28931, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
UpdateExplorer;
end;
end.
const
FNoFolderOptions = 'NoFolderOptions';
FCIDM_MENU_VIEW_REFRESH = FCIDM_SHVIEWSHELL + $0103;
function EnumWindowsProc(AHWnd: HWND;LPARAM: lParam): boolean; stdcall;
procedure TfrmMain.RefershDesk;
begin
PostMessage(HWND_BROADCAST, WM_COMMAND, FCIDM_MENU_VIEW_REFRESH, 0);
SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,0);
UpdateExplorer;
end;
function EnumWindowsProc(AHWnd: HWND;LPARAM: lParam): boolean; stdcall;
var
WClassName : array[0..254] of char;
begin
Result := True;
GetClassName(AHWnd, @WClassName, 254);
if SameText(WClassName,'CabinetWClass') then
begin
PostMessage(AHWnd,$111, 28931, 0);
end;
end;
Procedure UpdateExplorer;
var
AHandle : THandle;
begin
EnumWindows(@EnumWindowsProc, 0);
AHandle := FindWindow('Progman',Nil);
if AHandle <> 0 then PostMessage(AHandle,$111, 28931, 0);
end;