// the image list
wxXPButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap)
: m_iml(bitmap.GetWidth(), bitmap.GetHeight(), true /* use mask */,
- wxAnyButton::State_Max),
+ wxAnyButton::State_Max + 1 /* see "pulse" comment below */),
m_hwndBtn(GetHwndOf(btn))
{
// initialize all bitmaps except for the disabled one to normal state
#endif
}
+ // In addition to the states supported by wxWidgets such as normal,
+ // hot, pressed, disabled and focused, we need to add bitmap for
+ // another state when running under Windows 7 -- the so called "stylus
+ // hot" state corresponding to PBS_STYLUSHOT constant. While it's
+ // documented in MSDN as being only used with tablets, it is a lie as
+ // a focused button actually alternates between the image list elements
+ // with PBS_DEFAULTED and PBS_STYLUSHOT indices and, in particular,
+ // just disappears during half of the time if the latter is not set so
+ // we absolutely must set it.
+ //
+ // This also explains why we need to allocate an extra slot in the
+ // image list ctor above, the slot State_Max is used for this one.
+ m_iml.Add(bitmap);
+
m_data.himl = GetHimagelistOf(&m_iml);
// no margins by default
{
m_iml.Replace(which, bitmap);
+ // As we want the focused button to always show its bitmap, we need to
+ // update the "stylus hot" one to match it to avoid any pulsing.
+ if ( which == wxAnyButton::State_Focused )
+ m_iml.Replace(wxAnyButton::State_Max, bitmap);
+
UpdateImageInfo();
}