// The new window view style
DWORD dwStyleNew = MSWGetStyle(m_windowStyle, NULL);
+ // some styles are not returned by MSWGetStyle()
+ if ( IsShown() )
+ dwStyleNew |= WS_VISIBLE;
+
// Get the current window style.
DWORD dwStyleOld = ::GetWindowLong(GetHwnd(), GWL_STYLE);
+ // we don't have wxVSCROLL style, but the list control may have it,
+ // don't change it then
+ dwStyleNew |= dwStyleOld & (WS_HSCROLL | WS_VSCROLL);
+
// Only set the window style if the view bits have changed.
if ( dwStyleOld != dwStyleNew )
{
flag = flag & ~wxLC_MASK_SORT;
}
- if ( flag & style )
- {
- if ( !add )
- flag -= style;
- }
+ if ( add )
+ flag |= style;
else
- {
- if ( add )
- {
- flag |= style;
- }
- }
-
- m_windowStyle = flag;
+ flag &= ~style;
- UpdateStyle();
+ SetWindowStyleFlag(flag);
}
// Set the whole window style
void wxListCtrl::SetWindowStyleFlag(long flag)
{
- m_windowStyle = flag;
+ if ( flag != m_windowStyle )
+ {
+ m_windowStyle = flag;
+
+ UpdateStyle();
- UpdateStyle();
+ Refresh();
+ }
}
// ----------------------------------------------------------------------------
// Deletes all items
bool wxListCtrl::DeleteAllItems()
{
- FreeAllInternalData();
return ListView_DeleteAllItems(GetHwnd()) != 0;
}
break;
case HDN_GETDISPINFOW:
- {
- LPNMHDDISPINFOW info = (LPNMHDDISPINFOW) lParam;
- // This is a fix for a strange bug under XP.
- // Normally, info->iItem is a valid index, but
- // sometimes this is a silly (large) number
- // and when we return false via wxControl::MSWOnNotify
- // to indicate that it hasn't yet been processed,
- // there's a GPF in Windows.
- // By returning true here, we avoid further processing
- // of this strange message.
- if ( (unsigned)info->iItem >= (unsigned)GetColumnCount() )
- return true;
- }
- // fall through
+ // letting Windows XP handle this message results in mysterious
+ // crashes in comctl32.dll seemingly because of bad message
+ // parameters
+ //
+ // I have no idea what is the real cause of the bug (which is,
+ // just to make things interesting, is impossible to reproduce
+ // reliably) but ignoring all these messages does fix it and
+ // doesn't seem to have any negative consequences
+ return true;
default:
return wxControl::MSWOnNotify(idCtrl, lParam, result);
// notifications - this makes deleting all items from a list ctrl
// much faster
*result = TRUE;
+
+ // also, we may free all user data now (couldn't do it before as
+ // the user should have access to it in OnDeleteAllItems() handler)
+ FreeAllInternalData();
return true;
case LVN_ENDLABELEDITA: