ReactOS 0.4.16-dev-2491-g3dc6630
listbox.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/test.h"
Include dependency graph for listbox.c:

Go to the source code of this file.

Classes

struct  listbox_prop
 
struct  listbox_stat
 
struct  listbox_test
 

Macros

#define WAIT
 
#define REDRAW
 
#define listbox_field_ok(t, s, f, got)
 
#define listbox_todo_field_ok(t, s, f, got)    todo_wine_if (t.s##_todo.f) { listbox_field_ok(t, s, f, got); }
 
#define listbox_ok(t, s, got)
 
#define listbox_test_query(exp, got)
 
#define ID_TEST_LABEL   1001
 
#define ID_TEST_LISTBOX   1002
 

Functions

static int strcmp_aw (LPCWSTR strw, const char *stra)
 
static HWND create_listbox (DWORD add_style, HWND parent)
 
static void listbox_query (HWND handle, struct listbox_stat *results)
 
static void buttonpress (HWND handle, WORD x, WORD y)
 
static void keypress (HWND handle, WPARAM keycode, BYTE scancode, BOOL extended)
 
static void check (DWORD style, const struct listbox_test test)
 
static void check_item_height (void)
 
static LRESULT WINAPI main_window_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static HWND create_parent (void)
 
static void test_ownerdraw (void)
 
static void test_LB_SELITEMRANGE (void)
 
static void test_LB_SETCURSEL (void)
 
static void test_LB_SETSEL (void)
 
static void test_listbox_height (void)
 
static void test_changing_selection_styles (void)
 
static void test_itemfrompoint (void)
 
static void test_listbox_item_data (void)
 
static void test_listbox_LB_DIR (void)
 
static BOOL on_listbox_container_create (HWND hwnd, LPCREATESTRUCTA lpcs)
 
static LRESULT CALLBACK listbox_container_window_procA (HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL RegisterListboxWindowClass (HINSTANCE hInst)
 
static void test_listbox_dlgdir (void)
 
static void test_set_count (void)
 
static DWORD (WINAPI *pGetListBoxInfo)(HWND)
 
static LRESULT WINAPI listbox_subclass_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static void test_GetListBoxInfo (void)
 
static void test_init_storage (void)
 
static void test_missing_lbuttonup (void)
 
static void test_extents (void)
 
static void test_WM_MEASUREITEM (void)
 
static void test_LBS_NODATA (void)
 
static void test_LB_FINDSTRING (void)
 
 START_TEST (listbox)
 

Variables

static const char *const strings [4]
 
static const char BAD_EXTENSION [] = "*.badtxt"
 
static unsigned int got_selchange
 
static unsigned int got_drawitem
 
static HWND g_listBox
 
static HWND g_label
 
static int lb_getlistboxinfo
 

Macro Definition Documentation

◆ ID_TEST_LABEL

#define ID_TEST_LABEL   1001

Definition at line 1421 of file listbox.c.

◆ ID_TEST_LISTBOX

#define ID_TEST_LISTBOX   1002

Definition at line 1422 of file listbox.c.

◆ listbox_field_ok

#define listbox_field_ok (   t,
  s,
  f,
  got 
)
Value:
ok (t.s.f==got.f, "style %#lx, step " #s ", field " #f \
": expected %d, got %d\n", style, t.s.f, got.f)
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLfloat f
Definition: glext.h:7540

Definition at line 130 of file listbox.c.

◆ listbox_ok

#define listbox_ok (   t,
  s,
  got 
)
Value:
listbox_todo_field_ok(t, s, anchor, got); \
listbox_todo_field_ok(t, s, caret, got); \
listbox_todo_field_ok(t, s, selcount, got)
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define listbox_todo_field_ok(t, s, f, got)
Definition: listbox.c:201

Definition at line 137 of file listbox.c.

◆ listbox_test_query

#define listbox_test_query (   exp,
  got 
)
Value:
ok(exp.selected == got.selected, "expected selected %d, got %d\n", exp.selected, got.selected); \
ok(exp.anchor == got.anchor, "expected anchor %d, got %d\n", exp.anchor, got.anchor); \
ok(exp.caret == got.caret, "expected caret %d, got %d\n", exp.caret, got.caret); \
ok(exp.selcount == got.selcount, "expected selcount %d, got %d\n", exp.selcount, got.selcount);
DWORD exp
Definition: msg.c:18625

Definition at line 459 of file listbox.c.

◆ listbox_todo_field_ok

