X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c085e333984dc079a001cd3f581aeb1f51a1f227..0492c5a094d1baac126331385d66d2f66aa5db52:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 2dd43b3b64..9de6a74b3b 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -23,6 +23,9 @@ #ifndef WX_PRECOMP #include "wx/listbox.h" #include "wx/settings.h" +#include "wx/brush.h" +#include "wx/font.h" +#include "wx/dc.h" #endif #include "wx/msw/private.h" @@ -30,9 +33,11 @@ #include #include +#ifndef __TWIN32__ #ifdef __GNUWIN32__ #include #endif +#endif #ifdef GetCharWidth #undef GetCharWidth @@ -149,7 +154,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_noItems = n; + m_noItems = 0; m_hWnd = 0; m_selected = 0; @@ -211,7 +216,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, wxCHECK_MSG( m_hWnd, FALSE, "Failed to create listbox" ); -#if CTL3D +#if wxUSE_CTL3D if (want3D) { Ctl3dSubclassCtl(hwnd); @@ -227,6 +232,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Append(choices[ui]); } + /* Not needed -- done in Append #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { for (ui = 0; ui < (size_t)n; ui++) { @@ -238,11 +244,12 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, } } #endif +*/ if ( (m_windowStyle & wxLB_MULTIPLE) == 0 ) SendMessage(hwnd, LB_SETCURSEL, 0, 0); - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); SetSize(x, y, width, height); @@ -294,7 +301,7 @@ void wxListBox::Append(const wxString& item) #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { - wxOwnerDrawn *pNewItem = CreateItem(-1); // dummy argument + wxOwnerDrawn *pNewItem = CreateItem(index); // dummy argument pNewItem->SetName(item); m_aItems.Add(pNewItem); ListBox_SetItemData(hwnd, index, pNewItem); @@ -493,7 +500,7 @@ void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags) int cx; // button font dimensions int cy; - wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont()); float control_width, control_height, control_x, control_y; @@ -538,8 +545,8 @@ void wxListBox::SetHorizontalExtent(const wxString& s) int existingExtent = (int)SendMessage(hwnd, LB_GETHORIZONTALEXTENT, 0, 0L); HDC dc = GetWindowDC(hwnd); HFONT oldFont = 0; - if (GetFont() && GetFont()->GetResourceHandle()) - oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle()); + if (GetFont().Ok() && GetFont().GetResourceHandle()) + oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle()); GetTextMetrics(dc, &lpTextMetric); SIZE extentXY; @@ -559,8 +566,8 @@ void wxListBox::SetHorizontalExtent(const wxString& s) int largestExtent = 0; HDC dc = GetWindowDC(hwnd); HFONT oldFont = 0; - if (GetFont() && GetFont()->GetResourceHandle()) - oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle()); + if (GetFont().Ok() && GetFont().GetResourceHandle()) + oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle()); GetTextMetrics(dc, &lpTextMetric); int i; @@ -681,7 +688,7 @@ void wxListBox::Command (wxCommandEvent & event) WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { -#if CTL3D +#if wxUSE_CTL3D if ( m_useCtl3D ) { HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);