]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
some updates for new methods, constants, etc.
[wxWidgets.git] / src / msw / window.cpp
index 6aa913b6b2266302ebd62ec02be038f2b7e655ee..628d0b76ec9c48ef34b997cf8c119604f35cb442 100644 (file)
@@ -46,6 +46,7 @@
     #include "wx/listbox.h"
     #include "wx/button.h"
     #include "wx/msgdlg.h"
     #include "wx/listbox.h"
     #include "wx/button.h"
     #include "wx/msgdlg.h"
+    #include "wx/settings.h"
 
     #include <stdio.h>
 #endif
 
     #include <stdio.h>
 #endif
     #include "wx/caret.h"
 #endif // wxUSE_CARET
 
     #include "wx/caret.h"
 #endif // wxUSE_CARET
 
+#if wxUSE_SPINCTRL
+    #include "wx/spinctrl.h"
+#endif // wxUSE_SPINCTRL
+
 #include "wx/intl.h"
 #include "wx/log.h"
 
 #include "wx/intl.h"
 #include "wx/log.h"
 
 #define SIF_TRACKPOS 16
 #endif
 
 #define SIF_TRACKPOS 16
 #endif
 
+#if wxUSE_MOUSEWHEEL
+    #ifndef WM_MOUSEWHEEL
+        #define WM_MOUSEWHEEL           0x020A
+        #define WHEEL_DELTA             120
+        #define SPI_GETWHEELSCROLLLINES 104
+    #endif
+#endif
+
+
 // ---------------------------------------------------------------------------
 // global variables
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // global variables
 // ---------------------------------------------------------------------------
@@ -162,7 +176,7 @@ END_EVENT_TABLE()
 // Find an item given the MS Windows id
 wxWindow *wxWindow::FindItem(long id) const
 {
 // Find an item given the MS Windows id
 wxWindow *wxWindow::FindItem(long id) const
 {
-    wxControl *item = wxDynamicCast(this, wxControl);
+    wxControl *item = wxDynamicThisCast(this, wxControl);
     if ( item )
     {
         // i it we or one of our "internal" children?
     if ( item )
     {
         // i it we or one of our "internal" children?
@@ -316,6 +330,8 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
     msflags |= WS_CHILD | WS_VISIBLE;
     if ( style & wxCLIP_CHILDREN )
         msflags |= WS_CLIPCHILDREN;
     msflags |= WS_CHILD | WS_VISIBLE;
     if ( style & wxCLIP_CHILDREN )
         msflags |= WS_CLIPCHILDREN;
+    if ( style & wxCLIP_SIBLINGS )
+        msflags |= WS_CLIPSIBLINGS;
 
     bool want3D;
     WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
 
     bool want3D;
     WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
@@ -336,12 +352,10 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
                      DLGC_WANTTAB | DLGC_WANTMESSAGE;
     }
 
                      DLGC_WANTTAB | DLGC_WANTMESSAGE;
     }
 
-    MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
-              pos.x, pos.y,
-              WidthDefault(size.x), HeightDefault(size.y),
-              msflags, NULL, exStyle);
-
-    return TRUE;
+    return MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
+                     pos.x, pos.y,
+                     WidthDefault(size.x), HeightDefault(size.y),
+                     msflags, NULL, exStyle);
 }
 
 // ---------------------------------------------------------------------------
 }
 
 // ---------------------------------------------------------------------------
@@ -865,7 +879,8 @@ WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders)
             exStyle |= WS_EX_DLGMODALFRAME;
 #if defined(__WIN95__)
         if ( style & wxRAISED_BORDER )
             exStyle |= WS_EX_DLGMODALFRAME;
 #if defined(__WIN95__)
         if ( style & wxRAISED_BORDER )
-            exStyle |= WS_EX_WINDOWEDGE;
+            // It seems that WS_EX_WINDOWEDGE doesn't work, but WS_EX_DLGMODALFRAME does
+            exStyle |= WS_EX_DLGMODALFRAME; /* WS_EX_WINDOWEDGE */;
         if ( style & wxSTATIC_BORDER )
             exStyle |= WS_EX_STATICEDGE;
 #endif
         if ( style & wxSTATIC_BORDER )
             exStyle |= WS_EX_STATICEDGE;
 #endif
@@ -970,7 +985,7 @@ void wxWindow::SetupColours()
         SetBackgroundColour(GetParent()->GetBackgroundColour());
 }
 
         SetBackgroundColour(GetParent()->GetBackgroundColour());
 }
 
