}
}
-void wxListBox::SetSelection(int N, bool select)
+void wxListBox::DoSetSelection(int N, bool select)
{
wxCHECK_RET( N == wxNOT_FOUND ||
(N >= 0 && N < m_noItems),
wxString wxListBox::GetString(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, wxEmptyString,
- wxT("invalid index in wxListBox::GetClientData") );
+ wxT("invalid index in wxListBox::GetString") );
int len = ListBox_GetTextLen(GetHwnd(), N);
// +1 for terminating NUL
wxString result;
- wxChar* buffer = result.GetWriteBuf(len + 1);
- ListBox_GetText(GetHwnd(), N, buffer);
- result.UngetWriteBuf();
+ ListBox_GetText(GetHwnd(), N, (wxChar*)wxStringBuffer(result, len + 1));
return result;
}
return;
TEXTMETRIC lpTextMetric;
- if ( !s.IsEmpty() )
+ if ( !s.empty() )
{
int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L);
HDC dc = GetWindowDC(GetHwnd());
HFONT oldFont = 0;
- if (GetFont().Ok() && GetFont().GetResourceHandle())
+ if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
int largestExtent = 0;
HDC dc = GetWindowDC(GetHwnd());
HFONT oldFont = 0;
- if (GetFont().Ok() && GetFont().GetResourceHandle())
+ if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
- // FIXME: buffer overflow!!
- wxChar buf[1024];
for (int i = 0; i < m_noItems; i++)
{
- int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf);
- buf[len] = 0;
+ wxString str = GetString(i);
SIZE extentXY;
- ::GetTextExtentPoint(dc, buf, len, &extentXY);
+ ::GetTextExtentPoint(dc, str.c_str(), str.length(), &extentXY);
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (extentX > largestExtent)
largestExtent = extentX;
event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
}
- event.m_commandInt = n;
+ event.SetInt(n);
return GetEventHandler()->ProcessEvent(event);
}