#define listbox_todo_field_ok (   t,
  s,
  f,
  got 
)     todo_wine_if (t.s##_todo.f) { listbox_field_ok(t, s, f, got); }

Definition at line 134 of file listbox.c.

◆ REDRAW

#define REDRAW

Definition at line 37 of file listbox.c.

◆ WAIT

#define WAIT

Definition at line 36 of file listbox.c.

Function Documentation

◆ buttonpress()

static void buttonpress ( HWND  handle,
WORD  x,
WORD  y 
)
static

Definition at line 109 of file listbox.c.

110{
111 LPARAM lp=x+(y<<16);
112
113 WAIT;
116 REDRAW;
117}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
LONG_PTR LPARAM
Definition: minwindef.h:175
#define REDRAW
Definition: listbox.c:37
#define WAIT
Definition: listbox.c:36
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define MK_LBUTTON
Definition: winuser.h:2403

◆ check()

static void check ( DWORD  style,
const struct listbox_test  test 
)
static

Definition at line 144 of file listbox.c.

145{
146 struct listbox_stat answer;
147 RECT second_item;
148 int i;
149 int res;
150 HWND hLB;
151
152 hLB = create_listbox (style, 0);
153
154 listbox_query (hLB, &answer);
155 listbox_ok (test, init, answer);
156
157 SendMessageA(hLB, LB_GETITEMRECT, 1, (LPARAM) &second_item);
158 buttonpress(hLB, (WORD)second_item.left, (WORD)second_item.top);
159
160 listbox_query (hLB, &answer);
161 listbox_ok (test, click, answer);
162
163 keypress (hLB, VK_DOWN, 0x50, TRUE);
164
165 listbox_query (hLB, &answer);
166 listbox_ok (test, step, answer);
167
168 DestroyWindow (hLB);
169 hLB = create_listbox(style, 0);
170
172 listbox_query (hLB, &answer);
173 listbox_ok (test, sel, answer);
174
175 for (i = 0; i < 4 && !(style & LBS_NODATA); i++) {
177 CHAR *txt;
178 WCHAR *txtw;
179 int resA, resW;
180
181 txt = calloc(1, size + 1);
182 resA=SendMessageA(hLB, LB_GETTEXT, i, (LPARAM)txt);
183 ok(!strcmp (txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]);
184
185 txtw = calloc(1, 2 * size + 2);
186 resW=SendMessageW(hLB, LB_GETTEXT, i, (LPARAM)txtw);
187 ok(resA == resW, "Unexpected text length.\n");
188 WideCharToMultiByte( CP_ACP, 0, txtw, -1, txt, size, NULL, NULL );
189 ok(!strcmp (txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]);
190
191 free(txtw);
192 free(txt);
193 }
194
195 /* Confirm the count of items, and that an invalid delete does not remove anything */
196 res = SendMessageA(hLB, LB_GETCOUNT, 0, 0);
197 ok((res==4), "Expected 4 items, got %d\n", res);
198 res = SendMessageA(hLB, LB_DELETESTRING, -1, 0);
199 ok((res==LB_ERR), "Expected LB_ERR items, got %d\n", res);
200 res = SendMessageA(hLB, LB_DELETESTRING, 4, 0);
201 ok((res==LB_ERR), "Expected LB_ERR items, got %d\n", res);
202 res = SendMessageA(hLB, LB_GETCOUNT, 0, 0);
203 ok((res==4), "Expected 4 items, got %d\n", res);
204
205 WAIT;
206 DestroyWindow (hLB);
207}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLsizei const GLchar *const * strings
Definition: glext.h:7622
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HWND create_listbox(DWORD add_style, HWND parent)
Definition: listbox.c:131
#define listbox_ok(t, s, got)
Definition: listbox.c:204
static void listbox_query(HWND handle, struct listbox_stat *results)
Definition: listbox.c:173
static void keypress(HWND handle, WPARAM keycode, BYTE scancode, BOOL extended)
Definition: listbox.c:189
static void buttonpress(HWND handle, WORD x, WORD y)
Definition: listbox.c:181
#define calloc
Definition: rosglue.h:14
#define test
Definition: rosglue.h:37
static int init
Definition: wintirpc.c:33
#define LB_ERR
Definition: winuser.h:2468
#define LB_GETCOUNT
Definition: winuser.h:2067
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
#define LB_GETTEXT
Definition: winuser.h:2085
#define LB_GETITEMRECT
Definition: winuser.h:2072
#define LB_SELITEMRANGE
Definition: winuser.h:2093
#define LB_DELETESTRING
Definition: winuser.h:2061
#define LBS_NODATA
Definition: winuser.h:313
#define LB_GETTEXTLEN
Definition: winuser.h:2086
#define VK_DOWN
Definition: winuser.h:2263
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

◆ check_item_height()

static void check_item_height ( void  )
static

Definition at line 209 of file listbox.c.

210{
211 HWND hLB;
212 HDC hdc;
213 HFONT font;
215 INT itemHeight;
216
217 hLB = create_listbox (0, 0);
218 ok ((hdc = GetDCEx( hLB, 0, DCX_CACHE )) != 0, "Can't get hdc\n");
219 ok ((font = GetCurrentObject(hdc, OBJ_FONT)) != 0, "Can't get the current font\n");
220 ok (GetTextMetricsA( hdc, &tm ), "Can't read font metrics\n");
221 ReleaseDC( hLB, hdc);
222
223 ok (SendMessageA(hLB, WM_SETFONT, (WPARAM)font, 0) == 0, "Can't set font\n");
224
225 itemHeight = SendMessageA(hLB, LB_GETITEMHEIGHT, 0, 0);
226 ok (itemHeight == tm.tmHeight, "Item height wrong, got %d, expecting %ld\n", itemHeight, tm.tmHeight);
227
228 DestroyWindow (hLB);
229
230 hLB = CreateWindowA("LISTBOX", "TestList", LBS_OWNERDRAWVARIABLE,
231 0, 0, 100, 100, NULL, NULL, NULL, 0);
232 itemHeight = SendMessageA(hLB, LB_GETITEMHEIGHT, 0, 0);
233 ok(itemHeight == tm.tmHeight, "itemHeight %d\n", itemHeight);
234 itemHeight = SendMessageA(hLB, LB_GETITEMHEIGHT, 5, 0);
235 ok(itemHeight == tm.tmHeight, "itemHeight %d\n", itemHeight);
236 itemHeight = SendMessageA(hLB, LB_GETITEMHEIGHT, -5, 0);
237 ok(itemHeight == tm.tmHeight, "itemHeight %d\n", itemHeight);
238 DestroyWindow (hLB);
239}
UINT_PTR WPARAM
Definition: minwindef.h:174
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
Definition: mk_font.cpp:20
#define OBJ_FONT
Definition: objidl.idl:1019
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
int32_t INT
Definition: typedefs.h:58
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DCX_CACHE
Definition: winuser.h:2150
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define LB_GETITEMHEIGHT
Definition: winuser.h:2071
#define WM_SETFONT
Definition: winuser.h:1678

Referenced by START_TEST().

◆ create_listbox()

static HWND create_listbox ( DWORD  add_style,
HWND  parent 
)
static

Definition at line 59 of file listbox.c.

60{
62 INT_PTR ctl_id=0;
63 if (parent)
64 ctl_id=1;
65 handle=CreateWindowA("LISTBOX", "TestList",
66 (LBS_STANDARD & ~LBS_SORT) | add_style,
67 0, 0, 100, 100,
68 parent, (HMENU)ctl_id, NULL, 0);
69
70 assert (handle);
75
76#ifdef VISIBLE
78#endif
79 REDRAW;
80
81 return handle;
82}
#define assert(_expr)
Definition: assert.h:32
r parent
Definition: btrfs.c:3010
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define LBS_SORT
Definition: pedump.c:679
int32_t INT_PTR
Definition: typedefs.h:64
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define LB_ADDSTRING
Definition: winuser.h:2060
#define LBS_STANDARD
Definition: winuser.h:321
#define SW_SHOW
Definition: winuser.h:786

◆ create_parent()

static HWND create_parent ( void  )
static

Definition at line 311 of file listbox.c.

312{
313 WNDCLASSA cls;
314 HWND parent;
315 static ATOM class;
316
317 if (!class)
318 {
319 cls.style = 0;
321 cls.cbClsExtra = 0;
322 cls.cbWndExtra = 0;
324 cls.hIcon = 0;
327 cls.lpszMenuName = NULL;
328 cls.lpszClassName = "main_window_class";
329 class = RegisterClassA( &cls );
330 }
331
332 parent = CreateWindowExA(0, "main_window_class", NULL,
334 100, 100, 400, 400,
335 GetDesktopWindow(), 0,
337 return parent;
338}
WORD ATOM
Definition: dimm.idl:113
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: listbox.c:331
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
HBRUSH hbrBackground
Definition: winuser.h:3278
HICON hIcon
Definition: winuser.h:3276
HINSTANCE hInstance
Definition: winuser.h:3275
HCURSOR hCursor
Definition: winuser.h:3277
int cbWndExtra
Definition: winuser.h:3274
UINT style
Definition: winuser.h:3271
LPCSTR lpszMenuName
Definition: winuser.h:3279
LPCSTR lpszClassName
Definition: winuser.h:3280
WNDPROC lpfnWndProc
Definition: winuser.h:3272
int cbClsExtra
Definition: winuser.h:3273
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define IDC_ARROW
Definition: winuser.h:695
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2459
const char * LPCSTR
Definition: xmlstorage.h:183

◆ DWORD()

static DWORD ( WINAPI pGetListBoxInfo)
static

◆ keypress()

static void keypress ( HWND  handle,
WPARAM  keycode,
BYTE  scancode,
BOOL  extended 
)
static

Definition at line 120 of file listbox.c.

121{
122 LPARAM lp=1+(scancode<<16)+(extended?KEYEVENTF_EXTENDEDKEY:0);
123
124 WAIT;
125 SendMessageA(handle, WM_KEYDOWN, keycode, lp);
126 SendMessageA(handle, WM_KEYUP , keycode, lp | 0xc000000);
127 REDRAW;
128}
#define WM_KEYUP
Definition: winuser.h:1744
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1112
#define WM_KEYDOWN
Definition: winuser.h:1743

◆ listbox_container_window_procA()

static LRESULT CALLBACK listbox_container_window_procA ( HWND  hwnd,
UINT  uiMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1444 of file listbox.c.

1446{
1447 LRESULT result = 0;
1448
1449 switch (uiMsg) {
1450 case WM_DESTROY:
1451 PostQuitMessage(0);
1452 break;
1453 case WM_CREATE:
1455 ? 0 : (LRESULT)-1;
1456 break;
1457 default:
1458 result = DefWindowProcA (hwnd, uiMsg, wParam, lParam);
1459 break;
1460 }
1461 return result;
1462}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
GLuint64EXT * result
Definition: glext.h:11304
LONG_PTR LRESULT
Definition: minwindef.h:176
static BOOL on_listbox_container_create(HWND hwnd, CREATESTRUCTA *lpcs)
Definition: listbox.c:1501
#define LRESULT
Definition: ole.h:14
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1636
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DESTROY
Definition: winuser.h:1637

◆ listbox_query()

static void listbox_query ( HWND  handle,
struct listbox_stat results 
)
static

Definition at line 100 of file listbox.c.

101{
102 results->selected = SendMessageA(handle, LB_GETCURSEL, 0, 0);
105 results->selcount = SendMessageA(handle, LB_GETSELCOUNT, 0, 0);
106}
static struct _test_info results[8]
Definition: SetCursorPos.c:31
#define LB_GETSELCOUNT
Definition: winuser.h:2083
#define LB_GETANCHORINDEX
Definition: winuser.h:2065
#define LB_GETCARETINDEX
Definition: winuser.h:2066
#define LB_GETCURSEL
Definition: winuser.h:2068

◆ listbox_subclass_proc()

static LRESULT WINAPI listbox_subclass_proc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1991 of file listbox.c.

1992{
1994
1995 if (message == LB_GETLISTBOXINFO)
1997
1998 return CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
1999}
static int lb_getlistboxinfo
Definition: listbox.c:1989
Definition: tftpd.h:60
#define GWLP_USERDATA
Definition: treelist.c:63
#define GetWindowLongPtrA
Definition: winuser.h:4982
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by test_GetListBoxInfo().

◆ main_window_proc()

static LRESULT WINAPI main_window_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 243 of file listbox.c.

244{
245 switch (msg)
246 {
247 case WM_MEASUREITEM:
248 {
250 MEASUREITEMSTRUCT *mi = (void*)lparam;
251
252 ok(wparam == mi->CtlID, "got wParam=%08Ix, expected %08x\n", wparam, mi->CtlID);
253 ok(mi->CtlType == ODT_LISTBOX, "mi->CtlType = %u\n", mi->CtlType);
254 ok(mi->CtlID == 1, "mi->CtlID = %u\n", mi->CtlID);
255 ok(mi->itemHeight, "mi->itemHeight = 0\n");
256
257 if (mi->itemID > 4 || style & LBS_OWNERDRAWFIXED)
258 break;
259
260 if (style & LBS_HASSTRINGS)
261 {
262 ok(!strcmp_aw((WCHAR*)mi->itemData, strings[mi->itemID]),
263 "mi->itemData = %s (%d)\n", wine_dbgstr_w((WCHAR*)mi->itemData), mi->itemID);
264 }
265 else
266 {
267 ok((void*)mi->itemData == strings[mi->itemID],
268 "mi->itemData = %08Ix, expected %p\n", mi->itemData, strings[mi->itemID]);
269 }
270 break;
271 }
272 case WM_DRAWITEM:
273 {
274 RECT rc_item, rc_client, rc_clip;
276
277 trace("%p WM_DRAWITEM %08Ix %08Ix\n", hwnd, wparam, lparam);
278
279 ok(wparam == dis->CtlID, "got wParam=%08Ix instead of %08x\n",
280 wparam, dis->CtlID);
281 ok(dis->CtlType == ODT_LISTBOX, "wrong CtlType %04x\n", dis->CtlType);
282
283 GetClientRect(dis->hwndItem, &rc_client);
284 trace("hwndItem %p client rect %s\n", dis->hwndItem, wine_dbgstr_rect(&rc_client));
285 GetClipBox(dis->hDC, &rc_clip);
286 trace("clip rect %s\n", wine_dbgstr_rect(&rc_clip));
287 ok(EqualRect(&rc_client, &rc_clip) || IsRectEmpty(&rc_clip),
288 "client rect of the listbox should be equal to the clip box,"
289 "or the clip box should be empty\n");
290
291 trace("rcItem %s\n", wine_dbgstr_rect(&dis->rcItem));
292 SendMessageA(dis->hwndItem, LB_GETITEMRECT, dis->itemID, (LPARAM)&rc_item);
293 trace("item rect %s\n", wine_dbgstr_rect(&rc_item));
294 ok(EqualRect(&dis->rcItem, &rc_item), "item rects are not equal\n");
295
296 got_drawitem++;
297 break;
298 }
299
300 case WM_COMMAND:
302 break;
303
304 default:
305 break;
306 }
307
309}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define trace
Definition: atltest.h:70
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define msg(x)
Definition: auth_time.c:54
#define wine_dbgstr_w
Definition: kernel32.h:34
static int got_selchange
Definition: listbox.c:329
static unsigned int got_drawitem
Definition: listbox.c:241
static int strcmp_aw(LPCWSTR strw, const char *stra)
Definition: listbox.c:49
static MONITORINFO mi
Definition: win.c:9400
#define LBS_OWNERDRAWFIXED
Definition: pedump.c:682
#define LBS_HASSTRINGS
Definition: pedump.c:684
#define HIWORD(l)
Definition: typedefs.h:247
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1768
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define WM_DRAWITEM
Definition: winuser.h:1673
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_MEASUREITEM
Definition: winuser.h:1674
#define LBN_SELCHANGE
Definition: winuser.h:2111
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define GW_CHILD
Definition: winuser.h:774
#define GWL_STYLE
Definition: winuser.h:863
#define ODT_LISTBOX
Definition: winuser.h:2574
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

◆ on_listbox_container_create()

static BOOL on_listbox_container_create ( HWND  hwnd,
LPCREATESTRUCTA  lpcs 
)
static

Definition at line 1424 of file listbox.c.

1425{
1427 "Static",
1428 "Contents of static control before DlgDirList.",
1430 10, 10, 512, 32,
1432 if (!g_label) return FALSE;
1434 "ListBox",
1435 "DlgDirList test",
1437 10, 60, 256, 256,
1439 if (!g_listBox) return FALSE;
1440
1441 return TRUE;
1442}
#define FALSE
Definition: types.h:117
static HWND g_listBox
Definition: listbox.c:1495
static HWND g_label
Definition: listbox.c:1496
#define ID_TEST_LABEL
Definition: listbox.c:1498
#define ID_TEST_LISTBOX
Definition: listbox.c:1499
#define WS_CHILD
Definition: pedump.c:617
#define WS_TABSTOP
Definition: pedump.c:634
#define WS_BORDER
Definition: pedump.c:625
#define WS_VSCROLL
Definition: pedump.c:627

◆ RegisterListboxWindowClass()

static BOOL RegisterListboxWindowClass ( HINSTANCE  hInst)
static

Definition at line 1464 of file listbox.c.

1465{
1466 WNDCLASSA cls;
1467
1468 cls.style = 0;
1469 cls.cbClsExtra = 0;
1470 cls.cbWndExtra = 0;
1471 cls.hInstance = hInst;
1472 cls.hIcon = NULL;
1474 cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1475 cls.lpszMenuName = NULL;
1477 cls.lpszClassName = "ListboxContainerClass";
1478 if (!RegisterClassA (&cls)) return FALSE;
1479
1480 return TRUE;
1481}
HINSTANCE hInst
Definition: dxdiag.c:13
static LRESULT CALLBACK listbox_container_window_procA(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
Definition: listbox.c:1515
#define COLOR_WINDOW
Definition: winuser.h:929

◆ START_TEST()

START_TEST ( listbox  )

Definition at line 2507 of file listbox.c.

2508{
2509 const struct listbox_test SS =
2510/* {add_style} */
2511 {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
2512 { 1, 1, 1, LB_ERR}, {0,0,0,0},
2513 { 2, 2, 2, LB_ERR}, {0,0,0,0},
2514 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
2515/* {selected, anchor, caret, selcount}{TODO fields} */
2516 const struct listbox_test SS_NS =
2517 {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
2518 { 1, 1, 1, LB_ERR}, {0,0,0,0},
2519 { 2, 2, 2, LB_ERR}, {0,0,0,0},
2520 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
2521 const struct listbox_test MS =
2522 {{ 0, LB_ERR, 0, 0}, {0,0,0,0},
2523 { 1, 1, 1, 1}, {0,0,0,0},
2524 { 2, 1, 2, 1}, {0,0,0,0},
2525 { 0, LB_ERR, 0, 2}, {0,0,0,0}};
2526 const struct listbox_test MS_NS =
2527 {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
2528 { 1, 1, 1, LB_ERR}, {0,0,0,0},
2529 { 2, 2, 2, LB_ERR}, {0,0,0,0},
2530 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
2531 const struct listbox_test ES =
2532 {{ 0, LB_ERR, 0, 0}, {0,0,0,0},
2533 { 1, 1, 1, 1}, {0,0,0,0},
2534 { 2, 2, 2, 1}, {0,0,0,0},
2535 { 0, LB_ERR, 0, 2}, {0,0,0,0}};
2536 const struct listbox_test ES_NS =
2537 {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
2538 { 1, 1, 1, LB_ERR}, {0,0,0,0},
2539 { 2, 2, 2, LB_ERR}, {0,0,0,0},
2540 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
2541 const struct listbox_test EMS =
2542 {{ 0, LB_ERR, 0, 0}, {0,0,0,0},
2543 { 1, 1, 1, 1}, {0,0,0,0},
2544 { 2, 2, 2, 1}, {0,0,0,0},
2545 { 0, LB_ERR, 0, 2}, {0,0,0,0}};
2546 const struct listbox_test EMS_NS =
2547 {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
2548 { 1, 1, 1, LB_ERR}, {0,0,0,0},
2549 { 2, 2, 2, LB_ERR}, {0,0,0,0},
2550 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
2551
2552 trace (" Testing single selection...\n");
2553 check (0, SS);
2554 trace (" ... with NOSEL\n");
2555 check (LBS_NOSEL, SS_NS);
2556 trace (" ... LBS_NODATA variant ...\n");
2558 trace (" ... with NOSEL\n");
2560
2561 trace (" Testing multiple selection...\n");
2563 trace (" ... with NOSEL\n");
2564 check (LBS_MULTIPLESEL | LBS_NOSEL, MS_NS);
2565 trace (" ... LBS_NODATA variant ...\n");
2567 trace (" ... with NOSEL\n");
2569
2570 trace (" Testing extended selection...\n");
2572 trace (" ... with NOSEL\n");
2573 check (LBS_EXTENDEDSEL | LBS_NOSEL, ES_NS);
2574 trace (" ... LBS_NODATA variant ...\n");
2576 trace (" ... with NOSEL\n");
2578
2579 trace (" Testing extended and multiple selection...\n");
2581 trace (" ... with NOSEL\n");
2583 trace (" ... LBS_NODATA variant ...\n");
2585 trace (" ... with NOSEL\n");
2587
2602 test_extents();
2607}
#define check(expected, result)
Definition: dplayx.c:32
#define SS(fs)
Definition: ff.c:54
#define MS
Definition: i386-dis.c:451
@ ES
Definition: bidi.c:78
static void test_listbox_height(void)
Definition: listbox.c:760
static void test_listbox_dlgdir(void)
Definition: listbox.c:1553
static void test_listbox_LB_DIR(void)
Definition: listbox.c:1046
static void test_set_count(void)
Definition: listbox.c:1990
static void test_WM_MEASUREITEM(void)
Definition: listbox.c:2431
static void test_itemfrompoint(void)
Definition: listbox.c:944
static void test_LB_SETCURSEL(void)
Definition: listbox.c:618
static void test_changing_selection_styles(void)
Definition: listbox.c:815
static void test_init_storage(void)
Definition: listbox.c:2071
static void test_LB_SETSEL(void)
Definition: listbox.c:694
static void test_missing_lbuttonup(void)
Definition: listbox.c:2134
static void test_LBS_NODATA(void)
Definition: listbox.c:2522
static void test_LB_SELITEMRANGE(void)
Definition: listbox.c:540
static void test_extents(void)
Definition: listbox.c:2157
static void test_ownerdraw(void)
Definition: listbox.c:463
static void test_GetListBoxInfo(void)
Definition: listbox.c:2049
static void test_listbox_item_data(void)
Definition: listbox.c:1025
static void test_LB_FINDSTRING(void)
Definition: listbox.c:2430
static void check_item_height(void)
Definition: listbox.c:209
#define LBS_MULTIPLESEL
Definition: pedump.c:681
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define LBS_NOSEL
Definition: winuser.h:316

◆ strcmp_aw()

static int strcmp_aw ( LPCWSTR  strw,
const char stra 
)
static

Definition at line 49 of file listbox.c.

50{
51 WCHAR buf[1024];
52
53 if (!stra) return 1;
55 return lstrcmpW(strw, buf);
56}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define MultiByteToWideChar
Definition: compat.h:110
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Referenced by main_window_proc().

◆ test_changing_selection_styles()

static void test_changing_selection_styles ( void  )
static

Definition at line 732 of file listbox.c.

733{
734 static const DWORD styles[] =
735 {
736 0,
738 };
739 static const DWORD selstyles[] =
740 {
741 0,
745 };
746 static const LONG selexpect_single[] = { 0, 0, 1 };
747 static const LONG selexpect_single2[] = { 1, 0, 0 };
748 static const LONG selexpect_multi[] = { 1, 0, 1 };
749 static const LONG selexpect_multi2[] = { 1, 1, 0 };
750
751 HWND parent, listbox;
752 DWORD style;
753 LONG ret;
754 UINT i, j, k;
755
757 ok(parent != NULL, "Failed to create parent window.\n");
758 for (i = 0; i < ARRAY_SIZE(styles); i++)
759 {
760 /* Test if changing selection styles affects selection storage */
761 for (j = 0; j < ARRAY_SIZE(selstyles); j++)
762 {
763 LONG setcursel_expect, selitemrange_expect, getselcount_expect;
764 const LONG *selexpect;
765
766 listbox = CreateWindowA("listbox", "TestList", styles[i] | selstyles[j] | WS_CHILD | WS_VISIBLE,
767 0, 0, 100, 100, parent, (HMENU)1, NULL, 0);
768 ok(listbox != NULL, "%u: Failed to create ListBox window.\n", j);
769
770 if (selstyles[j] & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL))
771 {
772 setcursel_expect = LB_ERR;
773 selitemrange_expect = LB_OKAY;
774 getselcount_expect = 2;
775 selexpect = selexpect_multi;
776 }
777 else
778 {
779 setcursel_expect = 2;
780 selitemrange_expect = LB_ERR;
781 getselcount_expect = LB_ERR;
782 selexpect = selexpect_single;
783 }
784
785 for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++)
786 {
787 ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)"x");
788 ok(ret == k, "%u: Unexpected return value %ld, expected %d.\n", j, ret, k);
789 }
790 ret = SendMessageA(listbox, LB_GETCOUNT, 0, 0);
791 ok(ret == ARRAY_SIZE(selexpect_multi), "%u: Unexpected count %ld.\n", j, ret);
792
793 /* Select items with different methods */
794 ret = SendMessageA(listbox, LB_SETCURSEL, 2, 0);
795 ok(ret == setcursel_expect, "%u: Unexpected return value %ld.\n", j, ret);
796 ret = SendMessageA(listbox, LB_SELITEMRANGE, TRUE, MAKELPARAM(0, 0));
797 ok(ret == selitemrange_expect, "%u: Unexpected return value %ld.\n", j, ret);
798 ret = SendMessageA(listbox, LB_SELITEMRANGE, TRUE, MAKELPARAM(2, 2));
799 ok(ret == selitemrange_expect, "%u: Unexpected return value %ld.\n", j, ret);
800
801 /* Verify that the proper items are selected */
802 for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++)
803 {
804 ret = SendMessageA(listbox, LB_GETSEL, k, 0);
805 ok(ret == selexpect[k], "%u: Unexpected selection state %ld, expected %ld.\n",
806 j, ret, selexpect[k]);
807 }
808
809 /* Now change the selection style */
810 style = GetWindowLongA(listbox, GWL_STYLE);
811 ok((style & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == selstyles[j],
812 "%u: unexpected window styles %#lx.\n", j, style);
813 if (selstyles[j] & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL))
814 style &= ~selstyles[j];
815 else
817 SetWindowLongA(listbox, GWL_STYLE, style);
818 style = GetWindowLongA(listbox, GWL_STYLE);
819 ok(!(style & selstyles[j]), "%u: unexpected window styles %#lx.\n", j, style);
820
821 /* Verify that the same items are selected */
822 ret = SendMessageA(listbox, LB_GETSELCOUNT, 0, 0);
823 ok(ret == getselcount_expect, "%u: expected %ld from LB_GETSELCOUNT, got %ld\n",
824 j, getselcount_expect, ret);
825
826 for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++)
827 {
828 ret = SendMessageA(listbox, LB_GETSEL, k, 0);
829 ok(ret == selexpect[k], "%u: Unexpected selection state %ld, expected %ld.\n",
830 j, ret, selexpect[k]);
831 }
832
833 /* Lastly see if we can still change the selection as before with old style */
834 if (setcursel_expect != LB_ERR) setcursel_expect = 0;
835 ret = SendMessageA(listbox, LB_SETCURSEL, 0, 0);
836 ok(ret == setcursel_expect, "%u: Unexpected return value %ld.\n", j, ret);
837 ret = SendMessageA(listbox, LB_SELITEMRANGE, TRUE, MAKELPARAM(1, 1));
838 ok(ret == selitemrange_expect, "%u: Unexpected return value %ld.\n", j, ret);
839 ret = SendMessageA(listbox, LB_SELITEMRANGE, FALSE, MAKELPARAM(2, 2));
840 ok(ret == selitemrange_expect, "%u: Unexpected return value %ld.\n", j, ret);
841
842 /* And verify the selections */
843 selexpect = (selstyles[j] & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) ? selexpect_multi2 : selexpect_single2;
844 ret = SendMessageA(listbox, LB_GETSELCOUNT, 0, 0);
845 ok(ret == getselcount_expect, "%u: expected %ld from LB_GETSELCOUNT, got %ld\n",
846 j, getselcount_expect, ret);
847
848 for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++)
849 {
850 ret = SendMessageA(listbox, LB_GETSEL, k, 0);
851 ok(ret == selexpect[k], "%u: Unexpected selection state %ld, expected %ld.\n",
852 j, ret, selexpect[k]);
853 }
854
855 DestroyWindow(listbox);
856 }
857 }
859}
return ret
Definition: mutex.c:146
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static HWND create_parent(void)
Definition: listbox.c:439
int k
Definition: mpi.c:3369
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
#define LB_OKAY
Definition: winuser.h:2467
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
#define LB_GETSEL
Definition: winuser.h:2082
#define LB_INSERTSTRING
Definition: winuser.h:2089
#define LB_SETCURSEL
Definition: winuser.h:2099

◆ test_extents()

static void test_extents ( void  )
static

Definition at line 2117 of file listbox.c.

2118{
2119 HWND listbox, parent;
2120 DWORD res;
2122 BOOL br;
2123
2125
2127
2128 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2129 ok(res == 0, "Got wrong initial horizontal extent: %lu\n", res);
2130
2131 sinfo.cbSize = sizeof(sinfo);
2132 sinfo.fMask = SIF_RANGE;
2133 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2134 ok(br == TRUE, "GetScrollInfo failed\n");
2135 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2136 ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
2137 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
2138 "List box should not have a horizontal scroll bar\n");
2139
2140 /* horizontal extent < width */
2141 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 64, 0);
2142
2143 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2144 ok(res == 64, "Got wrong horizontal extent: %lu\n", res);
2145
2146 sinfo.cbSize = sizeof(sinfo);
2147 sinfo.fMask = SIF_RANGE;
2148 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2149 ok(br == TRUE, "GetScrollInfo failed\n");
2150 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2151 ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
2152 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
2153 "List box should not have a horizontal scroll bar\n");
2154
2155 /* horizontal extent > width */
2156 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 184, 0);
2157
2158 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2159 ok(res == 184, "Got wrong horizontal extent: %lu\n", res);
2160
2161 sinfo.cbSize = sizeof(sinfo);
2162 sinfo.fMask = SIF_RANGE;
2163 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2164 ok(br == TRUE, "GetScrollInfo failed\n");
2165 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2166 ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
2167 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
2168 "List box should not have a horizontal scroll bar\n");
2169
2170 DestroyWindow(listbox);
2171
2172
2174
2175 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2176 ok(res == 0, "Got wrong initial horizontal extent: %lu\n", res);
2177
2178 sinfo.cbSize = sizeof(sinfo);
2179 sinfo.fMask = SIF_RANGE;
2180 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2181 ok(br == TRUE, "GetScrollInfo failed\n");
2182 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2183 ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
2184 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
2185 "List box should not have a horizontal scroll bar\n");
2186
2187 /* horizontal extent < width */
2188 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 64, 0);
2189
2190 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2191 ok(res == 64, "Got wrong horizontal extent: %lu\n", res);
2192
2193 sinfo.cbSize = sizeof(sinfo);
2194 sinfo.fMask = SIF_RANGE;
2195 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2196 ok(br == TRUE, "GetScrollInfo failed\n");
2197 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2198 ok(sinfo.nMax == 63, "got wrong max: %u\n", sinfo.nMax);
2199 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
2200 "List box should not have a horizontal scroll bar\n");
2201
2202 /* horizontal extent > width */
2203 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 184, 0);
2204
2205 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2206 ok(res == 184, "Got wrong horizontal extent: %lu\n", res);
2207
2208 sinfo.cbSize = sizeof(sinfo);
2209 sinfo.fMask = SIF_RANGE;
2210 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2211 ok(br == TRUE, "GetScrollInfo failed\n");
2212 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2213 ok(sinfo.nMax == 183, "got wrong max: %u\n", sinfo.nMax);
2214 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
2215 "List box should have a horizontal scroll bar\n");
2216
2217 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 0, 0);
2218
2219 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2220 ok(res == 0, "Got wrong horizontal extent: %lu\n", res);
2221
2222 sinfo.cbSize = sizeof(sinfo);
2223 sinfo.fMask = SIF_RANGE;
2224 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2225 ok(br == TRUE, "GetScrollInfo failed\n");
2226 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2227 ok(sinfo.nMax == 0, "got wrong max: %u\n", sinfo.nMax);
2228 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
2229 "List box should not have a horizontal scroll bar\n");
2230
2231 DestroyWindow(listbox);
2232
2233
2235
2236 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2237 ok(res == 0, "Got wrong initial horizontal extent: %lu\n", res);
2238
2239 sinfo.cbSize = sizeof(sinfo);
2240 sinfo.fMask = SIF_RANGE;
2241 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2242 ok(br == TRUE, "GetScrollInfo failed\n");
2243 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2244 ok(sinfo.nMax == 0, "got wrong max: %u\n", sinfo.nMax);
2245 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
2246 "List box should have a horizontal scroll bar\n");
2247
2248 /* horizontal extent < width */
2249 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 64, 0);
2250
2251 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2252 ok(res == 64, "Got wrong horizontal extent: %lu\n", res);
2253
2254 sinfo.cbSize = sizeof(sinfo);
2255 sinfo.fMask = SIF_RANGE;
2256 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2257 ok(br == TRUE, "GetScrollInfo failed\n");
2258 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2259 ok(sinfo.nMax == 63, "got wrong max: %u\n", sinfo.nMax);
2260 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
2261 "List box should have a horizontal scroll bar\n");
2262
2263 /* horizontal extent > width */
2264 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 184, 0);
2265
2266 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2267 ok(res == 184, "Got wrong horizontal extent: %lu\n", res);
2268
2269 sinfo.cbSize = sizeof(sinfo);
2270 sinfo.fMask = SIF_RANGE;
2271 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2272 ok(br == TRUE, "GetScrollInfo failed\n");
2273 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2274 ok(sinfo.nMax == 183, "got wrong max: %u\n", sinfo.nMax);
2275 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
2276 "List box should have a horizontal scroll bar\n");
2277
2278 SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 0, 0);
2279
2280 res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
2281 ok(res == 0, "Got wrong horizontal extent: %lu\n", res);
2282
2283 sinfo.cbSize = sizeof(sinfo);
2284 sinfo.fMask = SIF_RANGE;
2285 br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
2286 ok(br == TRUE, "GetScrollInfo failed\n");
2287 ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
2288 ok(sinfo.nMax == 0, "got wrong max: %u\n", sinfo.nMax);
2289 ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
2290 "List box should have a horizontal scroll bar\n");
2291
2292 DestroyWindow(listbox);
2293
2295}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LBS_DISABLENOSCROLL
Definition: pedump.c:690
#define WS_HSCROLL
Definition: pedump.c:628
Definition: general.c:220
#define LB_SETHORIZONTALEXTENT
Definition: winuser.h:2100
#define SIF_RANGE
Definition: winuser.h:1246
#define LB_GETHORIZONTALEXTENT
Definition: winuser.h:2069
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SB_HORZ
Definition: winuser.h:552

