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

📄 sskinprovider.pas

📁 AlphaControls是一个Delphi标准控件的集合
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        Message.Result := CallWindowProc(pointer(OldInstance), Form.Handle, Message.Msg, Message.wParam, Message.lParam);
        if OldCaption <> Form.Caption then begin
          OldCaption := Form.Caption;
          BGChanged := True;
          SendMessage(Form.Handle, WM_NCPAINT, 0, 0);
        end;
      end;
      WM_GETTEXT : begin
        Message.Result := CallWindowProc(pointer(OldInstance), Form.Handle, Message.Msg, Message.wParam, Message.lParam);
        if OldCaption1 <> Form.Caption then begin
          OldCaption1 := Form.Caption;
          BGChanged := True;
          SendMessage(Form.Handle, WM_NCPAINT, 0, 0);
        end;
      end;
      // Caption changing
      WM_COMMAND : begin
        cm := TWMCommand(Message);
        case cm.NotifyCode of
          EN_CHANGE : begin
            Message.Result := CallWindowProc(pointer(OldInstance), Form.Handle, Message.Msg, Message.wParam, Message.lParam);
            BGChanged := True;
            SendMessage(Form.Handle, WM_NCPAINT, 0, 0);
          end;
          EN_UPDATE : begin
          end
          else Message.Result := CallWindowProc(pointer(OldInstance), Form.Handle, Message.Msg, Message.wParam, Message.lParam);
        end;
      end
      else begin
{$IFDEF LOCALDEBUG}
        if Assigned(Form1) and Assigned(Form1.List) and not (csCreating in Form1.ControlState) then
        Form1.List.Add(MessageToStr(Message.Msg) + ' : ' + IntToStr(Message.WParam));
{$ENDIF}
        if Message.Msg = RM_TaskbarCreated then else
          Message.Result := CallWindowProc(pointer(OldInstance), Form.Handle, Message.Msg, Message.wParam, Message.lParam);
      end;
    end;
  end;
end;

procedure TsSkinProvider.PaintBorderIcons;
var
  i, b : integer;
