LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Function Callback - panel ID

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.

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

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");

 



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?
Message 2 of 3
(4,219 Views)

Well, it works with a little tweak:

 

GetPanelHandleFromTabPage (mainPanelHandle, PANEL_TAB, 0, &handle);

 

The numbering starts at 0.

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