+ if ( nMsg == WM_NCHITTEST )
+ {
+ // This code breaks some other processing such as enter/leave tracking
+ // so it's off by default.
+
+ static int s_useHTClient = -1;
+ if (s_useHTClient == -1)
+ s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient"));
+ if (s_useHTClient == 1)
+ {
+ int xPos = LOWORD(lParam); // horizontal position of cursor
+ int yPos = HIWORD(lParam); // vertical position of cursor
+
+ ScreenToClient(&xPos, &yPos);
+
+ // Make sure you can drag by the top of the groupbox, but let
+ // other (enclosed) controls get mouse events also
+ if ( yPos < 10 )
+ return (long)HTCLIENT;
+ }
+ }
+#endif // !__WXWINCE__
+
+ return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
+{
+ wxStaticBoxBase::GetBordersForSizer(borderTop, borderOther);
+
+ // if not using correct (but backwards cojmpatible) text metrics
+ // calculations, we need to add some extra margin or otherwise static box
+ // title is clipped
+#if !wxDIALOG_UNIT_COMPATIBILITY
+ if ( !GetLabel().empty() )
+ *borderTop += GetCharHeight()/3;
+#endif // !wxDIALOG_UNIT_COMPATIBILITY
+}
+
+// MSWGetRegionWithoutSelf helper: removes the given rectangle from region
+static inline void
+SubtractRectFromRgn(HRGN hrgn, int left, int top, int right, int bottom)
+{
+ AutoHRGN hrgnRect(::CreateRectRgn(left, top, right, bottom));
+ if ( !hrgnRect )
+ {
+ wxLogLastError(_T("CreateRectRgn()"));
+ return;
+ }
+
+ ::CombineRgn(hrgn, hrgn, hrgnRect, RGN_DIFF);
+}
+
+void wxStaticBox::MSWGetRegionWithoutSelf(WXHRGN hRgn, int w, int h)
+{
+ HRGN hrgn = (HRGN)hRgn;
+
+ // remove the area occupied by the static box borders from the region
+ int borderTop, border;
+ GetBordersForSizer(&borderTop, &border);
+
+ // top
+ SubtractRectFromRgn(hrgn, 0, 0, w, borderTop);
+
+ // bottom
+ SubtractRectFromRgn(hrgn, 0, h - border, w, h);
+
+ // left
+ SubtractRectFromRgn(hrgn, 0, 0, border, h);
+
+ // right
+ SubtractRectFromRgn(hrgn, w - border, 0, w, h);
+}
+
+WXHRGN wxStaticBox::MSWGetRegionWithoutChildren()
+{
+ RECT rc;
+ ::GetWindowRect(GetHwnd(), &rc);
+ HRGN hrgn = ::CreateRectRgn(rc.left, rc.top, rc.right + 1, rc.bottom + 1);
+
+ // iterate over all child windows (not just wxWindows but all windows)
+ for ( HWND child = ::GetWindow(GetHwndOf(GetParent()), GW_CHILD);
+ child;
+ child = ::GetWindow(child, GW_HWNDNEXT) )
+ {
+ wxWindow *childWindow = wxGetWindowFromHWND((WXHWND) child);
+
+ // can't just test for (this != child) here since if a wxStaticBox
+ // overlaps another wxStaticBox then neither are drawn. The overlapping
+ // region will flicker but we shouldn't have overlapping windows anyway.
+ if ( !childWindow || !wxDynamicCast(childWindow, wxStaticBox) )
+ {
+ ::GetWindowRect(child, &rc);
+ if ( ::RectInRegion(hrgn, &rc) )