From: Fibre Optic on
Hello,

I have problem with event handling... I have defined MyFrame class,
besides number of different members it has the following two:

MyListCtrl* navigation;
wxNotebook* notebook;


All I wanted to do is change status of object i.e. 'notebook' from event
handler of different i.e. 'navigation'. I have defined event handler
method 'MyFrame::OnSelectedT' of 'navigation' to deal with 'notebook' by
pointer. It compiles without warnings, the app starts but when I click
on items of 'navigation' the app printes "!!! SELECTED !!!" (wqhich is
ok)then it generates stack trace :-( :

wxDivingLogBook.exe caused an Access Violation at location 00403d61 in
module wxDivingLogBook.exe Reading from location 454c4553.

Registers:
eax=454c4553 ebx=00257f58 ecx=7c810e16 edx=00275db8 esi=006590d0
edi=0023ef4c
eip=00403d61 esp=0023eb2c ebp=0023eb34 iopl=0 nv up ei pl nz na
pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000
efl=00000202

Call stack:
00403D61 wxDivingLogBook.exe:00403D61
MyFrame::OnSelectedT(wxListEvent&) MyFrame.cpp:207
...

printf("!!! SELECTED !!!\n");
> notebook->SetSelection(2);

....
....






Could some one of you explain me where is problem and how to improve the
code?


bool MyApp::OnInit()
{
....
....
MyFrame *frame = new MyFrame(0,
wxID_ANY,
wxT("wxDivingLogBook v0.1"),
wxDefaultPosition,
wxDefaultSize,
wxDEFAULT_FRAME_STYLE);

// Show it
frame->Show(true);
....
....
}

//*******************************************************************

class MyFrame : public wxFrame
{
public:

// Constructors
MyFrame(const wxString& title);
MyFrame(wxWindow* parent, int id, const wxString& title,
const wxPoint& pos=wxDefaultPosition,
const wxSize& size=wxDefaultSize,
long style=wxDEFAULT_FRAME_STYLE);

//Destructor
virtual ~MyFrame();

// Creation
bool Create();

// Event handlers of MyListCtrl class
void OnSelectedT(wxListEvent& event);


// setters & getters
....
....

private:
// This class handles events
DECLARE_EVENT_TABLE()

//Widgets
MyListCtrl* navigation;
wxNotebook* notebook;
....
....
};

....
....

//***************************************************************

void MyFrame::OnSelectedT(wxListEvent& event)
{

printf("!!! SELECTED !!!\n");

notebook->SetSelection(2);

}


// Event table for MyListCtrl
BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
END_EVENT_TABLE()


Regards,
Fibre Optic
From: Thomas Zehbe on
Am Dienstag, 24. Oktober 2006 17:24 schrieb Fibre Optic:
> Hello,
>
> I have problem with event handling... I have defined MyFrame class,
> besides number of different members it has the following two:
>
> MyListCtrl* navigation;
> wxNotebook* notebook;
>
>
> All I wanted to do is change status of object i.e. 'notebook' from event
> handler of different i.e. 'navigation'. I have defined event handler
> method 'MyFrame::OnSelectedT' of 'navigation' to deal with 'notebook' by
> pointer. It compiles without warnings, the app starts but when I click
> on items of 'navigation' the app printes "!!! SELECTED !!!" (wqhich is
> ok)then it generates stack trace :-( :
>
> wxDivingLogBook.exe caused an Access Violation at location 00403d61 in
> module wxDivingLogBook.exe Reading from location 454c4553.
>
> Registers:
> eax=454c4553 ebx=00257f58 ecx=7c810e16 edx=00275db8 esi=006590d0
> edi=0023ef4c
> eip=00403d61 esp=0023eb2c ebp=0023eb34 iopl=0 nv up ei pl nz na
> pe nc
> cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000
> efl=00000202
>
> Call stack:
> 00403D61 wxDivingLogBook.exe:00403D61
> MyFrame::OnSelectedT(wxListEvent&) MyFrame.cpp:207

What is in line 207 of MyFrame?
Have you started it in the debugger to get a callstack or backtrace?

Regards,

Thomas

> ...
>
> printf("!!! SELECTED !!!\n");
>
> > notebook->SetSelection(2);
>
> ...
> ...
>
>
>
>
>
>
> Could some one of you explain me where is problem and how to improve the
> code?
>
>
> bool MyApp::OnInit()
> {
> ...
> ...
> MyFrame *frame = new MyFrame(0,
> wxID_ANY,
> wxT("wxDivingLogBook v0.1"),
> wxDefaultPosition,
> wxDefaultSize,
> wxDEFAULT_FRAME_STYLE);
>
> // Show it
> frame->Show(true);
> ...
> ...
> }
>
> //*******************************************************************
>
> class MyFrame : public wxFrame
> {
> public:
>
> // Constructors
> MyFrame(const wxString& title);
> MyFrame(wxWindow* parent, int id, const wxString& title,
> const wxPoint& pos=wxDefaultPosition,
> const wxSize& size=wxDefaultSize,
> long style=wxDEFAULT_FRAME_STYLE);
>
> //Destructor
> virtual ~MyFrame();
>
> // Creation
> bool Create();
>
> // Event handlers of MyListCtrl class
> void OnSelectedT(wxListEvent& event);
>
>
> // setters & getters
> ...
> ...
>
> private:
> // This class handles events
> DECLARE_EVENT_TABLE()
>
> //Widgets
> MyListCtrl* navigation;
> wxNotebook* notebook;
> ...
> ...
> };
>
> ...
> ...
>
> //***************************************************************
>
> void MyFrame::OnSelectedT(wxListEvent& event)
> {
>
> printf("!!! SELECTED !!!\n");
>
> notebook->SetSelection(2);
>
> }
>
>
> // Event table for MyListCtrl
> BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
> EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
> END_EVENT_TABLE()
>
>
> Regards,
> Fibre Optic
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

--
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Fibre Optic on
Thomas Zehbe wrote:
>
> What is in line 207 of MyFrame?
> Have you started it in the debugger to get a callstack or backtrace?
>

In line207 of MyFrame I have the following:
notebook->SetSelection(2);

Why it crashed down when I try to call the SetSelection() method of
notebook? Basically, it looks like I can not call it even it compiles
without problem. I have tried to call different methods but result is
still the same.

Best Regards,
Fibre Optic
From: Thomas Zehbe on
Am Mittwoch, 25. Oktober 2006 10:54 schrieb Fibre Optic:
> Thomas Zehbe wrote:
> > What is in line 207 of MyFrame?
> > Have you started it in the debugger to get a callstack or backtrace?
>
> In line207 of MyFrame I have the following:
> notebook->SetSelection(2);
>
> Why it crashed down when I try to call the SetSelection() method of
> notebook? Basically, it looks like I can not call it even it compiles
> without problem. I have tried to call different methods but result is
> still the same.
How many tabs has the notebook? If there are only 2, you would try to select
the third, which doesn't exist.
Is notebook a valid pointer in this context? Does it point to a notebook?
Is the crash gone if you comment the line out?
Are there event functions OnSelect in the notebook?
Does it crash, if you do a "notebook->SetSelection(2);" in another part of the
program?

All these could be usefull to isolate the error.
Hope it helps.

Regards,

Thomas

>
> Best Regards,
> Fibre Optic
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

--
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Fibre Optic on
Thomas Zehbe wrote:

> How many tabs has the notebook? If there are only 2, you would try to select
> the third, which doesn't exist.
the notebook has 6 tabs

> Is notebook a valid pointer in this context? Does it point to a notebook?
i think it is valid pointer, at list

> Is the crash gone if you comment the line out?
yes!

> Are there event functions OnSelect in the notebook?
I have prepared only the following event handler:

// Event table for MyListCtrl
BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
END_EVENT_TABLE()

IOs it ok that OnSelectedT method is member of MyFrame?

> Does it crash, if you do a "notebook->SetSelection(2);" in another part of the
> program?

I have added the line in to body of MyFrame::OnAbout it works perfectly !!!

>
> All these could be usefull to isolate the error.
> Hope it helps.


Any ideas ?

Regards,
Fibre Optic