LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid control ID

Solved!
Go to solution

in my project, i have two uirs: main.uir, list.uir

when i click the menu "list" of main.uir, it will load list.uir.

in list.uir, i place an Command control, its callback function is test()

in fucntion test(),i have three lines codes below:

----------------------------------------------

GetCtrlAttribute(panel,PANELLIST_RINGSLIDE,ATTR_VISIBLE,&tempVar); //Retrieve
 if(tempVar)
SetCtrlAttribute(panel,PANELLIST_RINGSLIDE,ATTR_VISIBLE,0); //Hide

-------------------------------------------------

the RINGSLIDE control is in list.uir,and the headfile list.h also have the PANELLIST_RINGSLIDE define :

#define PANELLIST_RINGSLIDE 12 /* control type: slide, callback function: (none) */

....

But,

in Debug mode, when i close the panel of list.uir, the error appearence:

NON-FATAL RUN-TIME ERROR: "mainPanel.c", line 2229, col 5, thread id 0x00001774: Library function error (return value == -13 [0xfffffff3]). Invalid control ID

the error line is:

GetCtrlAttribute(panel,PANELLIST_RINGSLIDE,ATTR_VISIBLE,&tempVar); //Retrieve

And,

in Release mode, everthing is ok.

Bug?

 

 

 

0 Kudos
Message 1 of 8
(3,839 Views)
Solution
Accepted by topic author winter1970

Looks like you are not limiting the callback at the EVENT_COMMIT event: can you post the complete control callback code?

Since it is a non fatal error the executable does not report it.



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 8
(3,777 Views)

to 

0 Kudos
Message 3 of 8
(3,767 Views)

Returning 1 from a control callback means to swallow the event, i.e. prevent it to be passed along to other processing routines. It should be used cautiously, I remember to have used it only a few times in several years.

It probably isn't the solution to your problems but it possibly masks it under some circumstances.

Can you post the complete callback code? I'd like to understand if and how this can be an acceptable fix or not.



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 8
(3,760 Views)

 


@RobertoBozzolo  已写:

Returning 1 from a control callback means to swallow the event, i.e. prevent it to be passed along to other processing routines. It should be used cautiously, I remember to have used it only a few times in several years.

It probably isn't the solution to your problems but it possibly masks it under some circumstances.

Can you post the complete callback code? I'd like to understand if and how this can be an acceptable fix or not.


i dont know how to send the project to you,so i post some screenshot here.

 

Download All
0 Kudos
Message 5 of 8
(3,738 Views)

I was not intending to have the complete project, but simply to copy/paste the callback code here.

I cannot understand from the screenshots what is happening, but you are probably getting some error on EVENT_CLOSE event so that he code jumps to Error: and then Error_free: labels trying to address a control that has already been discarded: you should debug this condition to clear the code in order to prevent such a condition.

 

As a side note, I see that you are calling RunUserInterface () when showing the popup panel: this is not necessary and should be avoided since one RunUserInterface () is enough at code start to handle all the panels you may load and display during program life.



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 8
(3,713 Views)

@RobertoBozzolo  已写:

I was not intending to have the complete project, but simply to copy/paste the callback code here.

I cannot understand from the screenshots what is happening, but you are probably getting some error on EVENT_CLOSE event so that he code jumps to Error: and then Error_free: labels trying to address a control that has already been discarded: you should debug this condition to clear the code in order to prevent such a condition.

 

As a side note, I see that you are calling RunUserInterface () when showing the popup panel: this is not necessary and should be avoided since one RunUserInterface () is enough at code start to handle all the panels you may load and display during program life.


i remove the "RunUserInterface ()" ,but found the panel appear,and immediately disappear。so cannot remove "RunUserInterface ()".

 

-------------------------------------------------

and ,i add  the statements :

"default: return 0; " in switch case,and found the error disappear,it is ok now.

But,i don't know why it is so.

0 Kudos
Message 7 of 8
(3,707 Views)

@winter1970  ha scritto:

...cannot remove "RunUserInterface ()".

That's because you have a RemovePopup immediately after RunUserInterface ()!

You should:

- Remove RunUserInterface, RemovePopup and DiscardPanel from MergeExcel () function

- Add DiscardPanel instead of QuitUserInterface in QuitMergePanel

The underlying principle is that you can show a panel as a popup, let the unique RunUserInterface called at program start handle panel events and have on the panel a control that discards it.



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 8 of 8
(3,690 Views)