有很多皮肤控件有问题的!,有时就算是在你自己的计算机同样会出问题,比如VCL SKIN就有大大的问题,小心如果恶意的皮肤带有病毒!有本事还是自己设计皮肤! 提供方法: Delphi换肤当然不能象WinAmp那样Down一些皮肤文件就OK了,也不象IE那样修改注册表就可以了(看完本文后,你会发现就是这么简单)。 我们为Delphi换肤主要要做两件事(如果有其他要求,可参照之),一是将元件选项板多行显示,二是为集成开发环境工具栏和菜单加上图片,怎样做呢?Delphi是用来编程的,当然是通过编程来实现了。 第一件事是元件选项板的多行显示,Delphi的标准元件在元件选项板上有二三十页,还有数十页的第三方控件,但Delphi的标准界面的元件选项板是单行显示的,有时用起来很不方便,如果能多行显示该多好,请跟我来: 用New菜单创建一个新Package,在Package窗口按Add按钮,选New Component页,在Ancestor Type下拉框中输入TObject,在Class Name项中输入TMyIDE,然后OK,在代码编辑器中删除Register过程的定义程实现部份,在Uses中引用comctrls。 在private段添下面两个方法: procedure SetMultiLineComponentPalette(MuitLine:Boolean); procedure ResizeMultiLineComponentPalette(Sender:TObject); 在Public部份添加构造函数和析构函数,如下: constructor Create;// TObject的构造函数是静态方法,不能重载。 destructor Destroy;override; 定义一个全局变量:MyIDE1; Var MyIDE1:TMyIDE; 以上四个函数及过程的实现部份如下: constructor TMyIDE.Create; begin SetMultiLineComponentPalette(True); End; destructor TMyIDE.Destroy; begin SetMultiLineComponentPalette(False); end; procedure TMyIDE.SetMultiLineComponentPalette(MuitLine:Boolean); Var m:Integer; App:TForm; TabControl:TTabControl; begin if Screen.FormCount>0 then begin For m:=0 to Screen.FormCount-1 do//遍历IDE的所有窗体; begin App :=Screen.Forms[m]; if UpperCase(App.Name)='APPBUILDER' then//如果是Delphi的主窗体; begin TabControl:=TTabControl(App.FindComponent('TabControl'));//元件选项板; if TabControl<>nil then begin TabControl.MultiLine:=MuitLine;//多行显示; if MuitLine then TabControl.OnResize:=MyIDE1.ResizeMultiLineComponentPalette //OnResize事件,以便元件选项板能显示元件页;如果不处理该事件,元件选项板将不能显示出元件页。 else TabControl.OnResize:=nil; end; end; end; end; end; procedure TMyIDE.ResizeMultiLineComponentPalette(Sender:TObject); var AHeight: Integer; begin if Sender is TTabControl then begin with Sender as TTabControl do begin AHeight := Height-(DisplayRect.Bottom-DisplayRect.Top)+29; Constraints.MinHeight:=AHeight; Constraints.MaxHeight:=AHeight;//改变约束高度; (Sender as TTabControl).Parent.Constraints.MaxHeight:=AHeight; (Sender as TTabControl).Parent.Constraints.MinHeight:=AHeight;//改变父控件的约束高度; end; end; end; 代码应该不难看懂,但是定义好的方法如何使用呢?这就要单元的单元的初始化initialization部分Create MyIDE;又要在finalization部份释放MyIDE。代码如下: initialization MyIDE1:=TMyIDE.Create; finalization MyIDE1.Free; end. 下面对以上的代码略加解释: 在TMyIDE类的Create构造函数中使用SetMultiLineComponentPalette(True)过程改变IDE的元件选项板,在析构函数中调用SetMultiLineComponentPalette(False)将IDE改成标准IDE界面。 在SetMultiLineComponentPalette方法中,首先遍历系统所有的Form对象,找到Delphi IDE的主界面,然后用Tform的FindComponent函数找到名为TabControl的元件对象,改变其MultiLine属性,如果MultiLine为True就将其OnResize事件赋与自定义的过程,否则清除OnResize事件。 在OnResize(ResizeMultiLineComponentPalette方法)事件中,计算元件选项板的所需高度,然后改自已和父控件的约束度高度。 以上代码完成后,在Package窗口中按Install按钮,怎么样?还行吧!
提供方法:
Delphi换肤当然不能象WinAmp那样Down一些皮肤文件就OK了,也不象IE那样修改注册表就可以了(看完本文后,你会发现就是这么简单)。
我们为Delphi换肤主要要做两件事(如果有其他要求,可参照之),一是将元件选项板多行显示,二是为集成开发环境工具栏和菜单加上图片,怎样做呢?Delphi是用来编程的,当然是通过编程来实现了。
第一件事是元件选项板的多行显示,Delphi的标准元件在元件选项板上有二三十页,还有数十页的第三方控件,但Delphi的标准界面的元件选项板是单行显示的,有时用起来很不方便,如果能多行显示该多好,请跟我来:
用New菜单创建一个新Package,在Package窗口按Add按钮,选New Component页,在Ancestor Type下拉框中输入TObject,在Class Name项中输入TMyIDE,然后OK,在代码编辑器中删除Register过程的定义程实现部份,在Uses中引用comctrls。
在private段添下面两个方法:
procedure SetMultiLineComponentPalette(MuitLine:Boolean);
procedure ResizeMultiLineComponentPalette(Sender:TObject);
在Public部份添加构造函数和析构函数,如下:
constructor Create;// TObject的构造函数是静态方法,不能重载。
destructor Destroy;override;
定义一个全局变量:MyIDE1;
Var MyIDE1:TMyIDE;
以上四个函数及过程的实现部份如下:
constructor TMyIDE.Create;
begin
SetMultiLineComponentPalette(True);
End;
destructor TMyIDE.Destroy;
begin
SetMultiLineComponentPalette(False);
end;
procedure TMyIDE.SetMultiLineComponentPalette(MuitLine:Boolean);
Var m:Integer;
App:TForm;
TabControl:TTabControl;
begin
if Screen.FormCount>0 then
begin
For m:=0 to Screen.FormCount-1 do//遍历IDE的所有窗体;
begin
App :=Screen.Forms[m];
if UpperCase(App.Name)='APPBUILDER' then//如果是Delphi的主窗体;
begin
TabControl:=TTabControl(App.FindComponent('TabControl'));//元件选项板;
if TabControl<>nil then
begin
TabControl.MultiLine:=MuitLine;//多行显示;
if MuitLine then
TabControl.OnResize:=MyIDE1.ResizeMultiLineComponentPalette
//OnResize事件,以便元件选项板能显示元件页;如果不处理该事件,元件选项板将不能显示出元件页。
else
TabControl.OnResize:=nil;
end;
end;
end;
end;
end;
procedure TMyIDE.ResizeMultiLineComponentPalette(Sender:TObject);
var AHeight: Integer;
begin
if Sender is TTabControl then
begin
with Sender as TTabControl do
begin
AHeight := Height-(DisplayRect.Bottom-DisplayRect.Top)+29;
Constraints.MinHeight:=AHeight;
Constraints.MaxHeight:=AHeight;//改变约束高度;
(Sender as TTabControl).Parent.Constraints.MaxHeight:=AHeight;
(Sender as TTabControl).Parent.Constraints.MinHeight:=AHeight;//改变父控件的约束高度;
end;
end;
end;
代码应该不难看懂,但是定义好的方法如何使用呢?这就要单元的单元的初始化initialization部分Create MyIDE;又要在finalization部份释放MyIDE。代码如下:
initialization
MyIDE1:=TMyIDE.Create;
finalization
MyIDE1.Free;
end.
下面对以上的代码略加解释:
在TMyIDE类的Create构造函数中使用SetMultiLineComponentPalette(True)过程改变IDE的元件选项板,在析构函数中调用SetMultiLineComponentPalette(False)将IDE改成标准IDE界面。
在SetMultiLineComponentPalette方法中,首先遍历系统所有的Form对象,找到Delphi IDE的主界面,然后用Tform的FindComponent函数找到名为TabControl的元件对象,改变其MultiLine属性,如果MultiLine为True就将其OnResize事件赋与自定义的过程,否则清除OnResize事件。
在OnResize(ResizeMultiLineComponentPalette方法)事件中,计算元件选项板的所需高度,然后改自已和父控件的约束度高度。
以上代码完成后,在Package窗口中按Install按钮,怎么样?还行吧!