⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winskindlg.pas

📁 这是VCLSKIN v4.22 的所有的源代码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
         if (sd.skinformtype=atype) then begin
             adata:=sd;
             result:=true;
         end;
     end;
  end;

begin
   if FindOnlyThisForm then exit;
   s:=lowercase(getwindowclassname(ahwnd));
   if ((s='tmessageform') or (s='#32770')) and finddata(sfDialog) then exit;
   if finddata(sfMainform) then exit;
   if dlist.count>0 then adata:=dlist.items[0]
   else adata:=nil;
end;

function TSkinManage.OnBeforeSkin(ahwnd:Thandle;aname:string):boolean;
var b:boolean;
    i:integer;
    sd:Tskindata;
    s:string;
    dwstyle: DWORD;
begin
   b:=true;
   if maindata<>nil then begin
     if not (xoPreview in TSkindata(maindata).Options) then begin
        s := lowercase(aname);
        if (pos('preview',s)>0) then
          b:=false;
     end;
     dwstyle := GetWindowLong(ahwnd,GWL_STYLE);
     if (aname = '#32770') and ((dwstyle  and WS_EX_CLIENTEDGE) > 0) then
       b:=false;
     TSkindata(maindata).DoFormSkin(ahwnd,aname,b);
   end;
{   for i:= 0 to dlist.count-1 do begin
       sd:=Tskindata(dlist.items[i]);
       if (sd.skinformtype=sfMainform) then begin
            sd.DoFormSkin(aname,b);
            break;
       end;
   end;}
   result:=b;
end;

procedure TSkinManage.ActiveForm(aform:Tform);
var dwstyle:dword;
    b:boolean;
begin
    dwstyle := GetWindowLong( aform.handle, GWL_STYLE );
    b:= (dwstyle and ws_child)>0;   //child
    //if aform.formstyle=fsmdichild then b:=false;//mdichild
    if not aform.Visible then b:=true;
    if not b then addform(aform.handle);
end;

function TSkinManage.AddForm(aHwnd:THandle):boolean;
var aform:TWinskinform;
    atform:TForm;
    r:Trect;
    s:string;
    aptr:pointer;
    adata:Tskindata;
    isskin:integer;
    dw:dword;
    b:boolean;
begin
   result:=false;
   if not active then exit;

   DeleteDeleted;
   
   isskin:=sendmessage(ahwnd,CN_IsSkined,0,0);
// {$IFDEF demo}
//    atform:=findtform(ahwnd);
//    if atform<>nil then
//      setproperty(atform,'Caption',' ');
// {$endif}
   if isskin=1 then exit;

   if findskinform(ahwnd)<>0 then exit;

   atform:=findtform(ahwnd);
   if (not skinchildform) and nestedform(ahwnd) then exit;

   s:=getwindowclassname(ahwnd);
//   b:= (s='#32770') {or (s='TMessageForm')};
   dw:=GetWindowLong(ahwnd,GWL_HINSTANCE);
   if (atform=nil) and (dw<>myinstance) and (s<>'#32770') then exit;
//   if (not b) and (atform=nil) and (not isdllform(ahwnd)) then exit;
//   if not isdllform(ahwnd) then exit;
//   TSkindata(maindata).DoDebug(s);

   getwindowrect(ahwnd,r);
   offsetrect(r,-r.left,-r.top);
   dw:=GetWindowLong(ahwnd, GWL_EXSTYLE);
   if (r.right*r.bottom=0) and ((dw and ws_ex_mdichild)=0) then exit;
   if (atform<>nil) and (atform.tag=99) then exit;

   if pos('TcxPopupEditPopupWindow',s)>0 then exit;
   if s='TApplication' then exit;
//   if s='TQRStandardPreview' then exit; //quickreport preview form
   if not OnBeforeSkin(ahwnd,s) then exit;

   FindSkindata(aptr,ahwnd);
   if aptr=nil then exit;

   adata:=Tskindata(aptr);
   if adata.empty then exit;

   if atform<>nil then begin
      aform:=Twinskinform.create(atform);
      aform.hwnd:=ahwnd;
      aform.mode:=mode;
      aform.formclass := s;
      aform.InitTform(adata,atform)
   end else begin
      aform:=Twinskinform.create(nil);
      aform.hwnd:=ahwnd;
      aform.mode:=mode;
      aform.formclass := s;
      aform.initDlg(adata);
   end;

   flist.add(aform);
//   LockWindowUpdate(ahwnd);
   postMessage(ahwnd, CN_NewForm, 0, 1000);
   result:=true;
end;

