wxtextctrl clear, stuck on how to structure

This is a discussion on wxtextctrl clear, stuck on how to structure within the C++ Programming forums, part of the General Programming Boards category; Hi there, I've made a program for myself that takes wxtextctrl fields, arranges them and prints them out using a ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    wxtextctrl clear, stuck on how to structure

    Hi there, I've made a program for myself that takes wxtextctrl fields, arranges them and prints them out using a dot matrix printer, however I need to create a button that on click clears the fields, and I can't figure out how to structure the command. I'm fairly sure I need to use wxtextctrl::clear but can't for the life of me remember how to structure it.

    Code:
    void FormFrame::OnClearButtonClick(wxCommandEvent& event)
    {
        [need to clear a field called varname (ID_VARNAME)]
    }
    Thank you for your help in advance.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    If you mean that you don't already have a pointer to the textctrl in question, you should be able to ask the parent of FormFrame (wxWindow) to find it for you using FindWindow or one of the functions below.

    Since you want functionality not all wxWidows have, you'll have to downcast the result into a pointer to wxTextCtrl (using dynamic_cast or static_cast, if you are sure/bold).

    Code:
    wxWindow* text_field = this->FindWindow(ID_VARNAME);
    if (text_field && dynamic_cast<wxTextCtrl*>(text_field) {
        static_cast<wxTextCtrl*>(text_field)->Clear();
    }
    (E.g using dynamic_cast to check if the found window is actually a text control, and then a static_cast because I am already sure it is.)
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    27
    hmm, thanks for helping me with this, a lot more complicated than I thought it should be. I had to add another bracket to the second line to make it accept it, but now I'm getting the following:

    obj\Release\FormMain.o:Confidence_Order_FormMain.c pp:(.text+0x41d4)||undefined reference to `FormFrame::OnvarchargeText1(wxCommandEvent&)'|
    obj\Release\FormMain.o:Confidence_Order_FormMain.c pp:(.text+0x9f74)||undefined reference to `FormFrame::OnvarchargeText1(wxCommandEvent&)'|
    ||=== Build finished: 2 errors, 0 warnings ===|

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    This means that you have only declared that function but not implemented it (or aren't linking it).
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem referencing structure elements by pointer
    By trillianjedi in forum C Programming
    Replies: 19
    Last Post: 06-13-2008, 05:46 PM
  2. Reference to a Structure
    By boschow in forum C Programming
    Replies: 3
    Last Post: 03-28-2008, 02:37 PM
  3. Passing Structure Pointers to Functions
    By samus250 in forum C Programming
    Replies: 15
    Last Post: 03-20-2008, 03:13 PM
  4. Global Structure
    By computerfreaks in forum C Programming
    Replies: 8
    Last Post: 02-18-2005, 12:59 PM
  5. Replies: 1
    Last Post: 02-03-2005, 02:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21