I wanted an OnClick event for a notification message, which I dont get from wxSplashScreen, so I made it myself (With vs2015, wxWidgets 3.1.0, win10x64).
A frame with a Panel and a StaticText as message, as a child of a parent frame. It works all fine and dandy until I stress it to much and it crashes.
Using the frame derived class as notification class:
Code: Select all
MyMsg::MyMsg(wxPoint pos, wxSize size, wxString title, wxString msg, wxWindow *parent, int timeout)
: wxFrame(parent, wxID_ANY, title, pos, size, wxSTAY_ON_TOP)
{
wxFlexGridSizer *fgs_main = new wxFlexGridSizer(1);
wxPanel *pn_body = new wxPanel(this);
wxFlexGridSizer *fgs_body = new wxFlexGridSizer(1);
mst_info = new wxStaticText(pn_body, ID_TMP_STATIC_INFO, msg);
fgs_body->Add(mst_info, 1, wxALL|wxEXPAND, 10);
fgs_body->AddGrowableCol(0,1);
fgs_body->AddGrowableRow(0,1);
pn_body->SetSizer(fgs_body);
mst_info->Bind(wxEVT_LEFT_DOWN, &MyMsg::OnMouse, this);
mst_info->Connect(ID_TMP_STATIC_INFO, wxEVT_LEFT_DOWN, wxMouseEventHandler(MyMsg::OnMouse), NULL, this);
fgs_main->Add(pn_body, 1, wxEXPAND);
fgs_main->AddGrowableCol(0, 1);
fgs_main->AddGrowableRow(0, 1);
this->SetSizer(fgs_main);
mt_timer = new wxTimer(this, ID_TMP_TIMER);
mt_timer->Start(timeout);
this->SetFocus();
this->Raise();
Code: Select all
MyMsg *msg = new MyMsg(wxDefaultPosition, wxDefaultSize, "infoskopMsgNotification", sMsgText, NULL, lSplashOnTime);
//[...]
msg->SetSize(GetTextPixelLength(sMsgText, font, msg), 50);
//[...]
msg->SetPosition(wxPoint(x, y));
msg->Show();
I gave the StaticText an OnClick to destroy itself when clicked upon.
Code: Select all
void MyMsg::OnMouse(wxMouseEvent &event)
{
Close(true);
}
void MyMsg::OnTimer(wxTimerEvent &event)
{
mt_timer->Stop();
Close(true);
}
EDIT: A quick test showed: I can get a crash even without using the icon close. Once the first frames start closing, creating new frames or clicking on a frame to close it will very likely generate a program crash.
Some ideas, what might cause this?
Greetz
Natu