📄 agentdialog.pas
字号:
unit AgentDialog;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, OleCtrls, AgentObjects_TLB, KsSkinButtons, Buttons,
StdCtrls, SysPublic;
type
TfrmAgentDialog = class(TForm)
sbYes: TSpeedButton;
sbNo: TSpeedButton;
lblMsg: TLabel;
lblMsg1: TLabel;
lblMsg2: TLabel;
lblAnn: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure sbNoClick(Sender: TObject);
procedure sbYesClick(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure lblMsg1Click(Sender: TObject);
procedure lblMsg2Click(Sender: TObject);
procedure lblMsgClick(Sender: TObject);
private
{ Private declarations }
lReturn: Integer;
sPubMsg: string;
lPubMode: Integer;
procedure MainRun;
procedure LoadData;
procedure DrawRndRectRegion(wnd: HWND; rect: TRect);
public
procedure UniteDialog;
procedure UniteAgent;
{ Public declarations }
end;
const
MB_ANNUNCTATOR = $000000FF;
var
frmAgentDialog: TfrmAgentDialog;
function AgentShowMsg(sMsg: string; lMode: Integer = MB_OK): Integer;
implementation
uses DBData;
{$R *.dfm}
function AgentShowMsg(sMsg: string; lMode: Integer = MB_OK): Integer;
begin
frmAgentDialog := TfrmAgentDialog.Create(Application); //新建窗体
with frmAgentDialog do
begin
sPubMsg := sMsg;
lPubMode := lMode;
MainRun;
Result := lReturn;
Free;
end;
end;
procedure TfrmAgentDialog.MainRun;
begin
lReturn := 0;
LoadData;
ShowModal;
end;
procedure TfrmAgentDialog.LoadData;
begin
lblMsg.Caption := sPubMsg;
if lPubMode = MB_OK then
sbNo.Visible := False
else
sbNo.Visible := True;
case lPubMode of
MB_OK: sbNo.Visible := False;
MB_ANNUNCTATOR:
begin
lblMsg1.Visible := True;
lblMsg2.Visible := True;
lblAnn.Visible := True;
sbYes.Visible := False;
sbNo.Visible := False;
lblMsg.Font.Color := clBlue;
lblMsg1.Font.Color := clBlue;
lblMsg2.Font.Color := clBlue;
lblMsg.Cursor := crHandPoint;
lblMsg1.Cursor := crHandPoint;
lblMsg2.Cursor := crHandPoint;
lblMsg.Caption := GetCommaStr(sPubMsg, 1);
lblMsg1.Caption := GetCommaStr(sPubMsg, 2);
lblMsg2.Caption := GetCommaStr(sPubMsg, 3);
lblMsg.Visible := StrToBool2(GetIniValue(frmData.ADOConnet, 'StockAnnunct'));
lblMsg1.Visible := StrToBool2(GetIniValue(frmData.ADOConnet, 'ARAnnunct'));
lblMsg2.Visible := StrToBool2(GetIniValue(frmData.ADOConnet, 'APAnnunct'));
end;
end;
if lblMsg.Width + 35 > width then width := lblMsg.Width + 35;
if lblMsg.Height + 50 > Height then Height := lblMsg.Height + 50;
DrawRndRectRegion(Handle, ClientRect);
UniteDialog;
end;
procedure TfrmAgentDialog.UniteDialog;
begin
if bExistAgent then
with self do
begin
top := Peedy.Top - Height;
Left := Peedy.Left - Width div 2;
if Left < 0 then Left := 0;
if Top < 0 then Top := 0;
if Left + Width > Screen.Width then Left := Screen.Width - Width;
if Top + Height > Screen.Height - 20 then Top := Screen.Height - Height - 20;
end
else
begin
Left := Screen.Width - Width - 20;
Top := Screen.Height - Height - 40;
end;
end;
procedure TfrmAgentDialog.UniteAgent;
begin
if bExistAgent then
with Self do
begin
Peedy.Top := Top + Height;
Peedy.Left := Left + Width div 2;
if Peedy.Left < 0 then Peedy.Left := 0;
if Peedy.Top < 0 then Peedy.Top := 0;
if Peedy.Left + Peedy.Width > Screen.Width then Peedy.Left := Screen.Width - Peedy.Width;
if Peedy.Top + Peedy.Height > Screen.Height then Peedy.Top := Screen.Height - Peedy.Height;
end;
end;
procedure TfrmAgentDialog.DrawRndRectRegion(wnd: HWND; rect: TRect);
var
rgn: HRGN;
begin
rgn := CreateRoundRectRgn(rect.left, rect.top, rect.right, rect.bottom, width div 10, width div 10);
SetWindowRgn(wnd, rgn, TRUE);
end;
procedure TfrmAgentDialog.FormCreate(Sender: TObject);
begin
UniteDialog;
end;
procedure TfrmAgentDialog.FormMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
ReleaseCapture;
Perform(WM_SYSCOMMAND, SC_MOVE + 1, 0);
UniteAgent;
end;
end;
procedure TfrmAgentDialog.sbNoClick(Sender: TObject);
begin
lReturn := 2;
Close;
end;
procedure TfrmAgentDialog.sbYesClick(Sender: TObject);
begin
lReturn := 1;
Close;
end;
procedure TfrmAgentDialog.FormPaint(Sender: TObject);
begin
Canvas.RoundRect(ClientRect.left, ClientRect.top, ClientRect.right - 2, ClientRect.bottom - 2, width div 10, width div 10);
end;
procedure TfrmAgentDialog.FormClick(Sender: TObject);
begin
case lPubMode of
MB_ANNUNCTATOR: Close;
end;
end;
procedure TfrmAgentDialog.lblMsg1Click(Sender: TObject);
begin
case lPubMode of
MB_ANNUNCTATOR:
begin lReturn := 2;
Close;
end;
end;
end;
procedure TfrmAgentDialog.lblMsg2Click(Sender: TObject);
begin
case lPubMode of
MB_ANNUNCTATOR:
begin lReturn := 3;
Close;
end;
end;
end;
procedure TfrmAgentDialog.lblMsgClick(Sender: TObject);
begin
case lPubMode of
MB_ANNUNCTATOR:
begin lReturn := 1;
Close;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -