[PATCH v2 6/8] comctl32/listbox: Ignore certain messages and retrieve zero values with LBS_NODATA
Gabriel Ivăncescu
gabrielopcode at gmail.com
Tue Nov 6 05:30:58 CST 2018
With LBS_NODATA listboxes, LB_GETTEXT always retrieves the value zero,
LB_GETITEMDATA returns zero, and LB_SETITEMDATA does nothing. However,
all of them do check for valid indices and return LB_ERR if not valid.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
The next tests patch in the series deals with this.
dlls/comctl32/listbox.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c
index 5e33466..ab01430 100644
--- a/dlls/comctl32/listbox.c
+++ b/dlls/comctl32/listbox.c
@@ -762,7 +762,8 @@ static LRESULT LISTBOX_GetText( LB_DESCR *descr, INT index, LPWSTR buffer, BOOL
} else
{
if (buffer)
- *((DWORD *)buffer) = *(DWORD *)&descr->items[index].data;
+ *((DWORD *)buffer) = (descr->style & LBS_NODATA) ? 0 :
+ *(DWORD *)&descr->items[index].data;
len = sizeof(DWORD);
}
return len;
@@ -2635,7 +2636,7 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam,
SetLastError(ERROR_INVALID_INDEX);
return LB_ERR;
}
- return descr->items[wParam].data;
+ return (descr->style & LBS_NODATA) ? 0 : descr->items[wParam].data;
case LB_SETITEMDATA:
if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
@@ -2643,7 +2644,7 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam,
SetLastError(ERROR_INVALID_INDEX);
return LB_ERR;
}
- descr->items[wParam].data = lParam;
+ if (!(descr->style & LBS_NODATA)) descr->items[wParam].data = lParam;
/* undocumented: returns TRUE, not LB_OKAY (0) */
return TRUE;
--
2.19.1
More information about the wine-devel
mailing list