WxWidgets App with multiples windows

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
In need of some credit
In need of some credit
Posts: 3
Joined: Wed May 15, 2019 12:02 pm

WxWidgets App with multiples windows

Post by steph291 » Wed May 15, 2019 1:48 pm

Hi everyone,
I'm new to C++ and RAD tools (wxSmith within CodeBlocks)

So far it's working and fun BUT today is scratchingHead day...

I have a main window that call another window.

On event (a double click)
do your stuff and catch another event in the main window
which is OnTreeCtrl1ItemActivated(wxTreeEvent& event)
a treectrl widget...

But when the second window occur, I cannot access
variables from the first part (wxString test1 or test2)

The reason is not public?, Global?

code following :

Code: Select all

void test12052019Frame::OnButton1Click(wxCommandEvent& event)
    wxString test1 = "";
    wxString test2 = "";

    test1 = TextCtrl1->GetValue();
    test2 = TextCtrl2->GetValue();

    // compare/parse userid/password
    // Access ERP system and get credential schema
    // build the treeview

    if(test1 == "titou" && test2 == "123123"){
    // todo auth. against Mysql
        wxMessageBox("You're in !!\n");
        wxMessageBox("You're out !!\nWrong userid/password");

void test12052019Frame::OnTreeCtrl1ItemActivated(wxTreeEvent& event)
    //TreeCtrl1 is my tree
    //when I click on any option of my tree
    //it activates a wxMessageBox with the label
    //of the option selected...
    //just let go your imagination :)

    NewFrameActivities *mynewwindow = new NewFrameActivities(this);

    wxString thelabel;
    wxTreeItemId test3;

    test3 = TreeCtrl1->GetSelection();
    thelabel = TreeCtrl1->GetItemText(test3);



//    mynewwindow->StaticBox1->SetLabel(); // I would like to SetLabel to variable in the
//    first module/event like : test1, the name of the user



wtach the video on youtube and you'll get the picture :)

thanks and regards

Posts: 1589
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: WxWidgets App with multiples windows

Post by catalin » Wed May 15, 2019 2:07 pm

Is the value held in test3 valid? You should always get a valid tree item id using event.GetItem().

User avatar
Posts: 15068
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WxWidgets App with multiples windows

Post by doublemax » Wed May 15, 2019 4:10 pm

test1 and test2 are local variables in the method "OnButton1Click", you can't access them from anywhere else. You could turn them into member variables of "test12052019Frame", but i would just use TextCtrl1->GetValue() again.
Use the source, Luke!

Post Reply