home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / StaticDemo / Main.pas < prev    next >
Pascal/Delphi Source File  |  1998-02-28  |  2KB  |  68 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Buttons;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     StaticText2: TStaticText;
  12.     StaticText1: TStaticText;
  13.     StaticText3: TStaticText;
  14.     BitBtn1: TBitBtn;
  15.     procedure StaticText1MouseDown(Sender: TObject; Button: TMouseButton;
  16.       Shift: TShiftState; X, Y: Integer);
  17.     procedure StaticText1MouseUp(Sender: TObject; Button: TMouseButton;
  18.       Shift: TShiftState; X, Y: Integer);
  19.     procedure StaticText1Click(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   MainForm: TMainForm;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. var
  34.   SavedStyle: TStaticBorderStyle;
  35.  
  36. { Change static text border style to indicate its selection }
  37. procedure TMainForm.StaticText1MouseDown(Sender: TObject;
  38.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  39. begin
  40.   with Sender as TStaticText do
  41.   begin
  42.     SavedStyle := BorderStyle;
  43.     if BorderStyle = sbsSunken
  44.       then BorderStyle := sbsSingle
  45.       else BorderStyle := sbsSunken;
  46.   end;
  47. end;
  48.  
  49. { Reset static text border style when mouse button released }
  50. procedure TMainForm.StaticText1MouseUp(Sender: TObject;
  51.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  52. begin
  53.   with Sender as TStaticText do
  54.     BorderStyle := SavedStyle;
  55. end;
  56.  
  57. { Make a sound when text object is clicked }
  58. procedure TMainForm.StaticText1Click(Sender: TObject);
  59. var
  60.   S: String;
  61. begin
  62.   MessageBeep(0);
  63.   S := TStaticText(Sender).Name;
  64.   ShowMessage('You selected ' + S);
  65. end;
  66.  
  67. end.
  68.