Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 0.85 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Access child in customized wxPanel
  2. class MyPanel : public wxPanel
  3.  {
  4.        public:
  5.           MyPanel(wxWindow* parent) : wxPanel(parent){}
  6.           void OnMouseMove(wxMouseEvent& event);
  7.        private:
  8.           DECLAER_EVENT_TABLE()
  9.   };
  10.        
  11. class mainFrame : public wxFrame
  12.  {
  13.        ...
  14.        private:
  15.           ...
  16.           MyPanel* myPanel;
  17.           ...
  18.           wxStaticText* StaticText1;
  19.           ...
  20.  };
  21.        
  22. class mainFrame : public wxFrame
  23. {
  24.   friend class MyPanel;
  25.   ...
  26. };
  27.        
  28. class MyPanel : public wxPanel
  29.   {
  30.         public:
  31.            MyPanel(wxWindow* parent) : wxPanel(parent){}
  32.            void OnMouseMove(wxMouseEvent& event) { if (StaticText1) { /* do something */ } ;
  33.            void SetStaticText1(wxStaticText* txt) { StaticText1 = txt;}
  34.         private:
  35.            DECLAER_EVENT_TABLE()
  36.            wxStaticText* StaticText1;
  37.  
  38.    };