📄 jvqdesktopalertform.pas
字号:
end;
procedure TJvFormDesktopAlert.SetNewTop(const Value: Integer);
begin
SetNewOrigin(Left, Value);
end;
procedure TJvFormDesktopAlert.SetNewLeft(const Value: Integer);
begin
SetNewOrigin(Value, Top);
end;
procedure TJvFormDesktopAlert.SetNewOrigin(ALeft, ATop: Integer);
var
MoveEvent: TNotifyEvent;
begin
if ((Top <> ATop) or (Left <> ALeft)) and not MouseInControl then
begin
MoveEvent := FOnUserMove;
FOnUserMove := nil;
Left := ALeft;
Top := ATop;
FOnUserMove := MoveEvent;
end;
end;
procedure TJvFormDesktopAlert.DoMouseTimer(Sender: TObject);
var
P: TPoint;
function IsInForm(P: TPoint): Boolean;
var
W: TControl;
begin
W := ControlAtPos(P, True, True);
Result := (W = Self) or (FindVCLWindow(P) = Self) or ((W <> nil) and (GetParentForm(W) = Self));
end;
begin
// this is here to ensure that MouseInControl is correctly set even
// if we never got a CM_MouseLeave (that happens a lot)
MouseTimer.Enabled := False;
GetCursorPos(P);
MouseInControl := PtInRect(BoundsRect, P); // and IsInForm(P);
MouseTimer.Enabled := True;
if not TJvDesktopAlert(Owner).StyleHandler.Active and not MouseInControl and (TJvDesktopAlert(Owner).StyleHandler.DisplayDuration > 0) then
TJvDesktopAlert(Owner).StyleHandler.DoEndAnimation;
end;
procedure TJvFormDesktopAlert.DoClose(var Action: TCloseAction);
begin
MouseTimer.Enabled := False;
inherited DoClose(Action);
end;
//=== { TJvDesktopAlertButton } ==============================================
constructor TJvDesktopAlertButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FChangeLink := TChangeLink.Create;
FChangeLink.OnChange := DoImagesChange;
Width := 21;
Height := 21;
end;
destructor TJvDesktopAlertButton.Destroy;
begin
FChangeLink.Free;
inherited Destroy;
end;
procedure TJvDesktopAlertButton.DoImagesChange(Sender: TObject);
begin
Invalidate;
end;
procedure TJvDesktopAlertButton.MouseEnter(Control: TControl);
begin
inherited;
Invalidate;
end;
procedure TJvDesktopAlertButton.MouseLeave(Control: TControl);
begin
inherited;
Invalidate;
end;
procedure TJvDesktopAlertButton.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if Operation = opRemove then
if AComponent = Images then
Images := nil;
end;
procedure TJvDesktopAlertButton.Paint;
var
Rect: TRect;
begin
with Canvas do
begin
Rect := ClientRect;
Brush.Style := bsClear;
if bsMouseInside in MouseStates then
begin
Pen.Color := JvDefaultTrackBorderColor;
Rectangle(Rect);
InflateRect(Rect, -1, -1);
if bsMouseDown in MouseStates then
Brush.Color := JvDefaultHotTrackColor
else
Brush.Color := JvDefaultTrackColor;
FillRect(Rect);
end;
case ToolType of
abtArrowLeft:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Style := [];
Canvas.Font.Size := 10;
DrawText(Canvas.Handle, '3', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtArrowRight:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Style := [];
Canvas.Font.Size := 10;
DrawText(Canvas.Handle, '4', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtClose:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Size := 7;
Canvas.Font.Style := [];
DrawText(Canvas.Handle, 'r', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtMaximize:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Style := [];
DrawText(Canvas.Handle, '2', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtMinimize:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Style := [];
DrawText(Canvas.Handle, '1', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtDropDown:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Size := 10;
Canvas.Font.Style := [];
DrawText(Canvas.Handle, 'u', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtDropDownChevron:
begin // area should be 7x12
InflateRect(Rect, -((Rect.Right - Rect.Left) - 7) div 2, -((Rect.Bottom - Rect.Top) - 12) div 2);
Canvas.Pen.Color := clWindowText;
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 2, Rect.Top);
Canvas.MoveTo(Rect.Left + 3, Rect.Top);
Canvas.LineTo(Rect.Left + 5, Rect.Top);
OffsetRect(Rect, 1, 1);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 2, Rect.Top);
Canvas.MoveTo(Rect.Left + 3, Rect.Top);
Canvas.LineTo(Rect.Left + 5, Rect.Top);
OffsetRect(Rect, 1, 1);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 2, Rect.Top);
Canvas.MoveTo(Rect.Left + 3, Rect.Top);
Canvas.LineTo(Rect.Left + 5, Rect.Top);
OffsetRect(Rect, -1, 1);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 2, Rect.Top);
Canvas.MoveTo(Rect.Left + 3, Rect.Top);
Canvas.LineTo(Rect.Left + 5, Rect.Top);
OffsetRect(Rect, -1, 1);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 2, Rect.Top);
Canvas.MoveTo(Rect.Left + 3, Rect.Top);
Canvas.LineTo(Rect.Left + 5, Rect.Top);
OffsetRect(Rect, 1, 4);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 5, Rect.Top);
OffsetRect(Rect, 1, 1);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 3, Rect.Top);
OffsetRect(Rect, 1, 1);
Canvas.MoveTo(Rect.Left, Rect.Top);
Canvas.LineTo(Rect.Left + 1, Rect.Top);
end;
abtRestore:
begin
Canvas.Font.Name := 'Marlett';
Canvas.Font.Style := [];
DrawText(Canvas.Handle, '3', 1, Rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
abtImage:
begin
if (Images = nil) or (ImageIndex < 0) or (ImageIndex >= Images.Count) then
Exit;
Images.Draw(Canvas,
(Width - Images.Width) div 2 + Ord(bsMouseDown in MouseStates),
(Height - Images.Height) div 2 + Ord(bsMouseDown in MouseStates),
ImageIndex,
itImage,
Enabled);
end;
end;
end;
end;
procedure TJvDesktopAlertButton.SetImageIndex(const Value: TImageIndex);
begin
if FImageIndex <> Value then
begin
FImageIndex := Value;
Invalidate;
end;
end;
procedure TJvDesktopAlertButton.SetImages(const Value: TCustomImageList);
begin
if FImages <> Value then
begin
if FImages <> nil then
FImages.UnRegisterChanges(FChangeLink);
FImages := Value;
if FImages <> nil then
begin
FImages.FreeNotification(Self);
FImages.RegisterChanges(FChangeLink);
end;
Invalidate;
end;
end;
procedure TJvDesktopAlertButton.SetToolType(const Value: TJvDesktopAlertButtonType);
begin
if FToolType <> Value then
begin
FToolType := Value;
Invalidate;
end;
end;
procedure TJvFormDesktopAlert.JvDeskTopAlertAutoFree(var Msg: TMessage);
begin
// WPAram is us, LParam is the TJvDesktopAlert
if Msg.WParam = WPARAM(Self) then
begin
Release;
TObject(Msg.LParam).Free;
end;
end;
procedure TJvFormDesktopAlert.DoButtonClick(Sender: TObject);
var
FEndInterval: Cardinal;
begin
if Sender is TJvDesktopAlertButton then
begin
FEndInterval := TJvDesktopAlert(Owner).StyleHandler.EndInterval;
try
// stop the animation while the OnClick handler executes:
// we don't want the form to disappear before we return
TJvDesktopAlert(Owner).StyleHandler.EndInterval := 0;
if Assigned(TJvDesktopAlertButton(Sender).InternalClick) then
TJvDesktopAlertButton(Sender).InternalClick(Sender);
finally
TJvDesktopAlert(Owner).StyleHandler.EndInterval := FEndInterval;
if not MouseInControl then
TJvDesktopAlert(Owner).StyleHandler.DoEndAnimation;
end;
end;
end;
procedure TJvFormDesktopAlert.DoDropDownClose(Sender: TObject);
begin
// restore previous EndInterval value
if FEndInterval <> 0 then
TJvDesktopAlert(Owner).StyleHandler.EndInterval := FEndInterval;
FEndInterval := 0;
if not MouseInControl then
TJvDesktopAlert(Owner).StyleHandler.DoEndAnimation;
end;
procedure TJvFormDesktopAlert.DoDropDownMenu(Sender: TObject;
MousePos: TPoint; var Handled: Boolean);
begin
// suspend the form while the menu is visible
FEndInterval := TJvDesktopAlert(Owner).StyleHandler.EndInterval;
TJvDesktopAlert(Owner).StyleHandler.EndInterval := 0;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$RCSfile: JvQDesktopAlertForm.pas,v $';
Revision: '$Revision: 1.16 $';
Date: '$Date: 2005/02/11 10:11:55 $';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
initialization
{$IFDEF UNITVERSIONING}
RegisterUnitVersion(HInstance, UnitVersioning);
{$ENDIF UNITVERSIONING}
RegisterClasses([TLabel, TImage, TAction, TJvDesktopAlertButton, TJvLabel]);
{$IFDEF UNITVERSIONING}
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -