X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd71308fc89eac2dd212b715eba68a993fa78f53..94b49b9303a9fd119e24d1b07263f5bb0643afa5:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 711d73cf00..40f02d0f05 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -149,7 +149,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; @@ -198,37 +198,36 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, // 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) ) + { wstyle |= WS_BORDER; } - HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL, + m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "LISTBOX", NULL, wstyle | WS_CHILD, 0, 0, 0, 0, (HWND)parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); - m_hWnd = (WXHWND)wx_list; + wxCHECK_MSG( m_hWnd, FALSE, "Failed to create listbox" ); #if CTL3D if (want3D) { - Ctl3dSubclassCtl(wx_list); + Ctl3dSubclassCtl(hwnd); m_useCtl3D = TRUE; } #endif // Subclass again to catch messages - SubclassWin((WXHWND)wx_list); + SubclassWin(m_hWnd); size_t ui; for (ui = 0; ui < (size_t)n; ui++) { - SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]); + 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++) { @@ -236,19 +235,20 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, wxOwnerDrawn *pNewItem = CreateItem(ui); pNewItem->SetName(choices[ui]); m_aItems.Add(pNewItem); - ListBox_SetItemData(wx_list, ui, pNewItem); + ListBox_SetItemData(hwnd, ui, pNewItem); } } #endif +*/ - 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); - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); SetSize(x, y, width, height); - ShowWindow(wx_list, SW_SHOW); + Show(TRUE); return TRUE; } @@ -296,7 +296,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); @@ -495,7 +495,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, & GetFont()); float control_width, control_height, control_x, control_y; @@ -540,8 +540,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; @@ -561,8 +561,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;