LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problems with callback data

I have a few problems with the calbackData attribute. I know that the type of the callback data is a pointer to void. It is my understanding that this is 4 bytes. How do I store an integer value in the callback data instead of a pointer to another stucture. That is, can I store a value in the callback data without declaring a static integer variable and storing a pointer to the variable.

thanks-
Lorrie
0 Kudos
Message 1 of 3
(3,193 Views)
Lorrie,

It is an illegal operation to cast a void type as an integer type. You must store a pointer to your integer value into the callbackData, making sure that your integer value is either static/global. As far as I know, the only way to use the callbackData parameter is as follows:

//globally defined
int iData=1;

//this will set the callbackData to point to iData
(int *)callbackData = &iData;

//this will set the locally defined iData2 equal to the
//value pointed to by callbackData
iData2 = *(int *)callbackData;

//iData2 now equals 1

If you find a way to cast a void to an integer, let me know. Good Luck.

Ben
0 Kudos
Message 2 of 3
(3,193 Views)
Did you try it like following ?

SetCtrlAttribute (panel, CONTROL_ID, ATTR_CALLBACK_DATA, (void*)12345);

int i;
GetCtrlAttribute (panel, CONTROL_ID, ATTR_CALLBACK_DATA, (void**)&i);

I've often done things like that without problems.
Manfred

lorries323 schrieb in im Newsbeitrag:
50650000000800000087370000-1007855737000@exchange.ni.com...
> I have a few problems with the calbackData attribute. I know that the
> type of the callback data is a pointer to void. It is my understanding
> that this is 4 bytes. How do I store an integer value in the callback
> data instead of a pointer to another stucture. That is, can I store a
> value in the callback data without declaring a static integer variable
> and storing a pointer to the variable.
>
> t
hanks-
> Lorrie
0 Kudos
Message 3 of 3
(3,193 Views)