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

📄 skinhint.pas

📁 DynamicSkinForm.v9.15.For.Delphi.BCB 很好的皮肤控件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    end;
  if (FspHint.SkinData <> nil) and (FspHint.SkinData.ResourceStrData <> nil)
  then
    Canvas.Font.CharSet := FspHint.SkinData.ResourceStrData.CharSet
  else
    Canvas.Font.CharSet := FspHint.DefaultFont.CharSet;

  S := AHint;
  CheckText(S);
  Caption := S;
  CalcHintSizeEx(Canvas, Caption, AHintTitle, AImageIndex, AImageList,
    HintWidth, HintHeight);
  Rect.Right := Rect.Left + HintWidth;
  Rect.Bottom := Rect.Top + HIntHeight;
  //
  if (Rect.Right > Screen.Width) then OffsetRect(Rect, -HintWidth - 2, 0);
  if (Rect.Bottom > Screen.Height) then OffsetRect(Rect, 0, -HintHeight - 2);
  //
  BoundsRect := Rect;
  //
   if (OldAlphaBlend <> FspHint.AlphaBlend) and FSpHint.AlphaBlendSupport
  then
    begin
      if OldAlphaBlend
      then
       SetWindowLong(Handle, GWL_EXSTYLE,
            GetWindowLong(Handle, GWL_EXSTYLE) and (not WS_EX_LAYERED))
      else
        begin
          SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE)
                        or WS_EX_LAYERED);
          if not FspHint.AlphaBlendAnimation
          then
            SetAlphaBlendTransparent(Handle, FspHint.AlphaBlendValue);
        end;
      OldAlphaBlend := FspHint.AlphaBlend;
    end;

  if FSpHint.AlphaBlendSupport and FspHint.AlphaBlend and FspHint.AlphaBlendAnimation
  then
    begin
      SetAlphaBlendTransparent(Handle, 0);
    end;


  if (OldAlphaBlendValue <> FspHint.AlphaBlendValue) and FSpHint.AlphaBlendSupport and
     FspHint.AlphaBlend
  then
    begin
      if not FspHint.AlphaBlendAnimation
      then
        SetAlphaBlendTransparent(Handle, FspHint.AlphaBlendValue);
      OldAlphaBlendValue := FspHint.AlphaBlendValue;
    end;
  //
  if FspHint.AlphaBlend and not FspHint.AlphaBlendSupport
  then
    begin
      SI.Width := Width;
      SI.Height := Height;
      GetScreenImage(Rect.Left, Rect.Top, SI);
    end;
  //
  SetHintWindowRegion;
  //
  SetWindowPos(Handle, HWND_TOPMOST, Rect.Left, Rect.Top, 0,
    0, SWP_SHOWWINDOW or SWP_NOACTIVATE or SWP_NOSIZE);
  Visible := True;
  Self.RePaint;
  if FspHint.AlphaBlendSupport and FspHint.AlphaBlend and FspHint.AlphaBlendAnimation
  then
    begin
      i := 0;
      TickCount := 0;
      ABV := FspHint.AlphaBlendValue;
      repeat
        if (GetTickCount - TickCount > 3)
        then
          begin
            TickCount := GetTickCount;
            Inc(i, 20);
            if i > ABV then i := ABV;
            Self.RePaint;
            SetAlphaBlendTransparent(Handle, i);
          end;  
      until i >= ABV;
    end;
end;

procedure TspSkinHintWindow.ActivateHint(Rect: TRect; const AHint: string);
const
  WS_EX_LAYERED = $80000;
var
  ABV, TickCount, i, HintWidth, HintHeight: Integer;
  CanSkin: Boolean;
  S: String;
