Add WXWNDPROC typedef and use it in wxMSW instead of WXFARPROC
WNDPROC and FARPROC are not the same thing in MSW and it's wrong to use WXFARPROC as the type of different window procedures we use. Introduce WXWNDPROC which is more clear and correct and use it instead. Also get rid of a few casts which are not necessary any longer.
This commit is contained in:
@@ -2845,11 +2845,18 @@ typedef wxW64 long WXLPARAM;
|
|||||||
typedef wxW64 long WXLRESULT;
|
typedef wxW64 long WXLRESULT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is defined for compatibility only, it's not really the same thing as
|
||||||
|
FARPROC.
|
||||||
|
*/
|
||||||
#if defined(__GNUWIN32__)
|
#if defined(__GNUWIN32__)
|
||||||
typedef int (*WXFARPROC)();
|
typedef int (*WXFARPROC)();
|
||||||
#else
|
#else
|
||||||
typedef int (__stdcall *WXFARPROC)();
|
typedef int (__stdcall *WXFARPROC)();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef WXLRESULT (wxSTDCALL *WXWNDPROC)(WXHWND, WXUINT, WXWPARAM, WXLPARAM);
|
||||||
|
|
||||||
#endif /* __WIN32__ */
|
#endif /* __WIN32__ */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -939,7 +939,7 @@ extern WXDLLIMPEXP_CORE int wxGetWindowId(WXHWND hWnd);
|
|||||||
//
|
//
|
||||||
// wndProc parameter is unused and only kept for compatibility
|
// wndProc parameter is unused and only kept for compatibility
|
||||||
extern WXDLLIMPEXP_CORE
|
extern WXDLLIMPEXP_CORE
|
||||||
bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc = NULL);
|
bool wxCheckWindowWndProc(WXHWND hWnd, WXWNDPROC wndProc = NULL);
|
||||||
|
|
||||||
// Does this window style specify any border?
|
// Does this window style specify any border?
|
||||||
inline bool wxStyleHasBorder(long style)
|
inline bool wxStyleHasBorder(long style)
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
// for internal use only
|
// for internal use only
|
||||||
|
|
||||||
// get the subclassed window proc of the buddy text
|
// get the subclassed window proc of the buddy text
|
||||||
WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
|
WXWNDPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
|
||||||
|
|
||||||
// return the spinctrl object whose buddy is the given window or NULL
|
// return the spinctrl object whose buddy is the given window or NULL
|
||||||
static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
|
static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
|
||||||
@@ -145,7 +145,7 @@ protected:
|
|||||||
|
|
||||||
// the data for the "buddy" text ctrl
|
// the data for the "buddy" text ctrl
|
||||||
WXHWND m_hwndBuddy;
|
WXHWND m_hwndBuddy;
|
||||||
WXFARPROC m_wndProcBuddy;
|
WXWNDPROC m_wndProcBuddy;
|
||||||
|
|
||||||
// Block text update event after SetValue()
|
// Block text update event after SetValue()
|
||||||
bool m_blockEvent;
|
bool m_blockEvent;
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ public:
|
|||||||
void SubclassWin(WXHWND hWnd);
|
void SubclassWin(WXHWND hWnd);
|
||||||
void UnsubclassWin();
|
void UnsubclassWin();
|
||||||
|
|
||||||
WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; }
|
WXWNDPROC MSWGetOldWndProc() const { return m_oldWndProc; }
|
||||||
void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
|
void MSWSetOldWndProc(WXWNDPROC proc) { m_oldWndProc = proc; }
|
||||||
|
|
||||||
// return true if the window is of a standard (i.e. not wxWidgets') class
|
// return true if the window is of a standard (i.e. not wxWidgets') class
|
||||||
//
|
//
|
||||||
@@ -597,7 +597,7 @@ protected:
|
|||||||
WXHWND m_hWnd;
|
WXHWND m_hWnd;
|
||||||
|
|
||||||
// the old window proc (we subclass all windows)
|
// the old window proc (we subclass all windows)
|
||||||
WXFARPROC m_oldWndProc;
|
WXWNDPROC m_oldWndProc;
|
||||||
|
|
||||||
// additional (MSW specific) flags
|
// additional (MSW specific) flags
|
||||||
bool m_mouseInWindow:1;
|
bool m_mouseInWindow:1;
|
||||||
|
|||||||
@@ -81,10 +81,10 @@
|
|||||||
#if USE_NOTEBOOK_ANTIFLICKER
|
#if USE_NOTEBOOK_ANTIFLICKER
|
||||||
|
|
||||||
// the pointer to standard spin button wnd proc
|
// the pointer to standard spin button wnd proc
|
||||||
static WXFARPROC gs_wndprocNotebookSpinBtn = (WXFARPROC)NULL;
|
static WXWNDPROC gs_wndprocNotebookSpinBtn = NULL;
|
||||||
|
|
||||||
// the pointer to standard tab control wnd proc
|
// the pointer to standard tab control wnd proc
|
||||||
static WXFARPROC gs_wndprocNotebook = (WXFARPROC)NULL;
|
static WXWNDPROC gs_wndprocNotebook = NULL;
|
||||||
|
|
||||||
LRESULT APIENTRY
|
LRESULT APIENTRY
|
||||||
wxNotebookWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
wxNotebookWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
@@ -202,8 +202,7 @@ bool wxNotebook::Create(wxWindow *parent,
|
|||||||
|
|
||||||
if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) )
|
if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) )
|
||||||
{
|
{
|
||||||
gs_wndprocNotebook =
|
gs_wndprocNotebook = wc.lpfnWndProc;
|
||||||
reinterpret_cast<WXFARPROC>(wc.lpfnWndProc);
|
|
||||||
wc.lpszClassName = wxT("_wx_SysTabCtl32");
|
wc.lpszClassName = wxT("_wx_SysTabCtl32");
|
||||||
wc.style &= ~(CS_HREDRAW | CS_VREDRAW);
|
wc.style &= ~(CS_HREDRAW | CS_VREDRAW);
|
||||||
wc.hInstance = wxGetInstance();
|
wc.hInstance = wxGetInstance();
|
||||||
@@ -996,7 +995,7 @@ void wxNotebook::OnSize(wxSizeEvent& event)
|
|||||||
{
|
{
|
||||||
// subclass the spin button to override WM_ERASEBKGND
|
// subclass the spin button to override WM_ERASEBKGND
|
||||||
if ( !gs_wndprocNotebookSpinBtn )
|
if ( !gs_wndprocNotebookSpinBtn )
|
||||||
gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child);
|
gs_wndprocNotebookSpinBtn = wxGetWindowProc(child);
|
||||||
|
|
||||||
wxSetWindowProc(child, wxNotebookSpinBtnWndProc);
|
wxSetWindowProc(child, wxNotebookSpinBtnWndProc);
|
||||||
m_hasSubclassedUpdown = true;
|
m_hasSubclassedUpdown = true;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace
|
|||||||
{
|
{
|
||||||
|
|
||||||
// the pointer to standard radio button wnd proc
|
// the pointer to standard radio button wnd proc
|
||||||
WXFARPROC s_wndprocRadioBtn = (WXFARPROC)NULL;
|
WXWNDPROC s_wndprocRadioBtn = NULL;
|
||||||
|
|
||||||
// Hash allowing to find wxRadioBox containing the given radio button by its
|
// Hash allowing to find wxRadioBox containing the given radio button by its
|
||||||
// HWND. This is used by (subclassed) radio button window proc to find the
|
// HWND. This is used by (subclassed) radio button window proc to find the
|
||||||
@@ -298,7 +298,7 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
|
|||||||
HWND hwndBtn = (HWND)hWndBtn;
|
HWND hwndBtn = (HWND)hWndBtn;
|
||||||
|
|
||||||
if ( !s_wndprocRadioBtn )
|
if ( !s_wndprocRadioBtn )
|
||||||
s_wndprocRadioBtn = (WXFARPROC)wxGetWindowProc(hwndBtn);
|
s_wndprocRadioBtn = wxGetWindowProc(hwndBtn);
|
||||||
|
|
||||||
wxSetWindowProc(hwndBtn, wxRadioBtnWndProc);
|
wxSetWindowProc(hwndBtn, wxRadioBtnWndProc);
|
||||||
|
|
||||||
|
|||||||
@@ -329,8 +329,7 @@ bool wxSpinCtrl::Create(wxWindow *parent,
|
|||||||
// subclass the text ctrl to be able to intercept some events
|
// subclass the text ctrl to be able to intercept some events
|
||||||
gs_spinForTextCtrl[GetBuddyHwnd()] = this;
|
gs_spinForTextCtrl[GetBuddyHwnd()] = this;
|
||||||
|
|
||||||
m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(),
|
m_wndProcBuddy = wxSetWindowProc(GetBuddyHwnd(), wxBuddyTextWndProc);
|
||||||
wxBuddyTextWndProc);
|
|
||||||
|
|
||||||
// associate the text window with the spin button
|
// associate the text window with the spin button
|
||||||
(void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);
|
(void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);
|
||||||
|
|||||||
@@ -1248,7 +1248,7 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd)
|
|||||||
|
|
||||||
wxAssociateWinWithHandle(hwnd, this);
|
wxAssociateWinWithHandle(hwnd, this);
|
||||||
|
|
||||||
m_oldWndProc = (WXFARPROC)wxGetWindowProc((HWND)hWnd);
|
m_oldWndProc = wxGetWindowProc((HWND)hWnd);
|
||||||
|
|
||||||
// we don't need to subclass the window of our own class (in the Windows
|
// we don't need to subclass the window of our own class (in the Windows
|
||||||
// sense of the word)
|
// sense of the word)
|
||||||
@@ -1291,7 +1291,7 @@ void wxWindowMSW::UnsubclassWin()
|
|||||||
{
|
{
|
||||||
if ( !wxCheckWindowWndProc((WXHWND)hwnd) )
|
if ( !wxCheckWindowWndProc((WXHWND)hwnd) )
|
||||||
{
|
{
|
||||||
wxSetWindowProc(hwnd, (WNDPROC)m_oldWndProc);
|
wxSetWindowProc(hwnd, m_oldWndProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_oldWndProc = NULL;
|
m_oldWndProc = NULL;
|
||||||
@@ -1322,8 +1322,7 @@ void wxWindowMSW::DissociateHandle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxCheckWindowWndProc(WXHWND hWnd,
|
bool wxCheckWindowWndProc(WXHWND hWnd, WXWNDPROC WXUNUSED(wndProc))
|
||||||
WXFARPROC WXUNUSED(wndProc))
|
|
||||||
{
|
{
|
||||||
const wxString str(wxGetWindowClass(hWnd));
|
const wxString str(wxGetWindowClass(hWnd));
|
||||||
|
|
||||||
@@ -2408,7 +2407,7 @@ WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM l
|
|||||||
{
|
{
|
||||||
WXLRESULT rc;
|
WXLRESULT rc;
|
||||||
if ( m_oldWndProc )
|
if ( m_oldWndProc )
|
||||||
rc = ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
|
rc = ::CallWindowProc(m_oldWndProc, GetHwnd(), nMsg, wParam, lParam);
|
||||||
else
|
else
|
||||||
rc = ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
|
rc = ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user