LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetCtrlVal Problem

Solved!
Go to solution

Hello,

 

I have a problem with GetCtrlVal. Wenn I start my application and Quit it I get this error message: NON-FATAL RUN-TIME ERROR:   "Test.c", line 206, col 5, thread id 0x00001A4C:   Function GetCtrlVal: (return value == -13 [0xfffffff3]). Invalid control ID
I have checked the control ID and there should be no problems with it. I have this problem also when I run my application write some values in there and after the applications finished and I would like to quit the application with the standard quit button.
double Amplitude=0, DutyCycle=0;
int Mode=0, Samples=0, SampleRate=0;
    

    GetCtrlVal (panel, Panel_TREE, &Mode);
    GetCtrlVal (panel, Panel_Amplitude, &Amplitude);
    GetCtrlVal (panel, Panel_SampleRate, &SampleRate);
    GetCtrlVal (panel, Panel_Samples, &Samples);
    GetCtrlVal (panel, Panel_DutyCycle, &DutyCycle);
 
    switch (event)
    {
        case EVENT_COMMIT:
            switch(Mode)

........

 

Best Ragards

0 Kudos
Message 1 of 9
(5,957 Views)

I think the problem could be in the "panel" variable (firs parameter of GetCtrlVal function).

You should dobule check that "panel" refers to "Panel" where the controls Panel_TREE, Panel_Amplitude, ... exist

 

The variable panel is assigned with LoadPanel function

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 2 of 9
(5,951 Views)

This kind of error can also arise if the control you are accessing is on a tab page (i.e a page of a tab control): in this case in  'panel' parameter you must pass the handle of the tab page itself and not the handle of the panel the tab control is in. Handles for the pages of a tab control can be retrieved with GetPanelHandleFromTabPage instruction.



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 3 of 9
(5,947 Views)

I controlled my Panel Handle variable but the failure occured again.

 

For the variable I used a simple numeric field.

0 Kudos
Message 4 of 9
(5,943 Views)

Are you using tab controls? Is your control on a tab page?

Can you post your app here? I do not mean the entire application but a stripped down version the only handles the user interface and shows the misbehaviour you are seeing.



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 5 of 9
(5,935 Views)

I do not use a tab control.

 

In the following you can see the interface and the panel tree.

Now I have also the problem, that every new made GetCtrlVal has the problem with the failure message above.

 

 

 

 

Download All
0 Kudos
Message 6 of 9
(5,925 Views)
Solution
Accepted by topic author Fasching_K

Have you tried moving all GetCtrlVal inside the EVENT_COMMIT clause?

You say you have the problem at program end: in this case, the event is probably EVENT_DISCARD, which is sent to all controls and panels in the application; at some moment you may be accessing a control which has been already removed from memory. Those GetCtrlVal statements are executed for *ALL* events received from the control, even on every single mouse movement: this is an unnnecessary use of resources that can put you in unwanted situations.



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 9
(5,909 Views)

If the panel name is "AWG" and the control name is "TREE", the control ID is "AWG_TREE" not "Panel_TREE" as you wrote in your first message.

 

This is a really basic concept in LabWindows/CVI.

I suggest you to spend some time with some tutorials and how-to, before starting to write your own application.

This would save you a lot of time in the future, during the development.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 8 of 9
(5,908 Views)

Thank you RobertoBozzolo, that was the solution. 

 

Best Regards                                                                                     

0 Kudos
Message 9 of 9
(5,890 Views)