◆ test_GetListBoxInfo()

static void test_GetListBoxInfo ( void  )
static

Definition at line 2001 of file listbox.c.

2002{
2003 HWND listbox, parent;
2004 WNDPROC oldproc;
2005 DWORD ret;
2006
2007 pGetListBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetListBoxInfo");
2008
2009 if (!pGetListBoxInfo)
2010 {
2011 win_skip("GetListBoxInfo() not available\n");
2012 return;
2013 }
2014
2017
2019 SetWindowLongPtrA(listbox, GWLP_USERDATA, (LONG_PTR)oldproc);
2020
2022 ret = pGetListBoxInfo(listbox);
2023 ok(ret > 0, "got %ld\n", ret);
2024 todo_wine
2025 ok(lb_getlistboxinfo == 0, "got %d\n", lb_getlistboxinfo);
2026
2027 DestroyWindow(listbox);
2029}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define win_skip
Definition: minitest.h:67
#define todo_wine
Definition: minitest.h:80
static LRESULT WINAPI listbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: listbox.c:1991
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SetWindowLongPtrA
Definition: winuser.h:5511

◆ test_init_storage()

static void test_init_storage ( void  )
static

Definition at line 2031 of file listbox.c.

2032{
2033 static const DWORD styles[] =
2034 {
2037 };
2038 HWND parent, listbox;
2039 LONG ret, items_size;
2040 int i, j;
2041
2043 for (i = 0; i < ARRAY_SIZE(styles); i++)
2044 {
2045 listbox = CreateWindowA("listbox", "TestList", styles[i] | WS_CHILD,
2046 0, 0, 100, 100, parent, (HMENU)1, NULL, 0);
2047
2048 items_size = SendMessageA(listbox, LB_INITSTORAGE, 100, 0);
2049 ok(items_size >= 100, "expected at least 100, got %ld\n", items_size);
2050
2051 ret = SendMessageA(listbox, LB_INITSTORAGE, 0, 0);
2052 ok(ret == items_size, "expected %ld, got %ld\n", items_size, ret);
2053
2054 /* it doesn't grow since the space was already reserved */
2055 ret = SendMessageA(listbox, LB_INITSTORAGE, items_size, 0);
2056 ok(ret == items_size, "expected %ld, got %ld\n", items_size, ret);
2057
2058 /* it doesn't shrink the reserved space */
2059 ret = SendMessageA(listbox, LB_INITSTORAGE, 42, 0);
2060 ok(ret == items_size, "expected %ld, got %ld\n", items_size, ret);
2061
2062 /* now populate almost all of it so it's not reserved anymore */
2063 if (styles[i] & LBS_NODATA)
2064 {
2065 ret = SendMessageA(listbox, LB_SETCOUNT, items_size - 1, 0);
2066 ok(ret == 0, "unexpected return value %ld\n", ret);
2067 }
2068 else
2069 {
2070 for (j = 0; j < items_size - 1; j++)
2071 {
2072 ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)"");
2073 ok(ret == j, "expected %d, got %ld\n", j, ret);
2074 }
2075 }
2076
2077 /* we still have one more reserved slot, so it doesn't grow yet */
2078 ret = SendMessageA(listbox, LB_INITSTORAGE, 1, 0);
2079 ok(ret == items_size, "expected %ld, got %ld\n", items_size, ret);
2080
2081 /* fill the slot and check again, it should grow this time */
2082 ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)"");
2083 ok(ret == items_size - 1, "expected %ld, got %ld\n", items_size - 1, ret);
2084 ret = SendMessageA(listbox, LB_INITSTORAGE, 0, 0);
2085 ok(ret == items_size, "expected %ld, got %ld\n", items_size, ret);
2086 ret = SendMessageA(listbox, LB_INITSTORAGE, 1, 0);
2087 ok(ret > items_size, "expected it to grow past %ld, got %ld\n", items_size, ret);
2088
2089 DestroyWindow(listbox);
2090 }
2092}
#define LB_SETCOUNT
Definition: winuser.h:2098
#define LB_INITSTORAGE
Definition: winuser.h:2088

