📄 jvqthreaddialog.pas
字号:
Parent := FTimeTextPanel;
Align := alClient;
Alignment := taCenter;
AutoSize := False;
BorderStyle := bsSunken3D;
ParentFont := False;
end;
with FCancelButtonPanel do
begin
Top := FTimeTextPanel.Top + FTimeTextPanel.Height + 1;
Caption := '';
Parent := ThreadStatusDialog;
Align := alTop;
BevelOuter := bvNone;
end;
with FCancelBtn do
begin
Parent := FCancelButtonPanel;
Anchors := [akTop];
Caption := DialogOptions.CancelButtonCaption;
OnClick := CancelBtnClick;
Top := 0;
FCancelButtonPanel.Height := FCancelBtn.Height + 3;
end;
SetFormData;
with FMainTimer do
begin
Interval := 500;
OnTimer := MainTimerTimer;
end;
if DialogOptions.ShowModal then
ThreadStatusDialog.ShowModal
else
ThreadStatusDialog.Show;
end;
end;
procedure TJvThreadSimpleDialog.FormShow(Sender: TObject);
begin
FStartTime := Now;
FCounter := 0;
MainTimerTimer(nil);
SetFormData;
end;
procedure TJvThreadSimpleDialog.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FMainTimer.OnTimer := nil;
FMainTimer.Enabled := False;
Action := caFree;
end;
procedure TJvThreadSimpleDialog.CancelBtnClick(Sender: TObject);
begin
if Assigned(JvThreadComp(ThreadStatusDialog.ConnectedThread)) then
JvThreadComp(ThreadStatusDialog.ConnectedThread).Terminate;
end;
procedure TJvThreadSimpleDialog.MainTimerTimer(Sender: TObject);
begin
if not (csDestroying in ComponentState) and Assigned(ThreadStatusDialog) then
if Assigned(ThreadStatusDialog.ConnectedThread) and
Assigned(DialogOptions) then
if JvThreadComp(ThreadStatusDialog.ConnectedThread).Terminated then
ThreadStatusDialog.Close
else
begin
SetFormData;
FCounter := FCounter + 1;
case FCounter mod 4 of
0:
FInfoText.Caption := DialogOptions.FInfoText + ' | ';
1:
FInfoText.Caption := DialogOptions.FInfoText + ' / ';
2:
FInfoText.Caption := DialogOptions.FInfoText + ' --';
3:
FInfoText.Caption := DialogOptions.FInfoText + ' \ ';
end;
FTimeText.Caption := FormatDateTime('hh:nn:ss', Now - FStartTime);
end
else
ThreadStatusDialog.Close;
end;
procedure TJvThreadSimpleDialog.TransferThreadDialogOptions;
begin
SetFormData;
end;
procedure TJvThreadSimpleDialog.SetFormHeightWidth;
var
H, W: Integer;
begin
if Assigned(ThreadStatusDialog) then
begin
W := ThreadStatusDialog.Canvas.TextWidth(DialogOptions.FInfoText) + 80;
if W < 200 then
W := 200;
ThreadStatusDialog.ClientWidth := W;
FCancelBtn.Left := (FCancelButtonPanel.Width - FCancelBtn.Width) div 2;
H := FInfoTextPanel.Height + 6;
if FTimeTextPanel.Visible then
H := H + FTimeTextPanel.Height;
if FCancelButtonPanel.Visible then
H := H + FCancelButtonPanel.Height;
if ThreadStatusDialog.ClientHeight <> H then
ThreadStatusDialog.ClientHeight := H;
end;
end;
procedure TJvThreadSimpleDialog.SetFormData;
begin
if Assigned(ThreadStatusDialog) and Assigned(DialogOptions) then
begin
ThreadStatusDialog.Caption := DialogOptions.Caption;
FTimeTextPanel.Visible := DialogOptions.ShowElapsedTime;
FCancelBtn.Enabled := DialogOptions.EnableCancelButton;
FCancelButtonPanel.Visible := DialogOptions.ShowCancelButton;
SetFormHeightWidth;
end;
end;
//=== { TJvThreadAnimateDialog } =============================================
function TJvThreadAnimateDialog.CreateDialogOptions: TJvThreadBaseDialogOptions;
begin
Result := TJvThreadAnimateDialogOptions.Create(Self);
end;
function TJvThreadAnimateDialog.GetDialogOptions: TJvThreadAnimateDialogOptions;
begin
Result := TJvThreadAnimateDialogOptions(inherited DialogOptions);
end;
function TJvThreadAnimateDialog.CreateThreadDialogForm(ConnectedThread: TComponent): TJvCustomThreadDialogForm;
begin
Result := nil;
if DialogOptions.ShowDialog then
begin
ThreadStatusDialog := TJvCustomThreadDialogForm.CreateNew(Self);
ThreadStatusDialog.ConnectedThread := ConnectedThread;
Result := ThreadStatusDialog;
FCancelButtonPanel := TPanel.Create(ThreadStatusDialog);
FCancelBtn := TBitBtn.Create(ThreadStatusDialog);
FAnimatePanel := TPanel.Create(ThreadStatusDialog);
FAnimate := TAnimate.Create(ThreadStatusDialog);
FInfoTextPanel := TPanel.Create(ThreadStatusDialog);
FInfoText := TStaticText.Create(ThreadStatusDialog);
FTimeTextPanel := TPanel.Create(ThreadStatusDialog);
FTimeText := TStaticText.Create(ThreadStatusDialog);
FMainTimer := TTimer.Create(ThreadStatusDialog);
with ThreadStatusDialog do
begin
BorderIcons := [];
BorderStyle := fbsDialog;
Caption := ' ';
ClientHeight := 88;
ClientWidth := 268;
FormStyle := fsStayOnTop;
Position := poScreenCenter;
OnClose := FormClose;
OnCloseQuery := FormCloseQuery;
OnShow := FormShow;
PixelsPerInch := 96;
end;
with FInfoTextPanel do
begin
Top := 0;
Parent := ThreadStatusDialog;
Align := alTop;
BevelOuter := bvNone;
BorderWidth := 3;
end;
with FInfoText do
begin
Height := 22;
Parent := FInfoTextPanel;
FInfoTextPanel.Height := FInfoText.Height + 6;
Align := alClient;
AutoSize := False;
ParentFont := False;
end;
with FAnimatePanel do
begin
Caption := '';
Top := FInfoTextPanel.Height + 1;
Parent := ThreadStatusDialog;
Align := alTop;
BevelOuter := bvNone;
BorderWidth := 3;
end;
with FAnimate do
begin
Parent := FAnimatePanel;
Top := 0;
Left := 0;
AutoSize := True;
// CommonAVI := TJvThreadAnimateDialogOptions(DialogOptions).CommonAVI;
FileName := TJvThreadAnimateDialogOptions(DialogOptions).FileName;
FAnimatePanel.Height := Height + 6;
end;
with FTimeTextPanel do
begin
Top := FAnimatePanel.Top + FAnimatePanel.Height + 1;
Caption := '';
Parent := ThreadStatusDialog;
Align := alTop;
BevelOuter := bvNone;
BorderWidth := 3;
end;
with FTimeText do
begin
Height := 22;
FTimeTextPanel.Height := FTimeText.Height + 6;
Parent := FTimeTextPanel;
Align := alClient;
Alignment := taCenter;
AutoSize := False;
BorderStyle := bsSunken3D;
ParentFont := False;
end;
with FCancelButtonPanel do
begin
Top := FTimeTextPanel.Top + FTimeText.Height + 1;
Caption := '';
Parent := ThreadStatusDialog;
Align := alTop;
BevelOuter := bvNone;
end;
with FCancelBtn do
begin
Top := 0;
Parent := FCancelButtonPanel;
Anchors := [akTop];
Caption := DialogOptions.CancelButtonCaption;
OnClick := CancelBtnClick;
FCancelButtonPanel.Height := FCancelBtn.Height + 3;
end;
SetFormData;
with FMainTimer do
begin
Interval := 500;
OnTimer := MainTimerTimer;
end;
if DialogOptions.ShowModal then
ThreadStatusDialog.ShowModal
else
ThreadStatusDialog.Show;
end;
end;
procedure TJvThreadAnimateDialog.FormShow(Sender: TObject);
begin
FStartTime := Now;
FCounter := 0;
SetFormData;
FAnimate.Active := True;
MainTimerTimer(nil);
end;
procedure TJvThreadAnimateDialog.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FMainTimer.OnTimer := nil;
FMainTimer.Enabled := False;
Action := caFree;
end;
procedure TJvThreadAnimateDialog.CancelBtnClick(Sender: TObject);
begin
if Assigned(JvThreadComp(ThreadStatusDialog.ConnectedThread)) then
JvThreadComp(ThreadStatusDialog.ConnectedThread).Terminate;
end;
procedure TJvThreadAnimateDialog.MainTimerTimer(Sender: TObject);
begin
if not (csDestroying in ComponentState) and Assigned(ThreadStatusDialog) then
if Assigned(ThreadStatusDialog.ConnectedThread) and Assigned(DialogOptions) then
if JvThreadComp(ThreadStatusDialog.ConnectedThread).Terminated then
ThreadStatusDialog.Close
else
begin
SetFormData;
FTimeText.Caption := FormatDateTime('hh:nn:ss',Now-FStartTime);
end
else
ThreadStatusDialog.Close
end;
procedure TJvThreadAnimateDialog.TransferThreadDialogOptions;
begin
SetFormData;
end;
procedure TJvThreadAnimateDialog.SetFormHeightWidth;
var
H, W: Integer;
begin
H := 6;
if Assigned(ThreadStatusDialog) then
begin
W := 200;
if FInfoTextPanel.Visible then
begin
W := ThreadStatusDialog.Canvas.TextWidth(DialogOptions.FInfoText) + 80;
if ThreadStatusDialog.Canvas.TextWidth(DialogOptions.FInfoText) + 80 > W then
W := ThreadStatusDialog.Canvas.TextWidth(DialogOptions.FInfoText) + 80;
H := H + FInfoTextPanel.Height;
end;
if FAnimatePanel.Visible then
begin
if FAnimate.Width + 20 > W then
W := FAnimate.Width + 20;
H := H + FAnimate.Height;
end;
FCancelBtn.Left := (W - FCancelBtn.Width) div 2;
FAnimate.Left := (W - FAnimate.Width) div 2;
if FTimeTextPanel.Visible then
H := H + FTimeTextPanel.Height;
if FCancelButtonPanel.Visible then
H := H + FCancelButtonPanel.Height;
if ThreadStatusDialog.ClientWidth <> W then
ThreadStatusDialog.ClientWidth := W;
if ThreadStatusDialog.ClientHeight <> H then
ThreadStatusDialog.ClientHeight := H;
end;
end;
procedure TJvThreadAnimateDialog.SetFormData;
begin
if Assigned(ThreadStatusDialog) and Assigned(DialogOptions) then
begin
FInfoText.Caption := DialogOptions.FInfoText;
ThreadStatusDialog.Caption := DialogOptions.Caption;
FInfoTextPanel.Visible := DialogOptions.InfoText <> '';
FAnimatePanel.Visible := FileExists(FAnimate.Filename) ;
FTimeTextPanel.Visible := DialogOptions.ShowElapsedTime;
FCancelBtn.Enabled := DialogOptions.EnableCancelButton;
FCancelButtonPanel.Visible := DialogOptions.ShowCancelButton;
SetFormHeightWidth;
end;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$RCSfile: JvQThreadDialog.pas,v $';
Revision: '$Revision: 1.3 $';
Date: '$Date: 2005/02/06 14:06:17 $';
LogPath: 'JVCL\run'
);
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -