Creating Custom Control Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
wxND
In need of some credit
In need of some credit
Posts: 8
Joined: Mon Feb 23, 2009 11:48 am

Creating Custom Control

Post by wxND » Fri Apr 03, 2009 9:51 am

Hello dear forum,

I try to create my own control (graph). Therefore derive my class from wxControl according to the 'Custom Control' section in the SVN Ref manual.

I get the following error messages:
obj\release\LogViewMain.o:LogViewMain.cpp:(.text+0xf1c)||undefined reference to `simpleGraph::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&)'|

obj\release\LogViewMain.o:LogViewMain.cpp:(.text+0x283c)||undefined reference to `simpleGraph::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&)'|
||=== Build finished: 2 errors ===|


I guess this problem is related to the two-step-creation of a wxWindow, but have no clue since I'm a wxWidgets and C++ newbie.

Thank you for any help.

System: Code::Blocks, MinGW, WindowsXP
Last edited by wxND on Mon Apr 06, 2009 2:13 pm, edited 1 time in total.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Fri Apr 03, 2009 1:49 pm

Hi,

if your component is to behave panel-like, I would first and foremost recommend deriving from wxPanel and not wxComponent, this will save you work from implementing some basic features, and you can then concentrate only on the drawing aspects.

The errors you get probably come from declaring methods (the ones mentionned in the message) but never actually defining them.

Code: Select all

// header
class Foo
{
public:
  void foo();
  void bar();
  void foobar();
};


// code file
void Foo::foo()
{
  // do something
}
void Foo::bar()
{
  // do something
}
void Foo::foobar()
{
  // do something
}

wxND
In need of some credit
In need of some credit
Posts: 8
Joined: Mon Feb 23, 2009 11:48 am

Post by wxND » Fri Apr 03, 2009 7:31 pm

Thanks a lot :)
wxND
Last edited by wxND on Mon Apr 06, 2009 2:12 pm, edited 1 time in total.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sat Apr 04, 2009 12:13 am

wxND wrote: Wouldn't the compiler generate a compiler error when a declared member was not defined (or in the case of a methode/function: implemented) ? I would assume so.
No, because the declaration and definition can be in different files; even in different librairies -- and the compiler doesn't get to see all of them, only the linker does.
It seems as the generated objects can't be linked due to missing definition of reference regarding Creat() member function.
As I don't have a deep insight in internal wxWidgets procedures and compiler/linker, I can't see the element to cause the build failing.
Not sure i get what you mean. This has nothing to do with wxWidgets internals, this is plain C++. Declaring a function and not defining it is a C++ error, no matter if you're using wx or not. If you don't understand the code example I posted, then sorry, you're not ready to create a custom wxWidgets control; I would strongly recommend studying C++ (especially inheritance) to have a strong basis on which to build. BTW, the syntax you posted as example is plain wrong, it won't compile, and i can't really figure what's it's supposed to mean.
Last edited by Auria on Sat Apr 04, 2009 4:48 pm, edited 1 time in total.

Post Reply