1,183
社区成员
发帖
与我相关
我的任务
分享
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, AppEvnts;
type
TForm1 = class(TForm)
rg1: TRadioGroup;
rg2: TRadioGroup;
// 放个TApplicationEvents 控件
aplctnvnts1: TApplicationEvents;
procedure aplctnvnts1Message(var Msg: tagMSG; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// 处理TApplicationEvents 的OnMessage事件
procedure TForm1.aplctnvnts1Message(var Msg: tagMSG; var Handled: Boolean);
var
i: Integer;
ctr: TWinControl;
begin
if Msg.message = WM_LBUTTONDOWN then
begin
for i := 0 to ControlCount - 1 do
begin
if ctr is TWinControl then ctr := Controls[i] as TWinControl;
if (ctr.ClassNameIs('TRadioGroup')) and (ctr.Handle = Msg.hwnd) then
ShowMessage(‘点击了’ + ctr.Name);
end;
end;
end;
end.