Fix destruction of wxNativeContainerWindow in wxMSW.
WM_CLOSE was not processed at all for native windows wrapped by wxNativeContainerWindow because we don't handle it ourselves at wxWindow level but still mark it as processed in order to prevent DefWindowProc() from destroying the window. Unfortunately this also prevented the original handler for this message in the native window from being called. Calling just the original handler and not the wxWidgets one is not ideal neither but is much better as it allows to e.g. close MFC frames wrapped in wxNativeContainerWindow whereas before this didn't work at all as WM_CLOSE was completely ignored. Also call the original handler for WM_DESTROY to avoid similar potential problems with this message, even if it doesn't seem to create any with MFC. Extend the mfc sample to show how a wxPanel can be embedded into the existing CFrameWnd.
This commit is contained in:
@@ -69,11 +69,24 @@ WXLRESULT wxNativeContainerWindow::MSWWindowProc(WXUINT nMsg,
|
||||
WXWPARAM wParam,
|
||||
WXLPARAM lParam)
|
||||
{
|
||||
if ( nMsg == WM_DESTROY )
|
||||
switch ( nMsg )
|
||||
{
|
||||
OnNativeDestroyed();
|
||||
case WM_CLOSE:
|
||||
// wxWindow itself, unlike wxFrame, doesn't react to WM_CLOSE and
|
||||
// just ignores it without even passing it to DefWindowProc(),
|
||||
// which means that the original WM_CLOSE handler wouldn't be
|
||||
// called if we didn't explicitly do it here.
|
||||
return MSWDefWindowProc(nMsg, wParam, lParam);
|
||||
|
||||
return 0;
|
||||
case WM_DESTROY:
|
||||
// Send it to the original handler which may have some cleanup to
|
||||
// do as well. Notice that we must do it before calling
|
||||
// OnNativeDestroyed() as we can't use this object after doing it.
|
||||
MSWDefWindowProc(nMsg, wParam, lParam);
|
||||
|
||||
OnNativeDestroyed();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return wxTopLevelWindow::MSWWindowProc(nMsg, wParam, lParam);
|
||||
|
||||
Reference in New Issue
Block a user