◆ test_itemfrompoint()

static void test_itemfrompoint ( void  )
static

Definition at line 861 of file listbox.c.

862{
863 /* WS_POPUP is required in order to have a more accurate size calculation (
864 without caption). LBS_NOINTEGRALHEIGHT is required in order to test
865 behavior of partially-displayed item.
866 */
867 HWND hList = CreateWindowA( "ListBox", "list test",
869 1, 1, 600, 100, NULL, NULL, NULL, NULL );
870 ULONG r, id;
871 RECT rc;
872
873 /* For an empty listbox win2k returns 0x1ffff, win98 returns 0x10000, nt4 returns 0xffffffff */
874 r = SendMessageA(hList, LB_ITEMFROMPOINT, 0, MAKELPARAM( /* x */ 30, /* y */ 30 ));
875 ok( r == 0x1ffff || r == 0x10000 || r == 0xffffffff, "ret %lx\n", r );
876
878 ok( r == 0x1ffff || r == 0x10000 || r == 0xffffffff, "ret %lx\n", r );
879
881 ok( r == 0x1ffff || r == 0x10000 || r == 0xffffffff, "ret %lx\n", r );
882
883 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi");
884 ok( id == 0, "item id wrong\n");
885 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi1");
886 ok( id == 1, "item id wrong\n");
887
888 r = SendMessageA(hList, LB_ITEMFROMPOINT, 0, MAKELPARAM( /* x */ 30, /* y */ 30 ));
889 ok( r == 0x1, "ret %lx\n", r );
890
891 r = SendMessageA(hList, LB_ITEMFROMPOINT, 0, MAKELPARAM( /* x */ 30, /* y */ 601 ));
892 ok( r == 0x10001 || broken(r == 1), /* nt4 */
893 "ret %lx\n", r );
894
895 /* Resize control so that below assertions about sizes are valid */
897 ok( r == 1, "ret %lx\n", r);
898 r = MoveWindow(hList, 1, 1, 600, (rc.bottom - rc.top + 1) * 9 / 2, TRUE);
899 ok( r != 0, "ret %lx\n", r);
900
901 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi2");
902 ok( id == 2, "item id wrong\n");
903 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi3");
904 ok( id == 3, "item id wrong\n");
905 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi4");
906 ok( id == 4, "item id wrong\n");
907 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi5");
908 ok( id == 5, "item id wrong\n");
909 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi6");
910 ok( id == 6, "item id wrong\n");
911 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi7");
912 ok( id == 7, "item id wrong\n");
913
914 /* Set the listbox up so that id 1 is at the top, this leaves 5
915 partially visible at the bottom and 6, 7 are invisible */
916
919 ok( r == 1, "top %ld\n", r);
920
922 ok( r == 1, "ret %lx\n", r);
924 ok( r == 0, "ret %lx\n", r);
925
926 r = SendMessageA( hList, LB_ITEMFROMPOINT, 0, MAKELPARAM(/* x */ 10, /* y */ 10) );
927 ok( r == 1, "ret %lx\n", r);
928
929 r = SendMessageA( hList, LB_ITEMFROMPOINT, 0, MAKELPARAM(1000, 10) );
930 ok( r == 0x10001 || broken(r == 1), /* nt4 */
931 "ret %lx\n", r );
932
934 ok( r == 0x10001 || broken(r == 1), /* nt4 */
935 "ret %lx\n", r );
936
938 ok( r == 0x10005 || broken(r == 5), /* nt4 */
939 "item %lx\n", r );
940
942 ok( r == 0x10005 || broken(r == 5), /* nt4 */
943 "item %lx\n", r );
944
946}
#define broken(x)
Definition: atltest.h:178
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint id
Definition: glext.h:5910
HWND hList
Definition: livecd.c:10
#define LBS_NOINTEGRALHEIGHT
Definition: pedump.c:686
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
uint32_t ULONG
Definition: typedefs.h:59
#define LB_SETTOPINDEX
Definition: winuser.h:2106
#define LB_GETTOPINDEX
Definition: winuser.h:2087
#define LB_ITEMFROMPOINT
Definition: winuser.h:2090
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

◆ test_LB_FINDSTRING()

static void test_LB_FINDSTRING ( void  )
static

Definition at line 2430 of file listbox.c.

2431{
2432 static const WCHAR *strings[] =
2433 {
2434 L"abci",
2435 L"AbCI",
2436 L"abcI",
2437 L"abc\xcdzz",
2438 L"abc\xedzz",
2439 L"abc\xcd",
2440 L"abc\xed",
2441 L"abcO",
2442 L"abc\xd8",
2443 L"abcP",
2444 };
2445 static const struct { const WCHAR *str; LRESULT from, res, exact, alt_res, alt_exact; } tests[] =
2446 {
2447 { L"ab", -1, 0, -1, 0, -1 },
2448 { L"abc", -1, 0, -1, 0, -1 },
2449 { L"abci", -1, 0, 0, 0, 0 },
2450 { L"ABCI", -1, 0, 0, 0, 0 },
2451 { L"ABC\xed", -1, 3, 3, 3, 3 },
2452 { L"ABC\xcd", 4, 5, 3, 5, 3 },
2453 { L"abcp", -1, 9, 9, 8, 8 },
2454 };
2455 HWND listbox;
2456 unsigned int i;
2457 LRESULT ret;
2458
2459 listbox = CreateWindowW( L"listbox", L"TestList", LBS_HASSTRINGS | LBS_SORT,
2460 0, 0, 100, 100, NULL, NULL, NULL, 0 );
2461 ok( listbox != NULL, "Failed to create listbox\n" );
2463 for (i = 0; i < ARRAY_SIZE(strings); i++) SendMessageW( listbox, LB_ADDSTRING, 0, (LPARAM)strings[i] );
2464
2465 for (i = 0; i < ARRAY_SIZE(tests); i++)
2466 {
2468 ok( ret == tests[i].res, "%u: wrong result %Id / %Id\n", i, ret, tests[i].res );
2470 ok( ret == tests[i].exact, "%u: wrong result %Id / %Id\n", i, ret, tests[i].exact );
2471 }
2472
2473 SendMessageW( listbox, LB_RESETCONTENT, 0, 0 );
2475 for (i = 0; i < ARRAY_SIZE(strings); i++) SendMessageW( listbox, LB_ADDSTRING, 0, (LPARAM)strings[i] );
2476 ret = SendMessageW( listbox, LB_FINDSTRING, -1, (LPARAM)L"abcp" );
2477 for (i = 0; i < ARRAY_SIZE(tests); i++)
2478 {
2480 ok( ret == tests[i].alt_res, "%u: wrong result %Id / %Id\n", i, ret, tests[i].alt_res );
2482 ok( ret == tests[i].alt_exact, "%u: wrong result %Id / %Id\n", i, ret, tests[i].alt_exact );
2483 }
2484
2485 SendMessageW( listbox, LB_RESETCONTENT, 0, 0 );
2486 SendMessageW( listbox, LB_ADDSTRING, 0, (LPARAM)L"abc" );
2487 SendMessageW( listbox, LB_ADDSTRING, 0, (LPARAM)L"[abc]" );
2488 SendMessageW( listbox, LB_ADDSTRING, 0, (LPARAM)L"[-abc-]" );
2489 ret = SendMessageW( listbox, LB_FINDSTRING, -1, (LPARAM)L"abc" );
2490 ok( ret == 0, "wrong result %Id\n", ret );
2491 ret = SendMessageW( listbox, LB_FINDSTRINGEXACT, -1, (LPARAM)L"abc" );
2492 todo_wine
2493 ok( ret == 0, "wrong result %Id\n", ret );
2494 ret = SendMessageW( listbox, LB_FINDSTRING, 0, (LPARAM)L"abc" );
2495 ok( ret == 1, "wrong result %Id\n", ret );
2496 ret = SendMessageW( listbox, LB_FINDSTRINGEXACT, 0, (LPARAM)L"abc" );
2497 todo_wine
2498 ok( ret == 0, "wrong result %Id\n", ret );
2499 ret = SendMessageW( listbox, LB_FINDSTRING, 1, (LPARAM)L"abc" );
2500 ok( ret == 2, "wrong result %Id\n", ret );
2501 ret = SendMessageW( listbox, LB_FINDSTRINGEXACT, 1, (LPARAM)L"abc" );
2502 todo_wine
2503 ok( ret == 0, "wrong result %Id\n", ret );
2504 DestroyWindow( listbox );
2505}
#define L(x)
Definition: resources.c:13
static struct test_info tests[]
const WCHAR * str
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define LANG_SWEDISH
Definition: nls.h:125
#define LANG_FRENCH
Definition: nls.h:58
CardRegion * from
Definition: spigame.cpp:19
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2064
#define LB_SETLOCALE
Definition: winuser.h:2103
#define LB_RESETCONTENT
Definition: winuser.h:2091
#define LB_FINDSTRING
Definition: winuser.h:2063
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4470

Referenced by START_TEST().

◆ test_LB_SELITEMRANGE()

static void test_LB_SELITEMRANGE ( void  )
static

Definition at line 465 of file listbox.c.

466{
467 static const struct listbox_stat test_nosel = { 0, LB_ERR, 0, 0 };
468 static const struct listbox_stat test_1 = { 0, LB_ERR, 0, 2 };
469 static const struct listbox_stat test_2 = { 0, LB_ERR, 0, 3 };
470 static const struct listbox_stat test_3 = { 0, LB_ERR, 0, 4 };
471 HWND hLB;
472 struct listbox_stat answer;
473 INT ret;
474
475 trace("testing LB_SELITEMRANGE\n");
476
478 assert(hLB);
479
480 listbox_query(hLB, &answer);
481 listbox_test_query(test_nosel, answer);
482
484 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
485 listbox_query(hLB, &answer);
486 listbox_test_query(test_1, answer);
487
488 SendMessageA(hLB, LB_SETSEL, FALSE, -1);
489 listbox_query(hLB, &answer);
490 listbox_test_query(test_nosel, answer);
491
493 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
494 listbox_query(hLB, &answer);
495 listbox_test_query(test_3, answer);
496
497 SendMessageA(hLB, LB_SETSEL, FALSE, -1);
498 listbox_query(hLB, &answer);
499 listbox_test_query(test_nosel, answer);
500
502 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
503 listbox_query(hLB, &answer);
504 listbox_test_query(test_nosel, answer);
505
506 SendMessageA(hLB, LB_SETSEL, FALSE, -1);
507 listbox_query(hLB, &answer);
508 listbox_test_query(test_nosel, answer);
509
511 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
512 listbox_query(hLB, &answer);
513 listbox_test_query(test_1, answer);
514
515 SendMessageA(hLB, LB_SETSEL, FALSE, -1);
516 listbox_query(hLB, &answer);
517 listbox_test_query(test_nosel, answer);
518
520 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
521 listbox_query(hLB, &answer);
522 listbox_test_query(test_nosel, answer);
523
524 SendMessageA(hLB, LB_SETSEL, FALSE, -1);
525 listbox_query(hLB, &answer);
526 listbox_test_query(test_nosel, answer);
527
529 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
530 listbox_query(hLB, &answer);
531 listbox_test_query(test_2, answer);
532
533 SendMessageA(hLB, LB_SETSEL, FALSE, -1);
534 listbox_query(hLB, &answer);
535 listbox_test_query(test_nosel, answer);
536
538 ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret);
539 listbox_query(hLB, &answer);
540 listbox_test_query(test_2, answer);
541
542 DestroyWindow(hLB);
543}
#define listbox_test_query(exp, got)
Definition: listbox.c:534
#define LB_SETSEL
Definition: winuser.h:2104

◆ test_LB_SETCURSEL()

static void test_LB_SETCURSEL ( void  )
static

Definition at line 545 of file listbox.c.

546{
547 HWND parent, hLB;
548 INT ret;
549
550 trace("testing LB_SETCURSEL\n");
551
553 assert(parent);
554
556 assert(hLB);
557
558 SendMessageA(hLB, LB_SETITEMHEIGHT, 0, 32);
559
560 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
561 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
562
563 ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0);
564 ok(ret == 2, "LB_SETCURSEL returned %d instead of 2\n", ret);
565 ret = GetScrollPos(hLB, SB_VERT);
566 ok(ret == 0, "expected vscroll 0, got %d\n", ret);
567
568 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
569 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
570
571 ret = SendMessageA(hLB, LB_SETCURSEL, 3, 0);
572 ok(ret == 3, "LB_SETCURSEL returned %d instead of 3\n", ret);
573 ret = GetScrollPos(hLB, SB_VERT);
574 ok(ret == 1, "expected vscroll 1, got %d\n", ret);
575
576 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
577 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
578
579 DestroyWindow(hLB);
580
581 hLB = create_listbox(0, 0);
582 ok(hLB != NULL, "Failed to create ListBox window.\n");
583
584 ret = SendMessageA(hLB, LB_SETCURSEL, 1, 0);
585 ok(ret == 1, "Unexpected return value %d.\n", ret);
586
587 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
588 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
589
590 DestroyWindow(hLB);
591
592 /* LBS_EXTENDEDSEL */
594 ok(hLB != NULL, "Failed to create ListBox window.\n");
595
596 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
597 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
598
599 ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0);
600 ok(ret == -1, "Unexpected return value %d.\n", ret);
601
602 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
603 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
604
605 DestroyWindow(hLB);
606
607 /* LBS_MULTIPLESEL */
609 ok(hLB != NULL, "Failed to create ListBox window.\n");
610
611 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
612 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
613
614 ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0);
615 ok(ret == -1, "Unexpected return value %d.\n", ret);
616
617 ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0);
618 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
619
620 DestroyWindow(hLB);
621}
#define SB_VERT
Definition: winuser.h:553
#define LB_SETITEMHEIGHT
Definition: winuser.h:2102
int WINAPI GetScrollPos(_In_ HWND, _In_ int)

◆ test_LB_SETSEL()

static void test_LB_SETSEL ( void  )
static

Definition at line 623 of file listbox.c.

