LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

pointer to function

I would like to programmically call the callback of a panel object. I can use GetCtrlAttrinute to get the pointer and name but, the syntax is not coming to me.

I've tried the QueueUserEvent but it seems that the processsystemevents is not calling the callback.

Can anyone supply a example of calling the callback programmically.

Thanks in advance
Kenny
0 Kudos
Message 1 of 3
(3,378 Views)
Trying to call the callback programmatically is really not the easiest approach. It would be much easier to just create a subfunction and call it from both locations. For example, if you callback code looks like:

switch (event)
{
case EVENT_COMMIT:
//Callback code
break;
}
return 0;

Then you would change that to:

switch (event)
{
case EVENT_COMMIT:
subFunctionName();
break;
}
return 0;

and write a new function:

subFunctionName()
{
//Callback code
}

Then, you can call subFunctionName() from the callback and anywhere else.

Calling the callback itself is not difficult though, but you have to fill in all the callback arguments and get the
function pointer which makes it more work. If you wanted to call the callback directly it would look something like this:

int (_cdecl *pt2Function) (int, int, int, void*, int, int);

GetCtrlAttribute (panelHandle, PANEL_GO, ATTR_CALLBACK_FUNCTION_POINTER, &pt2Function);
pt2Function(panelHandle, PANEL_GO, EVENT_COMMIT, NULL, 0, 0);

Where PANEL_GO is the control, and you want to execute the EVENT_COMMIT switch block of the callback.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 3
(3,378 Views)
This is perfect. I was missing the declaration of the pointer. Thanks for the incredible fast response.
Kenny
0 Kudos
Message 3 of 3
(3,378 Views)