LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CtrlMenuCallbackPtr example using

I am trying to use add a menu item called "ADD TO WATCH" when I right click on a Table Cell.
 
I cannot figure out how to "pass'  the CtrlMenuCallbackPtr eventFunction parameter!
 
Here is the fuction prototype:
int NewCtrlMenuItem (int panelHandle, int controlID, char itemLabel[], int beforeMenuItemID, CtrlMenuCallbackPtr eventFunction, void *eventCallbackData);
 
Here is my call:
NewCtrlMenuItem (run_table_panel, RUNDATA_TABLE, "Add To Watch", -1, ***?****,0);  
   
Here is the callback fuction:
int CVICALLBACK Add_Run_To_Watch (int panelHandle, int controlID, int MenuItemID, void *callbackData);
{
  switch (event)
  {
  case EVENT_COMMIT:
   break;
  }
 return 0;
}
0 Kudos
Message 1 of 4
(3,298 Views)
The NewCtrlMenuItem function call should look like this:

NewCtrlMenuItem (run_table_panel, RUNDATA_TABLE, "Add To Watch", -1, Add_Run_To_Watch, 0);

You'll need to make sure that somewhere above the call, or in a header file, you have declared
Add_Run_To_Watch like this:

int CVICALLBACK Add_Run_To_Watch (int panelHandle, int controlID, int MenuItemID, void *callbackData);

Meanwhile, in the function definition itself, you have a couple of things wrong: 1) you have a semic-colon at the end of the definition line, which the compiler will not accept, and 2) in the body of the function you are looking for an EVENT_COMMIT. Menu callbacks, unlike control callbacks, are not sent specific events, so there is no parameter for you to check.

Hope this helps.

Luis
NI





 
0 Kudos
Message 2 of 4
(3,294 Views)
Luis,
 
At the top of the file I have this:
int CVICALLBACK Add_Run_To_Watch (int panelHandle, int controlID, int MenuItemID, void *callbackData); 
 
I corrected the semi colon in the function definition, but I get the same error:
 
NewCtrlMenuItem (run_table_panel, RUNDATA_TABLE, "Add To Watch", -1, Add_Run_To_Watch, 0); 
 
 
  123, 98   Type error in argument 5 to `NewCtrlMenuItem'; found 'pointer to __cdecl int function(int,int,int,pointer to void)' expected 'CtrlMenuCallbackPtr'.
 
Any suggestions?
 
Thanks for you help
 
Fred

 

 


0 Kudos
Message 3 of 4
(3,286 Views)
Fred,

In order to compile properly, the function prototype of your callback function needs to match exactly the function prototype used in the definition of the CtrlMenuCallbackPtr typedef, in userint.h. When I first looked at your prototype it looked right, but now that I look at it more carefully, I can see where it's different: the return type of the function should be void. Yours returns an integer. Change it to a void and see if it will compile.

Luis
0 Kudos
Message 4 of 4
(3,273 Views)