02-08-2011 01:36 AM
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
02-08-2011 02:06 AM
The usual problem with tab pages is that one tends to forget to include a call to GetPanelHandleFromTabPage...
02-08-2011 02:21 AM - edited 02-08-2011 02:23 AM
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.
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);
}
02-08-2011 02:31 AM
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