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

📄 winskinform.pas

📁 超级报表系统软件VclSkin.v2.60.4.29.完整源代码版.rar
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  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 MenuItem.OnDrawItem := nil;
  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) and (not enable)//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;

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 (cname='TDBCOMBOBOXEH') then exit;
     if (cname='TQRPREVIEW') then exit;
     if (cname='TFRDESIGNERPAGE') then exit;
     if (cname='TFRPBOX') then exit;
     
     // not success
     if (Comp is TTabControl) 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 (Find3rdControl(cname,TWinControl(comp))) then begin
       exit;
     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 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 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');
         with TSkinBox.create(comp) do
         init(self,self.fsd,self.fcanvas2,true);
     end

     else if ((Comp is Tstatusbar) and
          (xcStatusBar in Fsd.SkinControls)) then begin
       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 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='TRICHEDIT')) then begin
       with TSkinScrollBar.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self);
     end

     else if (xcScrollBar in Fsd.SkinControls) AND
        ((cname='TWWDBRICHEDIT') or (cname='TDXDBMEMO')) then begin
       with TSkinScrollBar.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self);
     end

     else if (Comp is Tbitbtn) then begin
       if  (xcbitbtn in Fsd.SkinControls) then begin
          with TSkinBitButton.create(comp) do
          init(self,self.fsd,self.fcanvas2);
       end else exit;
     end

     else if ((Comp is Tspeedbutton) and
          (xcSpeedButton in Fsd.SkinControls)) then begin
       with TSkinSpeedButton.create(comp) do
        InitGraphicControl(self,self.fsd,self.fcanvas2);
     end

     else if ((Comp is TCustomPanel))
       and (xcPanel in Fsd.SkinControls) then begin
       with TSkinBox.create(comp) do
         init(self,self.fsd,self.fcanvas2,true);
       self.InitControls(Comp as TWinControl);
     end

     else if ((cname='TDXTREELIST') or (cname='TDXDBTREELIST') or
         (cname='TDXDBGRID')) and (xcScrollBar in Fsd.SkinControls) then begin
       with TSkinScrollBar.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self,false);
     end

     else if (Comp is TCustomListView)
         and (xcScrollBar in Fsd.SkinControls) then begin
         //not success
       with TSkinlistview.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self,false);
//        init(TWinControl(Comp),self.fsd,self.fcanvas2,false);

//       with TSkinScrollBar.create(self) do
//        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,false);
     end

     else if (xcScrollBar in Fsd.SkinControls)
         and (Comp is TCustomMemo) then begin
       with TSkinScrollBar.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self);
     end

     else if (xcScrollBar in Fsd.SkinControls)
         and (Comp is TCustomgrid) then begin
       with TSkinScrollBar.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self);
       TAcgrid(Comp).fixedcolor:=fsd.colors[csButtonFace];
     end

     else if (xcScrollBar in Fsd.SkinControls)
         and ( isscrollcontrol(Comp)) then begin
       with TSkinScrollBar.create(comp) do
        initScrollbar(TWinControl(Comp),self.fsd,self.fcanvas2,self);
     end

     else if ((Comp is TButton) and (xcButton in Fsd.SkinControls)) then begin
       with TSkinButton.create(comp) do
        init(self,self.fsd,self.fcanvas2);
     end

     else if ((Comp is TCustomEdit)) and
          (xcedit in Fsd.SkinControls) then begin
        skin:=TSkinEdit.create(comp);
        skin.inithwnd(TWinControl(Comp).handle,self.fsd,fcanvas2,self);
//        controllist.add(skin);
     end

     else if (Comp is TCustomFrame) then
      self.InitControls(Comp as TWinControl)

     else if (Comp is TCustomform) then begin
      with TSkinBox.create(comp) do
         init(self,self.fsd,self.fcanvas2,true);
      self.InitControls(Comp as TWinControl);
//      spy := TWinSkinspy.Create(comp);
//      spy.sf:=self;
     end;
end;
procedure TWinSkinForm.InitControls(wForm: TWinControl);
var
  i, x,j,tag: integer;
  Comp: TComponent;
begin
  DeleteSkinDeleted;
  for i := 0 to wForm.ComponentCount - 1 do begin
     Comp := wForm.Components[i];
     addcomp(comp,wform);
  end;
end;

{procedure TWinSkinForm.InitControls(wForm: TWinControl);
var
  i, x,j,tag: integer;
  Comp: TComponent;
  subcomp:Twincontrol;
  skin:TSkinControl;
  buf:array[0..100] of char;
  cname:string;
  b:boolean;
  chwnd:Thandle;
  skincomp: TComponent;
  tag2:integer;
begin
  for i := 0 to wForm.ComponentCount - 1 do begin
     Comp := wForm.Components[i];
     cname:=Uppercase(comp.ClassName);
     tag2:= comp.tag mod 100;
     if tag2=fsd.disabletag then continue;
     if FindSkinComp(comp) then continue;
     if (comp is Twincontrol) then begin
        chwnd:= TACWinControl(comp).WindowHandle;
        if chwnd=0 then
          try
            chwnd:=TACWinControl(comp).handle;
          except
            continue;
          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(TWinControl(Comp),self.

⌨️ 快捷键说明

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