📄 winskindlg.pas
字号:
mh:Thandle;
begin
{ mh:=FindWindowex(0,0,'#32768',nil);
if (mh<>0) and (mh<>smenu.hwnd) then begin
smenu.InitSkin(mh,GSkinData,amenu);
end;}
end;
function TSkinManage.GetMenuBg(amenu:Hmenu):Tbitmap;
var i: integer;
begin
result:=nil;
for I:= 0 to mlist.count-1 do
if TWinSkinPopMenu(mlist[i]).hmenu=amenu then begin
result:=TWinSkinPopMenu(mlist[i]).menubg;
break;
end;
end;
procedure TSkinManage.FindPopupMenu(amenu:Hmenu);
var i: integer;
begin
for I:= 0 to PopupList.count-1 do
if TPopupMenu(PopupList[i]).handle=amenu then begin
menuactive:=true;
break;
end;
end;
procedure TSkinManage.SetMDIMax(b:boolean);
var i: integer;
sf:Twinskinform;
sd:TSkinData;
begin
if mdimax=b then exit;
mdimax:=b;
sd:=SkinManager.maindata;
if (xoMDIChildBorder in sd.Options) then exit;
for I:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if sf.formstyle=sfsmdichild then begin
if b then begin
if sf.crop then sf.Uncropwindow;
sf.EnableSysbtn(b);
end else begin
if sf.windowstate<>swsmin then begin
sf.windowstate:=swsnormal;
sf.cropwindow;
sf.EnableSysbtn(b);
if not sf.crop then sf.refresh;
end else sf.EnableSysbtn(true);
end;
end;
end;
// if b then skinaddlog('***** SetMdiMax True')
// else skinaddlog('***** SetMdiMax Flase');
end;
procedure TSkinManage.SetMDIMax2(b:boolean);
var i: integer;
sf:Twinskinform;
begin
if mdimax=b then exit;
mdimax:=b;
for I:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if sf.formstyle=sfsmdichild then begin
if b then begin
if sf.crop then sf.Uncropwindow;
sf.EnableSysbtn(b);
end else begin
if sf.windowstate<>swsmin then begin
sf.windowstate:=swsnormal;
sf.cropwindow;
sf.EnableSysbtn(b);
if not sf.crop then sf.refresh;
end else sf.EnableSysbtn(true);
end;
end;
end;
if b then skinaddlog('***** SetMdiMax True')
else skinaddlog('***** SetMdiMax Flase');
end;
procedure TSkinManage.SetCaption(b:boolean);
var i: integer;
sf:Twinskinform;
dwstyle:Dword;
begin
for I:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if sf.formstyle=sfsmdichild then begin
dwstyle := GetWindowLong( sf.hwnd, GWL_STYLE );
dwstyle := dwstyle or WS_CAPTION;
SetWindowLong( sf.hwnd, GWL_STYLE, dwstyle );
end;
end;
end;
function TSkinManage.GetMDIChildNum:integer;
var i: integer;
sf:Twinskinform;
begin
result:=0;
for I:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if sf.formstyle=sfsmdichild then
inc(result);
end;
end;
{function EnumProp(ahwnd:HWND;prop:Pchar;data:Thandle):boolean;stdcall;
var s:string;
p:dword;
buf: array[0..31] of Char;
begin
//p:=GetProp(ahwnd,prop);
// s:=format('%4x',[data]);
// if pos('FF',s)=1 then exit;
// StrCopy(buf,prop);
result:=true;
if ATOM(prop) = dword(prop) then exit;
result:=true;
s:=format('%s',[prop]);
if pos('ControlOfs',s)=1 then begin
// b:=true;
result:=false;
end;
end; }
function TSkinManage.IsDllForm(ahwnd:Thandle):boolean;
var b:boolean;
i:integer;
function EnumProp(ahwnd:HWND;prop:Pchar;data:Thandle):boolean;stdcall;
var s:string;
p:^integer;
begin
result:=true;
if ATOM(prop) = dword(prop) then exit;
s:=strpas(prop);
if pos('ControlOfs',s)=1 then begin
result:=false;
end;
end;
begin
b:=true;
i:=0;
i:=EnumProps(ahwnd,@enumprop);
if i=0 then result:=false
else result:=true;
end;
function TSkinManage.FindTForm(ahwnd:Thandle):TForm;
var i:integer;
aform:TForm;
begin
aform:=nil;
for I := 0 to Screen.FormCount - 1 do begin
if Screen.Forms[I].handle=ahwnd then begin
aform := Screen.Forms[I];
break;
end;
end;
if aform=nil then
aform:=Tform(FindControlx(ahwnd));
result:=aform;
// Result := TForm(SendMessage(ahwnd, RM_GetObjectInstance, 0, 0)) ;
end;
procedure TSkinManage.SetAction(acode:integer;Interval:integer=250);
var i:integer;
sm:Tskinmanage;
begin
action:=acode;
timer.Interval:=interval;
if (state=skin_creating) then begin
if acode=skin_Active then active:=true
else if acode=skin_uninstall then active:=false;
end else begin
if mode=0 then begin
//other skinmanager
for i:=0 to sublist.count-1 do begin
sm:=TSkinManage(sublist[i]);
sm.UpdateData:=UpdateData;
if acode=skin_Active then begin
sm.active:=true ;
sm.SetAction(skin_Active,300)
end else if acode=skin_change then begin
//sm.SetAction(skin_change,300)
end else if acode=skin_uninstall then
sm.active:=false;
end;
end;
timer.enabled:=true;
end;
end;
function EnumWindow(ahwnd :HWND;lParam: LPARAM):boolean;stdcall;
var s:string;
r:Trect;
begin
result:=false;
// if (GetParent(ahwnd)= lparam) then begin
s:=getwindowclassname(ahwnd);
getwindowrect(ahwnd,r);
// skinaddlog(format('***enumWindow %1x,%s (%1d,%1d,%1d,%1d)',
// [ahwnd,s,r.left,r.top,r.right,r.bottom]));
result:=true;
// end;
end;
function EnumAddWindow(ahwnd :HWND;lParam: LPARAM):boolean;stdcall;
var s:string;
r:Trect;
begin
result:=true;
Skinmanager.addform(ahwnd);
end;
procedure TSkinManage.DeleteSysbtn;
var i: integer;
sf :TWinSkinform;
begin
for i:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if sf.fsd=updatedata then
sf.DeleteSysbtn;
end;
end;
function TSkinManage.initsb(ahwnd:Thandle):boolean;
begin
result:=false;
if SBinstall and (@pinitsb<>nil) then
result := boolean(pinitsb(ahwnd));
end;
function TSkinManage.Uninitsb(ahwnd:Thandle):boolean;
begin
result:=false;
if SBinstall and (@pUninitsb<>nil) then
result := boolean(pUninitsb(ahwnd));
end;
procedure TSkinManage.WndProc(var Msg: TMessage);
var ahwnd:hwnd;
sf :TWinSkinform;
begin
if (msg.Msg = CN_SkinNotify ) then begin
ahwnd:=msg.LParam;
if (msg.WParam=skin_update) then begin
sf := TWinSkinform(findskinform(ahwnd));
if sf<>nil then begin
application.ProcessMessages();
sleep(10);
sf.UnSubclass();
sf.skinstate:=skin_Deleted;
deleteDeleted;
sleep(10);
application.ProcessMessages();
AddForm(ahwnd);
end;
end;
msg.result:=0;
end else
msg.Result := DefWindowProc(handle, msg.msg, msg.wParam, msg.lParam);
end;
procedure TSkinManage.OnTimer(Sender: TObject);
var i: integer;
sf :TWinSkinform;
sd: TSkindata;
sm:Tskinmanage;
ahwnd:Thandle;
begin
timer.enabled:=false;
if UpdateData=nil then exit;
sd := TSkindata(updateData);
if sd.SkinFormtype = sfOnlyThisForm then begin
case action of
skin_uninstall:begin
active:=false;
DeleteDeleted;
for i:= flist.count-1 downto 0 do begin
sf:=TWinSkinform(flist[i]);
if sf.fsd = sd then begin
sf.unsubclass;
sf.repaint(sf.hwnd);
flist.delete(i);
sf.free;
break;
end;
end;
end;
skin_change:begin
DeleteDeleted;
for i:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if (sf.fsd = sd) then begin
sf.DeleteSysbtn;
sf.InitSkinData;
sf.skinchange;
break;
end;
end;
end;
skin_Active: begin
active:=true;
skinchildform:=true;
// EnumThreadWindows(GetCurrentThreadId,@EnumAddWindow,0);
for I := Screen.FormCount - 1 downto 0 do begin
if Screen.Forms[I]=sd.Owner then begin
activeform(Screen.Forms[I]);
break;
end;
end;
skinchildform:=false;
end;
skin_deleted : deleteform3;
end;//endcase
sd.doskinchanged;
UpdateData:=nil;
end else begin
case action of
skin_Active: begin
active:=true;
wmsetdraw:=false;
skinchildform:=true;
// EnumThreadWindows(GetCurrentThreadId,@EnumAddWindow,0);
DeleteDeleted;
for I := Screen.FormCount - 1 downto 0 do begin
ActiveForm(Screen.Forms[I]);
end;
skinchildform:=false;
if mode=0 then begin
for i:=0 to sublist.count-1 do begin
sm:=TSkinManage(sublist[i]);
sm.UpdateData:=UpdateData;
sm.active:=true ;
sm.SetAction(skin_Active,300)
end;
end;
end;
skin_uninstall:begin
active:=false;
DeleteDeleted;
{ for i:= flist.count-1 downto 0 do begin
sf:=TWinSkinform(flist[i]);
sf.unsubclass;
sf.repaint(sf.hwnd);
flist.delete(i);
sf.free;
end;}
while flist.count>0 do begin
sf:=TWinSkinform(flist[0]);
sf.unsubclass;
sf.repaint(sf.hwnd);
flist.delete(0);
sf.free;
end;
if mode=0 then begin
for i:=0 to sublist.count-1 do begin
sm:=TSkinManage(sublist[i]);
sm.active:=false ;
end;
end;
{ for i:= flist.count-1 downto 0 do begin
sf:=TWinSkinform(flist[i]);
sf.unsubclass;
sf.repaint(sf.hwnd);
flist.delete(i);
sf.free;
end;}
end;
skin_change:begin
DeleteDeleted;
for i:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if (sf.fsd = sd) {and (sf.mode=mode)} then begin
sf.DeleteSysbtn;
sf.InitSkinData;
end;
end;
// for i:= flist.count-1 downto 0 do begin
for i:= 0 to flist.count-1 do begin
sf:=TWinSkinform(flist[i]);
if (sf.fsd = sd) {and (sf.mode=mode)}then
sf.skinchange;
end;
end;
skin_deleted : deleteform3;
skin_update : begin
ahwnd:=lpara;
sf := TWinSkinform(findskinform(ahwnd));
if sf<>nil then begin
sf.UnSubclass();
sf.skinstate:=skin_Deleted;
deleteDeleted;
AddForm(ahwnd);
end;
exit;
end;
end;//endcase
sd.doskinchanged;
UpdateData:=nil;
end;
end;
function LCIDToCodePage(ALcid: LCID): Cardinal;
var
Buf: array[0..6] of AnsiChar;
begin
GetLocaleInfo(ALcid, LOCALE_IDefaultAnsiCodePage, Buf, 6);
Result := StrToIntDef(Buf, GetACP);
end;
procedure InitMsg;
var AtomText: array[0..31] of Char;
begin
PropName := Format('ControlOfs%.8X%.8X', [HInstance, GetCurrentThreadID]);
RM_GetObjectInstance := RegisterWindowMessage(PChar(PropName));
DefaultUserCodePage := CP_ACP;
myinstance:=HInstance;
// DefaultUserCodePage := 3; //CP_THREAD_ACP
ControlAtom := GlobalAddAtom(
StrFmt(AtomText, 'ControlOfs%.8X%.8X', [HInstance, GetCurrentThreadID]));
end;
Procedure Fini;
var i:integer;
begin
if skinmanager<>nil then
SkinManager.free;
SkinManager:=nil;
{ for i := 1 to 10 do
begin
Application.ProcessMessages;
Sleep(20);
end;}
end;
initialization
Win32PlatformIsUnicode := (Win32Platform = VER_PLATFORM_WIN32_NT);
InitMsg;
// Win32PlatformIsUnicode := false;
// skinmanager := TSkinManage.create;
// skinmanager.installhook;
finalization
fini;
// if skinmanager<>nil then
// SkinManager.free;
// SkinManager:=nil;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -