X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/51cdee11e0cbf47d78584822aaaf1eb975a992ea..964f23b70eb72fe6f35b6cfe0b5642408239b4d6:/src/msw/combobox.cpp diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 4bb8998363..0bd353a41a 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -558,6 +558,9 @@ void wxComboBox::SelectAll() bool wxComboBox::CanUndo() const { + if (!IsEditable()) + return false; + HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) return ::SendMessage(hEditWnd, EM_CANUNDO, 0, 0) != 0; @@ -567,6 +570,9 @@ bool wxComboBox::CanUndo() const bool wxComboBox::CanRedo() const { + if (!IsEditable()) + return false; + HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) return ::SendMessage(hEditWnd, EM_CANUNDO, 0, 0) != 0; @@ -589,7 +595,7 @@ bool wxComboBox::CanCopy() const bool wxComboBox::CanCut() const { - return CanCopy() && IsEditable(); + return IsEditable() && CanCopy() ; } bool wxComboBox::CanPaste() const @@ -650,12 +656,11 @@ void wxComboBox::SetInsertionPointEnd() long wxComboBox::GetInsertionPoint() const { -#ifdef __WIN32__ - DWORD Pos=(DWORD)SendMessage(GetHwnd(), CB_GETEDITSEL, 0, 0L); - return Pos&0xFFFF; -#else - return 0; -#endif + // CB_GETEDITSEL returns the index of the last character after selection in + // its high-order word + DWORD pos= (DWORD)::SendMessage(GetHwnd(), CB_GETEDITSEL, 0, 0L); + + return HIWORD(pos); } wxTextPos wxComboBox::GetLastPosition() const @@ -691,19 +696,15 @@ void wxComboBox::Remove(long from, long to) void wxComboBox::SetSelection(long from, long to) { - HWND hWnd = GetHwnd(); - long fromChar = from; - long toChar = to; - // if from and to are both -1, it means - // (in wxWidgets) that all text should be selected. - // This translates into Windows convention - if ((from == -1) && (to == -1)) + // if from and to are both -1, it means (in wxWidgets) that all text should + // be selected, translate this into Windows convention + if ( (from == -1) && (to == -1) ) { - fromChar = 0; - toChar = -1; + from = 0; } - if ( SendMessage(hWnd, CB_SETEDITSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar)) == CB_ERR ) + if ( SendMessage(GetHwnd(), CB_SETEDITSEL, + 0, (LPARAM)MAKELONG(from, to)) == CB_ERR ) { wxLogDebug(_T("CB_SETEDITSEL failed")); } @@ -712,10 +713,17 @@ void wxComboBox::SetSelection(long from, long to) void wxComboBox::GetSelection(long* from, long* to) const { DWORD dwStart, dwEnd; - ::SendMessage(GetHwnd(), CB_GETEDITSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); - - *from = dwStart; - *to = dwEnd; + if ( ::SendMessage(GetHwnd(), CB_GETEDITSEL, + (WPARAM)&dwStart, (LPARAM)&dwEnd) == CB_ERR ) + { + *from = + *to = 0; + } + else + { + *from = dwStart; + *to = dwEnd; + } } int wxComboBox::GetSelection() const