don't generate EVT_LISTBOX_DCLICK events with incorrect indices [backport of r58405 from trunk] (closes #10429)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -154,6 +154,7 @@ wxMSW:
|
||||
- Fixed invisible CHM tooltip text bug when window text colour is black.
|
||||
- Automatically adjust toolbar's tool size if the provided bitmaps
|
||||
don't fit into the default size.
|
||||
- Don't generate EVT_LISTBOX_DCLICK events with incorrect indices.
|
||||
|
||||
|
||||
wxMSW/CE:
|
||||
|
@@ -544,12 +544,12 @@ wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
||||
|
||||
int wxListBox::DoListHitTest(const wxPoint& point) const
|
||||
{
|
||||
LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
|
||||
0L, MAKELONG(point.x, point.y));
|
||||
LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
|
||||
0, MAKELPARAM(point.x, point.y));
|
||||
|
||||
// non zero high-order word means that this item is outside of the client
|
||||
// area, IOW the point is outside of the listbox
|
||||
return HIWORD(lRes) ? wxNOT_FOUND : lRes;
|
||||
return HIWORD(lRes) ? wxNOT_FOUND : LOWORD(lRes);
|
||||
}
|
||||
|
||||
void wxListBox::SetString(unsigned int n, const wxString& s)
|
||||
@@ -702,13 +702,18 @@ wxSize wxListBox::DoGetBestSize() const
|
||||
bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
||||
{
|
||||
wxEventType evtType;
|
||||
int n;
|
||||
if ( param == LBN_SELCHANGE )
|
||||
{
|
||||
evtType = wxEVT_COMMAND_LISTBOX_SELECTED;
|
||||
n = SendMessage(GetHwnd(), LB_GETCARETINDEX, 0, 0);
|
||||
|
||||
// NB: conveniently enough, LB_ERR is the same as wxNOT_FOUND
|
||||
}
|
||||
else if ( param == LBN_DBLCLK )
|
||||
{
|
||||
evtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
|
||||
n = HitTest(ScreenToClient(wxGetMousePosition()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -716,23 +721,21 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
||||
return false;
|
||||
}
|
||||
|
||||
wxCommandEvent event(evtType, m_windowId);
|
||||
event.SetEventObject( this );
|
||||
|
||||
// retrieve the affected item
|
||||
int n = SendMessage(GetHwnd(), LB_GETCARETINDEX, 0, 0);
|
||||
if ( n != LB_ERR )
|
||||
{
|
||||
if ( HasClientObjectData() )
|
||||
event.SetClientObject( GetClientObject(n) );
|
||||
else if ( HasClientUntypedData() )
|
||||
event.SetClientData( GetClientData(n) );
|
||||
if ( n == wxNOT_FOUND )
|
||||
return false;
|
||||
|
||||
event.SetString(GetString(n));
|
||||
event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
|
||||
}
|
||||
wxCommandEvent event(evtType, m_windowId);
|
||||
event.SetEventObject(this);
|
||||
|
||||
if ( HasClientObjectData() )
|
||||
event.SetClientObject( GetClientObject(n) );
|
||||
else if ( HasClientUntypedData() )
|
||||
event.SetClientData( GetClientData(n) );
|
||||
|
||||
event.SetString(GetString(n));
|
||||
event.SetInt(n);
|
||||
event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
|
||||
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
Reference in New Issue
Block a user