624{
625 HWND list;
626 int ret;
627
628 /* LBS_EXTENDEDSEL */
630 ok(list != NULL, "Failed to create ListBox window.\n");
631
633 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
635 ok(ret == 0, "Unexpected caret index %d.\n", ret);
636
638 ok(ret == 0, "Unexpected return value %d.\n", ret);
640 ok(ret == 0, "Unexpected anchor index %d.\n", ret);
642 ok(ret == 0, "Unexpected caret index %d.\n", ret);
643
645 ok(ret == 0, "Unexpected return value %d.\n", ret);
647 ok(ret == 1, "Unexpected anchor index %d.\n", ret);
649 ok(ret == 1, "Unexpected caret index %d.\n", ret);
650
652 ok(ret == 0, "Unexpected return value %d.\n", ret);
654 ok(ret == 1, "Unexpected anchor index %d.\n", ret);
656 ok(ret == 1, "Unexpected caret index %d.\n", ret);
657
659
660 /* LBS_MULTIPLESEL */
662 ok(list != NULL, "Failed to create ListBox window.\n");
663
665 ok(ret == -1, "Unexpected anchor index %d.\n", ret);
667 ok(ret == 0, "Unexpected caret index %d.\n", ret);
668
670 ok(ret == 0, "Unexpected return value %d.\n", ret);
672 ok(ret == 0, "Unexpected anchor index %d.\n", ret);
674 ok(ret == 0, "Unexpected caret index %d.\n", ret);
675
677 ok(ret == 0, "Unexpected return value %d.\n", ret);
679 ok(ret == 1, "Unexpected anchor index %d.\n", ret);
681 ok(ret == 1, "Unexpected caret index %d.\n", ret);
682
684 ok(ret == 0, "Unexpected return value %d.\n", ret);
686 ok(ret == 1, "Unexpected anchor index %d.\n", ret);
688 ok(ret == 1, "Unexpected caret index %d.\n", ret);
689
691}
Definition: list.h:37
#define list
Definition: rosglue.h:35

◆ test_LBS_NODATA()

static void test_LBS_NODATA ( void  )
static

Definition at line 2317 of file listbox.c.

2318{
2319 static const DWORD invalid_styles[] =
2320 {
2321 0,
2323 LBS_SORT,
2327 };
2328 static const UINT invalid_idx[] = { -2, 2 };
2329 static const UINT valid_idx[] = { 0, 1 };
2330 static const ULONG_PTR zero_data;
2331 HWND listbox, parent;
2332 unsigned int i;
2334 INT ret;
2335
2336 listbox = CreateWindowA("listbox", "TestList", LBS_NODATA | LBS_OWNERDRAWFIXED | WS_VISIBLE,
2337 0, 0, 100, 100, NULL, NULL, NULL, 0);
2338 ok(listbox != NULL, "Failed to create ListBox window.\n");
2339
2340 ret = SendMessageA(listbox, LB_INSERTSTRING, -1, 0);
2341 ok(ret == 0, "Unexpected return value %d.\n", ret);
2342 ret = SendMessageA(listbox, LB_INSERTSTRING, -1, 0);
2343 ok(ret == 1, "Unexpected return value %d.\n", ret);
2344 ret = SendMessageA(listbox, LB_GETCOUNT, 0, 0);
2345 ok(ret == 2, "Unexpected return value %d.\n", ret);
2346
2347 /* Invalid indices. */
2348 for (i = 0; i < ARRAY_SIZE(invalid_idx); ++i)
2349 {
2350 ret = SendMessageA(listbox, LB_SETITEMDATA, invalid_idx[i], 42);
2351 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2352 ret = SendMessageA(listbox, LB_GETTEXTLEN, invalid_idx[i], 0);
2353 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2354 if (ret == LB_ERR)
2355 {
2356 ret = SendMessageA(listbox, LB_GETTEXT, invalid_idx[i], (LPARAM)&data);
2357 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2358 }
2359 ret = SendMessageA(listbox, LB_GETITEMDATA, invalid_idx[i], 0);
2360 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2361 }
2362
2363 /* Valid indices. */
2364 for (i = 0; i < ARRAY_SIZE(valid_idx); ++i)
2365 {
2366 ret = SendMessageA(listbox, LB_SETITEMDATA, valid_idx[i], 42);
2367 ok(ret == TRUE, "Unexpected return value %d.\n", ret);
2368 ret = SendMessageA(listbox, LB_GETTEXTLEN, valid_idx[i], 0);
2369 ok(ret == sizeof(data), "Unexpected return value %d.\n", ret);
2370
2371 memset(&data, 0xee, sizeof(data));
2372 ret = SendMessageA(listbox, LB_GETTEXT, valid_idx[i], (LPARAM)&data);
2373 ok(ret == sizeof(data), "Unexpected return value %d.\n", ret);
2374 ok(!memcmp(&data, &zero_data, sizeof(data)), "Unexpected item data.\n");
2375
2376 ret = SendMessageA(listbox, LB_GETITEMDATA, valid_idx[i], 0);
2377 ok(ret == 0, "Unexpected return value %d.\n", ret);
2378 }
2379
2380 /* More messages that don't work with LBS_NODATA. */
2381 SetLastError(0xdeadbeef);
2382 ret = SendMessageA(listbox, LB_FINDSTRING, 1, 0);
2383 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2384 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%lX\n", GetLastError());
2385 SetLastError(0xdeadbeef);
2386 ret = SendMessageA(listbox, LB_FINDSTRING, 1, 42);
2387 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2388 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%lX\n", GetLastError());
2389 SetLastError(0xdeadbeef);
2390 ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 0);
2391 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2392 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%lX\n", GetLastError());
2393 SetLastError(0xdeadbeef);
2394 ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 42);
2395 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2396 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%lX\n", GetLastError());
2397 SetLastError(0xdeadbeef);
2398 ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 0);
2399 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2400 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%lX\n", GetLastError());
2401 SetLastError(0xdeadbeef);
2402 ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 42);
2403 ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
2404 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%lX\n", GetLastError());
2405
2406 DestroyWindow(listbox);
2407
2408 /* Invalid window style combinations. */
2410 ok(parent != NULL, "Failed to create parent window.\n");
2411
2412 for (i = 0; i < ARRAY_SIZE(invalid_styles); ++i)
2413 {
2414 DWORD style;
2415
2416 listbox = CreateWindowA("listbox", "TestList", LBS_NODATA | WS_CHILD | invalid_styles[i],
2417 0, 0, 100, 100, parent, (HMENU)1, NULL, 0);
2418 ok(listbox != NULL, "Failed to create a listbox.\n");
2419
2420 style = GetWindowLongA(listbox, GWL_STYLE);
2421 ok((style & invalid_styles[i]) == invalid_styles[i], "%u: unexpected window styles %#lx.\n", i, style);
2422 ret = SendMessageA(listbox, LB_SETCOUNT, 100, 0);
2423 ok(ret == LB_ERR, "%u: unexpected return value %d.\n", i, ret);
2424 DestroyWindow(listbox);
2425 }
2426
2428}
static NTSTATUS zero_data(device_extension *Vcb, fcb *fcb, uint64_t start, uint64_t length, PIRP Irp, LIST_ENTRY *rollback)
Definition: fsctl.c:1811
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memset(x, y, z)
Definition: compat.h:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LB_GETITEMDATA
Definition: winuser.h:2070
#define LB_SELECTSTRING
Definition: winuser.h:2092
#define LB_SETITEMDATA
Definition: winuser.h:2101

◆ test_listbox_dlgdir()

static void test_listbox_dlgdir ( void  )
static

Definition at line 1483 of file listbox.c.

