]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/radiobox.cpp
fix for potention crash when conversion fails
[wxWidgets.git] / src / msw / radiobox.cpp
index 9f0c6b131eb9638071897203c9c2541c46e4b3dc..66534b1e2ad23d0a99b148c7a07cf4be5db4a368 100644 (file)
 
 #if wxUSE_RADIOBOX
 
+#include "wx/radiobox.h"
+
 #ifndef WX_PRECOMP
     #include "wx/bitmap.h"
     #include "wx/brush.h"
-    #include "wx/radiobox.h"
     #include "wx/settings.h"
     #include "wx/log.h"
 #endif
@@ -655,6 +656,23 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
     }
 }
 
+int wxRadioBox::GetItemFromPoint(const wxPoint& pt) const
+{
+    const unsigned int count = GetCount();
+    for ( unsigned int i = 0; i < count; i++ )
+    {
+        RECT rect = wxGetWindowRect((*m_radioButtons)[i]);
+
+        if ( rect.left <= pt.x && pt.x < rect.right &&
+                rect.top  <= pt.y && pt.y < rect.bottom )
+        {
+            return i;
+        }
+    }
+
+    return wxNOT_FOUND;
+}
+
 // ----------------------------------------------------------------------------
 // radio box drawing
 // ----------------------------------------------------------------------------
@@ -706,32 +724,6 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
                 return lDlgCode | DLGC_WANTARROWS;
             }
 
-#if wxUSE_TOOLTIPS
-        case WM_NOTIFY:
-            {
-                NMHDR* hdr = (NMHDR *)lParam;
-                if ( hdr->code == TTN_NEEDTEXT )
-                {
-                    wxRadioBox *
-                        radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
-
-                    wxCHECK_MSG( radiobox, 0,
-                                 wxT("radio button without radio box?") );
-
-                    wxToolTip *tooltip = radiobox->GetToolTip();
-                    if ( tooltip )
-                    {
-                        TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
-                        ttt->lpszText = (wxChar *)tooltip->GetTip().c_str();
-                    }
-
-                    // processed
-                    return 0;
-                }
-            }
-            break;
-#endif // wxUSE_TOOLTIPS
-
         case WM_KEYDOWN:
             {
                 wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);