{function TSkinManage.AddMDIForm(atform:Tform):boolean;
var aform:TWinskinform;
    r:Trect;
    s:string;
    aptr:pointer;
    adata:Tskindata;
    isskin:integer;
    ahwnd:Thandle;
begin
   result:=false;
   if not active then exit;
   DeleteDeleted;
   ahwnd:=atform.handle;
   isskin:=sendmessage(ahwnd,CN_IsSkined,0,0);
   if isskin=1 then exit;

   if not OnBeforeSkin(s) then exit;

   FindSkindata(aptr,ahwnd);
   if aptr=nil then exit;

   adata:=Tskindata(aptr);
   if adata.empty then exit;

   if atform<>nil then begin
      aform:=Twinskinform.create(atform);
      aform.hwnd:=ahwnd;
      aform.InitTform(adata,atform);
      flist.add(aform);
      postMessage(ahwnd, CN_NewForm, 0, 1000);
      result:=true;
   end;
end;    }

function TSkinManage.DeleteForm(aHwnd:THandle):boolean;
var i: integer;
    sf :TWinSkinform;
begin
   if (state=skin_destory) then exit;
   result:=false;
   for i:=0 to flist.count-1 do begin
      sf:=TWinSkinform(flist[i]);
      if sf.hwnd=ahwnd then begin
         if sf.FForm = nil then exit;
         sf.Skinstate:=skin_Destory;
         sf.unsubclass;
         flist.delete(i);
         sf.free;
         sf:=nil;
         result:=true;
         break;
      end;
   end;
end;

procedure TSkinManage.DeleteForm2(aHwnd:THandle);
var i: integer;
    sf :TWinSkinform;
begin
   if (state=skin_destory) then exit;
   for i:=0 to flist.count-1 do begin
      sf:=TWinSkinform(flist[i]);
      if sf.hwnd=ahwnd then begin
         flist.delete(i);
         break;
      end;
   end;
end;

procedure TSkinManage.DeleteDeleted;
var i: integer;
    sf :TWinSkinform;
begin
   if (state=skin_destory) then exit;
   for i:=flist.count-1 downto 0 do begin
      sf:=TWinSkinform(flist[i]);
      if IsBadReadPtr(sf, InstanceSize) then begin
         flist.delete(i);
      end else if (sf.skinstate=skin_Deleted) and (sf.mode=mode) then begin
         //sf.UnSubclass3;
         flist.delete(i);
         sf.free;
      end;
   end;
end;

procedure TSkinManage.DeleteAllForms;
var i: integer;
    sf :TWinSkinform;
begin
    active:=false;
//    DeleteDeleted;
    for i:=flist.count-1 downto 0 do begin
        sf:=TWinSkinform(flist[i]);
        if IsBadReadPtr(sf, InstanceSize) then continue;
//??  remove dialog
        if sf.mode<>mode then continue;
        //sf.Skinstate:=skin_Destory;
        flist.delete(i);
        sf.unsubclass3;
        sf.free;
   end;
end;

procedure TSkinManage.DeleteSubForm(amode:integer);
var i: integer;
    sf :TWinSkinform;
begin
    for i:=flist.count-1 downto 0 do begin
        sf:=TWinSkinform(flist[i]);
        if IsBadReadPtr(sf, InstanceSize) then continue;
        if sf.mode<>amode then continue;
        //sf.Skinstate:=skin_Destory;
        flist.delete(i);
        sf.FForm.Free;
        //sf.unsubclass3;
        //sf.free;
   end;
end;

procedure TSkinManage.DeleteForm3;
var i: integer;
    sf :TWinSkinform;
begin
   if (state=skin_destory) then exit;
   for i:=flist.count-1 downto 0 do begin
      sf:=TWinSkinform(flist[i]);
      if sf.skinstate=skin_deleted then begin
         flist.delete(i);
         sf.free;
      end;
   end;
end;

procedure TSkinManage.AddSkinData(adata: Pointer);
begin
   dlist.add(adata);
   if (maindata=nil) and (TSkindata(adata).skinformtype=sfmainform) then
    maindata:=adata;
end;

procedure TSkinManage.RemoveSkinData(adata: Pointer);
var i:integer;
begin
   i:= dlist.indexof(adata);
   if i<>-1 then begin
     dlist[i]:=nil;
     dlist.delete(i);
   end;
end;

procedure TSkinManage.AssignData(adata: Pointer);
var d:TSkinmanage;
begin
   if adata<>nil then begin
      d:=TskinManage(adata);
      flist:=d.Flist;
      Mlist:=d.Mlist;
      dlist:=d.Dlist;
      threadlist:=d.Threadlist;
      maindata:=d.MainData;
      mmgr:=d;
      state:=1;
      active:=d.active;
      //active:=false;
      d.sublist.Add(self);
   end else begin
      flist:=nil;
      Mlist:=nil;
      dlist:=nil;
      threadlist:=nil;
      maindata:=nil;
      active:=false;
      state:=skin_destory;
      if HookCallback<>0 then
         UnhookWindowsHookEx( HookCallback );
      HookCallback:=0;
   end;