1484{
1486 HWND hWnd;
1487 int res, itemCount;
1488 int itemCount_allDirs;
1489 int itemCount_justFiles;
1490 int itemCount_justDrives;
1491 int i;
1492 char pathBuffer[MAX_PATH];
1493 char itemBuffer[MAX_PATH];
1494 char tempBuffer[MAX_PATH];
1495 char * p;
1496 char driveletter;
1497 HANDLE file;
1498
1500 ok(file != INVALID_HANDLE_VALUE, "Error creating the test file: %ld\n", GetLastError());
1501 CloseHandle( file );
1502
1503 /* NOTE: for this test to succeed, there must be no subdirectories
1504 under the current directory. In addition, there must be at least
1505 one file that fits the wildcard w*.c . Normally, the test
1506 directory itself satisfies both conditions.
1507 */
1508
1511 hWnd = CreateWindowA("ListboxContainerClass", "ListboxContainerClass",
1514 NULL, NULL, hInst, 0);
1515 assert(hWnd);
1516
1517 /* Test for standard usage */
1518
1519 /* The following should be overwritten by the directory path */
1520 SendMessageA(g_label, WM_SETTEXT, 0, (LPARAM)"default contents");
1521
1522 /* This should list all the w*.c files in the test directory
1523 * As of this writing, this includes win.c, winstation.c, wsprintf.c
1524 */
1525 strcpy(pathBuffer, "w*.c");
1527 ok (res == 1, "DlgDirList(*.c, 0) returned %d - expected 1 - 0x%08lx\n", res, GetLastError());
1528
1529 /* Path specification gets converted to uppercase */
1530 ok (!strcmp(pathBuffer, "W*.C"),
1531 "expected conversion to uppercase, got %s\n", pathBuffer);
1532
1533 /* Loaded path should have overwritten the label text */
1535 trace("Static control after DlgDirList: %s\n", pathBuffer);
1536 ok (strcmp("default contents", pathBuffer), "DlgDirList() did not modify static control!\n");
1537
1538 /* There should be some content in the listbox */
1539 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1540 ok (itemCount > 0, "DlgDirList() did NOT fill the listbox!\n");
1541 itemCount_justFiles = itemCount;
1542
1543 /* Every single item in the control should start with a w and end in .c */
1544 for (i = 0; i < itemCount; i++) {
1548 ok(((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1549 (*(p-1) == 'c' || *(p-1) == 'C') &&
1550 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1551 }
1552
1553 /* Test behavior when no files match the wildcard */
1556 ok (res == 1, "DlgDirList(%s, 0) returned %d expected 1\n", BAD_EXTENSION, res);
1557
1558 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1559 ok (itemCount == 0, "DlgDirList() DID fill the listbox!\n");
1560
1561 /* Test DDL_DIRECTORY */
1562 strcpy(pathBuffer, "w*.c");
1565 ok (res == 1, "DlgDirList(*.c, DDL_DIRECTORY) failed - 0x%08lx\n", GetLastError());
1566
1567 /* There should be some content in the listbox. In particular, there should
1568 * be exactly more elements than before, since the directories should
1569 * have been added.
1570 */
1571 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1572 itemCount_allDirs = itemCount - itemCount_justFiles;
1573 ok (itemCount >= itemCount_justFiles,
1574 "DlgDirList(DDL_DIRECTORY) filled with %d entries, expected > %d\n",
1575 itemCount, itemCount_justFiles);
1576
1577 /* Every single item in the control should start with a w and end in .c,
1578 * except for the "[..]" string, which should appear exactly as it is.
1579 */
1580 for (i = 0; i < itemCount; i++) {
1584 ok( (pathBuffer[0] == '[' && pathBuffer[strlen(pathBuffer)-1] == ']') ||
1585 ((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1586 (*(p-1) == 'c' || *(p-1) == 'C') &&
1587 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1588 }
1589
1590 /* Test behavior when no files match the wildcard */
1594 ok (res == 1, "DlgDirList(%s, DDL_DIRECTORY) returned %d expected 1\n", BAD_EXTENSION, res);
1595
1596 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1597 ok (itemCount == itemCount_allDirs,
1598 "DlgDirList() incorrectly filled the listbox! (expected %d got %d)\n",
1599 itemCount_allDirs, itemCount);
1600 for (i = 0; i < itemCount; i++) {
1603 ok( pathBuffer[0] == '[' && pathBuffer[strlen(pathBuffer)-1] == ']',
1604 "Element %d (%s) does not fit requested [...]\n", i, pathBuffer);
1605 }
1606
1607
1608 /* Test DDL_DRIVES. At least on WinXP-SP2, this implies DDL_EXCLUSIVE */
1609 strcpy(pathBuffer, "w*.c");
1611 DDL_DRIVES);
1612 ok (res == 1, "DlgDirList(*.c, DDL_DRIVES) failed - 0x%08lx\n", GetLastError());
1613
1614 /* There should be some content in the listbox. In particular, there should
1615 * be at least one element before, since the string "[-c-]" should
1616 * have been added. Depending on the user setting, more drives might have
1617 * been added.
1618 */
1619 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1620 ok (itemCount >= 1,
1621 "DlgDirList(DDL_DRIVES) filled with %d entries, expected at least %d\n",
1622 itemCount, 1);
1623 itemCount_justDrives = itemCount;
1624
1625 /* Every single item in the control should fit the format [-c-] */
1626 for (i = 0; i < itemCount; i++) {
1628 driveletter = '\0';
1630 ok( strlen(pathBuffer) == 5, "Length of drive string is not 5\n" );
1631 ok( sscanf(pathBuffer, "[-%c-]", &driveletter) == 1, "Element %d (%s) does not fit [-X-]\n", i, pathBuffer);
1632 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1633 if (!(driveletter >= 'a' && driveletter <= 'z')) {
1634 /* Correct after invalid entry is found */
1635 trace("removing count of invalid entry %s\n", pathBuffer);
1636 itemCount_justDrives--;
1637 }
1638 }
1639
1640 /* Test behavior when no files match the wildcard */
1643 DDL_DRIVES);
1644 ok (res == 1, "DlgDirList(%s, DDL_DRIVES) returned %d expected 1\n", BAD_EXTENSION, res);
1645
1646 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1647 ok (itemCount == itemCount_justDrives, "DlgDirList() incorrectly filled the listbox!\n");
1648
1649
1650 /* Test DDL_DIRECTORY|DDL_DRIVES. This does *not* imply DDL_EXCLUSIVE */
1651 strcpy(pathBuffer, "w*.c");
1654 ok (res == 1, "DlgDirList(*.c, DDL_DIRECTORY|DDL_DRIVES) failed - 0x%08lx\n", GetLastError());
1655
1656 /* There should be some content in the listbox. In particular, there should
1657 * be exactly the number of plain files, plus the number of mapped drives,
1658 * plus one "[..]"
1659 */
1660 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1661 ok (itemCount == itemCount_justFiles + itemCount_justDrives + itemCount_allDirs,
1662 "DlgDirList(DDL_DIRECTORY|DDL_DRIVES) filled with %d entries, expected %d\n",
1663 itemCount, itemCount_justFiles + itemCount_justDrives + itemCount_allDirs);
1664
1665 /* Every single item in the control should start with a w and end in .c,
1666 * except for the "[..]" string, which should appear exactly as it is,
1667 * and the mapped drives in the format "[-X-]".
1668 */
1669 for (i = 0; i < itemCount; i++) {
1671 driveletter = '\0';
1674 if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) {
1675 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1676 } else {
1677 ok( (pathBuffer[0] == '[' && pathBuffer[strlen(pathBuffer)-1] == ']') ||
1678 ((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1679 (*(p-1) == 'c' || *(p-1) == 'C') &&
1680 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1681 }
1682 }
1683
1684 /* Test behavior when no files match the wildcard */
1688 ok (res == 1, "DlgDirList(%s, DDL_DIRECTORY|DDL_DRIVES) returned %d expected 1\n", BAD_EXTENSION, res);
1689
1690 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1691 ok (itemCount == itemCount_justDrives + itemCount_allDirs,
1692 "DlgDirList() incorrectly filled the listbox! (expected %d got %d)\n",
1693 itemCount_justDrives + itemCount_allDirs, itemCount);
1694
1695
1696
1697 /* Test DDL_DIRECTORY|DDL_EXCLUSIVE. */
1698 strcpy(pathBuffer, "w*.c");
1701 ok (res == 1, "DlgDirList(*.c, DDL_DIRECTORY|DDL_EXCLUSIVE) failed - 0x%08lx\n", GetLastError());
1702
1703 /* There should be exactly one element: "[..]" */
1704 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1705 ok (itemCount == itemCount_allDirs,
1706 "DlgDirList(DDL_DIRECTORY|DDL_EXCLUSIVE) filled with %d entries, expected %d\n",
1707 itemCount, itemCount_allDirs);
1708
1709 if (itemCount && GetCurrentDirectoryA( MAX_PATH, pathBuffer ) > 3) /* there's no [..] in drive root */
1710 {
1713 ok( !strcmp(pathBuffer, "[..]"), "First (and only) element is not [..]\n");
1714 }
1715
1716 /* Test behavior when no files match the wildcard */
1720 ok (res == 1, "DlgDirList(%s, DDL_DIRECTORY|DDL_EXCLUSIVE) returned %d expected 1\n", BAD_EXTENSION, res);
1721
1722 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1723 ok (itemCount == itemCount_allDirs, "DlgDirList() incorrectly filled the listbox!\n");
1724
1725
1726 /* Test DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE. */
1727 strcpy(pathBuffer, "w*.c");
1730 ok (res == 1, "DlgDirList(*.c, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE) failed - 0x%08lx\n", GetLastError());
1731
1732 /* There should be no plain files on the listbox */
1733 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1734 ok (itemCount == itemCount_justDrives + itemCount_allDirs,
1735 "DlgDirList(DDL_DIRECTORY|DDL_EXCLUSIVE) filled with %d entries, expected %d\n",
1736 itemCount, itemCount_justDrives + itemCount_allDirs);
1737
1738 for (i = 0; i < itemCount; i++) {
1740 driveletter = '\0';
1742 if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) {
1743 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1744 } else {
1745 ok( pathBuffer[0] == '[' && pathBuffer[strlen(pathBuffer)-1] == ']',
1746 "Element %d (%s) does not fit expected [...]\n", i, pathBuffer);
1747 }
1748 }
1749
1750 /* Test behavior when no files match the wildcard */
1754 ok (res == 1, "DlgDirList(%s, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE) returned %d expected 1\n", BAD_EXTENSION, res);
1755
1756 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1757 ok (itemCount == itemCount_justDrives + itemCount_allDirs,
1758 "DlgDirList() incorrectly filled the listbox!\n");
1759
1760 /* Now test DlgDirSelectEx() in normal operation */
1761 /* Fill with everything - drives, directory and all plain files. */
1762 strcpy(pathBuffer, "*");
1765 ok (res != 0, "DlgDirList(*, DDL_DIRECTORY|DDL_DRIVES) failed - 0x%08lx\n", GetLastError());
1766
1767 SendMessageA(g_listBox, LB_SETCURSEL, -1, 0); /* Unselect any current selection */
1769 SetLastError(0xdeadbeef);
1771 ok (GetLastError() == 0xdeadbeef,
1772 "DlgDirSelectEx() with no selection modified last error code from 0xdeadbeef to 0x%08lx\n",
1773 GetLastError());
1774 ok (res == 0, "DlgDirSelectEx() with no selection returned %d, expected 0\n", res);
1775 /* WinXP-SP2 leaves pathBuffer untouched, but Win98 fills it with garbage. */
1776 /*
1777 ok (!*pathBuffer, "DlgDirSelectEx() with no selection filled buffer with %s\n", pathBuffer);
1778 */
1779 /* Test proper drive/dir/file recognition */
1780 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1781 for (i = 0; i < itemCount; i++) {
1782 memset(itemBuffer, 0, MAX_PATH);
1784 memset(tempBuffer, 0, MAX_PATH);
1785 driveletter = '\0';
1786 SendMessageA(g_listBox, LB_GETTEXT, i, (LPARAM)itemBuffer);
1788 ok (res == i, "SendMessageA(LB_SETCURSEL, %d) failed\n", i);
1789 if (sscanf(itemBuffer, "[-%c-]", &driveletter) == 1) {
1790 /* Current item is a drive letter */
1791 SetLastError(0xdeadbeef);
1793 ok (GetLastError() == 0xdeadbeef,
1794 "DlgDirSelectEx() with selection at %d modified last error code from 0xdeadbeef to 0x%08lx\n",
1795 i, GetLastError());
1796 ok(res == 1, "DlgDirSelectEx() thinks %s (%s) is not a drive/directory!\n", itemBuffer, pathBuffer);
1797
1798 /* For drive letters, DlgDirSelectEx tacks on a colon */
1799 ok (pathBuffer[0] == driveletter && pathBuffer[1] == ':' && pathBuffer[2] == '\0',
1800 "%d: got \"%s\" expected \"%c:\"\n", i, pathBuffer, driveletter);
1801 } else if (itemBuffer[0] == '[') {
1802 /* Current item is the parent directory */
1803 SetLastError(0xdeadbeef);
1805 ok (GetLastError() == 0xdeadbeef,
1806 "DlgDirSelectEx() with selection at %d modified last error code from 0xdeadbeef to 0x%08lx\n",
1807 i, GetLastError());
1808 ok(res == 1, "DlgDirSelectEx() thinks %s (%s) is not a drive/directory!\n", itemBuffer, pathBuffer);
1809
1810 /* For directories, DlgDirSelectEx tacks on a backslash */
1812 ok (*(p-1) == '\\', "DlgDirSelectEx did NOT tack on a backslash to dir, got %s\n", pathBuffer);
1813
1814 tempBuffer[0] = '[';
1815 lstrcpynA(tempBuffer + 1, pathBuffer, strlen(pathBuffer));
1816 strcat(tempBuffer, "]");
1817 ok (!strcmp(tempBuffer, itemBuffer), "Formatted directory should be %s, got %s\n", tempBuffer, itemBuffer);
1818 } else {
1819 /* Current item is a plain file */
1820 SetLastError(0xdeadbeef);
1822 ok (GetLastError() == 0xdeadbeef,
1823 "DlgDirSelectEx() with selection at %d modified last error code from 0xdeadbeef to 0x%08lx\n",
1824 i, GetLastError());
1825 ok(res == 0, "DlgDirSelectEx() thinks %s (%s) is a drive/directory!\n", itemBuffer, pathBuffer);
1826
1827 /* NOTE: WinXP tacks a period on all files that lack an extension. This affects
1828 * for example, "Makefile", which gets reported as "Makefile."
1829 */
1830 strcpy(tempBuffer, itemBuffer);
1831 if (strchr(tempBuffer, '.') == NULL) strcat(tempBuffer, ".");
1832 ok (!strcmp(pathBuffer, tempBuffer), "Formatted file should be %s, got %s\n", tempBuffer, pathBuffer);
1833 }
1834 }
1835
1836 DeleteFileA( "wtest1.tmp.c" );
1837
1838 /* Now test DlgDirSelectEx() in abnormal operation */
1839 /* Fill list with bogus entries, that look somewhat valid */
1841 SendMessageA(g_listBox, LB_ADDSTRING, 0, (LPARAM)"[notexist.dir]");
1842 SendMessageA(g_listBox, LB_ADDSTRING, 0, (LPARAM)"notexist.fil");
1843 itemCount = SendMessageA(g_listBox, LB_GETCOUNT, 0, 0);
1844 for (i = 0; i < itemCount; i++) {
1845 memset(itemBuffer, 0, MAX_PATH);
1847 memset(tempBuffer, 0, MAX_PATH);
1848 driveletter = '\0';
1849 SendMessageA(g_listBox, LB_GETTEXT, i, (LPARAM)itemBuffer);
1851 ok (res == i, "SendMessage(LB_SETCURSEL, %d) failed\n", i);
1852 if (sscanf(itemBuffer, "[-%c-]", &driveletter) == 1) {
1853 /* Current item is a drive letter */
1854 SetLastError(0xdeadbeef);
1856 ok (GetLastError() == 0xdeadbeef,
1857 "DlgDirSelectEx() with selection at %d modified last error code from 0xdeadbeef to 0x%08lx\n",
1858 i, GetLastError());
1859 ok(res == 1, "DlgDirSelectEx() thinks %s (%s) is not a drive/directory!\n", itemBuffer, pathBuffer);
1860
1861 /* For drive letters, DlgDirSelectEx tacks on a colon */
1862 ok (pathBuffer[0] == driveletter && pathBuffer[1] == ':' && pathBuffer[2] == '\0',
1863 "%d: got \"%s\" expected \"%c:\"\n", i, pathBuffer, driveletter);
1864 } else if (itemBuffer[0] == '[') {
1865 /* Current item is the parent directory */
1866 SetLastError(0xdeadbeef);
1868 ok (GetLastError() == 0xdeadbeef,
1869 "DlgDirSelectEx() with selection at %d modified last error code from 0xdeadbeef to 0x%08lx\n",
1870 i, GetLastError());
1871 ok(res == 1, "DlgDirSelectEx() thinks %s (%s) is not a drive/directory!\n", itemBuffer, pathBuffer);
1872
1873 /* For directories, DlgDirSelectEx tacks on a backslash */
1875 ok (*(p-1) == '\\', "DlgDirSelectEx did NOT tack on a backslash to dir, got %s\n", pathBuffer);
1876
1877 tempBuffer[0] = '[';
1878 lstrcpynA(tempBuffer + 1, pathBuffer, strlen(pathBuffer));
1879 strcat(tempBuffer, "]");
1880 ok (!strcmp(tempBuffer, itemBuffer), "Formatted directory should be %s, got %s\n", tempBuffer, itemBuffer);
1881 } else {
1882 /* Current item is a plain file */
1883 SetLastError(0xdeadbeef);
1885 ok (GetLastError() == 0xdeadbeef,
1886 "DlgDirSelectEx() with selection at %d modified last error code from 0xdeadbeef to 0x%08lx\n",
1887 i, GetLastError());
1888 ok(res == 0, "DlgDirSelectEx() thinks %s (%s) is a drive/directory!\n", itemBuffer, pathBuffer);
1889
1890 /* NOTE: WinXP and Win98 tack a period on all files that lack an extension.
1891 * This affects for example, "Makefile", which gets reported as "Makefile."
1892 */
1893 strcpy(tempBuffer, itemBuffer);
1894 if (strchr(tempBuffer, '.') == NULL) strcat(tempBuffer, ".");
1895 ok (!strcmp(pathBuffer, tempBuffer), "Formatted file should be %s, got %s\n", tempBuffer, pathBuffer);
1896 }
1897 }
1898
1899 /* Test behavior when loading folders from root with and without wildcard */
1900 strcpy(pathBuffer, "C:\\");
1902 ok(res || broken(!res) /* NT4/W2K */, "DlgDirList failed to list C:\\ folders\n");
1903 ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */,
1904 "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer);
1905
1906 strcpy(pathBuffer, "C:\\*");
1908 ok(res || broken(!res) /* NT4/W2K */, "DlgDirList failed to list C:\\* folders\n");
1909 ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */,
1910 "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer);
1911
1912 /* Try loading files from an invalid folder */
1913 SetLastError(0xdeadbeef);
1914 strcpy(pathBuffer, "C:\\INVALID$$DIR");
1916 ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res);
1918 "GetLastError should return 0x589, got 0x%lX\n",GetLastError());
1919
1921}
HWND hWnd
Definition: settings.c:17
static LPWSTR pathBuffer
Definition: treeview.c:16
#define CloseHandle
Definition: compat.h:739
#define lstrcpynA
Definition: compat.h:751
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2065
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3286
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
GLfloat GLfloat p
Definition: glext.h:8902
#define CREATE_NEW
Definition: disk.h:69
static const char BAD_EXTENSION[]
Definition: listbox.c:90
static BOOL RegisterListboxWindowClass(HINSTANCE hInst)
Definition: listbox.c:1534
#define GENERIC_WRITE
Definition: nt_native.h:90
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
Definition: fci.c:127
#define ERROR_NO_WILDCARD_CHARACTERS
Definition: winerror.h:1243
#define DDL_DRIVES
Definition: winuser.h:425
#define WM_GETTEXT
Definition: winuser.h:1646
#define WM_SETTEXT
Definition: winuser.h:1645
#define DDL_EXCLUSIVE
Definition: winuser.h:426
#define DDL_DIRECTORY
Definition: winuser.h:422
#define CW_USEDEFAULT
Definition: winuser.h:225
int WINAPI DlgDirListA(_In_ HWND, _Inout_ LPSTR, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI DlgDirSelectExA(_In_ HWND hwndDlg, _Out_writes_(chCount) LPSTR lpString, _In_ int chCount, _In_ int idListBox)

◆ test_listbox_height()

static void test_listbox_height ( void  )
static

Definition at line 693 of file listbox.c.

694{
695 HWND hList;
696 int r, id;
697
698 hList = CreateWindowA( "ListBox", "list test", 0,
699 1, 1, 600, 100, NULL, NULL, NULL, NULL );
700 ok( hList != NULL, "failed to create listbox\n");
701
702 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi");
703 ok( id == 0, "item id wrong\n");
704
706 ok( r == 0, "send message failed\n");
707
709 ok( r == 20, "height wrong\n");
710
712 ok( r == -1, "send message failed\n");
713
715 ok( r == 20, "height wrong\n");
716
717 r = SendMessageA( hList, LB_SETITEMHEIGHT, 0, MAKELPARAM( 0x100, 0 ));
718 ok( r == -1, "send message failed\n");
719
721 ok( r == 20, "height wrong\n");
722
723 r = SendMessageA( hList, LB_SETITEMHEIGHT, 0, MAKELPARAM( 0xff, 0 ));
724 ok( r == 0, "send message failed\n");
725
727 ok( r == 0xff, "height wrong\n");
728
730}

◆ test_listbox_item_data()

static void test_listbox_item_data ( void  )
static

Definition at line 948 of file listbox.c.

949{
950 HWND hList;
951 int r, id;
952
953 hList = CreateWindowA( "ListBox", "list test", 0,
954 1, 1, 600, 100, NULL, NULL, NULL, NULL );
955 ok( hList != NULL, "failed to create listbox\n");
956
957 id = SendMessageA( hList, LB_ADDSTRING, 0, (LPARAM) "hi");
958 ok( id == 0, "item id wrong\n");
959
960 r = SendMessageA( hList, LB_SETITEMDATA, 0, MAKELPARAM( 20, 0 ));
961 ok(r == TRUE, "LB_SETITEMDATA returned %d instead of TRUE\n", r);
962
964 ok( r == 20, "get item data failed\n");
965
967}

◆ test_listbox_LB_DIR()

static void test_listbox_LB_DIR ( void  )
static

Definition at line 969 of file listbox.c.

970{
971 char path[MAX_PATH], curdir[MAX_PATH];
972 HWND hList;
973 int res, itemCount;
974 int itemCount_justFiles;
975 int itemCount_justDrives;
976 int itemCount_allFiles;
977 int itemCount_allDirs;
978 int i;
979 char pathBuffer[MAX_PATH];
980 char * p;
981 char driveletter;
982 const char *wildcard = "*";
983 HANDLE file;
984 BOOL ret;
985
986 GetCurrentDirectoryA(ARRAY_SIZE(curdir), curdir);
987
990 ok(ret, "Failed to set current directory.\n");
991
992 ret = CreateDirectoryA("lb_dir_test", NULL);
993 ok(ret, "Failed to create test directory.\n");
994
996 ok(file != INVALID_HANDLE_VALUE, "Error creating the test file: %ld\n", GetLastError());
997 CloseHandle( file );
998
999 /* NOTE: for this test to succeed, there must be no subdirectories
1000 under the current directory. In addition, there must be at least
1001 one file that fits the wildcard w*.c . Normally, the test
1002 directory itself satisfies both conditions.
1003 */
1004 hList = CreateWindowA( "ListBox", "list test", WS_VISIBLE|WS_POPUP,
1005 1, 1, 600, 100, NULL, NULL, NULL, NULL );
1006 assert(hList);
1007
1008 /* Test for standard usage */
1009
1010 /* This should list all the files in the test directory. */
1011 strcpy(pathBuffer, wildcard);
1014 if (res == -1) /* "*" wildcard doesn't work on win9x */
1015 {
1016 wildcard = "*.*";
1017 strcpy(pathBuffer, wildcard);
1019 }
1020 ok (res >= 0, "SendMessage(LB_DIR, 0, *) failed - 0x%08lx\n", GetLastError());
1021
1022 /* There should be some content in the listbox */
1023 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1024 ok (itemCount > 0, "SendMessage(LB_DIR) did NOT fill the listbox!\n");
1025 itemCount_allFiles = itemCount;
1026 ok(res + 1 == itemCount,
1027 "SendMessage(LB_DIR, 0, *) returned incorrect index (expected %d got %d)!\n",
1028 itemCount - 1, res);
1029
1030 /* This tests behavior when no files match the wildcard */
1034 ok (res == -1, "SendMessage(LB_DIR, 0, %s) returned %d, expected -1\n", BAD_EXTENSION, res);
1035
1036 /* There should be NO content in the listbox */
1037 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1038 ok (itemCount == 0, "SendMessage(LB_DIR) DID fill the listbox!\n");
1039
1040
1041 /* This should list all the w*.c files in the test directory
1042 * As of this writing, this includes win.c, winstation.c, wsprintf.c
1043 */
1044 strcpy(pathBuffer, "w*.c");
1047 ok (res >= 0, "SendMessage(LB_DIR, 0, w*.c) failed - 0x%08lx\n", GetLastError());
1048
1049 /* Path specification does NOT converted to uppercase */
1050 ok (!strcmp(pathBuffer, "w*.c"),
1051 "expected no change to pathBuffer, got %s\n", pathBuffer);
1052
1053 /* There should be some content in the listbox */
1054 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1055 ok (itemCount > 0, "SendMessage(LB_DIR) did NOT fill the listbox!\n");
1056 itemCount_justFiles = itemCount;
1057 ok(res + 1 == itemCount,
1058 "SendMessage(LB_DIR, 0, w*.c) returned incorrect index (expected %d got %d)!\n",
1059 itemCount - 1, res);
1060
1061 /* Every single item in the control should start with a w and end in .c */
1062 for (i = 0; i < itemCount; i++) {
1066 ok(((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1067 (*(p-1) == 'c' || *(p-1) == 'C') &&
1068 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1069 }
1070
1071 /* Test DDL_DIRECTORY */
1072 strcpy(pathBuffer, wildcard);
1075 ok (res > 0, "SendMessage(LB_DIR, DDL_DIRECTORY, *) failed - 0x%08lx\n", GetLastError());
1076
1077 /* There should be some content in the listbox.
1078 * All files plus "[..]"
1079 */
1080 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1081 itemCount_allDirs = itemCount - itemCount_allFiles;
1082 ok (itemCount > itemCount_allFiles,
1083 "SendMessage(LB_DIR, DDL_DIRECTORY, *) filled with %d entries, expected > %d\n",
1084 itemCount, itemCount_allFiles);
1085 ok(res + 1 == itemCount,
1086 "SendMessage(LB_DIR, DDL_DIRECTORY, *) returned incorrect index (expected %d got %d)!\n",
1087 itemCount - 1, res);
1088
1089 /* This tests behavior when no files match the wildcard */
1093 ok (res == -1, "SendMessage(LB_DIR, DDL_DIRECTORY, %s) returned %d, expected -1\n", BAD_EXTENSION, res);
1094
1095 /* There should be NO content in the listbox */
1096 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1097 ok (itemCount == 0, "SendMessage(LB_DIR) DID fill the listbox!\n");
1098
1099
1100 /* Test DDL_DIRECTORY */
1101 strcpy(pathBuffer, "w*.c");
1104 ok (res >= 0, "SendMessage(LB_DIR, DDL_DIRECTORY, w*.c) failed - 0x%08lx\n", GetLastError());
1105
1106 /* There should be some content in the listbox. Since the parent directory does not
1107 * fit w*.c, there should be exactly the same number of items as without DDL_DIRECTORY
1108 */
1109 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1110 ok (itemCount == itemCount_justFiles,
1111 "SendMessage(LB_DIR, DDL_DIRECTORY, w*.c) filled with %d entries, expected %d\n",
1112 itemCount, itemCount_justFiles);
1113 ok(res + 1 == itemCount,
1114 "SendMessage(LB_DIR, DDL_DIRECTORY, w*.c) returned incorrect index (expected %d got %d)!\n",
1115 itemCount - 1, res);
1116
1117 /* Every single item in the control should start with a w and end in .c. */
1118 for (i = 0; i < itemCount; i++) {
1122 ok(
1123 ((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1124 (*(p-1) == 'c' || *(p-1) == 'C') &&
1125 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1126 }
1127
1128
1129 /* Test DDL_DRIVES|DDL_EXCLUSIVE */
1130 strcpy(pathBuffer, wildcard);
1133 ok (res >= 0, "SendMessage(LB_DIR, DDL_DRIVES|DDL_EXCLUSIVE, *) failed - 0x%08lx\n", GetLastError());
1134
1135 /* There should be some content in the listbox. In particular, there should
1136 * be at least one element before, since the string "[-c-]" should
1137 * have been added. Depending on the user setting, more drives might have
1138 * been added.
1139 */
1140 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1141 ok (itemCount >= 1,
1142 "SendMessage(LB_DIR, DDL_DRIVES|DDL_EXCLUSIVE, *) filled with %d entries, expected at least %d\n",
1143 itemCount, 1);
1144 itemCount_justDrives = itemCount;
1145 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DRIVES|DDL_EXCLUSIVE, *) returned incorrect index!\n");
1146
1147 /* Every single item in the control should fit the format [-c-] */
1148 for (i = 0; i < itemCount; i++) {
1150 driveletter = '\0';
1152 ok( strlen(pathBuffer) == 5, "Length of drive string is not 5\n" );
1153 ok( sscanf(pathBuffer, "[-%c-]", &driveletter) == 1, "Element %d (%s) does not fit [-X-]\n", i, pathBuffer);
1154 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1155 if (!(driveletter >= 'a' && driveletter <= 'z')) {
1156 /* Correct after invalid entry is found */
1157 trace("removing count of invalid entry %s\n", pathBuffer);
1158 itemCount_justDrives--;
1159 }
1160 }
1161
1162 /* This tests behavior when no files match the wildcard */
1166 ok (res == itemCount_justDrives -1, "SendMessage(LB_DIR, DDL_DRIVES|DDL_EXCLUSIVE, %s) returned %d, expected %d\n",
1167 BAD_EXTENSION, res, itemCount_justDrives -1);
1168
1169 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1170 ok (itemCount == itemCount_justDrives, "SendMessage(LB_DIR) returned %d expected %d\n",
1171 itemCount, itemCount_justDrives);
1172
1173 trace("Files with w*.c: %d Mapped drives: %d Directories: 1\n",
1174 itemCount_justFiles, itemCount_justDrives);
1175
1176 /* Test DDL_DRIVES. */
1177 strcpy(pathBuffer, wildcard);
1180 ok (res > 0, "SendMessage(LB_DIR, DDL_DRIVES, *) failed - 0x%08lx\n", GetLastError());
1181
1182 /* There should be some content in the listbox. In particular, there should
1183 * be at least one element before, since the string "[-c-]" should
1184 * have been added. Depending on the user setting, more drives might have
1185 * been added.
1186 */
1187 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1188 ok (itemCount == itemCount_justDrives + itemCount_allFiles,
1189 "SendMessage(LB_DIR, DDL_DRIVES, *) filled with %d entries, expected %d\n",
1190 itemCount, itemCount_justDrives + itemCount_allFiles);
1191 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DRIVES, *) returned incorrect index!\n");
1192
1193 /* This tests behavior when no files match the wildcard */
1197 ok (res == itemCount_justDrives -1, "SendMessage(LB_DIR, DDL_DRIVES, %s) returned %d, expected %d\n",
1198 BAD_EXTENSION, res, itemCount_justDrives -1);
1199
1200 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1201 ok (itemCount == res + 1, "SendMessage(LB_DIR) returned %d expected %d\n", itemCount, res + 1);
1202
1203
1204 /* Test DDL_DRIVES. */
1205 strcpy(pathBuffer, "w*.c");
1208 ok (res > 0, "SendMessage(LB_DIR, DDL_DRIVES, w*.c) failed - 0x%08lx\n", GetLastError());
1209
1210 /* There should be some content in the listbox. In particular, there should
1211 * be at least one element before, since the string "[-c-]" should
1212 * have been added. Depending on the user setting, more drives might have
1213 * been added.
1214 */
1215 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1216 ok (itemCount == itemCount_justDrives + itemCount_justFiles,
1217 "SendMessage(LB_DIR, DDL_DRIVES, w*.c) filled with %d entries, expected %d\n",
1218 itemCount, itemCount_justDrives + itemCount_justFiles);
1219 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DRIVES, w*.c) returned incorrect index!\n");
1220
1221 /* Every single item in the control should fit the format [-c-], or w*.c */
1222 for (i = 0; i < itemCount; i++) {
1224 driveletter = '\0';
1227 if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) {
1228 ok( strlen(pathBuffer) == 5, "Length of drive string is not 5\n" );
1229 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1230 } else {
1231 ok(
1232 ((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1233 (*(p-1) == 'c' || *(p-1) == 'C') &&
1234 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1235 }
1236 }
1237
1238
1239 /* Test DDL_DIRECTORY|DDL_DRIVES. This does *not* imply DDL_EXCLUSIVE */
1240 strcpy(pathBuffer, wildcard);
1243 ok (res > 0, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES, *) failed - 0x%08lx\n", GetLastError());
1244
1245 /* There should be some content in the listbox. In particular, there should
1246 * be exactly the number of plain files, plus the number of mapped drives.
1247 */
1248 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1249 ok (itemCount == itemCount_allFiles + itemCount_justDrives + itemCount_allDirs,
1250 "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES) filled with %d entries, expected %d\n",
1251 itemCount, itemCount_allFiles + itemCount_justDrives + itemCount_allDirs);
1252 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES, w*.c) returned incorrect index!\n");
1253
1254 /* Every single item in the control should start with a w and end in .c,
1255 * except for the "[..]" string, which should appear exactly as it is,
1256 * and the mapped drives in the format "[-X-]".
1257 */
1258 for (i = 0; i < itemCount; i++) {
1260 driveletter = '\0';
1262 if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) {
1263 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1264 }
1265 }
1266
1267 /* This tests behavior when no files match the wildcard */
1271 ok (res == itemCount_justDrives -1, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES, %s) returned %d, expected %d\n",
1272 BAD_EXTENSION, res, itemCount_justDrives -1);
1273
1274 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1275 ok (itemCount == res + 1, "SendMessage(LB_DIR) returned %d expected %d\n", itemCount, res + 1);
1276
1277
1278
1279 /* Test DDL_DIRECTORY|DDL_DRIVES. */
1280 strcpy(pathBuffer, "w*.c");
1283 ok (res > 0, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES, w*.c) failed - 0x%08lx\n", GetLastError());
1284
1285 /* There should be some content in the listbox. In particular, there should
1286 * be exactly the number of plain files, plus the number of mapped drives.
1287 */
1288 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1289 ok (itemCount == itemCount_justFiles + itemCount_justDrives,
1290 "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES) filled with %d entries, expected %d\n",
1291 itemCount, itemCount_justFiles + itemCount_justDrives);
1292 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES, w*.c) returned incorrect index!\n");
1293
1294 /* Every single item in the control should start with a w and end in .c,
1295 * except the mapped drives in the format "[-X-]". The "[..]" directory
1296 * should not appear.
1297 */
1298 for (i = 0; i < itemCount; i++) {
1300 driveletter = '\0';
1303 if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) {
1304 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1305 } else {
1306 ok(
1307 ((pathBuffer[0] == 'w' || pathBuffer[0] == 'W') &&
1308 (*(p-1) == 'c' || *(p-1) == 'C') &&
1309 (*(p-2) == '.')), "Element %d (%s) does not fit requested w*.c\n", i, pathBuffer);
1310 }
1311 }
1312
1313 /* Test DDL_DIRECTORY|DDL_EXCLUSIVE. */
1314 strcpy(pathBuffer, wildcard);
1317 ok (res != -1, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err %lu\n", GetLastError());
1318
1319 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1320 ok (itemCount == itemCount_allDirs,
1321 "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE) filled with %d entries, expected %d\n",
1322 itemCount, itemCount_allDirs);
1323 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) returned incorrect index!\n");
1324
1325 if (itemCount)
1326 {
1329 ok( !strcmp(pathBuffer, "[..]"), "First element is %s, not [..]\n", pathBuffer);
1330 }
1331
1332 /* This tests behavior when no files match the wildcard */
1336 ok (res == -1, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, %s) returned %d, expected %d\n",
1337 BAD_EXTENSION, res, -1);
1338
1339 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1340 ok (itemCount == res + 1, "SendMessage(LB_DIR) returned %d expected %d\n", itemCount, res + 1);
1341
1342
1343 /* Test DDL_DIRECTORY|DDL_EXCLUSIVE. */
1344 strcpy(pathBuffer, "w*.c");
1347 ok (res == LB_ERR, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, w*.c) returned %d expected %d\n", res, LB_ERR);
1348
1349 /* There should be no elements, since "[..]" does not fit w*.c */
1350 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1351 ok (itemCount == 0,
1352 "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE) filled with %d entries, expected %d\n",
1353 itemCount, 0);
1354
1355 /* Test DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE. */
1356 strcpy(pathBuffer, wildcard);
1359 ok (res > 0, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE, w*.c,) failed - 0x%08lx\n", GetLastError());
1360
1361 /* There should be no plain files on the listbox */
1362 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1363 ok (itemCount == itemCount_justDrives + itemCount_allDirs,
1364 "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE) filled with %d entries, expected %d\n",
1365 itemCount, itemCount_justDrives + itemCount_allDirs);
1366 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE, w*.c) returned incorrect index!\n");
1367
1368 for (i = 0; i < itemCount; i++) {
1370 driveletter = '\0';
1372 if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) {
1373 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1374 } else {
1375 ok( pathBuffer[0] == '[' && pathBuffer[strlen(pathBuffer)-1] == ']',
1376 "Element %d (%s) does not fit expected [...]\n", i, pathBuffer);
1377 }
1378 }
1379
1380 /* This tests behavior when no files match the wildcard */
1384 ok (res == itemCount_justDrives -1, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE, %s) returned %d, expected %d\n",
1385 BAD_EXTENSION, res, itemCount_justDrives -1);
1386
1387 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1388 ok (itemCount == res + 1, "SendMessage(LB_DIR) returned %d expected %d\n", itemCount, res + 1);
1389
1390 /* Test DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE. */
1391 strcpy(pathBuffer, "w*.c");
1394 ok (res >= 0, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE, w*.c,) failed - 0x%08lx\n", GetLastError());
1395
1396 /* There should be no plain files on the listbox, and no [..], since it does not fit w*.c */
1397 itemCount = SendMessageA(hList, LB_GETCOUNT, 0, 0);
1398 ok (itemCount == itemCount_justDrives,
1399 "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE) filled with %d entries, expected %d\n",
1400 itemCount, itemCount_justDrives);
1401 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES|DDL_EXCLUSIVE, w*.c) returned incorrect index!\n");
1402
1403 for (i = 0; i < itemCount; i++) {
1405 driveletter = '\0';
1407 ok (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1, "Element %d (%s) does not fit [-X-]\n", i, pathBuffer);
1408 ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter);
1409 }
1411
1412 DeleteFileA( "wtest1.tmp.c" );
1413 RemoveDirectoryA("lb_dir_test");
1414
1415 SetCurrentDirectoryA(curdir);
1416}
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:682
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2125
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:1973
#define LB_DIR
Definition: winuser.h:2062

