check for error in GetSelection(long *, long *); clean up SetSelect(long, long)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -650,12 +650,11 @@ void wxComboBox::SetInsertionPointEnd()
|
|||||||
|
|
||||||
long wxComboBox::GetInsertionPoint() const
|
long wxComboBox::GetInsertionPoint() const
|
||||||
{
|
{
|
||||||
#ifdef __WIN32__
|
// CB_GETEDITSEL returns the index of the last character after selection in
|
||||||
DWORD Pos=(DWORD)SendMessage(GetHwnd(), CB_GETEDITSEL, 0, 0L);
|
// its high-order word
|
||||||
return Pos&0xFFFF;
|
DWORD pos= (DWORD)::SendMessage(GetHwnd(), CB_GETEDITSEL, 0, 0L);
|
||||||
#else
|
|
||||||
return 0;
|
return HIWORD(pos);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextPos wxComboBox::GetLastPosition() const
|
wxTextPos wxComboBox::GetLastPosition() const
|
||||||
@@ -691,19 +690,15 @@ void wxComboBox::Remove(long from, long to)
|
|||||||
|
|
||||||
void wxComboBox::SetSelection(long from, long to)
|
void wxComboBox::SetSelection(long from, long to)
|
||||||
{
|
{
|
||||||
HWND hWnd = GetHwnd();
|
// if from and to are both -1, it means (in wxWidgets) that all text should
|
||||||
long fromChar = from;
|
// be selected, translate this into Windows convention
|
||||||
long toChar = to;
|
if ( (from == -1) && (to == -1) )
|
||||||
// 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))
|
|
||||||
{
|
{
|
||||||
fromChar = 0;
|
from = 0;
|
||||||
toChar = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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"));
|
wxLogDebug(_T("CB_SETEDITSEL failed"));
|
||||||
}
|
}
|
||||||
@@ -712,10 +707,17 @@ void wxComboBox::SetSelection(long from, long to)
|
|||||||
void wxComboBox::GetSelection(long* from, long* to) const
|
void wxComboBox::GetSelection(long* from, long* to) const
|
||||||
{
|
{
|
||||||
DWORD dwStart, dwEnd;
|
DWORD dwStart, dwEnd;
|
||||||
::SendMessage(GetHwnd(), CB_GETEDITSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
|
if ( ::SendMessage(GetHwnd(), CB_GETEDITSEL,
|
||||||
|
(WPARAM)&dwStart, (LPARAM)&dwEnd) == CB_ERR )
|
||||||
*from = dwStart;
|
{
|
||||||
*to = dwEnd;
|
*from =
|
||||||
|
*to = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*from = dwStart;
|
||||||
|
*to = dwEnd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxComboBox::GetSelection() const
|
int wxComboBox::GetSelection() const
|
||||||
|
Reference in New Issue
Block a user