通过消息处理的方法,点击鼠标的右键,来改变form1的caption.
Code
procedure WMRButtonDown(var msg:Tmsg);message WM_RBUTTONDOWN;
procedure WMRButtonUp(var msg:Tmsg);message WM_RBUTTONUP;
//implement
procedure TForm1.WMRButtonDown(var msg: Tmsg);
begin
Form1.Caption:='Button Down';
inherited;
end;
procedure TForm1.WMRButtonUp(var msg: Tmsg);
begin
Form1.Caption:='Button Up';
inherited;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(Form1.Handle,WM_RBUTTONDOWN,0,0);
end;
点击button1也可以实现右键的点击功能。
procedure WMRButtonDown(var msg:Tmsg);message WM_RBUTTONDOWN;
procedure WMRButtonUp(var msg:Tmsg);message WM_RBUTTONUP;
//implement
procedure TForm1.WMRButtonDown(var msg: Tmsg);
begin
Form1.Caption:='Button Down';
inherited;
end;
procedure TForm1.WMRButtonUp(var msg: Tmsg);
begin
Form1.Caption:='Button Up';
inherited;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(Form1.Handle,WM_RBUTTONDOWN,0,0);
end;