ReadOnlyMsgBox.pas 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. unit ReadOnlyMsgBox;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls, ExtCtrls;
  6. type
  7. TfrmReadOnlyMsgBox = class(TForm)
  8. imgIcon: TImage;
  9. lblMessage: TLabel;
  10. Label2: TLabel;
  11. pnlButtons: TPanel;
  12. Button3: TButton;
  13. Button2: TButton;
  14. Button1: TButton;
  15. procedure FormShow(Sender: TObject);
  16. procedure FormResize(Sender: TObject);
  17. private
  18. { Private declarations }
  19. public
  20. { Public declarations }
  21. function MessageBox(sMsg: String; sCaption: String): Integer;
  22. end;
  23. var
  24. frmReadOnlyMsgBox: TfrmReadOnlyMsgBox;
  25. implementation
  26. {$R *.dfm}
  27. function TfrmReadOnlyMsgBox.MessageBox(sMsg: String; sCaption: String): Integer;
  28. begin
  29. // Initialize form first
  30. imgIcon.Picture.Icon.Handle := LoadIcon(0, IDI_EXCLAMATION);
  31. Caption := sCaption;
  32. lblMessage.Caption := sMsg;
  33. // Show the form
  34. Result := ShowModal;
  35. end;
  36. procedure TfrmReadOnlyMsgBox.FormShow(Sender: TObject);
  37. begin
  38. MessageBeep(MB_ICONEXCLAMATION);
  39. end;
  40. procedure TfrmReadOnlyMsgBox.FormResize(Sender: TObject);
  41. begin
  42. // Center button panel in the middle of the form
  43. pnlButtons.Left := (Width - pnlButtons.Width) div 2;
  44. Left := (Screen.Width - Width) div 2;
  45. end;
  46. end.