01-09-2015 04:07 PM
I use a button on one tab to change the content of textboxes with one on another different tab.
int CVICALLBACK cbfGetIP (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_CLICK:
ResetTextBox (panel, tabPanel1_Textbox_1, "AAA"); //current panel, works
ResetTextBox (panel, tabPanel2_Textbox_2, "BBB"); //other panel, not work
break;
}
return 0;
}
The second line where the textbox on the other tab is does not work. the ID of the panel is not good. I use debugging to obtain the integer that make it work. Problem: that number does not correspond to anything resembling that is the tab number. Of course, I do not want to be amateur using integer this way. Can someone explain this to me? Thanks.
01-10-2015 01:15 AM - edited 01-10-2015 01:18 AM
This argument is very common and ihas been discussed several times in the forum.
To make the long story short, each tab page is an independent panel with its own handle, which you must use to correctly address controls on a tab page.
GetPanelhandleFromTabPage function can be used to retrieve tab pages handles.
While inside a control callback, 'panel' variable holds the panel handle of the owning panel, which is different from the panel handles of the other tabs. Your code could be modified as follows (assuming mainPanelHandle is the handle of the panel the tab control is in and assuming tabPanel2 is the second page in the tab control):
ResetTextBox (panel, tabPanel1_Textbox_1, "AAA");
GetPanelHandleFromTabPage (mainPanelHandle, PANEL_TAB, 1, &handle);
ResetTextBox (handle, tabPanel2_Textbox_2, "BBB");
01-12-2015 08:31 AM
Well, it works with a little tweak:
GetPanelHandleFromTabPage (mainPanelHandle, PANEL_TAB, 0, &handle);
The numbering starts at 0.