Deriving a class from wxHyperlinkCtrl

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
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Deriving a class from wxHyperlinkCtrl

Post by spflanze »

I attempted to derive a class from wxHyperlinkCtrl . The below code snippet from my attempt:

Code: Select all

class WXDLLIMPEXP_ADV wxHyperlinkCtrlDataFile : wxHyperlinkCtrl
{
	public:
		wxHyperlinkCtrlDataFile() : wxHyperlinkCtrl(){}

		wxHyperlinkCtrlDataFile( wxWindow *parent,
                        wxWindowID id,
                        const wxString& label,
                        const wxString& url,
                        const wxPoint& pos = wxDefaultPosition,
                        const wxSize& size = wxDefaultSize,
                        long style = wxHL_DEFAULT_STYLE,
                        const wxString& name = wxHyperlinkCtrlNameStr)
					: wxHyperlinkCtrl( parent, id, label, url, pos, size, style, name ){}
That snippet gets these errors:
||=== Build: Debug in TIA Designer (compiler: GNU GCC Compiler) ===|
C:\wxWidgets-3.0.3\include\wx\window.h||In constructor 'TIA_DesignerFrame::TIA_DesignerFrame(wxWindow*, wxWindowID)':|
C:\wxWidgets-3.0.3\include\wx\window.h|1077|error: 'virtual bool wxWindowBase::SetBackgroundColour(const wxColour&)' is inaccessible|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|292|error: within this context|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|292|error: 'wxWindowBase' is not an accessible base of 'wxHyperlinkCtrlDataFile'|
C:\wxWidgets-3.0.3\include\wx\window.h|1320|error: 'void wxWindowBase::SetToolTip(const wxString&)' is inaccessible|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|293|error: within this context|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|293|error: 'wxWindowBase' is not an accessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|294|error: 'wxWindow' is an inaccessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|532|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:\wxWidgets-3.0.3\include\wx\event.h|3482|error: 'void wxEvtHandler::Connect(int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)' is inaccessible|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|540|error: within this context|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|540|error: 'wxEvtHandler' is not an accessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|547|error: 'wxHyperlinkCtrl' is an inaccessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp||In member function 'void TIA_DesignerFrame::OnQ1HyperlinkCtrlHTMLClick1(wxCommandEvent&)':|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|1519|error: 'wxHyperlinkCtrl' is an inaccessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp||In member function 'void TIA_DesignerFrame::OnQ1HyperlinkCtrlHTMLMidDown(wxMouseEvent&)':|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|1537|error: 'wxHyperlinkCtrl' is an inaccessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp||In member function 'void TIA_DesignerFrame::OnQ1ButtonAddClick(wxCommandEvent&)':|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|1556|error: 'wxHyperlinkCtrl' is an inaccessible base of 'wxHyperlinkCtrlDataFile'|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp||In member function 'void wxComboBoxDataFileQ::UpdateDisplay()':|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|1594|error: 'TheFrame' was not declared in this scope|
C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp|1570|warning: unused variable 'sel' [-Wunused-variable]|
||=== Build failed: 15 error(s), 2 warning(s) (0 minute(s), 1 second(s)) ===|
These errors are from the second constructor. What has gone wrong here? How can this class be derived from?
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 469
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Deriving a class from wxHyperlinkCtrl

Post by New Pagodi »

You forgot the 'public' keyword in the declaration for your derived class:

Code: Select all

class WXDLLIMPEXP_ADV wxHyperlinkCtrlDataFile : public wxHyperlinkCtrl
Without that, everything in the base class is private by default.

Also, do you really want to use the 'WXDLLIMPEXP_ADV' part? Those import/export declarations are really only needed when building/using a class from a library. If the class is from code in your own project, you shouldn't need them.
Post Reply