DEFINE_EVENT_TYPE obsolete?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

DEFINE_EVENT_TYPE obsolete?

Post by MoonKid »

I am using wx from SVN. In event.h I can read that DEFINE_EVENT_TYPE is obsolete.

What can I use alternatively?
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

As mentioned in the event overview in 2.9 you may/should use the wxDEFINE_EVENT() macro, which gives Bind() its type-safety.

Regards,

David
Last edited by DavidHart on Sun Oct 10, 2010 3:20 pm, edited 1 time in total.
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid »

I see but didn't understand the difference. ;)

This is how I fire the event.

Code: Select all

BFMainFrame::Instance()->GetEventHandler()->AddPendingEvent(wxCommandEvent(BF_EVENT_THREAD_END, BF_ID_MAINFRAME));
I tried

Code: Select all

wxDEFINE_EVENT(BF_EVENT_THREAD_END, wxCommandEvent);
But of course it cause in this error message

Code: Select all

1>d:\garage\projekte\blackfisk\trunk\src\bfthread_backuprunner.cpp(32) : error C2371: 'BF_EVENT_THREAD_END': Neudefinition; unterschiedliche Basistypen
because wxCommandEvent is still declared.

How can I solve that? I think I missinterpret the design rule behind it.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

I don't speak german so I'm not sure what the error message means. I think it could be that you left an old DECLARE_EVENT_TYPE macro around or so
"Keyboard not detected. Press F1 to continue"
-- Windows
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid »

It says

Code: Select all

new definition; different basic types
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Auria wrote:I think it could be that you left an old DECLARE_EVENT_TYPE macro around or so
I still think this ;)
"Keyboard not detected. Press F1 to continue"
-- Windows
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid »

I think it could be that you left an old DECLARE_EVENT_TYPE macro around or so
What do you mean exactly?

I can see nothing wrong on my code described below.
jfouche
Super wx Problem Solver
Super wx Problem Solver
Posts: 442
Joined: Tue May 06, 2008 4:52 pm
Location: France

Post by jfouche »

You probably left a DECLARE_EVENT_TYPE in a header file.

If you declare your event a way, and define it another way, you'll have this message. So if you need your event to be visible out of the scope of your cpp file, you'll have to define it in the header, using the 2.9 way (eg : wxDECLARE_EVENT instead of DECLARE_EVENT_TYPE) :

Code: Select all

// this is typically in a header: it just declares MY_EVENT event type
wxDECLARE_EVENT(MY_EVENT, wxCommandEvent);

// this is a definition so can't be in a header
wxDEFINE_EVENT(MY_EVENT, wxCommandEvent);
Jérémie
rogue
In need of some credit
In need of some credit
Posts: 6
Joined: Sun May 24, 2009 5:36 am

This was not mentioned in "Changes since 2.8"

Post by rogue »

This change was not mentioned on the page

http://docs.wxwidgets.org/2.9.1/overvie ... nce28.html

I have an existence proof that this change breaks the build potentially in eleven of my projects.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: This was not mentioned in "Changes since 2.8"

Post by Auria »

rogue wrote:This change was not mentioned on the page

http://docs.wxwidgets.org/2.9.1/overvie ... nce28.html

I have an existence proof that this change breaks the build potentially in eleven of my projects.
this link is not a full list of changes, it is only an overview of new features. For the full list, see http://svn.wxwidgets.org/viewvc/wx/wxWi ... iew=markup
"Keyboard not detected. Press F1 to continue"
-- Windows
dlchnr
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Tue Jan 27, 2009 6:45 pm
Location: Germany
Contact:

Post by dlchnr »

Auria wrote:I don't speak german ...

Neudefinition; unterschiedliche Basistypen == redefinition; different base types
Post Reply