1

I'm trying to implement a custom event in my wxWidgets application but I can't write the event table macros in a proper way.

the files that I use to implement the event is like the following:


the .h file

#ifndef __APP_FRAME_H__
#define __APP_FRAME_H__


#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/evtloop.h>
#include "wxApp.h"
#include "sampleCefApp.h"


class appFrame: public wxFrame
{
public:
    appFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
private:
    int OnExit();
    void OnCefStartEvent(wxCommandEvent &e);
    DECLARE_EVENT_TABLE()
};

#endif

the .cpp file

// File : appFrame.cpp

#include "appFrame.h"


wxDEFINE_EVENT(CEF_START_EVT, wxCommandEvent)

void appFrame::OnCefStartEvent(wxCommandEvent &e)
{    
    CefRunMessageLoop();
}

int appFrame::OnExit(){
    CefShutdown();
    Destroy();
    return 0;
}

appFrame::appFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
    : wxFrame(NULL, wxID_ANY, title, pos, size)
{

}

wxBEGIN_EVENT_TABLE(appFrame, wxFrame)
    EVT_COMMAND(wxID_ANY, CEF_START_EVT, appFrame::OnCefStartEvent)
wxEND_EVENT_TABLE()

And when I build my make file I get the following errors:

../src/appFrame.cpp:4:15: error: expected constructor, destructor, or type conversion before ‘(’ token
../src/appFrame.cpp:24:2: error: expected constructor, destructor, or type conversion before ‘wxEventTableEntry

I think the problem is related to mis-placing event table macros.

I want to know what is the problem exactly and how to fix it ?

Sameh K. Mohamed
  • 2,323
  • 4
  • 29
  • 55

1 Answers1

0

You need a semicolon after wxDEFINE_EVENT() macro (as for almost all macros with wx prefix, they consistently require a semicolon, unlike the legacy macros without the prefix).

As usual, see the sample for the example of use of this macro.

VZ.
  • 21,740
  • 3
  • 39
  • 42