whwre is problem?

0 views
Skip to first unread message

zeroDwa

unread,
Nov 15, 2007, 11:22:58 AM11/15/07
to wx-u...@lists.wxwidgets.org

#include "wx/wx.h"
#include "wx/treectrl.h"
#include "wx/event.h"
#include "wx/image.h"

class MyApp: public wxApp
{
public:
virtual bool OnInit();
};

class MyTreeCtrl: public wxTreeCtrl
{
public:
MyTreeCtrl(wxWindow *parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style);
virtual ~MyTreeCtrl(){};
void OnItemActivated(wxTreeEvent& event);
void OnSelChanged(wxTreeEvent& event);
DECLARE_EVENT_TABLE()
};

class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};

enum
{ ID_LISTBOX = 6,
ID_DRZEWO = 5,
ID_Quit = 1, };

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
END_EVENT_TABLE()

BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
EVT_TREE_SEL_CHANGED(ID_DRZEWO, MyTreeCtrl::OnSelChanged)
EVT_TREE_ITEM_ACTIVATED(ID_DRZEWO,MyTreeCtrl::OnItemActivated)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( "zzz", wxPoint(50,50), wxSize(520,540) );
frame->Centre();
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const
wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
MyTreeCtrl* drzewo = new
MyTreeCtrl(this,ID_DRZEWO,wxDefaultPosition,wxSize(180,300),
wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);

wxBoxSizer *pion = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *poziom = new wxBoxSizer(wxHORIZONTAL);

poziom->Add(drzewo, 0, wxEXPAND|wxALL);
pion->Add(poziom, 1, wxEXPAND|wxALL);

SetSizer(pion);
pion->Fit(this);
SetBackgroundColour(* wxBLACK);
SetAutoLayout(TRUE);
Layout();
}

void MyTreeCtrl::OnItemActivated(wxTreeEvent& event)
{
printf(wxT("OnItemActivated"));
};

void MyTreeCtrl::OnSelChanged(wxTreeEvent& event)
{
printf(wxT("OnSelChanged"));
event.Skip();
}


__________
$ make
g++ -Wall -o ttt1 `wx-config --cxxflags --libs` ttt1.cpp
/home/times/tmp/ccgpWFjO.o: In function `MyFrame::MyFrame(wxString
const&, wxPoint const&, wxSize const&)':
ttt1.cpp:(.text+0x3a2): undefined reference to
`MyTreeCtrl::MyTreeCtrl(wxWindow*, int, wxPoint const&, wxSize const&,
long)'
/home/times/tmp/ccgpWFjO.o: In function `MyFrame::MyFrame(wxString
const&, wxPoint const&, wxSize const&)':
ttt1.cpp:(.text+0x772): undefined reference to
`MyTreeCtrl::MyTreeCtrl(wxWindow*, int, wxPoint const&, wxSize const&,
long)'
collect2: ld returned 1 exit status
make: *** [all] error 1

zeroDwa

unread,
Nov 15, 2007, 11:33:23 AM11/15/07
to wx-u...@lists.wxwidgets.org

Paul Koning pisze:
> Just like the message says: you forgot to define the constructor for
> class MyTreeCtrl. There's a declaration in the class, but no
> definition (no function body).

hm... not happened (core dumped when put empty)

MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,

{
};

Paul Koning

unread,
Nov 15, 2007, 11:22:54 AM11/15/07
to wx-u...@lists.wxwidgets.org
Just like the message says: you forgot to define the constructor for
class MyTreeCtrl. There's a declaration in the class, but no
definition (no function body).

paul


Paul Koning

unread,
Nov 15, 2007, 11:32:20 AM11/15/07
to wx-u...@lists.wxwidgets.org
>>>>> "zeroDwa" == zeroDwa <tra...@wupe.pl> writes:

zeroDwa> Paul Koning pisze:


>> Just like the message says: you forgot to define the constructor
>> for class MyTreeCtrl. There's a declaration in the class, but no
>> definition (no function body).

zeroDwa> hm... not happened (core dumped when put empty)

zeroDwa> MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID
zeroDwa> id, const wxPoint& pos, const wxSize& size, long style) { };

Of course. You need to do something in that constructor. Minimally,
you have to construct the base classes (wxTreeCtrl in this case).

paul


zeroDwa

unread,
Nov 15, 2007, 11:39:12 AM11/15/07
to wx-u...@lists.wxwidgets.org

Paul Koning pisze:

http://dark-code.bulix.org/l0zoe1-61031
What I have to change?

simple return?

zeroDwa