begin
  b := 2;
  if biSystemMenu in FsBorderIcons then begin
    if IsValidImgIndex(ButtonClose.ImageIndex) then begin
      ButtonClose.Rect.Left := Form.Width - BorderWidth - ButtonWidth - 1;
      ButtonClose.Rect.Top := (CaptionHeight - ButtonHeight + BorderHeight) div 2;
      ButtonClose.Rect.Right := ButtonClose.Rect.Left + ButtonWidth;
      ButtonClose.Rect.Bottom := ButtonClose.Rect.Top + ButtonHeight;
      PaintBlendGlyph(sStyle.FCacheBmp, ma[ButtonClose.ImageIndex].Bmp,
                Point(ButtonClose.Rect.Left, ButtonClose.Rect.Top),
                ButtonClose.State, ma[ButtonClose.ImageIndex].TransparentColor, 1 + integer(not FormActive));
    end;
    if SystemMenu.VisibleMax then begin
      if SystemMenu.EnabledMax then begin
        if IsValidImgIndex(ButtonMax.ImageIndex) then begin
          ButtonMax.Rect.Left := Form.Width - BorderWidth - b * (ButtonWidth + 1);
          ButtonMax.Rect.Top := (CaptionHeight - ButtonHeight + BorderHeight) div 2;
          ButtonMax.Rect.Right := ButtonMax.Rect.Left + ButtonWidth;
          ButtonMax.Rect.Bottom := ButtonMax.Rect.Top + ButtonHeight;
          PaintBlendGlyph(sStyle.FCacheBmp, ma[ButtonMax.ImageIndex].Bmp,
                    Point(ButtonMax.Rect.Left, ButtonMax.Rect.Top),
                    ButtonMax.State, ma[ButtonMax.ImageIndex].TransparentColor, 1 + integer(not FormActive));
          inc(b);
        end;
      end
      else begin
        i := sStyle.GetMaskIndex(BorderIconNormalize);
        if i > -1 then begin
          ButtonMax.Rect.Left := Form.Width - BorderWidth - b * (ButtonWidth + 1);
          ButtonMax.Rect.Top := (CaptionHeight - ButtonHeight + BorderHeight) div 2;
          ButtonMax.Rect.Right := ButtonMax.Rect.Left + ButtonWidth;
          ButtonMax.Rect.Bottom := ButtonMax.Rect.Top + ButtonHeight;
          PaintBlendGlyph(sStyle.FCacheBmp, ma[i].Bmp,
                    Point(ButtonMax.Rect.Left, ButtonMax.Rect.Top),
                    ButtonMax.State, ma[i].TransparentColor, 1 + integer(not FormActive));
          inc(b);
        end;
      end;
    end;
    if SystemMenu.VisibleMin then begin
      if IsValidImgIndex(ButtonMin.ImageIndex) then begin
        ButtonMin.Rect.Left := Form.Width - BorderWidth - b * (ButtonWidth + 1);
        ButtonMin.Rect.Top := (CaptionHeight - ButtonHeight + BorderHeight) div 2;
        ButtonMin.Rect.Right := ButtonMin.Rect.Left + ButtonWidth;
        ButtonMin.Rect.Bottom := ButtonMin.Rect.Top + ButtonHeight;
        PaintBlendGlyph(sStyle.FCacheBmp, ma[ButtonMin.ImageIndex].Bmp,
                  Point(ButtonMin.Rect.Left, ButtonMin.Rect.Top),
                  ButtonMin.State, ma[ButtonMin.ImageIndex].TransparentColor, 1 + integer(not FormActive));
        inc(b);
      end;
    end;
    if biHelp in FsBorderIcons then begin
      if IsValidImgIndex(ButtonHelp.ImageIndex) then begin
        ButtonHelp.Rect.Left := Form.Width - BorderWidth - b * (ButtonWidth + 1);
        ButtonHelp.Rect.Top := (CaptionHeight - ButtonHeight + BorderHeight) div 2;
        ButtonHelp.Rect.Right := ButtonHelp.Rect.Left + ButtonWidth;
        ButtonHelp.Rect.Bottom := ButtonHelp.Rect.Top + ButtonHeight;
        PaintBlendGlyph(sStyle.FCacheBmp, ma[ButtonHelp.ImageIndex].Bmp,
                  Point(ButtonHelp.Rect.Left, ButtonHelp.Rect.Top),
                  ButtonHelp.State, ma[ButtonHelp.ImageIndex].TransparentColor, 1 + integer(not FormActive));
      end;
    end;
  end;

  // Drawing of MDI child buttons if maximized
  if MDIButtonsNeeded then begin
    LinesCount := GetLinesCount;
    if IsValidImgIndex(MDIMin.ImageIndex) then begin
      MDIMin.Rect := Rect(
                          Form.Width - BorderWidth - 3 * (SmallButtonWidth + 1),
                          HeaderHeight - (MenuHeight - SmallButtonHeight) div 2 - SmallButtonHeight - 1,
                          MDIMin.Rect.Left + SmallButtonWidth,
                          MDIMin.Rect.Top + SmallButtonHeight
                         );

      PaintBlendGlyph(sStyle.FCacheBmp, ma[MDIMin.ImageIndex].Bmp,
                Point(MDIMin.Rect.Left, MDIMin.Rect.Top),
                MDIMin.State, ma[MDIMin.ImageIndex].TransparentColor, 1 + integer(not FormActive));
    end;
    if IsValidImgIndex(MDIMax.ImageIndex) then begin
      MDIMax.Rect := Rect(
                          Form.Width - BorderWidth - 2 * (SmallButtonWidth + 1),
                          HeaderHeight - (MenuHeight - SmallButtonHeight) div 2 - SmallButtonHeight - 1,
                          MDIMax.Rect.Left + SmallButtonWidth,
                          MDIMax.Rect.Top + SmallButtonHeight
                         );

      PaintBlendGlyph(sStyle.FCacheBmp, ma[MDIMax.ImageIndex].Bmp,
                Point(MDIMax.Rect.Left, MDIMax.Rect.Top),
                MDIMax.State, ma[MDIMax.ImageIndex].TransparentColor, 1 + integer(not FormActive));
    end;
    if IsValidImgIndex(MDIClose.ImageIndex) then begin
      MDIClose.Rect.Left   := Form.Width - BorderWidth - SmallButtonWidth - 1;
      MDIClose.Rect.Top    := HeaderHeight - (MenuHeight - SmallButtonHeight) div 2 - SmallButtonHeight - 1;
      MDIClose.Rect.Right  := MDIClose.Rect.Left + SmallButtonWidth;
      MDIClose.Rect.Bottom := MDIClose.Rect.Top + SmallButtonHeight;

      PaintBlendGlyph(sStyle.FCacheBmp, ma[MDIClose.ImageIndex].Bmp,
                Point(MDIClose.Rect.Left, MDIClose.Rect.Top),
                MDIClose.State, ma[MDIClose.ImageIndex].TransparentColor, 1 + integer(not FormActive));
    end;
  end;
