📄 bsskinhint.pas
字号:
end;
end
else
begin
Inc(W, 4);
Inc(H, 4);
end;
end;
procedure TbsSkinHintWindow.CalcHintSize(Cnvs: TCanvas; S: String; var W, H: Integer);
var
R: TRect;
PW, PH, OX, OY: Integer;
begin
R := Rect(0, 0, 0, 0);
DrawText(Cnvs.Handle, PChar(S), -1, R, DT_CALCRECT or DT_LEFT);
W := RectWidth(R);
H := RectHeight(R);
if FSD <> nil
then
begin
with FSD.HintWindow do
begin
PW := TBitMap(FSD.FActivePictures[WindowPictureIndex]).Width;
PH := TBitMap(FSD.FActivePictures[WindowPictureIndex]).Height;
W := W + ClRect.Left + (PW - ClRect.Right);
H := H + ClRect.Top + (PH - ClRect.Bottom);
W := W + 5;
OX := W - PW;
OY := H - PH;
if RTPoint.X + OX < LTPoint.X
then
begin
W := W + LTPoint.X - (RTPoint.X + OX);
OX := W - PW;
end;
if RBPoint.X + OX < LBPoint.X
then
begin
W := W + LBPoint.X - (RBPoint.X + OX);
OX := W - PW;
end;
if LBPoint.Y + OY < LTPoint.Y
then
begin
H := H + LTPoint.Y - (LBPoint.Y + OY);
OY := H - PH;
end;
if RBPoint.Y + OY < RTPoint.Y
then
begin
H := H + RTPoint.Y - (RBPoint.Y + OY);
OX := H - PH;
end;
NewClRect := ClRect;
Inc(NewClRect.Right, OX);
Inc(NewClRect.Bottom, OY);
NewLTPoint := LTPoint;
NewRTPoint := Point(RTPoint.X + OX, RTPoint.Y);
NewLBPoint := Point(LBPoint.X, LBPoint.Y + OY);
NewRBPoint := Point(RBPoint.X + OX, RBPoint.Y + OY);
end;
end
else
begin
Inc(W, 4);
Inc(H, 4);
end;
end;
function TbsSkinHintWindow.FindHintComponent;
var
i: Integer;
begin
Result := nil;
if (Application.MainForm <> nil) and
(Application.MainForm.ComponentCount > 0)
then
with Application.MainForm do
for i := 0 to ComponentCount - 1 do
if (Components[i] is TbsSkinHint) and
(TbsSkinHint(Components[i]).Active)
then
begin
Result := TbsSkinHint(Components[i]);
Break;
end;
end;
procedure TbsSkinHintWindow.ActivateHint(Rect: TRect; const AHint: string);
const
WS_EX_LAYERED = $80000;
AnimationStep = 1;
var
HintWidth, HintHeight: Integer;
CanSkin: Boolean;
i: Integer;
TickCount, ABV: Integer;
S: String;
begin
AExtendedStyle := False;
FspHint := FindHintComponent;
if FspHint = nil then Exit;
if (FspHint.FHintTitle <> '') or (FspHint.FHintImageList <> nil)
then
begin
ActivateHintEx(Rect, FspHint.FHintTitle, AHint,
FspHint.FHintImageIndex, FspHint.FHintImageList);
Exit;
end;
if not FspHint.Active then Exit;
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 CheckW2KWXP
then
begin
if FspHint.AlphaBlend and not FOldAlphaBlend
then
begin
SetWindowLong(Handle, GWL_EXSTYLE,
GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED);
end
else
if not FspHint.AlphaBlend and FOldAlphaBlend
then
begin
SetWindowLong(Handle, GWL_EXSTYLE,
GetWindowLong(Handle, GWL_EXSTYLE) and (not WS_EX_LAYERED));
end;
FOldAlphaBlend := FspHint.AlphaBlend;
if FspHint.AlphaBlend and FspHint.AlphaBlendAnimation
then
begin
SetAlphaBlendTransparent(Handle, 0);
end;
if (FOldAlphaBlendValue <> FspHint.AlphaBlendValue) and FspHint.AlphaBlend
then
begin
if not FspHint.AlphaBlendAnimation
then
SetAlphaBlendTransparent(Handle, FspHint.AlphaBlendValue);
FOldAlphaBlendValue := FspHint.AlphaBlendValue;
end;
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 CheckW2KWXP 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 TbsSkinHintWindow.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 TbsSkinHintWindow.PaintEx;
var
R, R1: TRect;
B: TBitMap;
W, H, X, Y, OffsetX, OffsetY, GX, GY: Integer;
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -