Avoid spurious errors when getting wxChoice or wxListBox client data in wxMSW.

Even after the changes of r70415, we could still report an error when the
item client data was set to -1 (== CB_ERR) as checking for GetLastError() was
not enough, we need to also ensure that the last error is reset before trying
to get the client data.

Also apply the same fix to wxListBox and add the tests verifying that this
does work correctly.

Closes #13883.

Also fix wxListBox::GetClientData().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74994 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-10-14 15:07:44 +00:00
parent 78a9e78ffd
commit 9d7f0c5f7e
3 changed files with 25 additions and 0 deletions

View File

@@ -304,6 +304,10 @@ bool wxListBox::IsSelected(int N) const
void *wxListBox::DoGetItemClientData(unsigned int n) const
{
// This is done here for the same reasons as in wxChoice method with the
// same name.
SetLastError(ERROR_SUCCESS);
LPARAM rc = SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
if ( rc == LB_ERR && GetLastError() != ERROR_SUCCESS )
{