I am running to a strange build error when creating my own class derived from wxTextCtrl when building with MSVC. I am using VS 2019 (latest) and have compiled wxWidgets 3.1.4 from source using CMake.
Code: Select all
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:/External
$ cmake --build .. --target install
Code: Select all
#include <wx/wx.h>
#include <wx/textctrl.h>
#include <wx/valnum.h>
#include <wx/sizer.h>
class MyTextCtrl : public wxTextCtrl {
public:
explicit MyTextCtrl(wxWindow* parent, int id, int value)
: wxTextCtrl()
{
wxIntegerValidator<int> val(nullptr);
auto str = wxString::Format(wxT("%i"), id);
this->Create(parent, id, str, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER, val);
}
virtual ~MyTextCtrl()
{
}
int GetInt() const
{
long value = 0;
this->GetValue().ToLong(&value);
return value;
}
};
class MyFrame : public wxFrame {
public:
MyFrame()
: wxFrame(nullptr, wxID_ANY, wxEmptyString, wxDefaultPosition)
{
auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(new MyTextCtrl(this, wxID_ANY, 50));
}
virtual ~MyFrame()
{
}
};
Code: Select all
textentry.h(101, 39): error 2601: syntax identifier 'wxKeyEvent'
textctrl.h(292,18): error C3668: 'wxTextCtrl::MSWProcessSpecialkey': method with override specifier 'override' did not override any base class methods
combobox.h(168,18): error C3668: 'wxComboBox::MSWProcessSpecialKey': method with override specifier 'override' did not override any base class methods
Code: Select all
if(MSVC)
set(wxWidgets_ROOT_DIR "C:/External/wxWidgets-3.1.4")
find_package(wxWidgets REQUIRED COMPONENTS gl core base)
include(${wxWidgets_USE_FILE})
add_compile_definitions(${wxWidgets_DEFINITIONS})
include_directories(${wxWidgets_INCLUDE_DIRS})
add_executable(MyExe
WIN32
main.cpp
)
target_link_libraries(MyExe
${wxWidgets_LIBRARIES}
)
endif()