-void wxWindow::OnIdle(wxIdleEvent& event)
+void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
 {
     // Check if we need to send a LEAVE event
     if ( m_mouseInWindow )
 {
     // Check if we need to send a LEAVE event
     if ( m_mouseInWindow )
@@ -996,7 +1011,7 @@ void wxWindow::OnIdle(wxIdleEvent& event)
                 state |= MK_MBUTTON;
             if ( GetKeyState( VK_RBUTTON ) )
                 state |= MK_RBUTTON;
                 state |= MK_MBUTTON;
             if ( GetKeyState( VK_RBUTTON ) )
                 state |= MK_RBUTTON;
-  
+
             wxMouseEvent event(wxEVT_LEAVE_WINDOW);
             InitMouseEvent(event, pt.x, pt.y, state);
 
             wxMouseEvent event(wxEVT_LEAVE_WINDOW);
             InitMouseEvent(event, pt.x, pt.y, state);
 
@@ -1008,7 +1023,7 @@ void wxWindow::OnIdle(wxIdleEvent& event)
 }
 
 // Set this window to be the child of 'parent'.
 }
 
 // Set this window to be the child of 'parent'.
-bool wxWindow::Reparent(wxWindow *parent)
+bool wxWindow::Reparent(wxWindowBase *parent)
 {
     if ( !wxWindowBase::Reparent(parent) )
         return FALSE;
 {
     if ( !wxWindowBase::Reparent(parent) )
         return FALSE;
@@ -1144,11 +1159,14 @@ void wxWindow::DoGetPosition(int *x, int *y) const
             ::ScreenToClient(hParentWnd, &point);
         }
 
             ::ScreenToClient(hParentWnd, &point);
         }
 
-        // We may be faking the client origin. So a window that's really at (0,
-        // 30) may appear (to wxWin apps) to be at (0, 0).
-        wxPoint pt(parent->GetClientAreaOrigin());
-        point.x -= pt.x;
-        point.y -= pt.y;
+        if ( parent )
+        {
+            // We may be faking the client origin. So a window that's really at (0,
+            // 30) may appear (to wxWin apps) to be at (0, 0).
+            wxPoint pt(parent->GetClientAreaOrigin());
+            point.x -= pt.x;
+            point.y -= pt.y;
+        }
     }
 
     if ( x )
     }
 
     if ( x )
@@ -1460,7 +1478,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
     ::ClientToScreen(hWnd, &point);
     wxCurrentPopupMenu = menu;
     ::TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL);
     ::ClientToScreen(hWnd, &point);
     wxCurrentPopupMenu = menu;
     ::TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL);
-    wxYield();
+    wxYieldIfNeeded();
     wxCurrentPopupMenu = NULL;
 
     menu->SetInvokingWindow(NULL);
     wxCurrentPopupMenu = NULL;
 
     menu->SetInvokingWindow(NULL);
@@ -1555,12 +1573,23 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
                         }
                         else if ( lDlgCode & DLGC_BUTTON )
                         {
                         }
                         else if ( lDlgCode & DLGC_BUTTON )
                         {
-                            // buttons want process Enter themselevs
+                            // let IsDialogMessage() handle this for all
+                            // buttons except the owner-drawn ones which it
+                            // just seems to ignore
+                            long style = ::GetWindowLong(msg->hwnd, GWL_STYLE);
+                            if ( (style & BS_OWNERDRAW) == BS_OWNERDRAW )
+                            {
+                                // emulate the button click
+                                wxWindow *btn = wxFindWinFromHandle((WXHWND)msg->hwnd);
+                                if ( btn )
+                                    btn->MSWCommand(BN_CLICKED, 0 /* unused */);
+                            }
+
                             bProcess = FALSE;
                         }
                         else
                         {
                             bProcess = FALSE;
                         }
                         else
                         {
-                            wxPanel *panel = wxDynamicCast(this, wxPanel);
+                            wxPanel *panel = wxDynamicThisCast(this, wxPanel);
                             wxButton *btn = NULL;
                             if ( panel )
                             {
                             wxButton *btn = NULL;
                             if ( panel )
                             {
@@ -1844,7 +1873,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             break;
 
         case WM_MOVE:
             break;
 
         case WM_MOVE:
-            processed = HandleMove(LOWORD(lParam), HIWORD(lParam));
+            processed = HandleMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
             break;
 
         case WM_SIZE:
             break;
 
         case WM_SIZE:
@@ -1885,17 +1914,21 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             break;
 
         case WM_MOUSEMOVE:
             break;
 
         case WM_MOUSEMOVE:
-           {
-                short x = LOWORD(lParam);
-                short y = HIWORD(lParam);
+            processed = HandleMouseMove(GET_X_LPARAM(lParam),
+                                        GET_Y_LPARAM(lParam),
+                                        wParam);
+            break;
 
 
-                processed = HandleMouseMove(x, y, wParam);
-           }
-           break;
+#if wxUSE_MOUSEWHEEL
+        case WM_MOUSEWHEEL:
+            processed = HandleMouseWheel(wParam, lParam);
+            break;
+#endif
 
         case WM_LBUTTONDOWN:
            // set focus to this window
 
         case WM_LBUTTONDOWN:
            // set focus to this window
-           SetFocus();
+           if (AcceptsFocus())
+                SetFocus();
 
            // fall through
 
 
            // fall through
 
@@ -1907,12 +1940,10 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
         case WM_MBUTTONDOWN:
         case WM_MBUTTONUP:
         case WM_MBUTTONDBLCLK:
         case WM_MBUTTONDOWN:
         case WM_MBUTTONUP:
         case WM_MBUTTONDBLCLK:
-            {
-                short x = LOWORD(lParam);
-                short y = HIWORD(lParam);
-
-                processed = HandleMouseEvent(message, x, y, wParam);
-            }
+            processed = HandleMouseEvent(message,
+                                         GET_X_LPARAM(lParam),
+                                         GET_Y_LPARAM(lParam),
+                                         wParam);
             break;
 
         case MM_JOY1MOVE:
             break;
 
         case MM_JOY1MOVE:
@@ -1923,12 +1954,10 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
         case MM_JOY2BUTTONDOWN:
         case MM_JOY1BUTTONUP:
         case MM_JOY2BUTTONUP:
         case MM_JOY2BUTTONDOWN:
         case MM_JOY1BUTTONUP:
         case MM_JOY2BUTTONUP:
-            {
-                int x = LOWORD(lParam);
-                int y = HIWORD(lParam);
-
-                processed = HandleJoystickEvent(message, x, y, wParam);
-            }
+            processed = HandleJoystickEvent(message,
+                                            GET_X_LPARAM(lParam),
+                                            GET_Y_LPARAM(lParam),
+                                            wParam);
             break;
 
         case WM_SYSCOMMAND:
             break;
 
         case WM_SYSCOMMAND:
@@ -2168,6 +2197,36 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
                 rc.result = TRUE;
             }
             break;
                 rc.result = TRUE;
             }
             break;
+#ifdef __WIN32__
+        case WM_HELP:
+        {
+            HELPINFO* info = (HELPINFO*) lParam;
+            // Don't yet process menu help events, just windows
+            if (info->iContextType == HELPINFO_WINDOW)
+            {
+                wxWindow* subjectOfHelp = this;
+                bool eventProcessed = FALSE;
+                while (subjectOfHelp && !eventProcessed)
+                {
+                    wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId);
+                    helpEvent.SetEventObject(this);
+                    eventProcessed = GetEventHandler()->ProcessEvent(helpEvent);
+
+                    // Go up the window hierarchy until the event is handled (or not)
+                    subjectOfHelp = subjectOfHelp->GetParent();
+                }
+                processed = eventProcessed;
+            }
+            else if (info->iContextType == HELPINFO_MENUITEM)
+            {
+                wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ;
+                helpEvent.SetEventObject(this);
+                processed = GetEventHandler()->ProcessEvent(helpEvent);
+            }
+            else processed = FALSE;
+            break;
+        }
+#endif
     }
 
     if ( !processed )
     }
 
     if ( !processed )
@@ -2184,7 +2243,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
 
 // Dialog window proc
 LONG APIENTRY _EXPORT
 
 // Dialog window proc
 LONG APIENTRY _EXPORT
-wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+wxDlgProc(HWND WXUNUSED(hWnd), UINT message, WPARAM WXUNUSED(wParam), LPARAM WXUNUSED(lParam))
 {
     if ( message == WM_INITDIALOG )
     {
 {
     if ( message == WM_INITDIALOG )
     {
@@ -2260,24 +2319,25 @@ void wxWindow::MSWDetachWindowMenu()
 {
     if ( m_hMenu )
     {
 {
     if ( m_hMenu )
     {
+        wxChar buf[1024];
         HMENU hMenu = (HMENU)m_hMenu;
 
         int N = ::GetMenuItemCount(hMenu);
         HMENU hMenu = (HMENU)m_hMenu;
 
         int N = ::GetMenuItemCount(hMenu);
-        int i;
-        for (i = 0; i < N; i++)
+        for ( int i = 0; i < N; i++ )
         {
         {
-            wxChar buf[100];
-            int chars = GetMenuString(hMenu, i, buf, 100, MF_BYPOSITION);
-            if ( !chars )
+            if ( !::GetMenuString(hMenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION) )
             {
                 wxLogLastError(wxT("GetMenuString"));
 
                 continue;
             }
 
             {
                 wxLogLastError(wxT("GetMenuString"));
 
                 continue;
             }
 
-            if ( wxStrcmp(buf, wxT("&Window")) == 0 )
+            if ( wxStrcmp(buf, _("&Window")) == 0 )
             {
             {
-                RemoveMenu(hMenu, i, MF_BYPOSITION);
+                if ( !::RemoveMenu(hMenu, i, MF_BYPOSITION) )
+                {
+                    wxLogLastError(wxT("RemoveMenu"));
+                }
 
                 break;
             }
 
                 break;
             }
@@ -2288,7 +2348,7 @@ void wxWindow::MSWDetachWindowMenu()
 bool wxWindow::MSWCreate(int id,
                          wxWindow *parent,
                          const wxChar *wclass,
 bool wxWindow::MSWCreate(int id,
                          wxWindow *parent,
                          const wxChar *wclass,
-                         wxWindow *wx_win,
+                         wxWindow *WXUNUSED(wx_win),
                          const wxChar *title,
                          int x,
                          int y,
                          const wxChar *title,
                          int x,
                          int y,
@@ -2314,10 +2374,14 @@ bool wxWindow::MSWCreate(int id,
         height1 = parent_rect.bottom - parent_rect.top;
     }
 
         height1 = parent_rect.bottom - parent_rect.top;
     }
 
-    if ( x > -1 ) x1 = x;
-    if ( y > -1 ) y1 = y;
-    if ( width > -1 ) width1 = width;
-    if ( height > -1 ) height1 = height;
+    if ( x != -1 )
+        x1 = x;
+    if ( y != -1 )
+        y1 = y;
+    if ( width != -1 )
+        width1 = width;
+    if ( height != -1 )
+        height1 = height;
 
     // unfortunately, setting WS_EX_CONTROLPARENT only for some windows in the
     // hierarchy with several embedded panels (and not all of them) causes the
 
     // unfortunately, setting WS_EX_CONTROLPARENT only for some windows in the
     // hierarchy with several embedded panels (and not all of them) causes the
@@ -2333,14 +2397,22 @@ bool wxWindow::MSWCreate(int id,
     }
 #endif // 0
 
     }
 #endif // 0
 
-    HWND hParent = (HWND)NULL;
-    if ( parent )
-        hParent = (HWND) parent->GetHWND();
+    HWND hParent = parent ? GetHwndOf(parent) : NULL;
 
     wxWndHook = this;
 
     if ( dialog_template )
     {
 
     wxWndHook = this;
 
     if ( dialog_template )
     {
+        // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
+        // app window as parent - this avoids creating modal dialogs without
+        // parent
+        if ( !hParent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
+        {
+            wxWindow *winTop = wxTheApp->GetTopWindow();
+            if ( winTop )
+                hParent = GetHwndOf(winTop);
+        }
+
         m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
                                         dialog_template,
                                         hParent,
         m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
                                         dialog_template,
                                         hParent,
@@ -2348,11 +2420,44 @@ bool wxWindow::MSWCreate(int id,
 
         if ( m_hWnd == 0 )
         {
 
         if ( m_hWnd == 0 )
         {
-            wxLogError(_("Can't find dummy dialog template!\nCheck resource include path for finding wx.rc."));
+            wxLogError(_("Can't find dialog template '%s'!\nCheck resource include path for finding wx.rc."),
+                       dialog_template);
 
             return FALSE;
         }
 
 
             return FALSE;
         }
 
+        if ( extendedStyle != 0 )
+        {
+            ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, extendedStyle);
+            ::SetWindowPos(GetHwnd(), NULL, 0, 0, 0, 0,
+                           SWP_NOSIZE |
+                           SWP_NOMOVE |
+                           SWP_NOZORDER |
+                           SWP_NOACTIVATE);
+        }
+
+#if defined(__WIN95__)
+        // For some reason, the system menu is activated when we use the
+        // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
+        if (extendedStyle & WS_EX_CONTEXTHELP)
+        {
+            wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame);
+            if ( winTop )
+            {
+                wxIcon icon = winTop->GetIcon();
+                if ( icon.Ok() )
+                {
+                    ::SendMessage(GetHwnd(), WM_SETICON,
+                                  (WPARAM)TRUE,
+                                  (LPARAM)GetHiconOf(icon));
+                }
+            }
+        }
+#endif // __WIN95__
+
+
+        // JACS: is the following still necessary? The above seems to work.
+
         // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try
         // to take care of (at least some) extended style flags ourselves
         if ( extendedStyle & WS_EX_TOPMOST )
         // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try
         // to take care of (at least some) extended style flags ourselves
         if ( extendedStyle & WS_EX_TOPMOST )
@@ -2370,7 +2475,7 @@ bool wxWindow::MSWCreate(int id,
             wxLogLastError(wxT("MoveWindow"));
         }
     }
             wxLogLastError(wxT("MoveWindow"));
         }
     }
-    else
+    else // creating a normal window, not a dialog
     {
         int controlId = 0;
         if ( style & WS_CHILD )
     {
         int controlId = 0;
         if ( style & WS_CHILD )
@@ -2406,6 +2511,7 @@ bool wxWindow::MSWCreate(int id,
     }
 
     wxWndHook = NULL;
     }
 
     wxWndHook = NULL;
+
 #ifdef __WXDEBUG__
     wxNode* node = wxWinHandleList->Member(this);
     if (node)
 #ifdef __WXDEBUG__
     wxNode* node = wxWinHandleList->Member(this);
     if (node)
@@ -2416,9 +2522,12 @@ bool wxWindow::MSWCreate(int id,
             wxLogError(wxT("A second HWND association is being added for the same window!"));
         }
     }
             wxLogError(wxT("A second HWND association is being added for the same window!"));
         }
     }
-#endif
+#endif // Debug
+
     wxAssociateWinWithHandle((HWND) m_hWnd, this);
 
     wxAssociateWinWithHandle((HWND) m_hWnd, this);
 
+    SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+
     return TRUE;
 }
 
     return TRUE;
 }
 
@@ -2525,7 +2634,7 @@ bool wxWindow::HandleEndSession(bool endSession, long logOff)
 // window creation/destruction
 // ---------------------------------------------------------------------------
 
 // window creation/destruction
 // ---------------------------------------------------------------------------
 
-bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate)
+bool wxWindow::HandleCreate(WXLPCREATESTRUCT WXUNUSED(cs), bool *mayCreate)
 {
     // TODO: should generate this event from WM_NCCREATE
     wxWindowCreateEvent event(this);
 {
     // TODO: should generate this event from WM_NCCREATE
     wxWindowCreateEvent event(this);
@@ -2635,7 +2744,7 @@ bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd))
 // miscellaneous
 // ---------------------------------------------------------------------------
 
 // miscellaneous
 // ---------------------------------------------------------------------------
 
-bool wxWindow::HandleShow(bool show, int status)
+bool wxWindow::HandleShow(bool show, int WXUNUSED(status))
 {
     wxShowEvent event(GetId(), show);
     event.m_eventObject = this;
 {
     wxShowEvent event(GetId(), show);
     event.m_eventObject = this;
@@ -2686,7 +2795,7 @@ bool wxWindow::HandleDropFiles(WXWPARAM wParam)
     return rc;
 }
 
     return rc;
 }
 
-bool wxWindow::HandleSetCursor(WXHWND hWnd,
+bool wxWindow::HandleSetCursor(WXHWND WXUNUSED(hWnd),
                                short nHitTest,
                                int WXUNUSED(mouseMsg))
 {
                                short nHitTest,
                                int WXUNUSED(mouseMsg))
 {
@@ -2766,11 +2875,9 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd,
         // cursor set, stop here
         return TRUE;
     }
         // cursor set, stop here
         return TRUE;
     }
-    else
-    {
-        // pass up the window chain
-        return FALSE;
-    }
+
+    // pass up the window chain
+    return FALSE;
 }
 
 // ---------------------------------------------------------------------------
 }
 
 // ---------------------------------------------------------------------------
@@ -2877,12 +2984,12 @@ bool wxWindow::HandleCtlColor(WXHBRUSH *brush,
 }
 
 // Define for each class of dialog and control
 }
 
 // Define for each class of dialog and control
-WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
-                              WXHWND hWnd,
-                              WXUINT nCtlColor,
-                              WXUINT message,
-                              WXWPARAM wParam,
-                              WXLPARAM lParam)
+WXHBRUSH wxWindow::OnCtlColor(WXHDC WXUNUSED(hDC),
+                              WXHWND WXUNUSED(hWnd),
+                              WXUINT WXUNUSED(nCtlColor),
+                              WXUINT WXUNUSED(message),
+                              WXWPARAM WXUNUSED(wParam),
+                              WXLPARAM WXUNUSED(lParam))
 {
     return (WXHBRUSH)0;
 }
 {
     return (WXHBRUSH)0;
 }
