whats the best way to do this with buttons

P

Peted

I have a form with 8 checkbuttons in "button" apearence mode

each button press activates a relay device on a connected piece of
hardware.

For the relay device to activate a specfic relay it needs to get a
number of the relay to be used from the button pressed

EG press button 1, activates relay number 1, button 2 activates relay
2.

So how can i do this:

with 8 check buttons on the form (in a panel) how can i direct the
"mousedown" and mouseup events for ALL 8 checkbuttons to only 1 method
or event that will derive the button pressed, and extract from that
the number of the button that will correspond to the relay number that
i can send to the relay device.

I also need to check if its the mouseup or mousedown even that
triggered the call.

Comms with the relay device is working so dont worry about that.

I just cant think of a way to derive a corresponding number resulting
from the relevant button to be pressed, via only 1 method that each
button points to for the mouseup and mousedown events



I hope this was clear in explaining

thanks for any advice
 
K

KWienhold

I have a form with 8 checkbuttons in "button" apearence mode

each button press activates a relay device on a connected piece of
hardware.

For the relay device to activate a specfic relay it needs to get a
number of the relay to be used from the button pressed

EG press button 1, activates relay number 1, button 2 activates relay
2.

So how can i do this:

with 8 check buttons on the form (in a panel) how can i direct the
"mousedown" and mouseup events for ALL 8 checkbuttons to only 1 method
or event that will derive the button pressed, and extract from that
the number of the button that will correspond to the relay number that
i can send to the relay device.

I also need to check if its the mouseup or mousedown even that
triggered the call.

Comms with the relay device is working so dont worry about that.

I just cant think of a way to derive a corresponding number resulting
from the relevant button to be pressed, via only 1 method that each
button points to for the mouseup and mousedown events

I hope this was clear in explaining

thanks for any advice

You could simply hook up all 8 mouseup/mousedown events to the same
handler-function and then act depending on the sender parameter.
Alternatively you could put the number in the tag of each control and
use that.

Sincerely,
Kevin Wienhold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top