InitDialog() is not called by wxPanel ! Topic is solved

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
manianis
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Jan 15, 2007 11:00 am

InitDialog() is not called by wxPanel !

Post by manianis »

I'm handling the EVT_INIT_DIALOG event to know about the the initialisation of the panel as mentionned in the documentation :

A wxInitDialogEvent is sent as a dialog or panel is being initialised.
clyde729
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Mon May 29, 2006 10:50 pm
Location: Jena, Germany

Post by clyde729 »

But it "should" work. wxPanel is a generic implementation and the event is fired. Show us how you catch the event.
OS: Windows XP Home, Compiler: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp
manianis
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Jan 15, 2007 11:00 am

Post by manianis »

The event table in the cpp file :

Code: Select all

BEGIN_EVENT_TABLE(ClientListPanel,wxPanel)
	EVT_INIT_DIALOG(ClientListPanel::OnInitDialog)
END_EVENT_TABLE()

// ... 

// the InitDialog handler
void ClientListPanel::OnInitDialog(wxInitDialogEvent& event)
{
  printf("I'm called...");
}
in .h file :

Code: Select all

class ClientListPanel : public wxPanel
{
 // ...

protected:
 void OnInitDialog(wxInitDialogEvent& event);
 //...

private:
 DECLARE_EVENT_TABLE()  
};
I'm called is never shown !!!
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

Just for kicks, can you use PRINTF at all in a GUI based environment? AFAIK printf goes nowhere in a GUI. I am not sure about Linux, but I definately know it is not going anywhere in Windows.

Either use a debugger and see if something is called, or try to use wxLogMessage / wxLogError to simulate a log action and it will be routed to either a dialog or console if possible.

But I am sure printf is not your answer.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
manianis
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Jan 15, 2007 11:00 am

Post by manianis »

Jorg wrote:Just for kicks, can you use PRINTF at all in a GUI based environment? AFAIK printf goes nowhere in a GUI. I am not sure about Linux, but I definately know it is not going anywhere in Windows.

Either use a debugger and see if something is called, or try to use wxLogMessage / wxLogError to simulate a log action and it will be routed to either a dialog or console if possible.

But I am sure printf is not your answer.

- Jorgen
I'm using Code::Blocks IDE and the output it shows the output on a separate window when in the debug mode. Also I'm linking without the -mwindows option.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Dunno about windows, but on my mac and linux machines GUI app output to console without problem.

Could you post a minimal working sampel, so that i can compile it?
manianis
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Jan 15, 2007 11:00 am

Post by manianis »

Is EVT_INIT_DIALOG sent automatically or must I call InitDialog explicitally ?
yakumoklesk
Knows some wx things
Knows some wx things
Posts: 36
Joined: Mon Jan 01, 2007 10:55 am

Post by yakumoklesk »

I just have the same problem, so I should request the same solution.

The code is similar as the one in this thread.

Thanks.
Yakumo, searching Pai.
yakumoklesk
Knows some wx things
Knows some wx things
Posts: 36
Joined: Mon Jan 01, 2007 10:55 am

Post by yakumoklesk »

Manianis, I just called InitDialog() in the constructor of the class derived from wxPanel and it works.

My OnInitDialog is called first. But there is called OnPaint() before OnSize(). I don't know if this should be this way, because in OnSize I want to create a backbuffer and I will have to do it in OnInitDialog(), but wxInitDialogEvent does not have a GetSize() function. Anyway this does not concert to this post.

See you.
Yakumo, searching Pai.
Post Reply