@@ -3076,6 +3183,7 @@ bool wxWindow::HandleGetMinMaxInfo(void *mmInfo)
 }
 
 // generate an artificial resize event
 }
 
 // generate an artificial resize event
+/* FUNCTION IS NOW A MEMBER OF wxFrame - gt
 void wxWindow::SendSizeEvent()
 {
     RECT r;
 void wxWindow::SendSizeEvent()
 {
     RECT r;
@@ -3091,6 +3199,7 @@ void wxWindow::SendSizeEvent()
     (void)::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED,
                         MAKELPARAM(r.right - r.left, r.bottom - r.top));
 }
     (void)::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED,
                         MAKELPARAM(r.right - r.left, r.bottom - r.top));
 }
+*/
 
 // ---------------------------------------------------------------------------
 // command messages
 
 // ---------------------------------------------------------------------------
 // command messages
@@ -3141,11 +3250,22 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
 
         return GetEventHandler()->ProcessEvent(event);
     }
 
         return GetEventHandler()->ProcessEvent(event);
     }
+#if wxUSE_SPINCTRL
+    else
+    {
+        // the text ctrl which is logically part of wxSpinCtrl sends WM_COMMAND
+        // notifications to its parent which we want to reflect back to
+        // wxSpinCtrl
+        wxSpinCtrl *spin = wxSpinCtrl::GetSpinForTextCtrl(control);
+        if ( spin && spin->ProcessTextCommand(cmd, id) )
+            return TRUE;
+    }
+#endif // wxUSE_SPINCTRL
 
     return FALSE;
 }
 
 
     return FALSE;
 }
 
-bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam)
+bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM WXUNUSED(lParam))
 {
     // 4 bits are reserved
     switch ( wParam & 0xFFFFFFF0 )
 {
     // 4 bits are reserved
     switch ( wParam & 0xFFFFFFF0 )
@@ -3173,6 +3293,7 @@ void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags)
     event.m_leftDown = ((flags & MK_LBUTTON) != 0);
     event.m_middleDown = ((flags & MK_MBUTTON) != 0);
     event.m_rightDown = ((flags & MK_RBUTTON) != 0);
     event.m_leftDown = ((flags & MK_LBUTTON) != 0);
     event.m_middleDown = ((flags & MK_MBUTTON) != 0);
     event.m_rightDown = ((flags & MK_RBUTTON) != 0);
+    event.m_altDown = (::GetKeyState(VK_MENU) & 0x80000000) != 0;
     event.SetTimestamp(s_currentMsg.time);
     event.m_eventObject = this;
 
     event.SetTimestamp(s_currentMsg.time);
     event.m_eventObject = this;
 
@@ -3241,6 +3362,46 @@ bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags)
     return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags);
 }
 
     return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags);
 }
 
+
+bool wxWindow::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam)
+{
+#if wxUSE_MOUSEWHEEL
+    wxMouseEvent event(wxEVT_MOUSEWHEEL);
+    InitMouseEvent(event,
+                   GET_X_LPARAM(lParam),
+                   GET_Y_LPARAM(lParam),
+                   LOWORD(wParam));
+    event.m_wheelRotation = (short)HIWORD(wParam);
+    event.m_wheelDelta = WHEEL_DELTA;
+
+#ifdef __WIN32__
+    static int s_linesPerRotation = -1;
+    if ( s_linesPerRotation == -1 )
+    {
+        if ( !::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
+                                     &s_linesPerRotation, 0))
+        {
+            // this is not supposed to happen
+            wxLogLastError(_T("SystemParametersInfo(GETWHEELSCROLLLINES)"));
+
+            // the default is 3, so use it if SystemParametersInfo() failed
+            s_linesPerRotation = 3;
+        }
+    }
+#else // Win16
+    // no SystemParametersInfo() under Win16
+    static const int s_linesPerRotation = 3;
+#endif
+
+    event.m_linesPerAction = s_linesPerRotation;
+    return GetEventHandler()->ProcessEvent(event);
+
+#else
+    return FALSE;
+#endif
+}
+
+
 // ---------------------------------------------------------------------------
 // keyboard handling
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // keyboard handling
 // ---------------------------------------------------------------------------
