]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/tbar95.cpp
Added wxDragLink
[wxWidgets.git] / src / msw / tbar95.cpp
index 9bbd2d4ce10076d81479a55f78c2f6accde6ee3f..afa81726ae1e6f8346105be550dcb6e4f442c67f 100644 (file)
 #include "wx/msw/dib.h"
 #include "wx/app.h"         // for GetComCtl32Version
 
+#if defined(__MWERKS__) && defined(__WXMSW__)
+// including <windef.h> for max definition doesn't seem
+// to work using CodeWarrior 6 Windows. So we define it
+// here. (Otherwise we get a undefined identifier 'max'
+// later on in this file.) (Added by dimitri@shortcut.nl)
+#   ifndef max
+#       define max(a,b)            (((a) > (b)) ? (a) : (b))
+#   endif
+
+#endif
+
 // ----------------------------------------------------------------------------
 // conditional compilation
 // ----------------------------------------------------------------------------
@@ -196,6 +207,8 @@ void wxToolBar::Init()
 
     m_defaultWidth = DEFAULTBITMAPX;
     m_defaultHeight = DEFAULTBITMAPY;
+
+    m_pInTool = 0;
 }
 
 bool wxToolBar::Create(wxWindow *parent,
@@ -895,7 +908,9 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
     pt.x = x;
     pt.y = y;
     int index = (int)::SendMessage(GetHwnd(), TB_HITTEST, 0, (LPARAM)&pt);
-    if ( index < 0 )
+    // MBN: when the point ( x, y ) is close to the toolbar border
+    //      TB_HITTEST returns m_nButtons ( not -1 )
+    if ( index < 0 || (size_t)index >= m_nButtons )
     {
         // it's a separator or there is no tool at all there
         return (wxToolBarToolBase *)NULL;