◆ test_missing_lbuttonup()

static void test_missing_lbuttonup ( void  )
static

Definition at line 2094 of file listbox.c.

2095{
2096 HWND listbox, parent, capture;
2097
2100
2101 /* Send button down without a corresponding button up */
2102 SendMessageA(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(10,10));
2103 capture = GetCapture();
2104 ok(capture == listbox, "got %p expected %p\n", capture, listbox);
2105
2106 /* Capture is released and LBN_SELCHANGE sent during WM_KILLFOCUS */
2107 got_selchange = 0;
2108 SetFocus(NULL);
2109 capture = GetCapture();
2110 ok(capture == NULL, "got %p\n", capture);
2111 ok(got_selchange, "got %d\n", got_selchange);
2112
2113 DestroyWindow(listbox);
2115}
HWND WINAPI GetCapture(void)
Definition: message.c:2881
HWND WINAPI SetFocus(_In_opt_ HWND)

◆ test_ownerdraw()

static void test_ownerdraw ( void  )
static

Definition at line 340 of file listbox.c.

341{
342 static const DWORD styles[] =
343 {
344 0,
346 };
347 static const struct {
351 UINT drawitem;
352 } testcase[] = {
353 { WM_NULL, 0, 0, 0 },
354 { WM_PAINT, 0, 0, 0 },
355 { LB_GETCOUNT, 0, 0, 0 },
357 { LB_ADDSTRING, 0, (LPARAM)"foo", ARRAY_SIZE(strings)+1 },
358 { LB_DELETESTRING, 0, 0, ARRAY_SIZE(strings)-1 },
359 };
360 HWND parent, hLB;
361 INT ret;
362 RECT rc;
363 UINT i;
364
366 assert(parent);
367
368 for (i = 0; i < ARRAY_SIZE(styles); i++)
369 {
371 assert(hLB);
372
374 UpdateWindow(hLB);
375
376 /* make height short enough */
377 SendMessageA(hLB, LB_GETITEMRECT, 0, (LPARAM)&rc);
378 SetWindowPos(hLB, 0, 0, 0, 100, rc.bottom - rc.top + 1,
380
381 /* make 0 item invisible */
382 SendMessageA(hLB, LB_SETTOPINDEX, 1, 0);
383 ret = SendMessageA(hLB, LB_GETTOPINDEX, 0, 0);
384 ok(ret == 1, "wrong top index %d\n", ret);
385
386 SendMessageA(hLB, LB_GETITEMRECT, 0, (LPARAM)&rc);
387 trace("item 0 rect %s\n", wine_dbgstr_rect(&rc));
388 ok(!IsRectEmpty(&rc), "empty item rect\n");
389 ok(rc.top < 0, "rc.top is not negative (%ld)\n", rc.top);
390
391 DestroyWindow(hLB);
392
393 /* Both FIXED and VARIABLE, FIXED should override VARIABLE. */
394 hLB = CreateWindowA("listbox", "TestList", LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE | styles[i],
395 0, 0, 100, 100, NULL, NULL, NULL, 0);
396 ok(hLB != NULL, "last error 0x%08lx\n", GetLastError());
397
398 ok(GetWindowLongA(hLB, GWL_STYLE) & LBS_OWNERDRAWVARIABLE, "Unexpected window style.\n");
399
400 ret = SendMessageA(hLB, LB_INSERTSTRING, -1, 0);
401 ok(ret == 0, "Unexpected return value %d.\n", ret);
402 ret = SendMessageA(hLB, LB_INSERTSTRING, -1, 0);
403 ok(ret == 1, "Unexpected return value %d.\n", ret);
404
405 ret = SendMessageA(hLB, LB_SETITEMHEIGHT, 0, 13);
406 ok(ret == LB_OKAY, "Failed to set item height, %d.\n", ret);
407
408 ret = SendMessageA(hLB, LB_GETITEMHEIGHT, 0, 0);
409 ok(ret == 13, "Unexpected item height %d.\n", ret);
410
411 ret = SendMessageA(hLB, LB_SETITEMHEIGHT, 1, 42);
412 ok(ret == LB_OKAY, "Failed to set item height, %d.\n", ret);
413
414 ret = SendMessageA(hLB, LB_GETITEMHEIGHT, 0, 0);
415 ok(ret == 42, "Unexpected item height %d.\n", ret);
416
417 ret = SendMessageA(hLB, LB_GETITEMHEIGHT, 1, 0);
418 ok(ret == 42, "Unexpected item height %d.\n", ret);
419
420 DestroyWindow (hLB);
421 }
422
423 /* test pending redraw state */
424 for (i = 0; i < ARRAY_SIZE(testcase); i++)
425 {
428 assert(hLB);
429
431 ok(!ret, "got %d\n", ret);
432 ret = SendMessageA(hLB, testcase[i].message, testcase[i].wparam, testcase[i].lparam);
433 if (testcase[i].message >= LB_ADDSTRING && testcase[i].message < LB_MSGMAX &&
434 testcase[i].message != LB_SETCOUNT)
435 ok(ret > 0, "expected > 0, got %d\n", ret);
436 else
437 ok(!ret, "expected 0, got %d\n", ret);
438
439 got_drawitem = 0;
441 ok(ret, "RedrawWindow failed\n");
442 ok(!got_drawitem, "got %u\n", got_drawitem);
443
444 ret = SendMessageA(hLB, WM_SETREDRAW, TRUE, 0);
445 ok(!ret, "got %d\n", ret);
446
447 got_drawitem = 0;
449 ok(ret, "RedrawWindow failed\n");
450 ok(got_drawitem == testcase[i].drawitem, "expected %u, got %u\n", testcase[i].drawitem, got_drawitem);
451
452 DestroyWindow(hLB);
454 }
455
457}
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
#define WM_PAINT
Definition: winuser.h:1648
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1255
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define RDW_UPDATENOW
Definition: winuser.h:1231
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WM_NULL
Definition: winuser.h:1635
#define LB_MSGMAX
Definition: winuser.h:2079
#define SWP_NOZORDER
Definition: winuser.h:1258
#define WM_SETREDRAW
Definition: winuser.h:1644

◆ test_set_count()

static void test_set_count ( void  )
static

Definition at line 1923 of file listbox.c.

1924{
1925 static const DWORD styles[] =
1926 {
1929 };
1930 HWND parent, listbox;
1931 unsigned int i;
1932 LONG ret;
1933 RECT r;
1934
1937
1938 UpdateWindow( listbox );
1939 GetUpdateRect( listbox, &r, TRUE );
1940 ok( IsRectEmpty( &r ), "got non-empty rect\n");
1941
1942 ret = GetWindowLongA( listbox, GWL_STYLE );
1943 ok((ret & (WS_VSCROLL | WS_HSCROLL)) == 0, "Listbox should not have scroll bars\n");
1944
1945 ret = SendMessageA( listbox, LB_SETCOUNT, 100, 0 );
1946 ok( ret == 0, "got %ld\n", ret );
1947 ret = SendMessageA( listbox, LB_GETCOUNT, 0, 0 );
1948 ok( ret == 100, "got %ld\n", ret );
1949
1950 ret = GetWindowLongA( listbox, GWL_STYLE );
1951 ok((ret & (WS_VSCROLL | WS_HSCROLL)) == WS_VSCROLL, "Listbox should have vertical scroll bar\n");
1952
1953 GetUpdateRect( listbox, &r, TRUE );
1954 ok( !IsRectEmpty( &r ), "got empty rect\n");
1955
1956 ValidateRect( listbox, NULL );
1957 GetUpdateRect( listbox, &r, TRUE );
1958 ok( IsRectEmpty( &r ), "got non-empty rect\n");
1959
1960 ret = SendMessageA( listbox, LB_SETCOUNT, 99, 0 );
1961 ok( ret == 0, "got %ld\n", ret );
1962
1963 GetUpdateRect( listbox, &r, TRUE );
1964 ok( !IsRectEmpty( &r ), "got empty rect\n");
1965
1966 ret = SendMessageA( listbox, LB_SETCOUNT, -5, 0 );
1967 ok( ret == 0, "got %ld\n", ret );
1968 ret = SendMessageA( listbox, LB_GETCOUNT, 0, 0 );
1969 ok( ret == -5, "got %ld\n", ret );
1970
1971 DestroyWindow( listbox );
1972
1973 for (i = 0; i < ARRAY_SIZE(styles); ++i)
1974 {
1975 listbox = create_listbox( styles[i] | WS_CHILD | WS_VISIBLE, parent );
1976
1977 SetLastError( 0xdeadbeef );
1978 ret = SendMessageA( listbox, LB_SETCOUNT, 100, 0 );
1979 ok( ret == LB_ERR, "expected %d, got %ld\n", LB_ERR, ret );
1980 ok( GetLastError() == ERROR_SETCOUNT_ON_BAD_LB, "Unexpected error %ld.\n", GetLastError() );
1981
1982 DestroyWindow( listbox );
1983 }
1984
1986}
#define ERROR_SETCOUNT_ON_BAD_LB
Definition: winerror.h:1259
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)