@@ -3277,7 +3438,7 @@ wxKeyEvent wxWindow::CreateKeyEvent(wxEventType evType,
 
 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
 // WM_KEYDOWN one
 
 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
 // WM_KEYDOWN one
-bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII)
+bool wxWindow::HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII)
 {
     bool ctrlDown = FALSE;
 
 {
     bool ctrlDown = FALSE;
 
@@ -3330,7 +3491,7 @@ bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII)
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam)
+bool wxWindow::HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam)
 {
     int id = wxCharCodeMSWToWX(wParam);
 
 {
     int id = wxCharCodeMSWToWX(wParam);
 
@@ -3352,7 +3513,7 @@ bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam)
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam)
+bool wxWindow::HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam)
 {
     int id = wxCharCodeMSWToWX(wParam);
 
 {
     int id = wxCharCodeMSWToWX(wParam);
 
@@ -3810,9 +3971,9 @@ void wxSetKeyboardHook(bool doIt)
     else
     {
         UnhookWindowsHookEx(wxTheKeyboardHook);
     else
     {
         UnhookWindowsHookEx(wxTheKeyboardHook);
-        // avoids mingw warning about statement with no effect (FreeProcInstance
-        // doesn't do anything under Win32)
-#ifndef __GNUC__
+               // avoids warning about statement with no effect (FreeProcInstance
+               // doesn't do anything under Win32)
+#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(__NT__) && !defined(__GNUWIN32__)
         FreeProcInstance(wxTheKeyboardHookProc);
 #endif
     }
         FreeProcInstance(wxTheKeyboardHookProc);
 #endif
     }
@@ -3992,6 +4153,7 @@ const char *wxGetMessageName(int message)
         case 0x0207: return "WM_MBUTTONDOWN";
         case 0x0208: return "WM_MBUTTONUP";
         case 0x0209: return "WM_MBUTTONDBLCLK";
         case 0x0207: return "WM_MBUTTONDOWN";
         case 0x0208: return "WM_MBUTTONUP";
         case 0x0209: return "WM_MBUTTONDBLCLK";
+        case 0x020A: return "WM_MOUSEWHEEL";
         case 0x0210: return "WM_PARENTNOTIFY";
         case 0x0211: return "WM_ENTERMENULOOP";
         case 0x0212: return "WM_EXITMENULOOP";
         case 0x0210: return "WM_PARENTNOTIFY";
         case 0x0211: return "WM_ENTERMENULOOP";
         case 0x0212: return "WM_EXITMENULOOP";
@@ -4330,3 +4492,38 @@ static TEXTMETRIC wxGetTextMetrics(const wxWindow *win)
 
     return tm;
 }
 
     return tm;
 }
+
+// Find the wxWindow at the current mouse position, returning the mouse
+// position.
+wxWindow* wxFindWindowAtPointer(wxPoint& WXUNUSED(pt))
+{
+    return wxFindWindowAtPoint(wxGetMousePosition());
+}
+
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    POINT pt2;
+    pt2.x = pt.x;
+    pt2.y = pt.y;
+    HWND hWndHit = ::WindowFromPoint(pt2);
+
+    wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ;
+    HWND hWnd = hWndHit;
+
+    // Try to find a window with a wxWindow associated with it
+    while (!win && (hWnd != 0))
+    {
+        hWnd = ::GetParent(hWnd);
+        win = wxFindWinFromHandle((WXHWND) hWnd) ;
+    }
+    return win;
+}
+
+// Get the current mouse position.
+wxPoint wxGetMousePosition()
+{
+    POINT pt;
+    GetCursorPos( & pt );
+    return wxPoint(pt.x, pt.y);
+}
+