Custom events - sent from one class and recieved in another

Andrzej Duś Jr gogoad at dakom.wielun.pl
Sun Sep 10 13:47:08 PDT 2006


Hi,

I'm trying to sent an event from function in class X and process it in 
event table in class Y. Situation is even more complicated because 
classes are splitted into different files (x.h, x.cpp, y.h, y.cpp). The 
problem occurs when I want to compile my code under Code::Blocks v1.0 
RC2 (with mingw32 bundled). To being precise, there is a linking 
problem: x.o:x.cpp:(.text+0x565a): undefined reference to 
`_imp__EVT_GOT_EXT_APP_INPUT'


Here is simplified files content (I've also ommited function defintions, 
application entry points etc):

----- FILE x.h ----
DECLARE_EVENT_TYPE(EVT_GOT_EXT_APP_INPUT, -1)

----- FILE x.cpp ----
#include "x.h"

class X {
     void SendEvent(wxString msg)
     {
         wxCommandEvent event(EVT_GOT_EXT_APP_INPUT , GetId() );
         event.SetEventObject( this );
         event.SetString( msg );
         GetEventHandler()->ProcessEvent( event );
     }
};

----- FILE y.h ----
class Y {
     void TextLogWindowChange( wxCommandEvent &event );

     DECLARE_EVENT_TABLE();
};

----- FILE y.cpp ----
#include "y.h"
#include "x.h"

DEFINE_EVENT_TYPE(EVT_GOT_EXT_APP_INPUT)

BEGIN_EVENT_TABLE(Y, wxFrame)
     EVT_COMMAND(WID_Main, EVT_GOT_EXT_APP_INPUT, Y::TextLogWindowChange)
END_EVENT_TABLE()


Anyone could help me with this problem or give an example of similar 
code which works under mingw32 compiler?

Thanks for any response

--
Andrzej Duś
http://gogoad.dakom.wielun.pl






More information about the wx-users mailing list