wxDialog do not generate wxEVT_CREATE event? 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
waterj
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Nov 07, 2005 8:39 am

wxDialog do not generate wxEVT_CREATE event?

Post by waterj »

I have a Mydialog which is simply inherited from wxDialog, and i never receive wxEVT_WINDOW_CREATE event. it's weird!
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

platform/os/compiler?
BlowdyNose
Experienced Solver
Experienced Solver
Posts: 52
Joined: Tue Sep 20, 2005 3:49 pm
Location: Konstanz, Germany

Post by BlowdyNose »

Hi

How do you try to catch it ( code ) ?
waterj
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Nov 07, 2005 8:39 am

Post by waterj »

Sorry for later reply. Here is the code(WinXP SP2, VC++ 6.0, build wxWidgets with Win32 DLL Debug):

Code: Select all

#define ID_DIALOG 10000
#define SYMBOL_MYDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_MYDIALOG_TITLE _("Dialog")
#define SYMBOL_MYDIALOG_IDNAME ID_DIALOG
#define SYMBOL_MYDIALOG_SIZE wxSize(400, 300)
#define SYMBOL_MYDIALOG_POSITION wxDefaultPosition

#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
#ifndef wxFIXED_MINSIZE
#define wxFIXED_MINSIZE 0
#endif

class MyDialog: public wxDialog
{    
public:
  MyDialog( );
    MyDialog( wxWindow* parent, wxWindowID id = SYMBOL_MYDIALOG_IDNAME, const wxString& caption = SYMBOL_MYDIALOG_TITLE, const wxPoint& pos = SYMBOL_MYDIALOG_POSITION, const wxSize& size = SYMBOL_MYDIALOG_SIZE, long style = SYMBOL_MYDIALOG_STYLE );

    /// Creation
    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_MYDIALOG_IDNAME, const wxString& caption = SYMBOL_MYDIALOG_TITLE, const wxPoint& pos = SYMBOL_MYDIALOG_POSITION, const wxSize& size = SYMBOL_MYDIALOG_SIZE, long style = SYMBOL_MYDIALOG_STYLE );

	void OnCreate(wxWindowCreateEvent&);
	
	DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(MyDialog, wxDialog)
	EVT_WINDOW_CREATE(MyDialog::OnCreate)
END_EVENT_TABLE()

MyDialog::MyDialog()
{
}

MyDialog::MyDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
    Create(parent, id, caption, pos, size, style);
}

bool MyDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
    wxDialog::Create( parent, id, caption, pos, size, style );
    return true;
}

void MyDialog::OnCreate(wxWindowCreateEvent&)
{
//never goes into here
}

class dlgapp: public wxApp
{    
public:
    /// Constructor
    dlgapp();

    /// Initialises the application
    virtual bool OnInit();
};

dlgapp::dlgapp()
{
}

bool dlgapp::OnInit()
{    
   MyDialog* mainWindow = new MyDialog(NULL, ID_DIALOG, _("Dialog"));
    mainWindow->Show(true);
    return true;
}

BlowdyNose
Experienced Solver
Experienced Solver
Posts: 52
Joined: Tue Sep 20, 2005 3:49 pm
Location: Konstanz, Germany

Post by BlowdyNose »

Hi waterj

I just read something about Dialoginitialization.

-> When a dialog is first shown, wxWidgets calls InitDialog...

And this is a wxEVT_INIT_DIALOG event!!

Perhaps this can help. Right know I have no time to verify it :roll:

- BlowdyNose
Post Reply