LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Easytab wont pass control to another panel

Hi:

I have a program in which a procedure is called that opens a new panel. It
worked fine until I added an easytab control to the calling panel. Now the
called panel does not have focus. It opens, but I all clicks are processed
by the calling panel.

Any ideas?

regards

Luis Villa
0 Kudos
Message 1 of 7
(3,288 Views)
This is a very strange behaviour.
Could you please post a skeleton of your program? I think most things will be clearer looking at the actual source code.
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(3,288 Views)
Roberto:

Here is the skeleton code where I am having problems.
Maintest loads maintest.uir, I load an easytab panel, at some point the
user presses
a button and calls Initrecording which at some point calls CountDown.
at that point CntDown.uir is loaded and displayed, but control is kept
within
Maintest.


int MainTest ()
{

if ((TPanelHandle = LoadPanel (0, "MainTest.UIR", T_PANEL)) < 0)
return -1;

/* Two function calls and, Voila!, a tab sheet dialog */
tabCtrl = EasyTab_ConvertFromCanvas(TPanelHandle, T_PANEL_TAB_CANVAS);
EasyTab_LoadPanels (TPanelHandle, tabCtrl, 1, "MainTest.UIR",
__CVIUserHInst, TEMP_SENS, &HandleTempSens, RH_SENS, &HandleRHSens,
0);

InstallPopup(TPanelHandle);
DisplayPanel (TPanelHandle);



RunUserInterfa
ce ();
DiscardPanel(TPanelHandle);
InitializeDigitalPorts();


return 0;
}





int CVICALLBACK InitRecording (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
// stuff ommitted

iStatus = CountDown(CntDownSecs); //Display CountDown / Fire recorder &
airbag

break;
case EVENT_RIGHT_CLICK:

break;
}
return 0;
}


int CountDown (int ValIni)
{

if (InitCVIRTE (0, 0, 0) == 0) /* Needed if linking in external compiler;
harmless otherwise */
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "CntDown.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
SetCtrlVal (panelHandle, PANEL_NUMERIC, DelaySecs); // Initialize display
counter
RunUserInterface ();
DiscardPanel (panelHandle);
return(CntDownStatus);
}


"Roberto Bozzolo" wrote in message
news:5065000000050000008E1E0000-984882144000@quiq.com...
> This is a very strange behaviour.
> Could you plea
se post a skeleton of your program? I think most things
> will be clearer looking at the actual source code.
> Roberto
0 Kudos
Message 3 of 7
(3,288 Views)
Dear Luis,
I note that in MainTest () you have used both InstallPopup(TPanelHandle); and DisplayPanel (TPanelHandle);
First of all: the use of DisplayPanel after InstallPopup is redundant 'cause the first call already displays the panel on the screen; second: if you call InstallPopup in MainTest you are displaying a modal window, that is a window that stays on top of others panels previously displayed both with DisplayPanel and with InstallPopup. When in CountDown you call DisplayPanel, that panel stays BELOW 'cause the caller is a modal window. If you 'must' use InstallPopup in MainTest, you should use the same call in CountDown: that way the panel will be displayed on top of the caller panel and the control will be transferred to it.
Another
observation. I noted that you have called RunUserInterface in two routines: this can be simply a probem of this skeleton, but in case it is not, be careful to use it only once in your program, otherwise you will have to call QuitUserInterface more than one time to close your program (the number of QuitUserInterface will have to match that of RunUserInterface). I don't know what other problems may arise from calling RunUserInterface more than one time in the program, but I suppose that some will be, since RunUserInterface is the starting point of event processing, timer counting and so on...
I hope you will find here the solution to your problem.
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 7
(3,288 Views)
Roberto:
Hmm. Your answer is very interesting.
I used DisplayPanel (TPanelHandle); right after InstallPopup(TPanelHandle);
mostly as a shot in the dark thinking it may help. It didn't and you
explained why so I will remove it. I had worked my way around this problem
by using

HidePanel (TPanelHandle);
iStatus = CountDown(CntDownSecs);
DisplayPanel (TPanelHandle);

but I think is not the cleanest solution. So, should I use
InstallPopup(TPanelHandle); inside CountDown()? lastly, I use
RunUserInterface in several places, because these routines started as
standalone projects which I joined in one big main project. So, Should I use
only RunUserInterface one in main()?
I've had problems with QuitUserInterface which sometimes kills the wrong
panel.
Should RunUserInterface and RunUserInterface be like balanced
parenthesis? Or should I simply have just one? in the latter case how do I
open a panel B from A?
As usual, one answer opens many more questions.
Thanks for your help
Luis Villa
0 Kudos
Message 5 of 7
(3,288 Views)
Let's start from the last: you should have only one RunUserInterface in your project and therefore only one QuitUserInterface.
It seems that you are using QuitUserInterface as a way of quitting single panels: this is not the best way. You should use DiscardPanel in order to remove one panel from the screen and from memory.
Since in one program you must have only one main () function (and usually RunUserInterface lies in it), I don't understand when you speak of 'standalone projects which I joined in one big main project': how you manage multiple main functions that way?

It seems to me that you are dealing with the 'reusable code' problem: in my opinion this would be better solutioned by creating instrument panels out of elem
entary functions and adding them to your projects when needed. At the cost of some time spent in structuring your functions as standalone routines (but it seems that they are already quite near to this) and of designing the interchange of data between them, you will have more flexibility and you will avoid all the problems you are in now.

With regard to the first problem, if you really need to InstallPopup the panel in the caller function, then you NEED to use InstallPopup in the called function in order to display the panel on top of the caller.

I hope all this can help you
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 7
(3,288 Views)
Let's start from the last: you should have only one RunUserInterface in your project and therefore only one QuitUserInterface.
It seems that you are using QuitUserInterface as a way of quitting single panels: this is not the best way. You should use DiscardPanel in order to remove one panel from the screen and from memory.
Since in one program you must have only one main () function (and usually RunUserInterface lies in it), I don't understand when you speak of 'standalone projects which I joined in one big main project': how you manage multiple main functions that way?

It seems to me that you are dealing with the 'reusable code' problem: in my opinion this would be better solutioned by creating instrument panels out of elem
entary functions and adding them to your projects when needed. At the cost of some time spent in structuring your functions as standalone routines (but it seems that they are already quite near to this) and of designing the interchange of data between them, you will have more flexibility and you will avoid all the problems you are in now.

With regard to the first problem, if you really need to InstallPopup the panel in the caller function, then you NEED to use InstallPopup in the called function in order to display the panel on top of the caller and to process events from this panel.

I hope all this can help you
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 7
(3,288 Views)