unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ButtonGroup, Vcl.StdCtrls;
type
TForm1 = class(TForm)
ButtonGroup1: TButtonGroup;
Edit1: TEdit;
Edit2: TEdit;
procedure ButtonGroup1Click(Sender: TObject);
procedure ButtonGroup1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
function FindItemIndex(ButtonGroup: TButtonGroup): Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.FindItemIndex(ButtonGroup: TButtonGroup): Integer;
var
p: TPoint;
x,y: Integer;
begin
GetCursorPos(p);
p := ScreenToClient(p);
x := p.X - ButtonGroup.Left;
y := p.Y - ButtonGroup.Top;
Edit2.Text := IntToStr(x) + ',' + IntToStr(y);
Result := ButtonGroup.IndexOfButtonAt(x,y);
end;
procedure TForm1.ButtonGroup1Click(Sender: TObject);
var
lv_nIndex: Integer;
begin
lv_nIndex := FindItemIndex(ButtonGroup1);
ShowMessage(IntToStr(lv_nIndex));
end;
procedure TForm1.ButtonGroup1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Edit1.Text := IntToStr(X) + ',' + IntToStr(Y);
end;
end.