12-09-2008 04:41 AM
Gents,
I recently upgrade my LabWindows to version 9.0 and I have a curious behavious when using RunPopupMenu.
Up to version 8.5 the following code was working fine :
popUpMenuBar = NewMenuBar (0);
popUpMenuId = NewMenu (popUpMenuBar, "JtagCopyMenu", -1);
cutId = NewMenuItem (popUpMenuBar, popUpMenuId, "Cut", -1,0,NULL,NULL);
copyId = NewMenuItem (popUpMenuBar, popUpMenuId, "Copy", -1,0,NULL,NULL);
pasteId = NewMenuItem (popUpMenuBar, popUpMenuId, "Paste", -1,0,NULL,NULL);
GetRelativeMouseState (panel, 0, &x, &y, NULL, NULL, NULL); //Get mouse coordinates
itemId = RunPopupMenu (popUpMenuBar, popUpMenuId, panel, y, x, 0, 0, 0, 0); //Display popup menu at mouse position
DiscardMenuBar (popUpMenuBar);
Since version 9.0, the menu displays correctly but I have a general protection fault as soon as I click on a item.
When I give a menu callback address like this :
cutId = NewMenuItem (popUpMenuBar, popUpMenuId, "Cut", -1,0,popupMenuClbk,NULL);
The problem disapear, event if the callback is an empty function.
Other observation, when I launch an executable compiled with 8.5 version on a version 9.0 run-time engine, this one also crash when I click on the same item.
Any idea ?
Stéphane
12-09-2008 10:58 AM - edited 12-09-2008 10:59 AM
Hello Stéphane,
I tried reproducing the crash but haven't been able to, so far. It's probably the case that I need to replicate some additional aspects of your program in order to trigger it. Would you be able to attach a small program that we can use to reproduce the problem?
Thanks,
Luis
12-11-2008 03:06 AM
Luis,
I have also tried on my side to isolate the problem in a small project without success.
I think also that there is some kind of interaction with another section of my application. But this one is quite big (more than 20000 lines of code) and uses some SDK functionalities to intercept windows messages like WM_DEVICECHANGE. So I am now trying to disable one by one all the modules to find which one is guilty.
Anyway, the problem wasn't happening in 8.5 version (on the same PC, same OS ...), so something has changed in the run-time engine concerning the callback management during RunPopupMenu execution.
thanks for your help,
Stephane
12-11-2008 07:53 AM
I got it !
The problem occur when using InstallMainCallback function to answer to EVENT_END_TASK message.
I attach a sample project that makes the problem occur.
Just right click on the knob or on the "generate" button to display the popup menu and click the "crash now !" item to crash the application.
regards,
Stephane
12-11-2008 01:02 PM
Hello Stephane,
Thanks for the simple example, I was able to recreate the behavior you described. This has been reported with ID 136678 for further investigation. Thanks again for the feedback.
NickB
National Instruments
01-05-2009 07:45 AM
Hello,
I have exactly the same problem. It there a way to bypass this problem or must I go back to CVI 8.5?
thanks for your help,
SamV
01-05-2009 07:55 AM
HI SamV,
You can bypass the problem by creating a dummy callback function like this one :
void CVICALLBACK DummyPopupMenuClbk (int menuBarHandle, int menuItemID, void *callbackData, int panelHandle)
{
}
and then specify to each "NewMenuItem" routine that you want to use that callback like this :
itemId = NewMenuItem (popUpMenuBar, popUpMenuId, "Cut", -1,0,DummyPopupMenuClbk,NULL);
Hope this will help you.
Stephane