X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c832ef4985a506330691e11ac13240355ed7195b..cfce733e1732b46ebb076ef10fae5a7d552dc2f9:/src/msw/combobox.cpp diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 7b65a4701d..283eab16ac 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -304,6 +304,11 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { + // pretend that wxComboBox is hidden while it is positioned and resized and + // show it only right before leaving this method because otherwise there is + // some noticeable flicker while the control rearranges itself + m_isShown = FALSE; + // first create wxWin object if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return FALSE; @@ -326,7 +331,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, // and now create the MSW control - if ( !MSWCreateControl(_T("COMBOBOX"), msStyle, pos, size, wxEmptyString, (WXDWORD)-1, false) ) + if ( !MSWCreateControl(_T("COMBOBOX"), msStyle) ) return FALSE; // A choice/combobox normally has a white background (or other, depending @@ -360,8 +365,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, ); } - // finally, show the combo box - Show(true); + // and finally, show the control + Show(TRUE); return TRUE; } @@ -371,9 +376,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, void wxComboBox::SetValue(const wxString& value) { // If newlines are denoted by just 10, must stick 13 in front. - int singletons = 0; - int len = value.Length(); - int i; + size_t singletons = 0; + size_t len = value.Length(); + size_t i; for (i = 0; i < len; i ++) { if ((i > 0) && (value[i] == 10) && (value[i-1] != 13)) @@ -381,8 +386,9 @@ void wxComboBox::SetValue(const wxString& value) } if (singletons > 0) { - wxChar *tmp = new wxChar[len + singletons + 1]; - int j = 0; + wxString tmp; + tmp.Alloc(len + singletons); + size_t j = 0; for (i = 0; i < len; i ++) { if ((i > 0) && (value[i] == 10) && (value[i-1] != 13)) @@ -393,12 +399,16 @@ void wxComboBox::SetValue(const wxString& value) tmp[j] = value[i]; j ++; } - tmp[j] = 0; - SetWindowText(GetHwnd(), tmp); - delete[] tmp; + if (GetWindowStyle() & wxCB_READONLY) + SetStringSelection(tmp); + else + SetWindowText(GetHwnd(), tmp.c_str()); } else - SetWindowText(GetHwnd(), value); + if (GetWindowStyle() & wxCB_READONLY) + SetStringSelection(value); + else + SetWindowText(GetHwnd(), value.c_str()); } // Clipboard operations