end;

procedure TsSkinProvider.PaintCaption(DC : hdc);
var
  h, hmnu : integer;
begin
  h := BorderHeight + CaptionHeight;
  if IsIconic(Form.Handle) then inc(h);

  if BGChanged then begin
    PaintAll;
    BGChanged := False;
  end;                             

  hmnu := LinesCount * MenuHeight * integer(MenuPresent);

  // Title and menu line update
  BitBlt(DC, 0, 0, Form.Width, h + hmnu + integer(MenuPresent) + TForm(Form).BorderWidth, FsStyle.FCacheBmp.Canvas.Handle, 0, 0, SRCCOPY);
  // Left border update
  BitBlt(DC, 0, h + hmnu + TForm(Form).BorderWidth, Borderwidth + TForm(Form).BorderWidth, FsStyle.FCacheBmp.Height, FsStyle.FCacheBmp.Canvas.Handle, 0, h + hmnu + TForm(Form).BorderWidth, SRCCOPY);
  // Bottom border update
  BitBlt(DC, Borderwidth + TForm(Form).BorderWidth,
             {FsStyle.FCacheBmp.}Form.Height - Borderwidth - TForm(Form).BorderWidth,
             Form.Width - BorderWidth - TForm(Form).BorderWidth,
             Borderwidth + TForm(Form).BorderWidth,
             FsStyle.FCacheBmp.Canvas.Handle,
             Borderwidth + TForm(Form).BorderWidth,
             Form.Height - BorderHeight - TForm(Form).BorderWidth,
  SRCCOPY);
  // Right border update
  BitBlt(DC, FsStyle.FCacheBmp.Width - Borderwidth - TForm(Form).BorderWidth, h + hmnu + TForm(Form).BorderWidth, Borderwidth + TForm(Form).BorderWidth, FsStyle.FCacheBmp.Height, FsStyle.FCacheBmp.Canvas.Handle, FsStyle.FCacheBmp.Width - Borderwidth - TForm(Form).BorderWidth, h + hmnu + TForm(Form).BorderWidth, SRCCOPY);
end;

procedure TsSkinProvider.PaintForm(DC : hdc);
//var
//  m : TMessage;
begin
  PaintAll;
//  m := MakeMessage(SM_SETBGCHANGED, 0, integer(BGChanged), 0);
//  BroadCasts(Form, m);
//  RepaintsControls(Form, BGChanged);

//  if Form.FormStyle <> fsMDIForm then begin
  BitBlt(DC, 0, 0,
         Form.Width, Form.Height,
         FsStyle.FCacheBmp.Canvas.Handle,
         (BorderWidth + Form.BorderWidth),
         (BorderHeight + CaptionHeight + LinesCount * MenuHeight * integer(MenuPresent) + Form.BorderWidth) + 1,
         SRCCOPY);
//  end;

  PaintPassiveControls(Form);
