Fix retrieving the size of item label in native MSW wxListCtrl

Closes https://github.com/wxWidgets/wxWidgets/pull/1461

Closes #11355.
This commit is contained in:
oneeyeman1
2019-08-02 18:52:12 -05:00
committed by Vadim Zeitlin
parent 32d8b5954a
commit da524ebacb
2 changed files with 19 additions and 5 deletions

View File

@@ -1247,7 +1247,6 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
LogEvent(event, "OnListKeyDown");
event.Skip();
return;
}
switch ( event.GetKeyCode() )
@@ -1325,10 +1324,15 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
wxLogError("Failed to retrieve rect of item %ld column %d", item, subItem + 1);
break;
}
wxLogMessage("Bounding rect of item %ld column %d is (%d, %d)-(%d, %d)",
item, subItem + 1,
r.x, r.y, r.x + r.width, r.y + r.height);
wxString message = "Bounding rect of %s item %ld column %d is (%d, %d)-(%d, %d)";
wxString part;
if( code == wxLIST_RECT_BOUNDS )
part = "subitem";
if( code == wxLIST_RECT_ICON )
part = "icon";
if( code == wxLIST_RECT_LABEL )
part = "label";
wxLogMessage( message, part, item, subItem + 1, r.x, r.y, r.x + r.width, r.y + r.height );
}
break;

View File

@@ -1241,6 +1241,16 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code)
{
return false;
}
if( code == wxLIST_RECT_LABEL )
{
RECT rectIcon;
rectIcon.top = subItem;
rectIcon.left = LVIR_ICON;
if( !( ::SendMessageA(GetHwnd(), LVM_GETSUBITEMRECT, item, (LPARAM)&rectIcon) ) )
return false;
else
rectWin.left = rectIcon.right;
}
wxCopyRECTToRect(rectWin, rect);