Buttongroup - doesn't seem to work as it should ?

Giganews Newsgroups
Subject:Buttongroup - doesn't seem to work as it should ?
Posted by: Mike Bruce (betspri…@btinternet.com)
Date:Wed, 31 May 2006

I have been playing about with the buttongroup component in Win32 - and its
implementation seem rather strange.
I presume its designed mainly so that you  can quickly create a lot of
buttons - and change the layout if needs be - under program control. However
when you add an item - for some reason if you write some code in the click
event ( to find out which button has been clicked - a general click event
which I assign under program control with

btn := buttongroup1.items.add;
btn.onclickevent := grpbuttonItemclick;

when arrives in the click event ( when I click the button ) the sender is
rather stranglely the buttongroup component -  NOT the grpButtonItem as I
expected since its the click event for that item - also if I try to read the
buttongroup.itemindex ( to find out which button was clicked - its always -
1 ) casting the sender to TButtonGroup ?

Am I missing something - or does it seem rather pointless since you can't
add buttons at run time - since you have no click event you can attach them
to if you can't determine which button was clicked ?

Mike Bruce

Replies