X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64b397664d8d8c0acd2630ea239ab420fe7fe007..e52d9c784ed95b099017cca9301b325085c7f4d1:/src/msw/combobox.cpp diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index e8bfc1b6d5..283eab16ac 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -114,7 +114,6 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd, } break; -#if 0 case WM_GETDLGCODE: { wxCHECK_MSG( win, 0, _T("should have a parent") ); @@ -126,7 +125,6 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd, } } break; -#endif // 0 // deal with tooltips here #if wxUSE_TOOLTIPS && defined(TTN_NEEDTEXT) @@ -306,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; @@ -362,6 +365,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, ); } + // and finally, show the control + Show(TRUE); + return TRUE; } @@ -370,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)) @@ -380,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)) @@ -392,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