diff --git a/include/wx/msw/slider.h b/include/wx/msw/slider.h index d6c2400cd3..23de38a607 100644 --- a/include/wx/msw/slider.h +++ b/include/wx/msw/slider.h @@ -106,6 +106,10 @@ protected: wxRect GetBoundingBox() const; // Get the height and, if the pointers are non NULL, widths of both labels. + // + // Notice that the return value will be 0 if we don't have wxSL_LABELS + // style but we do fill widthMin and widthMax even if we don't have + // wxSL_MIN_MAX_LABELS style set so the caller should account for it. int GetLabelsSize(int *widthMin = NULL, int *widthMax = NULL) const; diff --git a/src/msw/slider.cpp b/src/msw/slider.cpp index b2df912ba1..f7aefdd599 100644 --- a/src/msw/slider.cpp +++ b/src/msw/slider.cpp @@ -369,16 +369,8 @@ int wxSlider::GetLabelsSize(int *widthMin, int *widthMax) const { if ( widthMin && widthMax ) { - if ( HasFlag(wxSL_MIN_MAX_LABELS) ) - { - *widthMin = GetTextExtent(Format(m_rangeMin)).x; - *widthMax = GetTextExtent(Format(m_rangeMax)).x; - } - else - { - *widthMin = - *widthMax = 0; - } + *widthMin = GetTextExtent(Format(m_rangeMin)).x; + *widthMax = GetTextExtent(Format(m_rangeMax)).x; } return HasFlag(wxSL_LABELS) ? GetCharHeight() : 0; @@ -398,6 +390,11 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height) maxLabelWidth; const int labelHeight = GetLabelsSize(&minLabelWidth, &maxLabelWidth); const int longestLabelWidth = wxMax(minLabelWidth, maxLabelWidth); + if ( !HasFlag(wxSL_MIN_MAX_LABELS) ) + { + minLabelWidth = + maxLabelWidth = 0; + } int labelOffset = 0; int tickOffset = 0; @@ -594,7 +591,8 @@ wxSize wxSlider::DoGetBestSize() const int hLabel = GetLabelsSize(&widthMin, &widthMax); // account for the labels - size.x += HGAP + wxMax(widthMin, widthMax); + if ( HasFlag(wxSL_MIN_MAX_LABELS) ) + size.x += HGAP + wxMax(widthMin, widthMax); // labels are indented relative to the slider itself size.y += hLabel;