//  Form.PaintControls(Form.Canvas.Handle, nil);

  BGChanged := False;
end;

procedure TsSkinProvider.SetBorderIcons(const Value: TsBorderIcons);
begin
  if FsBorderIcons <> Value then begin
    FsBorderIcons := Value;
//    if not (csDesigning in ComponentState) then PaintForm;
  end;
end;

procedure TsSkinProvider.SetHotHT(i: integer);
begin
  if HotItem.Item <> nil then begin
    RepaintMenuItem(HotItem.Item, HotItem.R, []);
    HotItem.Item := nil;
  end;
  if (CurrentHT = i) then Exit;
  if (CurrentHT <> 0) then begin
    case CurrentHT of
      HTCLOSE : begin
        ButtonClose.State := 0;
      end;
      HTMAXBUTTON : begin
        ButtonMax.State := 0;
      end;
      HTMINBUTTON : begin
        ButtonMin.State := 0;
      end;
      HTHELP : begin
        ButtonHelp.State := 0;
      end;
      HTCHILDCLOSE : begin
        MDIClose.State := 0;
      end;
      HTCHILDMAX : begin
        MDIMax.State := 0;
      end;
      HTCHILDMIN : begin
        MDIMin.State := 0;
      end;
    end;
    RepaintButton(CurrentHT);
  end;
  CurrentHT := i;
  case CurrentHT of
    HTCLOSE : begin
      ButtonClose.State := 1;
    end;
    HTMAXBUTTON : begin
      ButtonMax.State := 1;
    end;
    HTMINBUTTON : begin
      ButtonMin.State := 1;
    end;
    HTHELP : begin
      ButtonHelp.State := 1;
    end;
    HTCHILDCLOSE : begin
      MDIClose.State := 1;
    end;
    HTCHILDMAX : begin
      MDIMax.State := 1;
    end;
    HTCHILDMIN : begin
      MDIMin.State := 1;
    end;
  end;
  RepaintButton(CurrentHT);
end;

procedure TsSkinProvider.SetPressedHT(i: integer);
begin
  if (CurrentHT <> i) and (CurrentHT <> 0) then begin
    case CurrentHT of
      HTCLOSE : begin
        ButtonClose.State := 0;
      end;
      HTMAXBUTTON : begin
        ButtonMax.State := 0;
      end;
      HTMINBUTTON : begin
        ButtonMin.State := 0;
      end;
      HTHELP : begin
        ButtonHelp.State := 0;
      end;
      HTCHILDCLOSE : begin
        MDIClose.State := 0;
      end;
      HTCHILDMAX : begin
        MDIMax.State := 0;
      end;
      HTCHILDMIN : begin
        MDIMin.State := 0;
      end;
    end;
    RepaintButton(CurrentHT);
  end;
  CurrentHT := i;
  case CurrentHT of
    HTCLOSE : begin
      ButtonClose.State := 2;
    end;
    HTMAXBUTTON : begin
      ButtonMax.State := 2;
    end;
    HTMINBUTTON : begin
      ButtonMin.State := 2;
    end;
    HTHELP : begin
      ButtonHelp.State := 2;
    end;
    HTCHILDCLOSE : begin
      MDIClose.State := 2;
    end;
    HTCHILDMAX : begin
      MDIMax.State := 2;
    end;
    HTCHILDMIN : begin
      MDIMin.State := 2;
    end;
  end;
  RepaintButton(CurrentHT);
  Application.ProcessMessages;
end;

procedure TsSkinProvider.PaintAll;
var
  Index, i, CY : integer;
  x, w, h, y : integer;
  s : string;
  r, rForm : TRect;
  ci : TCacheInfo;
  CurrentItem : TMenuItem;
  ItemProcessed : integer;
  ChangedIndex : integer;
  Iconic : boolean;
  function ProcessMerged(CurrentIndex : integer) : boolean;
  var
    i, j, h, w : integer;
    LocalItem : TMenuItem;
  begin

⌨️ 快捷键说明

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