mainunit.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
源码类别:

Delphi/CppBuilder

开发平台:

Delphi

  1. unit mainunit;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls;
  6. type
  7.   TForm1 = class(TForm)
  8.     Button1: TButton;
  9.     Button2: TButton;
  10.     Edit1: TEdit;
  11.     Label1: TLabel;
  12.     Button3: TButton;
  13.     Button4: TButton;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure FormShow(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.     procedure Button3Click(Sender: TObject);
  18.     procedure Button4Click(Sender: TObject);
  19.   private
  20.     { Private declarations }
  21.   public
  22.     { Public declarations }
  23.   end;
  24. var
  25.   Form1: TForm1;
  26. implementation
  27. {$R *.dfm}
  28. procedure TForm1.Button1Click(Sender: TObject);
  29. begin
  30.  Showmessage('主窗体的句柄是:'+IntToStr(Form1.Handle));
  31. end;
  32. procedure TForm1.FormShow(Sender: TObject);
  33. begin
  34.  Button1.SetFocus;
  35. end;
  36. procedure TForm1.Button2Click(Sender: TObject);
  37. begin
  38.  Showmessage('当前鼠标点击的按钮的句柄是:'+IntToStr(Button2.Handle));
  39. end;
  40. procedure TForm1.Button3Click(Sender: TObject);
  41. begin
  42.  if (Application.MessageBox('是否决定改变主窗体的标题','询问',MB_OKCANCEL + MB_OK)=ID_OK) then
  43.    begin
  44.     SetWindowText(Form1.Handle, Pchar(Edit1.Text));
  45.     if (Edit1.Text='')then
  46.      ShowMessage('用户将主窗体的标题设置为空!')
  47.     else
  48.      ShowMessage('用户将主窗体的新标题设置为:'+Edit1.Text);
  49.     Button3.SetFocus; 
  50.    end
  51.    else
  52.    begin
  53.     ShowMessage('用户取消了修改主窗体标题的操作!');
  54.     Button3.SetFocus;
  55.    end;
  56. end;
  57. procedure TForm1.Button4Click(Sender: TObject);
  58. begin
  59.  Close;
  60. end;
  61. end.