mainunit.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
- unit mainunit;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Edit1: TEdit;
- Label1: TLabel;
- Button3: TButton;
- Button4: TButton;
- procedure Button1Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Showmessage('主窗体的句柄是:'+IntToStr(Form1.Handle));
- end;
- procedure TForm1.FormShow(Sender: TObject);
- begin
- Button1.SetFocus;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- Showmessage('当前鼠标点击的按钮的句柄是:'+IntToStr(Button2.Handle));
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- if (Application.MessageBox('是否决定改变主窗体的标题','询问',MB_OKCANCEL + MB_OK)=ID_OK) then
- begin
- SetWindowText(Form1.Handle, Pchar(Edit1.Text));
- if (Edit1.Text='')then
- ShowMessage('用户将主窗体的标题设置为空!')
- else
- ShowMessage('用户将主窗体的新标题设置为:'+Edit1.Text);
- Button3.SetFocus;
- end
- else
- begin
- ShowMessage('用户取消了修改主窗体标题的操作!');
- Button3.SetFocus;
- end;
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- begin
- Close;
- end;
- end.