begin
  AExtendedStyle := False;
  FspHint := FindHintComponent;
  if FspHint = nil then Exit;
  if not FspHint.Active then Exit;

  if (FspHint.FHintTitle <> '') or (FspHint.FHintImageList <> nil)
  then
    begin
      ActivateHintEx(Rect, FspHint.FHintTitle, AHint,
        FspHint.FHintImageIndex, FspHint.FHintImageList);
      Exit;
    end;

  CanSkin := (FspHint.FSD <> nil) and (not FspHInt.FSD.Empty) and
             (FspHint.FSD.HintWindow.WindowPictureIndex <> -1);
  //
  if CanSkin then FSD := FspHint.FSD else FSD := nil;

  if FSD <> nil
  then
    begin
      with Canvas, FSD.HintWindow do
      begin
        if FspHint.UseSkinFont
        then
          begin
            Font.Height := FontHeight;
            Font.Name := FontName;
            Font.Style := FontStyle;
          end
        else
          Font.Assign(FspHint.FDefaultFont);
      end;
    end
  else
    with Canvas do
    begin
      Font.Assign(FspHint.FDefaultFont);
    end;

  if (FspHint.SkinData <> nil) and (FspHint.SkinData.ResourceStrData <> nil)
  then
    Canvas.Font.CharSet := FspHint.SkinData.ResourceStrData.CharSet
  else
    Canvas.Font.CharSet := FspHint.DefaultFont.CharSet;

  S := AHint;
  CheckText(S);
  Caption := S;

  CalcHintSize(Canvas, Caption, HintWidth, HintHeight);
  Rect.Right := Rect.Left + HintWidth;
  Rect.Bottom := Rect.Top + HIntHeight;
  //
  if (Rect.Right > Screen.Width) then OffsetRect(Rect, -HintWidth-2, 0);
  if (Rect.Bottom > Screen.Height) then OffsetRect(Rect, 0, -HintHeight-2);
  //
  BoundsRect := Rect;
  if (OldAlphaBlend <> FspHint.AlphaBlend) and FSpHint.AlphaBlendSupport
  then
    begin
      if OldAlphaBlend
      then
       SetWindowLong(Handle, GWL_EXSTYLE,
            GetWindowLong(Handle, GWL_EXSTYLE) and (not WS_EX_LAYERED))
      else
        begin
          SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE)
                        or WS_EX_LAYERED);
          if not FspHint.AlphaBlendAnimation
          then
            SetAlphaBlendTransparent(Handle, FspHint.AlphaBlendValue);
        end;
      OldAlphaBlend := FspHint.AlphaBlend;
    end;

  if FSpHint.AlphaBlendSupport and FspHint.AlphaBlend and FspHint.AlphaBlendAnimation
  then
    begin
      SetAlphaBlendTransparent(Handle, 0);
    end;


  if (OldAlphaBlendValue <> FspHint.AlphaBlendValue) and FSpHint.AlphaBlendSupport and
     FspHint.AlphaBlend
  then
    begin
      if not FspHint.AlphaBlendAnimation
      then
        SetAlphaBlendTransparent(Handle, FspHint.AlphaBlendValue);
      OldAlphaBlendValue := FspHint.AlphaBlendValue;
    end;
  //
  if FspHint.AlphaBlend and not FspHint.AlphaBlendSupport
  then
    begin
      SI.Width := Width;
      SI.Height := Height;
      GetScreenImage(Rect.Left, Rect.Top, SI);
    end;
  //
  SetHintWindowRegion;
  //
  SetWindowPos(Handle, HWND_TOPMOST, Rect.Left, Rect.Top, 0,
    0, SWP_SHOWWINDOW or SWP_NOACTIVATE or SWP_NOSIZE);
  Visible := True;
  Self.RePaint;
  if FspHint.AlphaBlendSupport and FspHint.AlphaBlend and FspHint.AlphaBlendAnimation
  then
    begin
      i := 0;
      TickCount := 0;
      ABV := FspHint.AlphaBlendValue;
      repeat
        if (GetTickCount - TickCount > 3)
        then
          begin
            TickCount := GetTickCount;
            Inc(i, 20);
            if i > ABV then i := ABV;
            Self.RePaint;
            SetAlphaBlendTransparent(Handle, i);
          end;  
      until i >= ABV;
    end;
end;

procedure TspSkinHintWindow.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style - WS_BORDER;
  if CheckWXP
  then
    Params.WindowClass.Style := Params.WindowClass.style or CS_DROPSHADOW_;
end;

procedure TspSkinHintWindow.PaintEx;
var
  R, R1: TRect;
  B: TBitMap;
  W, H, X, Y, OffsetX, OffsetY, GX, GY: Integer;
  kf: Double;
  EB1, EB2: TspEffectBmp;
