Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / what's wrong with this program

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. what's wrong with this program
#3367
Posted by: 2004-02-14 10:35:25
I wanted to create frame with window and textctrl, when user clicked on the window or the textctrl the messagebox had to appear. So I did this like that.
First I put definition of the class myevt in the header file:

class myevt : public wxEvtHandler
{
  public:
            void Mouse(wxMouseEvent&);  // that is the function with message
  private:
    DECLARE_EVENT_TABLE();
};
Then In my cpp file I wrote an implementation of this class

BEGIN_EVENT_TABLE(myevt, wxEvtHandler)
    EVT_LEFT_DOWN(myevt::Mouse)
END_EVENT_TABLE()

void myevt::Mouse(wxMouseEvent& event)
{
  wxMessageBox("dsfs", "sdfs", wxOK);
}
In the constructor of the frame I created one window and textctrl and of course evt. Everything looked like below:

evt = new myevt();
w3 = new wxWindow(this, -1, wxPoint(220, 120), wxSize(100, 100),        
                                   wxSIMPLE_BORDER);
w3->PushEventHandler(evt);

t1 = new wxTextCtrl(this, -1, "cbcbxcbxcvbxcvbbxcb", wxPoint(20, 100),
                                 wxSize(100, 100), wxTE_MULTILINE | 
                                 wxNO_FULL_REPAINT_ON_RESIZE);
t1->PushEventHandler(evt);
And when I compiled this program the window was transparent, but not on the whole area. And I have no idea why, does anybody know. I use winxp, maybe on other systems this program works correctly ?
Message2. Re: what's wrong with this program
#3368
Posted by: upCASE 2004-02-14 19:22:56
Hi!
Not sure what causes this problem, but try it like this:

w3 = new wxWindow(this, -1, wxPoint(220, 120), wxSize(100, 100),        
                                   wxSIMPLE_BORDER);
w3->PushEventHandler(new myevt());

t1 = new wxTextCtrl(this, -1, "cbcbxcbxcvbxcvbbxcb", wxPoint(20, 100),
                                 wxSize(100, 100), wxTE_MULTILINE | 
                                 wxNO_FULL_REPAINT_ON_RESIZE);
t1->PushEventHandler(new myevt());

Works for me showing the window with a standard grey background.

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: what's wrong with this program
#3371
Posted by: 2004-02-14 23:43:05
Thanks, It works.
Message4. Re: what's wrong with this program
#3372
Posted by: 2004-02-15 00:02:58
The most frustrating is that everything works fine until You add a wxTextCtrl object to the program and push event handler like this
PushEventHandler(evt)

You can add buttons, windows and the program works, but not with the textctrl.
rem
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-3-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0