1

i'm creating a x number of buttons runtime in this way:

btn is Control   
btn <- ControlCreate(name,typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn..Caption = name
btn..Process[trtClick] = buttonAction

the buttonAction code is:

Info("You pressed: " + btn..Caption)

But the result of the buttonAction is always the last button name I create, for eg. I create a button named "Luca" and when I click it the result is: You pressed: Luca. Then i create a new button named "Antonio" but when I press "Luca" button the output is You pressed Antonio. How can I assign one button action runtime for every button?

Luca Alberto
  • 1,195
  • 3
  • 11
  • 30

1 Answers1

0

Did you try to create a control per button ? Where did you run the creation of the buttons ? Like:

btn1 is Control   
btn1 <- ControlCreate("test1",typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn1..Caption = "test1"
btn1..Process[trtClick] = buttonAction

btn2 is Control   
btn2 <- ControlCreate("test2",typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn2..Caption = "test2"
btn2..Process[trtClick] = buttonAction

What result do you get ? I don't have the last version of Windev for tests.

I'm afraid "btn" became shared to the windows when you use

<- ControlCreate
Bidjes
  • 166
  • 4
  • 10