begin
  //
  DrawBuffer := TBitMap.Create;
  DrawBuffer.Width := Width;
  DrawBuffer.Height := Height;
  //
  if FSD <> nil
  then
    with DrawBuffer.Canvas, FSD.HintWindow do
    begin
      B := TBitMap(FSD.FActivePictures[WindowPictureIndex]);
      CreateSkinImageBS(LTPoint, RTPoint, LBPoint, RBPoint,
      CLRect, NewLTPoint, NewRTPoint, NewLBPoint, NewRBPoint,
      NewClRect, DrawBuffer, B,
      Rect(0, 0, B.Width, B.Height), Width, Height, True,
      FSD.HintWindow.LeftStretch, FSD.HintWindow.TopStretch,
      FSD.HintWindow.RightStretch, FSD.HintWindow.BottomStretch, StretchEffect, StretchType);
    end
  else
    with DrawBuffer.Canvas do
    begin
      Brush.Color := clInfoBk;
      FillRect(ClientRect);
      R := ClientRect;
      Frame3D(DrawBuffer.Canvas, R, clBtnShadow, clBtnShadow, 1);
    end;
  //
  if FSD <> nil
  then
    with DrawBuffer.Canvas, FSD.HintWindow do
    begin
      Brush.Style := bsClear;
      if FspHint.UseSkinFont
      then
        begin
          Font.Height := FontHeight;
          Font.Style := FontStyle;
          Font.Name := FontName;
        end
      else
        Font.Assign(FspHint.FDefaultFont);

      if (FspHint.SkinData <> nil) and (FspHint.SkinData.ResourceStrData <> nil)
      then
        Font.CharSet := FspHint.SkinData.ResourceStrData.CharSet
      else
        Font.CharSet := FspHint.DefaultFont.CharSet;

      Font.Color := FontColor;
      OffsetX := 0;
      OffsetY := 0;
      // title
      if FspHint.FHintTitle <> ''
      then
        begin
          R := Rect(0, 0, 0, 0);
          Font.Style := [fsBold];
          DrawText(Handle, PChar(FspHint.FHintTitle), -1, R, DT_CALCRECT or DT_LEFT);
          W := RectWidth(R);
          H := RectHeight(R);
          X := NewClRect.Left + 5;
          Y := NewClRect.Top;
          R := Rect(X, Y, X + W, Y + H);
          DrawText(Handle, PChar(FspHint.FHintTitle), -1, R, DT_LEFT);
          Font.Style := Font.Style  - [fsBold];
          OffsetY := H + 5;
        end;
      // image
      GX := -1;
      GY := -1;
      if (FspHint.FHintImageList <> nil) and (FspHint.FHintImageIndex >= 0) and
         (FspHint.FHintImageIndex < FspHint.FHintImageList.Count)
      then
        begin
          GX := NewClRect.Left + 5;
          if OffsetY = 0
          then
            GY := NewClRect.Top + RectHeight(NewClRect) div 2 -
                   FspHint.FHintImageList.Height div 2
          else
            GY := NewClRect.Top + OffsetY;
          FspHint.FHintImageList.Draw(DrawBuffer.Canvas,
            GX, GY, FspHint.FHintImageIndex);
          OffsetX := GX + FspHint.FHintImageList.Width + 5;
        end;
      //
      R := Rect(0, 0, 0, 0);
      DrawText(Handle, PChar(Caption), -1, R, DT_CALCRECT or DT_LEFT);
      W := RectWidth(R);
      H := RectHeight(R);
      if OffsetX = 0
      then
        X := NewClRect.Left + 5
      else
        X := OffsetX;
      if OffsetY <> 0
      then
        Y := NewClRect.Top + OffsetY
      else
        Y := NewClRect.Top + RectHeight(NewClRect) div 2 - H div 2;
      R := Rect(X, Y, X + W, Y + H);
      DrawText(Handle, PChar(Caption), -1, R, DT_LEFT);
    end
  else
    with DrawBuffer.Canvas do
    begin
      Font.Assign(FspHint.FDefaultFont);
      if (FspHint.SkinData <> nil) and (FspHint.SkinData.ResourceStrData <> nil)
      then
        Font.CharSet := FspHint.SkinData.ResourceStrData.CharSet
      else
        Font.CharSet := FspHint.DefaultFont.CharSet;
      Font.Color := clInfoText;
      Brush.Style := bsClear;
      R1 := Rect(2, 2, Width - 2, Height - 2);
      OffsetX := 0;
      OffsetY := 0;
      // title
      if FspHint.FHintTitle <> ''
      then
        begin
          R := Rect(0, 0, 0, 0);
          Font.Style := [fsBold];
          DrawText(Handle, PChar(FspHint.FHintTitle), -1, R, DT_CALCRECT or DT_LEFT);
          W := RectWidth(R);
          H := RectHeight(R);
          X := R1.Left;
          Y := R1.Top;
          R := Rect(X, Y, X + W, Y + H);
          DrawText(Handle, PChar(FspHint.FHintTitle), -1, R, DT_LEFT);
          Font.Style := Font.Style  - [fsBold];
          OffsetY := H + 5;
        end;
      // image
      GX := -1;
      GY := -1;
      if (FspHint.FHintImageList <> nil) and (FspHint.FHintImageIndex >= 0) and
         (FspHint.FHintImageIndex < FspHint.FHintImageList.Count)
      then
        begin
          GX := R1.Left;
          if OffsetY = 0
          then
            GY := R1.Top + RectHeight(R1) div 2 -
                   FspHint.FHintImageList.Height div 2
          else
            GY := OffsetY;
          FspHint.FHintImageList.Draw(DrawBuffer.Canvas,
            GX, GY, FspHint.FHintImageIndex);
          OffsetX := GX + FspHint.FHintImageList.Width + 5;
        end;
      //
      R1.Top := R1.Top + OffsetY;
      R1.Left := R1.Left + OffsetX;
      DrawText(Handle, PChar(Caption), -1, R1, DT_LEFT);
    end;
  //
  if FspHint.AlphaBlend and not FspHint.AlphaBlendSupport
  then
    begin
      EB1 := TspEffectBmp.CreateFromhWnd(DrawBuffer.Handle);
      SI.Width := DrawBuffer.Width;
      EB2 := TspEffectBmp.CreateFromhWnd(SI.Handle);
      kf := 1 - FspHint.AlphaBlendValue / 255;
      EB1.Morph(EB2, kf);
      EB1.Draw(DrawBuffer.Canvas.Handle, 0, 0);
      EB1.Free;
      EB2.Free;
    end;
  //
  Canvas.Draw(0, 0, DrawBuffer);
  DrawBuffer.Free;
end;

⌨️ 快捷键说明

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