Ensure wxFindReplaceDialog can be found from its HWND

Associate the dialog HWND with the corresponding C++ object to allow
wxGetWindowFromHWND() to work from it, as this will allow to avoid
having to handle it specially in several places.
This commit is contained in:
Vadim Zeitlin 2023-08-26 18:07:52 +02:00
parent c799a82764
commit 79e057fe06
2 changed files with 7 additions and 1 deletions

View file

@ -30,6 +30,10 @@
#include "wx/fdrepdlg.h"
// Use functions from src/msw/window.cpp
extern void wxRemoveHandleAssociation(wxWindowMSW *win);
extern void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win);
// ----------------------------------------------------------------------------
// functions prototypes
// ----------------------------------------------------------------------------
@ -334,6 +338,7 @@ wxFindReplaceDialog::~wxFindReplaceDialog()
m_isShown = false;
// and from destroying our window [again]
wxRemoveHandleAssociation(this);
m_hWnd = (WXHWND)nullptr;
}
@ -419,6 +424,7 @@ bool wxFindReplaceDialog::Show(bool show)
}
m_hWnd = (WXHWND)hwnd;
wxAssociateWinWithHandle(m_hWnd, this);
return true;
}

View file

@ -291,7 +291,7 @@ void wxTraceMSWMessage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
#endif // wxDEBUG_LEVEL >= 2
void wxRemoveHandleAssociation(wxWindowMSW *win);
extern void wxRemoveHandleAssociation(wxWindowMSW *win);
extern void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win);
// get the text metrics for the current font