// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "mswfdrepdlg.h"
#endif
#include "wx/msw/private.h"
-#if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
+#if !defined(__WIN32__) || defined(__WXWINCE__)
#include <commdlg.h>
#endif
LRESULT APIENTRY wxFindReplaceWindowProc(HWND hwnd, WXUINT nMsg,
WPARAM wParam, LPARAM lParam);
-UINT CALLBACK wxFindReplaceDialogHookProc(HWND hwnd,
- UINT uiMsg,
- WPARAM wParam,
- LPARAM lParam);
+UINT_PTR CALLBACK wxFindReplaceDialogHookProc(HWND hwnd,
+ UINT uiMsg,
+ WPARAM wParam,
+ LPARAM lParam);
// ----------------------------------------------------------------------------
// wxWin macros
// registered Message for Dialog
static UINT ms_msgFindDialog;
+
+ DECLARE_NO_COPY_CLASS(wxFindReplaceDialogImpl)
};
UINT wxFindReplaceDialogImpl::ms_msgFindDialog = 0;
// as then we'd have infinite recursion in wxFindReplaceWindowProc
if ( !wxCheckWindowWndProc((WXHWND)hwnd, (WXFARPROC)wxFindReplaceWindowProc) )
{
- WNDPROC oldParentWndProc = (WNDPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
- // save old wnd proc elsewhere to access it from
- // wxFindReplaceWindowProc
- m_oldParentWndProc = oldParentWndProc;
- (void)::SetWindowLong(hwnd, GWL_USERDATA, (LONG)oldParentWndProc);
-
- // and set the new one
- (void)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)wxFindReplaceWindowProc);
+ // set the new one and save the old as user data to allow access to it
+ // from wxFindReplaceWindowProc
+ m_oldParentWndProc = wxSetWindowProc(hwnd, wxFindReplaceWindowProc);
+
+ wxSetWindowUserData(hwnd, (void *)m_oldParentWndProc);
}
}
if ( m_hwndOwner )
{
- ::SetWindowLong(m_hwndOwner, GWL_WNDPROC, (LONG)m_oldParentWndProc);
+ // undo subclassing
+ wxSetWindowProc(m_hwndOwner, m_oldParentWndProc);
}
}
LRESULT APIENTRY wxFindReplaceWindowProc(HWND hwnd, WXUINT nMsg,
WPARAM wParam, LPARAM lParam)
{
+#if wxUSE_UNICODE_MSLU
+ static unsigned long s_lastMsgFlags = 0;
+
+ // This flag helps us to identify the bogus ANSI message
+ // sent by UNICOWS.DLL (see below)
+ // while we're sending our message to the dialog
+ // we ignore possible messages sent in between
+ static bool s_blockMsg = false;
+#endif // wxUSE_UNICODE_MSLU
+
if ( nMsg == wxFindReplaceDialogImpl::GetFindDialogMessage() )
{
FINDREPLACE *pFR = (FINDREPLACE *)lParam;
+
+#if wxUSE_UNICODE_MSLU
+ // This is a hack for a MSLU problem: Versions up to 1.0.4011
+ // of UNICOWS.DLL send the correct UNICODE item after button press
+ // and a bogus ANSI mode item right after this, so lets ignore
+ // the second bogus message
+ if ( s_lastMsgFlags == pFR->Flags )
+ {
+ s_lastMsgFlags = 0;
+ return 0;
+ }
+ s_lastMsgFlags = pFR->Flags;
+#endif // wxUSE_UNICODE_MSLU
+
wxFindReplaceDialog *dialog = (wxFindReplaceDialog *)pFR->lCustData;
// map flags from Windows
event.SetReplaceString(pFR->lpstrReplaceWith);
}
+#if wxUSE_UNICODE_MSLU
+ s_blockMsg = true;
+#endif // wxUSE_UNICODE_MSLU
+
dialog->Send(event);
+
+#if wxUSE_UNICODE_MSLU
+ s_blockMsg = false;
+#endif // wxUSE_UNICODE_MSLU
}
+#if wxUSE_UNICODE_MSLU
+ else if ( !s_blockMsg )
+ s_lastMsgFlags = 0;
+#endif // wxUSE_UNICODE_MSLU
- WNDPROC wndProc = (WNDPROC)::GetWindowLong(hwnd, GWL_USERDATA);
+ WNDPROC wndProc = (WNDPROC)wxGetWindowUserData(hwnd);
// sanity check
wxASSERT_MSG( wndProc != wxFindReplaceWindowProc,
// Find/replace dialog hook proc
// ----------------------------------------------------------------------------
-UINT CALLBACK wxFindReplaceDialogHookProc(HWND hwnd,
- UINT uiMsg,
- WPARAM WXUNUSED(wParam),
- LPARAM lParam)
+UINT_PTR CALLBACK
+wxFindReplaceDialogHookProc(HWND hwnd,
+ UINT uiMsg,
+ WPARAM WXUNUSED(wParam),
+ LPARAM lParam)
{
if ( uiMsg == WM_INITDIALOG )
{