// list box item declaration and implementation
// ============================================================================
// list box item declaration and implementation
// ============================================================================
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// we don't support LBS_OWNERDRAWVARIABLE yet
wstyle |= LBS_OWNERDRAWFIXED;
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// we don't support LBS_OWNERDRAWVARIABLE yet
wstyle |= LBS_OWNERDRAWFIXED;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if ( want3D || (m_windowStyle & wxSIMPLE_BORDER)
- || (m_windowStyle & wxRAISED_BORDER)
- || (m_windowStyle & wxSUNKEN_BORDER)
- || (m_windowStyle & wxDOUBLE_BORDER) ) {
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
+ {
- HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL,
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "LISTBOX", NULL,
- uint ui;
- for (ui = 0; ui < (uint)n; ui++) {
- SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]);
+ size_t ui;
+ for (ui = 0; ui < (size_t)n; ui++) {
+ Append(choices[ui]);
// create new item which will process WM_{DRAW|MEASURE}ITEM messages
wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
// create new item which will process WM_{DRAW|MEASURE}ITEM messages
wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
- if ((m_windowStyle & wxLB_MULTIPLE) == 0)
- SendMessage(wx_list, LB_SETCURSEL, 0, 0);
+ if ( (m_windowStyle & wxLB_MULTIPLE) == 0 )
+ SendMessage(hwnd, LB_SETCURSEL, 0, 0);
SetSize(x, y, width, height);
SetSize(x, y, width, height);
void wxListBox::SetupColours(void)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
void wxListBox::SetupColours(void)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// client data must be pointer to wxOwnerDrawn, otherwise we would crash
// in OnMeasure/OnDraw.
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// client data must be pointer to wxOwnerDrawn, otherwise we would crash
// in OnMeasure/OnDraw.
// If we're prepared to use the existing size, then...
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
{
// If we're prepared to use the existing size, then...
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
{
- wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+ wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
float control_width, control_height, control_x, control_y;
float control_width, control_height, control_x, control_y;
int existingExtent = (int)SendMessage(hwnd, LB_GETHORIZONTALEXTENT, 0, 0L);
HDC dc = GetWindowDC(hwnd);
HFONT oldFont = 0;
int existingExtent = (int)SendMessage(hwnd, LB_GETHORIZONTALEXTENT, 0, 0L);
HDC dc = GetWindowDC(hwnd);
HFONT oldFont = 0;
- if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+ if (GetFont().Ok() && GetFont().GetResourceHandle())
+ oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
- if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+ if (GetFont().Ok() && GetFont().GetResourceHandle())
+ oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{