Page 1 of 1

wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 3:43 pm
by Wolfgang
Hello
I made a derived class MyHtmlwindow from wxhtmlwindo, but now I need to call some code when this window is closed.
Tried with EVT_CLOSE but that is not working inside the event table declaration.

Code: Select all

EVT_CLOSE(MyHtmlWindow::Onclosewindow)

Code: Select all

C++ #define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func))

Code: Select all

wxEVT_CLOSE_WINDOW(MyHtmlWindow::Onclosewindow)

Code: Select all

C++ (<error-type>)<error>(&MyHtmlWindow::Onclosewindow)
Other try I had making a destructor for MyHtmlwindow, but this was not called.

I consturct it with htmlwindow on a panel with mainframe as parent, and then show ith with Addpane wihtin the wxAuimanager.
must I create an extra frame first, and then make it?

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 3:46 pm
by doublemax
Tried with EVT_CLOSE but that is not working inside the event table declaration.
That should work. Please show the whole event table and the full event handler. And what error do you get?

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 4:04 pm
by Wolfgang

Code: Select all

wxBEGIN_EVENT_TABLE(MyHtmlWindow, wxHtmlWindow)
EVT_MOTION(MyHtmlWindow::OnMouseMotion)
EVT_LEFT_DOWN(MyHtmlWindow::OnActivm)
EVT_CLOSE(MyHtmlWindow::Onclosewindow)
wxEND_EVENT_TABLE()

Code: Select all

EVT_CLOSE(MyHtmlWindow::Onclosewindow)
In Visual Studio EVT_CLOSE is marked red invalid typ converting


Code: Select all

void MyHtmlWindow::Onclosewindow(wxMouseEvent& event)
{
	wxInt16 countm = 1;
	while (!bibwinid[countm] == GetId())
	{
		countm++;
	};
	bibwin[countm] = NULL;
	bibwinid[countm] = NULL;
}

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 4:06 pm
by Wolfgang
found now the mistake, just have to find the right thing for it.
is of course not a mouse event

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 4:07 pm
by doublemax

Code: Select all

void MyHtmlWindow::Onclosewindow(wxMouseEvent& event)
This needs a wxCloseEvent as parameter.

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 4:08 pm
by Wolfgang
wxCloseEvent

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 4:09 pm
by Wolfgang
You were a bit quicker :)

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 4:28 pm
by Wolfgang
it compiles like that, but the onclosewindow never gets called.

The htmlwindow can only get closed with the x from the pane, must I make the eventtable for the auimanager?

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 5:24 pm
by doublemax
I think only toplevel windows receive an EVT_CLOSE event. So the destructor would be the best place to put your code. But it i understand you correctly, it doesn't get destroyed, just hidden? Or the toplevel parent gets closed? In the latter case, you need to put the code in the EVT_CLOSE handler of the containing toplevel window.

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 6:05 pm
by ONEEYEMAN
doublemax,
You are correct - only TLW receives EVT_CLOSE.
There is a ticket about sending it for wxDialog (its old).

So if this HtmlWindow is not a TLW - its better to put you code in the destructor or use the parent window (or TLW) EVT_CLOSE event to process it.

Thank you.

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 6:16 pm
by Wolfgang

Code: Select all

		m_bibf[count]->SetPage(page1);

		m_mgr.AddPane(m_bibf[count], wxAuiPaneInfo().Resizable().Dockable(false).Float());

Code: Select all

MyHtmlWindow* m_bibf[1024];
wxAuiManager m_mgr;
So it gets created. It has a close button on it, and if I press this close button the close event does not get called,I tried to make a destructor, but if I define a destructor for MyHTMLWindow it also does not get called.

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 6:20 pm
by ONEEYEMAN
Hi,
You need to define the EVT_CLOSE for the AUI panel.

Thank you.

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 6:40 pm
by doublemax
EVT_AUI_PANE_CLOSE(func):
Triggered when a docked or floating pane is closed.

Code: Select all

void handlerFuncName(wxAuiManagerEvent& event)
But i still think it's strange that the destructor of the MyHtmlWindow is not executed when the AUI pane gets closed. I've never used AUI, but i don't think you can get a closed AUI pane back, so it must be destroyed.

Re: wxhtmlwindow catch when closed

Posted: Tue Dec 17, 2019 6:46 pm
by Wolfgang
Aui Pane close works perfectly.

Thanks