LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronize controls cvi

Hello

I have two panels, that both are sometimes, not necessarily the same time, used. Both of them need one numerical control, representing the same number. I would like to synchronize both controls, so that when one is changed, the other will be as well. How do I do this best?
  • dupplicateCTRL() is not keeping both controls synchronized
  • Create a third panel with just this control inside: Probably the simplest option, but not the nicest.
  • Any other simple cloning with sync possibility?
Thanks, Matthias
0 Kudos
Message 1 of 4
(3,439 Views)

Each numeric gets its own callback function.

 

Panel1_cb

{

...

case EVENT_VAL_CHANGED:

GetCtrlVal(panel1Handle, &clonedNumVal)

SetCtrlVal(panel2Handle, clonedNumVal)

break;

}

 

Panel2_cb

{

...

case EVENT_VAL_CHANGED:

GetCtrlVal(panel2Handle, &clonedNumVal)

SetCtrlVal(panel1Handle, clonedNumVal)

break;

}

 

alternately, you can use one callbackl and check "who" called it and set them that way.

NOTE:  extreme shorthand notation was used in writing the above.  You will need to add more detail.

Message Edited by scomack on 06-07-2007 02:08 PM

0 Kudos
Message 2 of 4
(3,438 Views)
> Each numeric gets its own callback function.

Or a little more simple, same callback for both:

int CVICALLBACK cb_Both(int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int V;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(panel, control, &V); // Uses the function
parameters
SetCtrlVal(Pnl1, PNL_CTRLNAME, V); // uses globals and UIR consts
SetCtrlVal(Pnl2, PNL_CTRLNAME, V);
....

--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 3 of 4
(3,403 Views)
Thanks to both,

That would work, I'd have to add a check if the other panel is already open and also do sync at load of any panel. That would also work, but I was hoping there would be a simpler way. But apparently not.
0 Kudos
Message 4 of 4
(3,386 Views)