📄 winskinform.pas
字号:
// getwindowrect(ahwnd,r);
// offsetrect(r,-r.left,-r.top);
// if phwnd<>0 then begin
InvalidateRect(ahwnd, 0,true);
UpdateWindow(ahwnd);
end;
function TWinSkinForm.IsScrollControl(acontrol:TComponent):boolean;
var hwnd:Thandle;
Style:longword;
begin
result:=false;
if not (acontrol is Twincontrol) then exit;
hwnd:=Twincontrol(acontrol).handle;
Style := GetWindowLong( hWnd, GWL_STYLE );
if ((Style and WS_HSCROLL)=0) and
((Style and WS_VSCROLL)=0) then begin
if (acontrol is Tlistbox)
or (acontrol is Tmemo)
or (acontrol.tag = 55)
// or (acontrol is Tlistview)
or (acontrol is TCustomListBox)
or (acontrol is TCustomTreeView)
// or (acontrol is TCustomGrid)
or (acontrol is Tscrollbox) then
result:=true;
end else result:=true;
end;
procedure TWinSkinForm.InitToolbarMenu(Item: TMenuItem;enable:boolean);
var
a: integer;
procedure Activate(MenuItem: TMenuItem);
begin
if Enable then begin
MenuItem.OnDrawItem := DrawMenuItem;
MenuItem.OnMeasureItem := MeasureItem;
end else MenuItem.OnDrawItem := nil;
end;
begin
Activate(Item);
for a := 0 to Item.Count - 1 do
InitToolbarMenu(Item.Items[a],enable);
end;
procedure TWinSkinForm.InitPopMenu(wForm: TWinControl; Enable, Update: boolean );
var
i, x: integer;
Comp: TComponent;
procedure Activate(MenuItem: TMenuItem);
begin
if Enable then begin
if (not assigned(MenuItem.OnDrawItem)) or (FOverrideOwnerDraw) then begin
if (xcMainMenu in fsd.skinControls) then
MenuItem.OnDrawItem := DrawMenuItem;
MenuItem.OnMeasureItem := MeasureItem;
end;
end else MenuItem.OnDrawItem := nil;
end;
procedure Activatepop(MenuItem: TMenuItem);
begin
if Enable then begin
// if (not assigned(MenuItem.OnDrawItem)) then begin//or (FOverrideOwnerDraw) then begin
MenuItem.OnDrawItem := DrawMenuItem;
MenuItem.OnMeasureItem := MeasureItempop;
// end ;
end else begin
MenuItem.OnDrawItem := nil;
MenuItem.OnMeasureItem := nil;
end;
end;
procedure ItrateMenu(MenuItem: TMenuItem);
var
a: integer;
begin
Activate(MenuItem);
for a := 0 to MenuItem.Count - 1 do
ItrateMenu(MenuItem.Items[a]);
end;
procedure ItrateMenupop(MenuItem: TMenuItem);
var
a: integer;
begin
Activatepop(MenuItem);
for a := 0 to MenuItem.Count - 1 do
ItrateMenupop(MenuItem.Items[a]);
end;
begin
for i := 0 to wForm.ComponentCount - 1 do begin
Comp := wForm.Components[i];
{ if (Comp is TMainMenu) then //and (xcmainmenu in FSkinControls)
// and ((Comp.Tag mod 100)<> fdisabletag)then
begin
TMainMenu(Comp).OwnerDraw := Enable;
for x := 0 to TMainMenu(Comp).Items.Count - 1 do
begin
Activate(TMainMenu(Comp).Items[x]);
ItrateMenu(TMainMenu(Comp).Items[x]);
end;
end;}
if (Comp is TPopupMenu) and (xcPopupmenu in fsd.SkinControls)
and ((comp.Tag mod 100)<> fsd.disabletag)then
begin
TPopupMenu(Comp).OwnerDraw := Enable;
for x := 0 to TPopupMenu(Comp).Items.Count - 1 do
begin
Activatepop(TPopupMenu(Comp).Items[x]);
ItrateMenupop(TPopupMenu(Comp).Items[x]);
end;
end;
end;
end;
procedure TWinSkinForm.InitMainMenu(wForm: TWinControl; Enable, Update: boolean );
var
i, x,j: integer;
Comp: TComponent;
procedure Activate(MenuItem: TMenuItem);
begin
if Enable then begin
if (j>1) and (not assigned(MenuItem.OnDrawItem)) then begin
MenuItem.OnDrawItem := DrawMenuItem;
MenuItem.OnMeasureItem := MeasureItem;
end;
end else begin
MenuItem.OnDrawItem := nil;
MenuItem.OnMeasureItem := nil;
end;
end;
procedure ItrateMenu(MenuItem: TMenuItem);
var
a: integer;
begin
inc(j);
Activate(MenuItem);
for a := 0 to MenuItem.Count - 1 do
ItrateMenu(MenuItem.Items[a]);
dec(j);
end;
begin
for i := 0 to wForm.ComponentCount - 1 do begin
Comp := wForm.Components[i];
if (Comp is TMainMenu) then //and (xcmainmenu in FSkinControls)
// and ((Comp.Tag mod 100)<> fdisabletag)then
begin
TMainMenu(Comp).OwnerDraw := Enable;
for x := 0 to TMainMenu(Comp).Items.Count - 1 do begin
j:=0;
// Activate(TMainMenu(Comp).Items[x]);
ItrateMenu(TMainMenu(Comp).Items[x]);
end;
end;
end;
end;
function TWinSkinForm.FindSkinComp(acomp:Tcomponent):boolean;
var i:integer;
sc:Tskincontrol;
aname,name2:string;
begin
result:=false;
aname := fform.Name;
name2 := lowercase(aname);
for i:= 0 to controllist.count-1 do begin
sc:= Tskincontrol(controllist.items[i]);
if sc.GControl <> nil then begin
if sc.gcontrol=acomp then begin
result:=true;
break;
end;
end else if acomp is Twincontrol then begin
if Twincontrol(acomp).HandleAllocated then begin
if sc.hwnd=Twincontrol(acomp).handle then begin
result:=true;
break;
end;
end else begin
if (pos('preview',name2)>0) or
(aname='TQRStandardPreview') or
(aname='TppPrintPreview') or
(aname='TdxfmStdPreview') then begin
result:=true;
end;
break;
end;
end;
end;
end;
procedure TWinSkinForm.AddComp(Comp: TComponent;wForm: TWinControl);
var
i, x,j,tag: integer;
subcomp:Twincontrol;
skin:TSkinControl;
buf:array[0..100] of char;
cname:string;
b:boolean;
chwnd:Thandle;
skincomp: TComponent;
tag2:integer;
spy:TWinSkinspy;
begin
cname:=Uppercase(comp.ClassName);
tag2:= comp.tag mod 100;
if tag2=fsd.disabletag then exit;
if FindSkinComp(comp) then exit;
if (comp is Twincontrol) then begin
chwnd:= TACWinControl(comp).WindowHandle;
if chwnd=0 then
try
chwnd:=TACWinControl(comp).handle;
except
exit;
end;
end;
if Assigned(fsd.OnSkinControl) then begin
skincomp:= NIL;
fsd.OnSkinControl(self, fsd, wForm, TControl(comp), cname, skincomp);
if Assigned(skincomp) and (skincomp is TSkinControl) then begin
skin:= skincomp as TSkinControl;
if skin.newcolor then b:=true
else b:=false;
if not addcontrollist(skin) then begin
skin.init(self,self.fsd,self.fcanvas2,b);
if (Comp is TCustomPanel) then
self.InitControls(Comp as TWinControl);
end;
///skin.Inithwnd(TWinControl(Comp).Handle, Self.fsd, self.fcanvas2);
exit;
end;
end;
if (Find3rdControl(cname,TWinControl(comp))) then exit;
if (cname='TDBCOMBOBOXEH') then exit;
if (cname='TQRPREVIEW') then exit;
if (cname='TFRDESIGNERPAGE') then exit;
if (cname='TFRPBOX') then exit;
// not success
if (Comp is TCustomTabControl) and (xcTab in Fsd.SkinControls)
and (fsd.tab<>nil) then begin
skin:=TSkinTab.create(comp);
TSkinTab(skin).inithwnd(TWinControl(Comp).handle,self.fsd,self.fcanvas2,self);
end
else if (Comp is TToolbutton) and (xcmainmenu in Fsd.SkinControls) then begin
if TToolbutton(comp).MenuItem<>nil then
inittoolbarmenu(TToolbutton(comp).MenuItem,true);
end
else if (cname='TTABSET') and (xcTab in Fsd.SkinControls)
and (fsd.tab<>nil) then begin
// with TSkinTab31.create(comp) do
// init(self,self.fsd,self.fcanvas2);
skin:=TSkinTab31.create(comp);
TSkinTab(skin).init(self,self.fsd,self.fcanvas2);
end
else if (cname='TTABBEDNOTEBOOK') and (xcTab in Fsd.SkinControls)
and (fsd.tab<>nil) then begin
skin:=TSkinTab.create(comp);
TSkinTab(skin).inithwnd(TWinControl(Comp).handle,self.fsd,self.fcanvas2,self);
// controllist.add(skin);
end
else if (cname='TMVCPANEL') then
self.InitControls(Comp as TWinControl)
else if ((Comp is TPageControl) and (xcTab in Fsd.SkinControls))
and (fsd.tab<>nil) then begin
if Comp is TPageControl then begin
skin:=TSkinTab.create(self);
TSkinTab(skin).inithwnd(TWinControl(Comp).handle,self.fsd,self.fcanvas2,self);
// controllist.add(skin);
end;
end
else if ((Comp is TCustomCheckBox) and
(xcCheckBox in Fsd.SkinControls)) then begin
with TSkinCheckBox.create(comp) do
init(self,self.fsd,self.fcanvas2,false);
end
else if ((cname='TTRACKBAR') and
(xcbutton in Fsd.SkinControls)) then begin
with TSkinTrackBar.create(comp) do
init(self,self.fsd,self.fcanvas2);
end
else if ((cname='TUPDOWN') and
(xcButton in Fsd.SkinControls)) then begin
with TSkinUpDown.create(comp) do
init(self,self.fsd,self.fcanvas2);
end
else if ((Comp is TCustomRadiogroup))
and (xcRadioButton in Fsd.SkinControls) then begin
for j:= 0 to TWincontrol(comp).ControlCount-1 do begin
subcomp:=Twincontrol(Twincontrol(comp).Controls[j]);
//TAccontrol(subcomp).ParentColor := false;
with TSkinRadioButton.create(subcomp) do
init(self,self.fsd,self.fcanvas2,false);
end;
with TSkinGroupBox.create(comp) do
// with TSkinBox.create(comp) do
init(self,self.fsd,self.fcanvas2,true);
end
else if (cname='TDBNAVIGATOR') and (xcPanel in Fsd.SkinControls) then begin
setproperty(Comp,'Flat','True');
with TSkinBox.create(comp) do
init(self,self.fsd,self.fcanvas2,true);
end
{ else if ((Comp is TcustomGroupbox))
and (xcPanel in Fsd.SkinControls) then begin
for j:= 0 to Twincontrol(comp).ControlCount-1 do begin
subcomp:=Twincontrol(Twincontrol(comp).Controls[j]);
//TAccontrol(subcomp).ParentColor := false;
end;
with TSkinBox.create(comp) do
init(self,self.fsd,self.fcanvas2,true);
self.InitControls(Comp as TWinControl);
end}
else if ((Comp is TcustomGroupbox))
and (xcPanel in Fsd.SkinControls) then begin
with TSkinGroupbox.create(comp) do
// with TSkinbox.create(comp) do
init(self,self.fsd,self.fcanvas2,true);
self.InitControls(Comp as TWinControl);
end
else if ((Comp is TRadioButton))
and (xcRadioButton in Fsd.SkinControls) then begin
with TSkinRadioButton.create(comp) do begin
init(self,self.fsd,self.fcanvas2,false);
end;
end
else if (Comp is TToolbar) and (xcToolbar in Fsd.SkinControls) then begin
setproperty(Comp,'Flat','True');
// setproperty(Comp,'Transparent','True');
if (xcToolbar in Fsd.SkinControls) then begin
if not assigned(Ttoolbar(comp).OnCustomDrawButton) then
Ttoolbar(comp).OnCustomDrawButton:=ToolBarDrawButton;
with TSkinBox.create(comp) do
init(self,self.fsd,self.fcanvas2,true);
{$ifndef COMPILER_5}
if Ttoolbar(comp).Menu<>nil then
for j:=0 to Ttoolbar(comp).Menu.Items.count-1 do
inittoolbarmenu(TToolbar(comp).Menu.items[j],true);
{$endif}
end;
end
{$ifndef COMPILER_5}
else if ((Comp is TCustomStatusBar) and
(xcStatusBar in Fsd.SkinControls)) then begin
{$else}
else if ((Comp is TStatusBar) and
(xcStatusBar in Fsd.SkinControls)) then begin
{$endif}
Tstatusbar(comp).sizegrip:=false;
with TSkinStatusBar.create(comp) do begin
init(self,self.fsd,self.fcanvas2,false);
end;
end
else if ((Comp is TProgressBar) and
(xcProgress in Fsd.SkinControls)) then begin
with TSkinProgress.create(comp) do
init(self,self.fsd,self.fcanvas2);
end
else if ((Comp is TScrollbar) and
(xcScrollbar in Fsd.SkinControls)) then begin
with TSkinScControl.create(comp) do
init(self,self.fsd,self.fcanvas2);
// with TSkinScrollBar.create(self) do
// initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2);
end
else if (comp is TCustomComboBox) and
(xcCombo in Fsd.SkinControls) then begin
with TSkinCombox.create(comp) do
init(self,self.fsd,self.fcanvas2);
end
else if (cname='TDATETIMEPICKER') and
(xcedit in Fsd.SkinControls) then begin
if (TDateTimePicker(comp).DateMode = dmUpDown) or
(TDateTimePicker(comp).kind = dtkTime) then begin
with TSkinEdit.create(comp) do
init(self,self.fsd,self.fcanvas2);
end else begin
with TSkinCombox.create(comp) do
init(self,self.fsd,self.fcanvas2);
end;
end
else if (xcScrollBar in Fsd.SkinControls) AND
((cname=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -