1) Normally you QuitUserInterface before you DiscardPanel. If you discard your parent panel, all child panels will be discarded also.
2) If you hide a parent panel, all of its child (and grandchild, etc.) panels will be hidden. I'm guessing when all panels are hidden, the active panel is the parent panel.
3) I don't know if you can debug VC and CVI at the same time. I have previously done one at a time. If you're working on a problem in CVI, try the following steps.
3.1 Compile your VC code into an exe.
3.2 In the CVI project window for your DLL, select Run >> Select External Process, then enter the path to your VC exe in the Program Name box and select OK.
3.3 In any CVI window, select Run >> Debug YourVCProject.exe. You'll now be using the CVI environment to debug your DLL.
Here's some notes about your DisplayAPanel problem.
Your comment and code:
/** When the first DisplayAPanel is called, the Panel pops up,
and the debugging shows the execution of code stops here.
...
*/
void DisplayAPanel(int handle)
{
static int bRunFlag=0;
if (handle >= 0)
{
DisplayPanel(handle);
}
// Make sure RunUserInterface run only once
if (bRunFlag == 0)
{
RunUserInterface();
bRunFlag = 1;
}
}
RunUserInterface returns only when QuitUserInterface is called. So the first time you go into DisplayAPanel, you never set bRunFlag = 1 and return until you call QuitUserInterface. You can call DisplayAPanel again from your VC code, but it never sees bRunFlag == 1.
If you let CVI automatically generate the initial code for your DLL, it would have created a function called InitUIForDLL. Do RunUserInterface here and call InitUIForDLL once from your VC code as part of some init routine. Remember that RunUserInterface (and therefore InitUIForDLL) won't return until QuitUserInterface, so you need to put the VC call to InitUIForDLL where you don't need to continue sequential execution until after QuitUserInterface and where VC will still run other events. Or you need to structure your VC code so the CVI DLL UI takes over and you don't go back to VC until your QuitUserInterface.