◆ test_WM_MEASUREITEM()

static void test_WM_MEASUREITEM ( void  )
static

Definition at line 2297 of file listbox.c.

2298{
2299 HWND parent, listbox;
2300 LRESULT data;
2301
2304
2305 data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0);
2306 ok(data == (LRESULT)strings[0], "data = %08Ix, expected %p\n", data, strings[0]);
2308
2311
2312 data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0);
2313 ok(!data, "data = %08Ix\n", data);
2315}

Variable Documentation

◆ BAD_EXTENSION

const char BAD_EXTENSION[] = "*.badtxt"
static

Definition at line 47 of file listbox.c.

◆ g_label

HWND g_label
static

Definition at line 1419 of file listbox.c.

◆ g_listBox

HWND g_listBox
static

Definition at line 1418 of file listbox.c.

◆ got_drawitem

unsigned int got_drawitem
static

Definition at line 241 of file listbox.c.

Referenced by main_window_proc(), and test_ownerdraw().

◆ got_selchange

unsigned int got_selchange
static

Definition at line 241 of file listbox.c.

◆ lb_getlistboxinfo

int lb_getlistboxinfo
static

Definition at line 1989 of file listbox.c.

Referenced by listbox_subclass_proc(), and test_GetListBoxInfo().

◆ strings

const char* const strings[4]
static
Initial value:
= {
"First added",
"Second added",
"Third added",
"Fourth added which is very long because at some time we only had a 256 byte character buffer and that was overflowing in one of those applications that had a common dialog file open box and tried to add a 300 characters long custom filter string which of course the code did not like and crashed. Just make sure this string is longer than 256 characters."
}

Definition at line 40 of file listbox.c.