LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Get "Library function error (return value == -162)" message.

Hello,

 

My application need a child window. In the child window, I have placed a tab control, and on the tab page , there is a command button. When just pressing the quit button which is in the parent window, the application can quit normally, but once click the "ok" button in the tab page, then click the "Quit" button, it will report an error: "NON-FATAL RUN-TIME ERROR:   "Test.c", line 42, col 5, thread id 0x00001C0C:   Library function error (return value == -162 [0xffffff5e]). Operation cannot be performed on a tab panel". Please advise how to resolve the problem. I have attached the code.

 

David

0 Kudos
Message 1 of 4
(3,268 Views)

The usual problem with tab pages is that one tends to forget to include a call to GetPanelHandleFromTabPage...

0 Kudos
Message 2 of 4
(3,262 Views)

David,

I do not know why you are using that rather complicated way of having a child panel, but the problem in your code lies in the order the events are handled in your application.

You are iterating in a loop with GetUserEvent, which retrieves both user-defined events (which I suppose is your intendment) AND commit events. Now, all of your buttons are in hot mode, so they will fire a commit event every time you click them.

Next, you are trapping a left click event and not a commit to send the exit message to the main.

Additionally, you are rewriting the value of 'prPanel' inside the loop, and you are using it next in the button callback. Smiley Sad

The sum of all this is that when you are finally discarding the panel, you are using the handle of the tab page, which is not what you want (and evidently cannot be discarded with standard commands!).

 

Try modifying your code as follows:

 

In the main:

    int pnl;

    ...

    do {
        msg = GetUserEvent(1, &pnl, NULL);
    } while (pnl != prPanel && msg != 10000);

 

In the button callback:

    if (event == EVENT_COMMIT) {
        QueueUserEvent (10000, panelHandle, 0);
    }



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 4
(3,259 Views)

Hi Wolfgang,

 

If using the "RunUserInterface()" instead of using the the "GetUserEvent()" in the  "do...while()" loop, it will not happen such the error.

 

 

 

David

0 Kudos
Message 4 of 4
(3,256 Views)