end;

procedure TSkinManage.DeleteAllMenus;
var i: integer;
    sm :TWinSkinPopMenu;
begin
   for i:=0 to mlist.count-1 do begin
      sm:=TWinSkinPopMenu(mlist[i]);
      sm.free;
   end;
   mlist.clear;
   mlist.free;
   mlist:=nil;
end;

procedure TSkinManage.DeleteAllSub;
var i: integer;
    sm :TSkinmanage;
begin
   for i:=0 to sublist.count-1 do begin
      sm:=TSkinManage(sublist[i]);
      if not IsBadReadPtr(TSkinManage(sublist[i]), InstanceSize) then
         sm.Assigndata(nil);
//      sm.Assigndata(nil);
      //sm.Free;
   end;
   sublist.clear;
   sublist.free;
   sublist:=nil;
end;

procedure TSkinManage.DeleteSub(p:Pointer);
var i: integer;
begin
   for i:=0 to sublist.count-1 do begin
      if sublist[i]=p then begin
        sublist.delete(i);
        break;
      end;
   end;
end;

procedure TSkinManage.SetPopMenu;
var i: integer;
    sm :TWinSkinPopMenu;
begin
//   i:= mlist.count;
//   if i=0 then exit;
   for i:=0 to mlist.count-1 do begin
      sm:=TWinSkinPopMenu(mlist[i]);
      sm.ownerdraw:=true;
   end;
end;

procedure TSkinManage.SetHMenu(hmenu:Thandle);
var i: integer;
    sm :TWinSkinPopMenu;
begin
//   i:= mlist.count;
//   if i=0 then exit;
   for i:= mlist.count-1 downto 0 do begin
      sm:=TWinSkinPopMenu(mlist[i]);
      if sm.hmenu=0 then begin
         sm.hmenu:=hmenu;
         break;
      end;
   end;
end;

function  TSkinManage.FindSkinForm(aHwnd:THandle):dword;
var i: integer;
    sf :TWinSkinform;
begin
   result:=0;
   for i:=0 to flist.count-1 do begin
      sf:=TWinSkinform(flist[i]);
      if sf.hwnd=ahwnd then begin
         result:=dword(sf);
         break;
      end;
   end;
end;

function TSkinManage.AddMenu(aHwnd:THandle):boolean;
var amenu:TWinSkinPopMenu;
    s:string;
    adata:Tskindata;
    aptr:pointer;
    isskin:integer;
begin
   result:=false;
   if not active then exit;
   isskin:=sendmessage(ahwnd,CN_IsSkined,0,0);
   if isskin=1 then exit;

   if findskinMenu(ahwnd) then exit;

   FindSkindata(aptr,ahwnd);
   if aptr=nil then exit;

   adata:=Tskindata(aptr);
//   if (adata.empty) or (not(xcMainmenu in adata.SkinControls)) then exit;
   if (adata.empty) then exit;
   case menutype of
     m_popup : if (not(xcPopupmenu in adata.SkinControls)) then exit;
     m_menuitem : if (not(xcMainmenu in adata.SkinControls)
          and not(xcMenuitem in adata.SkinControls)) then exit;
     m_systemmenu: if (not(xcSystemmenu in adata.SkinControls)) then exit;
   end;

   amenu:=TWinSkinPopMenu.create;
   amenu.InitSkin(ahwnd,adata,0);
   Mlist.add(amenu);
   if menuactive then amenu.ownerdraw:=true;
end;

function TSkinManage.DeleteMenu(aHwnd:THandle):boolean;
var i: integer;
    sm :TWinSkinPopMenu;
begin
   result:=false;
//   if mlist=nil then exit;
   if IsBadReadPtr(mlist, InstanceSize) then exit;
   for i:=0 to mlist.count-1 do begin
      sm:=TWinSkinPopMenu(mlist[i]);
      if sm.hwnd=ahwnd then begin
         sm.unsubclass;
         mlist.delete(i);
         sm.free;
         result:=true;
         break;
      end;
   end;
   if mlist.count=0 then begin
     menuactive:=false;
         menutype:=0;
   end;
end;

function  TSkinManage.FindSkinMenu(aHwnd:THandle):boolean;
var i: integer;
    sm :TWinSkinPopMenu;
begin
   result:=false;
   for i:=0 to mlist.count-1 do begin
      sm:=TWinSkinPopMenu(mlist[i]);
      if sm.hwnd=ahwnd then begin
         result:=true;
         break;
      end;
   end;
end;

procedure TSkinManage.UpdateSkinMenu(amenu:Hmenu);
var i: integer;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -