unit ufrmSysPubMessage;
interface
uses Windows, Forms, Messages, Classes, ExtCtrls, Controls, StdCtrls;
type TfrmSysPubMessage = class(TForm) Image1: TImage; lblMessage: TLabel; procedure FormCreate(Sender: TObject); protected IconID: PChar; public procedure WndProc(var Msg: TMessage); override; procedure ShowMessage(AMsg: string); end;
implementation
{$R *.DFM}
{ TfrmMessageForm } procedure TfrmSysPubMessage.ShowMessage(AMsg: string); var TempWidth : Integer; begin lblMessage.Caption := AMsg; Application.ProcessMessages; //调整窗体宽度 TempWidth := lblMessage.Width + lblMessage.Left + Image1.Left; if TempWidth < 310 then TempWidth := 310; Width := TempWidth; if not Visible then Show; Application.ProcessMessages; FormStyle := fsStayOnTop; end;
procedure TfrmSysPubMessage.FormCreate(Sender: TObject); begin inherited; IconID := IDI_ASTERISK; Image1.Picture.Icon.Handle := LoadIcon(0, IconID); //使本窗体始终处于最上面,以免其它窗体挡住它 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE); end;
procedure TfrmSysPubMessage.WndProc(var Msg: TMessage); begin //屏蔽Alt+F4 if Msg.wParam <> SC_CLOSE then inherited; end;
end.
|
请发表评论