Dynamic callbacks for label

Hi,

I have created a GUI screen consisting of buttons(48) ,labels(48) and one slider(1). My problem is that i have only one slider but i need to update 48 labels,which label to be updated is defined by the button pressed and once the label is selected then the slider updation values must be displayed in that label. Please suggest me how to achieve this.

I’m going to assume that by “button pressed” you either mean the last button pressed, or you are using “radio” buttons, where only one stays pressed, and pops out when another is pressed.

There are a number of ways to do this, but I think some are better than others.

You could have 48 button callbacks, each one setting a variable indicating the button was pressed.
When the slider is moved, it could use this variable as an index into a table with the label widget pointers.
I would call this the hard way.

The buttons could all call one callback. In that callback you search a table of button widget pointers to find which one was pressed, and store the index. The index could also reference a table of label widgets that the slider would use.
This is ok, but needs a table search each time a button is pressed.

The following would be my choice, as there is very low overhead, although searching a 48 item table whenever a human action occurs is not many cycles.
The buttons could all call one callback. In that callback you read the widget’s user-data. You’ve previously stored something in the user-data which you retrieve and store in a global variable. This could either be an index as in the above example, or the label widget pointer itself.

Thanks for the quick reply

I have tried same thing with slight modification

What i have done is that I have obtained the button index with Ptgetresource and then using this index value i have updated global array and used the index value in the switch statement in the slider callback to update the label text instead of going to the label callback.

Suggest if any mistake exist.

The process worked fine except one problem.

I have named the textbox as AO while realizing for the first time and then while updating text for the text box from the slider callback the value is being backside of AOi.e., AO is visible and also value that i am changing through slider is being updated.

Suggest solution for this problem.