unread,
Nov 15, 2007, 11:57:32 AM11/15/07
to wx-u...@lists.wxwidgets.org

http://dark-code.bulix.org/8sfvv5-61033

3 version. please help me. I must select & read what I selected in
mytreectrl

zeroDwa

unread,
Nov 15, 2007, 12:04:33 PM11/15/07
to wx-u...@lists.wxwidgets.org

Patrick Steele pisze:
> Change it to this:
>
> MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id, const
> wxPoint& pos, const wxSize& size, long style) :
> wxTreeCtrl(parent, id, pos, size, style)
> {
> //any other initialisation code here
> };
>
>
> This way, as Paul was saying, you are initialising the base class.
> Patrick
ttt1.cpp:15: error: extra qualification 'MyTreeCtrl::' on member
'MyTreeCtrl'
ttt1.cpp: In constructor 'MyTreeCtrl::MyTreeCtrl(wxWindow*, wxWindowID,
const wxPoint&, const wxSize&, long int)':
ttt1.cpp:16: error: expected `{' at end of input
ttt1.cpp: At global scope:
ttt1.cpp:75: error: redefinition of 'MyTreeCtrl::MyTreeCtrl(wxWindow*,
wxWindowID, const wxPoint&, const wxSize&, long int)'
ttt1.cpp:15: error: 'MyTreeCtrl::MyTreeCtrl(wxWindow*, wxWindowID, const
wxPoint&, const wxSize&, long int)' previously defined here

zeroDwa

unread,
Nov 15, 2007, 12:12:39 PM11/15/07
to wx-u...@lists.wxwidgets.org

ok it compiled but not working

http://dark-code.bulix.org/10sm74-61034

when i click in tree not hapened (printf functions is not run why?

Paul Koning

unread,
Nov 15, 2007, 12:12:29 PM11/15/07
to wx-u...@lists.wxwidgets.org
>>>>> "zeroDwa" == zeroDwa <tra...@wupe.pl> writes:

zeroDwa> Patrick Steele pisze:


>> Change it to this:
>>
>> MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
>> const wxPoint& pos, const wxSize& size, long style) :
>> wxTreeCtrl(parent, id, pos, size, style) { //any other
>> initialisation code here };
>>
>>
>> This way, as Paul was saying, you are initialising the base class.
>> Patrick

zeroDwa> ttt1.cpp:15: error: extra qualification 'MyTreeCtrl::' on
zeroDwa> member 'MyTreeCtrl'

Outside the class declaration...

Maybe you need a C++ textbook. I've fount "C++ in a nutshell" (from
O'Reilly publications) to be very good.

paul


zeroDwa

unread,
Nov 15, 2007, 1:13:12 PM11/15/07
to wx-u...@lists.wxwidgets.org

zeroDwa pisze:

> ok it compiled but not working
>
> http://dark-code.bulix.org/10sm74-61034
>
> when i click in tree not hapened (printf functions is not run why?)

What is wrong?

Lukasz Michalski

unread,
Nov 15, 2007, 2:40:44 PM11/15/07
to wx-u...@lists.wxwidgets.org

How do you know that it is not run?

Regards,
Łukasz

zeroDwa

unread,
Nov 15, 2007, 2:46:58 PM11/15/07
to wx-u...@lists.wxwidgets.org

Lukasz Michalski pisze:
it runs but when i click in the tree items not happened
I thins the printf functions will be run

zeroDwa

unread,
Nov 15, 2007, 4:32:44 PM11/15/07
to wx-u...@lists.wxwidgets.org
> Thats why I asked how do you know that it is run or not. The printf function
> does nothing under MS Windows GUI application.
>
> Try wxMessgageBox.

yes, but Message not activate. Never activate. I ask why?

Lukasz Michalski

unread,
Nov 15, 2007, 2:58:04 PM11/15/07
to wx-u...@lists.wxwidgets.org

Thats why I asked how do you know that it is run or not. The printf function

does nothing under MS Windows GUI application.

Try wxMessgageBox.

Regards,
Łukasz

Patrick Steele

unread,
Nov 15, 2007, 11:54:38 AM11/15/07
to wx-u...@lists.wxwidgets.org
Change it to this:

MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style) :

wxTreeCtrl(parent, id, pos, size, style)
{
    //any other initialisation code here
};


This way, as Paul was saying, you are initialising the base class.
Patrick








---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org


Patrick Steele

unread,
Nov 15, 2007, 1:02:30 PM11/15/07
to wx-u...@lists.wxwidgets.org
Remove the semi-colon from the end of your MyTreeCtrl constructor, line #77

Reply all
Reply to author
Forward
0 new messages