ReactOS 0.4.16-dev-297-gc569aee
combo.c File Reference
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#include "wine/test.h"
Include dependency graph for combo.c:

Go to the source code of this file.

Macros

#define STRICT
 
#define WIN32_LEAN_AND_MEAN
 
#define COMBO_ID   1995
 
#define COMBO_YBORDERSIZE()   2
 
#define expect_eq(expr, value, type, fmt)   ; { type val = expr; ok(val == (value), #expr " expected " #fmt " got " #fmt "\n", (value), val); }
 
#define expect_rect(r, _left, _top, _right, _bottom)
 

Functions

static HWND build_combo (DWORD style)
 
static int font_height (HFONT hFont)
 
static INT CALLBACK is_font_installed_proc (const LOGFONTA *elf, const TEXTMETRICA *tm, DWORD type, LPARAM lParam)
 
static BOOL is_font_installed (const char *name)
 
static void test_setitemheight (DWORD style)
 
static void test_setfont (DWORD style)
 
static LRESULT (CALLBACK *old_parent_proc)(HWND hwnd
 
static LRESULT CALLBACK parent_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_selection (DWORD style, const char *const text[], const int *edit, const int *list)
 
static void test_CBN_SELCHANGE (void)
 
static void test_WM_LBUTTONDOWN (void)
 
static void test_changesize (DWORD style)
 
static void test_editselection (void)
 
static LRESULT CALLBACK combobox_subclass_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK test_window_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void test_editselection_focus (DWORD style)
 
static void test_listbox_styles (DWORD cb_style)
 
static void test_listbox_size (DWORD style)
 
static void test_WS_VSCROLL (void)
 
 START_TEST (combo)
 

Variables

static HWND hMainWnd
 
static UINT msg
 
static UINT WPARAM wparam
 
static UINT WPARAM LPARAM lparam
 
static LPCSTR expected_edit_text
 
static LPCSTR expected_list_text
 
static BOOL selchange_fired
 
static WNDPROC edit_window_proc
 
static long setsel_start = 1
 
static long setsel_end = 1
 
static HWND hCBN_SetFocus
 
static HWND hCBN_KillFocus
 

Macro Definition Documentation

◆ COMBO_ID

#define COMBO_ID   1995

Definition at line 30 of file combo.c.

◆ COMBO_YBORDERSIZE

#define COMBO_YBORDERSIZE ( )    2

Definition at line 32 of file combo.c.

◆ expect_eq

#define expect_eq (   expr,
  value,
  type,
  fmt 
)    ; { type val = expr; ok(val == (value), #expr " expected " #fmt " got " #fmt "\n", (value), val); }

Definition at line 36 of file combo.c.

◆ expect_rect

#define expect_rect (   r,
  _left,
  _top,
  _right,
  _bottom 
)
Value:
ok(r.left == _left && r.top == _top && \
r.bottom == _bottom && r.right == _right, "Invalid rect %s vs (%d,%d)-(%d,%d)\n", \
wine_dbgstr_rect(&r), _left, _top, _right, _bottom);
#define ok(value,...)
Definition: atltest.h:57
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Definition at line 37 of file combo.c.

◆ STRICT

#define STRICT

Definition at line 24 of file combo.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 25 of file combo.c.

Function Documentation

◆ build_combo()

static HWND build_combo ( DWORD  style)
static

Definition at line 41 of file combo.c.

42{
43 return CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
44}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
#define COMBO_ID
Definition: combo.c:38
static HWND hMainWnd
Definition: combo.c:49
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318

Referenced by test_changesize(), test_editselection(), test_editselection_focus(), test_listbox_styles(), test_selection(), test_setfont(), test_setitemheight(), and test_WS_VSCROLL().

◆ combobox_subclass_proc()

static LRESULT CALLBACK combobox_subclass_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 539 of file combo.c.

540{
541 if (msg == EM_SETSEL)
542 {
545 }
547}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static long setsel_start
Definition: combo.c:1032
static long setsel_end
Definition: combo.c:1032
static WNDPROC edit_window_proc
Definition: combo.c:1031
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define EM_SETSEL
Definition: winuser.h:2021
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ font_height()

static int font_height ( HFONT  hFont)
static

Definition at line 46 of file combo.c.

47{
49 HFONT hFontOld;
50 HDC hDC;
51
53 hFontOld = SelectObject(hDC, hFont);
55 SelectObject(hDC, hFontOld);
57
58 return tm.tmHeight;
59}
static HDC hDC
Definition: 3dtext.c:33
HFONT hFont
Definition: main.c:53
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
Definition: time.h:68
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by GdipGetFontHeight(), get_font_hfont(), OleCreatePropertyFrameIndirect(), test_combo_setitemheight(), test_font_height_scaling(), test_GetConsoleFontSize(), test_GetTextMetrics2(), test_ID3DXFont(), test_setfont(), and test_setitemheight().

◆ is_font_installed()

static BOOL is_font_installed ( const char name)
static

Definition at line 66 of file combo.c.

67{
68 HDC hdc = GetDC(NULL);
71 return ret;
72}
unsigned int BOOL
Definition: ntddk_ex.h:94
HDC hdc
Definition: main.c:9
static INT CALLBACK is_font_installed_proc(const LOGFONTA *elf, const TEXTMETRICA *tm, DWORD type, LPARAM lParam)
Definition: combo.c:61
Definition: name.c:39
int ret
int WINAPI EnumFontFamiliesA(_In_ HDC, _In_opt_ LPCSTR, _In_ FONTENUMPROCA, _In_ LPARAM)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by test_setfont().

◆ is_font_installed_proc()

static INT CALLBACK is_font_installed_proc ( const LOGFONTA elf,
const TEXTMETRICA tm,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 61 of file combo.c.

62{
63 return 0;
64}

Referenced by is_font_installed().

◆ LRESULT()

static LRESULT ( CALLBACK old_parent_proc)
static

◆ parent_wnd_proc()

static LRESULT CALLBACK parent_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 177 of file combo.c.

178{
179 switch (msg)
180 {
181 case WM_COMMAND:
182 switch (wparam)
183 {
185 {
186 HWND hCombo = (HWND)lparam;
187 int idx;
188 char list[20], edit[20];
189
190 memset(list, 0, sizeof(list));
191 memset(edit, 0, sizeof(edit));
192
193 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
195 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
196
197 ok(!strcmp(edit, expected_edit_text), "edit: got %s, expected %s\n",
198 edit, expected_edit_text);
199 ok(!strcmp(list, expected_list_text), "list: got %s, expected %s\n",
201
203 }
204 break;
205 }
206 break;
207 }
208
209 return CallWindowProcA(old_parent_proc, hwnd, msg, wparam, lparam);
210}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Definition: list.h:37
#define TRUE
Definition: types.h:120
unsigned int idx
Definition: utils.c:41
HANDLE HWND
Definition: compat.h:19
static BOOL selchange_fired
Definition: combo.c:745
static LPCSTR expected_edit_text
Definition: combo.c:743
static UINT WPARAM wparam
Definition: combo.c:742
static UINT WPARAM LPARAM lparam
Definition: combo.c:742
static LPCSTR expected_list_text
Definition: combo.c:744
#define memset(x, y, z)
Definition: compat.h:39
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define CB_GETLBTEXT
Definition: winuser.h:1955
#define WM_COMMAND
Definition: winuser.h:1743
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETTEXT
Definition: winuser.h:1621
#define CBN_SELCHANGE
Definition: winuser.h:1982
#define CB_GETCURSEL
Definition: winuser.h:1946

◆ START_TEST()

START_TEST ( combo  )

Definition at line 807 of file combo.c.

808{
809 hMainWnd = CreateWindowA("static", "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
811
828
830}
static void test_editselection(void)
Definition: combo.c:436
static void test_listbox_styles(DWORD cb_style)
Definition: combo.c:628
static void test_setitemheight(DWORD style)
Definition: combo.c:74
static void test_setfont(DWORD style)
Definition: combo.c:97
static void test_listbox_size(DWORD style)
Definition: combo.c:676
static void test_editselection_focus(DWORD style)
Definition: combo.c:571
static void test_changesize(DWORD style)
Definition: combo.c:361
static void test_WS_VSCROLL(void)
Definition: combo.c:772
static void test_WM_LBUTTONDOWN(void)
Definition: combo.c:278
static void test_CBN_SELCHANGE(void)
Definition: combo.c:267
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CBS_DROPDOWNLIST
Definition: winuser.h:284
#define CBS_SIMPLE
Definition: winuser.h:291
#define CBS_DROPDOWN
Definition: winuser.h:283
#define SW_SHOW
Definition: winuser.h:778
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ test_CBN_SELCHANGE()

static void test_CBN_SELCHANGE ( void  )
static

Definition at line 267 of file combo.c.

268{
269 static const char * const text[] = { "alpha", "beta", "" };
270 static const int sel_1[] = { 2, 0, 1, 0, 1 };
271 static const int sel_2[] = { 0, 1, 0, 0, 1 };
272
273 test_selection(CBS_SIMPLE, text, sel_1, sel_2);
274 test_selection(CBS_DROPDOWN, text, sel_1, sel_2);
275 test_selection(CBS_DROPDOWNLIST, text, sel_2, sel_2);
276}
const WCHAR * text
Definition: package.c:1794
static void test_selection(void)
Definition: trackbar.c:859

Referenced by START_TEST().

◆ test_changesize()

static void test_changesize ( DWORD  style)
static

Definition at line 361 of file combo.c.

362{
363 HWND hCombo = build_combo(style);
364 RECT rc;
365 INT ddheight, clheight, ddwidth, clwidth;
366 /* get initial measurements */
367 GetClientRect( hCombo, &rc);
368 clheight = rc.bottom - rc.top;
369 clwidth = rc.right - rc.left;
371 ddheight = rc.bottom - rc.top;
372 ddwidth = rc.right - rc.left;
373 /* use MoveWindow to move & resize the combo */
374 /* first make it slightly smaller */
375 MoveWindow( hCombo, 10, 10, clwidth - 2, clheight - 2, TRUE);
376 GetClientRect( hCombo, &rc);
377 ok( rc.right - rc.left == clwidth - 2, "clientrect width is %d vs %d\n",
378 rc.right - rc.left, clwidth - 2);
379 ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
380 rc.bottom - rc.top, clheight);
382 ok( rc.right - rc.left == clwidth - 2, "drop-down rect width is %d vs %d\n",
383 rc.right - rc.left, clwidth - 2);
384 ok( rc.bottom - rc.top == ddheight, "drop-down rect height is %d vs %d\n",
385 rc.bottom - rc.top, ddheight);
386 ok( rc.right - rc.left == ddwidth -2, "drop-down rect width is %d vs %d\n",
387 rc.right - rc.left, ddwidth - 2);
388 /* new cx, cy is slightly bigger than the initial values */
389 MoveWindow( hCombo, 10, 10, clwidth + 2, clheight + 2, TRUE);
390 GetClientRect( hCombo, &rc);
391 ok( rc.right - rc.left == clwidth + 2, "clientrect width is %d vs %d\n",
392 rc.right - rc.left, clwidth + 2);
393 ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
394 rc.bottom - rc.top, clheight);
396 ok( rc.right - rc.left == clwidth + 2, "drop-down rect width is %d vs %d\n",
397 rc.right - rc.left, clwidth + 2);
398 todo_wine {
399 ok( rc.bottom - rc.top == clheight + 2, "drop-down rect height is %d vs %d\n",
400 rc.bottom - rc.top, clheight + 2);
401 }
402
403 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, -1, 0);
404 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
405 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
406 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
407
408 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
409 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
410 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
411 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
412
413 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth - 1, 0);
414 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
415 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
416 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
417
418 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth << 1, 0);
419 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
420 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
421 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
422
423 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
424 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
425 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
426 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
427
428 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 1, 0);
429 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
430 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
431 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
432
433 DestroyWindow(hCombo);
434}
#define todo_wine
Definition: custom.c:89
static HWND build_combo(DWORD style)
Definition: combo.c:41
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
#define CB_SETDROPPEDWIDTH
Definition: winuser.h:1965
#define CB_GETDROPPEDWIDTH
Definition: winuser.h:1949
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define CB_GETDROPPEDCONTROLRECT
Definition: winuser.h:1947
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by START_TEST().

◆ test_editselection()

static void test_editselection ( void  )
static

Definition at line 436 of file combo.c.

437{
438 HWND hCombo;
439 INT start,end;
440 HWND hEdit;
441 COMBOBOXINFO cbInfo;
442 BOOL ret;
443 DWORD len;
444 char edit[20];
445
446 /* Build a combo */
447 hCombo = build_combo(CBS_SIMPLE);
448 cbInfo.cbSize = sizeof(COMBOBOXINFO);
449 SetLastError(0xdeadbeef);
450 ret = GetComboBoxInfo(hCombo, &cbInfo);
451 ok(ret, "Failed to get combobox info structure. LastError=%d\n",
452 GetLastError());
453 hEdit = cbInfo.hwndItem;
454
455 /* Initially combo selection is empty*/
456 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
457 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
458 ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
459
460 /* Set some text, and press a key to replace it */
461 edit[0] = 0x00;
462 SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason1");
463 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
464 ok(strcmp(edit, "Jason1")==0, "Unexpected text retrieved %s\n", edit);
465
466 /* Now what is the selection - still empty */
468 ok(start==0, "Unexpected start position for selection %d\n", start);
469 ok(end==0, "Unexpected end position for selection %d\n", end);
470 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
471 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
472 ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
473
474 /* Give it focus, and it gets selected */
475 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
477 ok(start==0, "Unexpected start position for selection %d\n", start);
478 ok(end==6, "Unexpected end position for selection %d\n", end);
479 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
480 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
481 ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
482
483 /* Now emulate a key press */
484 edit[0] = 0x00;
485 SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
486 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
487 ok(strcmp(edit, "A")==0, "Unexpected text retrieved %s\n", edit);
488
489 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
490 ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
491 ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
492
493 /* Now what happens when it gets more focus a second time - it doesn't reselect */
494 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
495 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
496 ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
497 ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
498 DestroyWindow(hCombo);
499
500 /* Start again - Build a combo */
501 hCombo = build_combo(CBS_SIMPLE);
502 cbInfo.cbSize = sizeof(COMBOBOXINFO);
503 SetLastError(0xdeadbeef);
504 ret = GetComboBoxInfo(hCombo, &cbInfo);
505 ok(ret, "Failed to get combobox info structure. LastError=%d\n",
506 GetLastError());
507 hEdit = cbInfo.hwndItem;
508
509 /* Set some text and give focus so it gets selected */
510 edit[0] = 0x00;
511 SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason2");
512 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
513 ok(strcmp(edit, "Jason2")==0, "Unexpected text retrieved %s\n", edit);
514
515 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
516
517 /* Now what is the selection */
519 ok(start==0, "Unexpected start position for selection %d\n", start);
520 ok(end==6, "Unexpected end position for selection %d\n", end);
521 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
522 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
523 ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
524
525 /* Now change the selection to the apparently invalid start -1, end -1 and
526 show it means no selection (ie start -1) but cursor at end */
527 SendMessageA(hCombo, CB_SETEDITSEL, 0, -1);
528 edit[0] = 0x00;
529 SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
530 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
531 ok(strcmp(edit, "Jason2A")==0, "Unexpected text retrieved %s\n", edit);
532 DestroyWindow(hCombo);
533}
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
#define LOWORD(l)
Definition: pedump.c:82
static HWND hEdit
Definition: autocomplete.c:34
#define HIWORD(l)
Definition: typedefs.h:247
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_SETFOCUS
Definition: winuser.h:1616
#define WM_SETTEXT
Definition: winuser.h:1620
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
struct tagCOMBOBOXINFO COMBOBOXINFO
#define CB_SETEDITSEL
Definition: winuser.h:1966
#define WM_CHAR
Definition: winuser.h:1720
#define CB_GETEDITSEL
Definition: winuser.h:1950

Referenced by START_TEST().

◆ test_editselection_focus()

static void test_editselection_focus ( DWORD  style)
static

Definition at line 571 of file combo.c.

572{
573 HWND hCombo, hEdit, hButton;
574 COMBOBOXINFO cbInfo;
575 BOOL ret;
576 const char wine_test[] = "Wine Test";
577 char buffer[16] = {0};
578 DWORD len;
579
580 hCombo = build_combo(style);
581 cbInfo.cbSize = sizeof(COMBOBOXINFO);
582 SetLastError(0xdeadbeef);
583 ret = GetComboBoxInfo(hCombo, &cbInfo);
584 ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());
585 hEdit = cbInfo.hwndItem;
586
587 hButton = CreateWindowA("Button", "OK", WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
588 5, 50, 100, 20, hMainWnd, NULL,
590
593
594 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
595 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
596 todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
597 ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
598 ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
599
601 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
602 todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
603 ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
604 ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
605
608 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
609 todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
610 ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
611 ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
612 SendMessageA(hCombo, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
613 ok(!strcmp(buffer, wine_test), "Unexpected text in edit control; got '%s'\n", buffer);
614
616 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
617 todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
618 ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
619 ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
620 len = SendMessageA(hCombo, CB_GETEDITSEL, 0, 0);
621 ok(len == 0, "Unexpected text selection; start: %u, end: %u\n", LOWORD(len), HIWORD(len));
622
624 DestroyWindow(hButton);
625 DestroyWindow(hCombo);
626}
GLuint buffer
Definition: glext.h:5915
#define INT_MAX
Definition: intsafe.h:150
static LRESULT CALLBACK combobox_subclass_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: combo.c:1035
static HWND hCBN_KillFocus
Definition: combo.c:1033
static LRESULT CALLBACK test_window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: combo.c:1045
static HWND hCBN_SetFocus
Definition: combo.c:1033
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
Definition: main.c:45
#define GWLP_WNDPROC
Definition: treelist.c:66
uint32_t ULONG_PTR
Definition: typedefs.h:65
HWND WINAPI GetFocus(void)
Definition: window.c:1865
#define SetWindowLongPtrA
Definition: winuser.h:5357
#define GetWindowLongPtrA
Definition: winuser.h:4831
#define GWLP_HINSTANCE
Definition: winuser.h:859
#define WM_NEXTDLGCTL
Definition: winuser.h:1646
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909

Referenced by START_TEST().

◆ test_listbox_size()

static void test_listbox_size ( DWORD  style)
static

Definition at line 676 of file combo.c.

677{
678 HWND hCombo, hList;
679 COMBOBOXINFO cbInfo;
680 UINT x, y;
681 BOOL ret;
682 int i, test;
683 const char wine_test[] = "Wine Test";
684
685 static const struct list_size_info
686 {
687 int num_items;
688 int height_combo;
689 BOOL todo;
690 } info_height[] = {
691 {2, 24, FALSE},
692 {2, 41, TRUE},
693 {2, 42, FALSE},
694 {2, 50, FALSE},
695 {2, 60},
696 {2, 80},
697 {2, 89},
698 {2, 90},
699 {2, 100},
700
701 {10, 24, FALSE},
702 {10, 41, TRUE},
703 {10, 42, FALSE},
704 {10, 50, FALSE},
705 {10, 60, FALSE},
706 {10, 80, FALSE},
707 {10, 89, TRUE},
708 {10, 90, FALSE},
709 {10, 100, FALSE},
710 };
711
712 for(test = 0; test < ARRAY_SIZE(info_height); test++)
713 {
714 const struct list_size_info *info_test = &info_height[test];
715 int height_item; /* Height of a list item */
716 int height_list; /* Height of the list we got */
717 int expected_count_list;
718 int expected_height_list;
719 int list_height_nonclient;
720 int list_height_calculated;
721 RECT rect_list_client, rect_list_complete;
722
723 hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100,
724 info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
725
726 cbInfo.cbSize = sizeof(COMBOBOXINFO);
727 SetLastError(0xdeadbeef);
728 ret = GetComboBoxInfo(hCombo, &cbInfo);
729 ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());
730
731 hList = cbInfo.hwndList;
732 for (i = 0; i < info_test->num_items; i++)
734
735 /* Click on the button to drop down the list */
736 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
737 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
738 ret = SendMessageA(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
739 ok(ret, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
740 GetLastError());
741 ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
742 "The dropdown list should have appeared after clicking the button.\n");
743
744 GetClientRect(hList, &rect_list_client);
745 GetWindowRect(hList, &rect_list_complete);
746 height_list = rect_list_client.bottom - rect_list_client.top;
747 height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0);
748
749 list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top)
750 - (rect_list_client.bottom - rect_list_client.top);
751
752 /* Calculate the expected client size of the listbox popup from the size of the combobox. */
753 list_height_calculated = info_test->height_combo
754 - (cbInfo.rcItem.bottom + COMBO_YBORDERSIZE())
755 - list_height_nonclient
756 - 1;
757
758 expected_count_list = list_height_calculated / height_item;
759 if(expected_count_list < 0)
760 expected_count_list = 0;
761 expected_count_list = min(expected_count_list, info_test->num_items);
762 expected_height_list = expected_count_list * height_item;
763
764 todo_wine_if(info_test->todo)
765 ok(expected_height_list == height_list,
766 "Test %d, expected list height to be %d, got %d\n", test, expected_height_list, height_list);
767
768 DestroyWindow(hCombo);
769 }
770}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FALSE
Definition: types.h:117
#define COMBO_YBORDERSIZE()
Definition: combo.c:74
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble n
Definition: glext.h:7729
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
#define d
Definition: ke_i.h:81
HWND hList
Definition: livecd.c:10
BOOL todo
Definition: filedlg.c:313
BOOL expected
Definition: store.c:2063
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define test
Definition: rosglue.h:37
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
#define LB_GETITEMHEIGHT
Definition: winuser.h:2045
#define CB_ADDSTRING
Definition: winuser.h:1939
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1948

Referenced by START_TEST().

◆ test_listbox_styles()

static void test_listbox_styles ( DWORD  cb_style)
static

Definition at line 628 of file combo.c.

629{
630 HWND combo;
632 DWORD style, exstyle, expect_style, expect_exstyle;
633 BOOL ret;
634
636 if (cb_style == CBS_SIMPLE)
637 {
639 expect_exstyle = WS_EX_CLIENTEDGE;
640 }
641 else
642 {
644 expect_exstyle = WS_EX_TOOLWINDOW;
645 }
646
647 combo = build_combo(cb_style);
648 info.cbSize = sizeof(COMBOBOXINFO);
649 SetLastError(0xdeadbeef);
650 ret = GetComboBoxInfo(combo, &info);
651 ok(ret, "Failed to get combobox info structure.\n");
652
653 style = GetWindowLongW( info.hwndList, GWL_STYLE );
654 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
655 ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
656 ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
657
658 if (cb_style != CBS_SIMPLE)
659 expect_exstyle |= WS_EX_TOPMOST;
660
661 SendMessageW(combo, CB_SHOWDROPDOWN, TRUE, 0 );
662 style = GetWindowLongW( info.hwndList, GWL_STYLE );
663 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
664 ok(style == (expect_style | WS_VISIBLE), "%08x: got %08x\n", cb_style, style);
665 ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
666
668 style = GetWindowLongW( info.hwndList, GWL_STYLE );
669 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
670 ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
671 ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
672
673 DestroyWindow(combo);
674}
#define WS_BORDER
Definition: pedump.c:625
#define LBS_HASSTRINGS
Definition: pedump.c:684
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define LBS_NOTIFY
Definition: pedump.c:678
#define expect_style(window, style)
#define CB_SHOWDROPDOWN
Definition: winuser.h:1973
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define LBS_COMBOBOX
Definition: winuser.h:324
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define GWL_STYLE
Definition: winuser.h:855
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GWL_EXSTYLE
Definition: winuser.h:854

Referenced by START_TEST().

◆ test_selection()

static void test_selection ( DWORD  style,
const char *const  text[],
const int edit,
const int list 
)
static

Definition at line 212 of file combo.c.

214{
215 INT idx;
216 HWND hCombo;
217
218 hCombo = build_combo(style);
219
220 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[0]);
221 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[1]);
222 SendMessageA(hCombo, CB_SETCURSEL, -1, 0);
223
225
226 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
227 ok(idx == -1, "expected selection -1, got %d\n", idx);
228
229 /* keyboard navigation */
230
232 expected_edit_text = text[edit[0]];
234 SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
235 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
236
238 expected_edit_text = text[edit[1]];
240 SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
241 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
242
244 expected_edit_text = text[edit[2]];
246 SendMessageA(hCombo, WM_KEYDOWN, VK_UP, 0);
247 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
248
249 /* programmatic navigation */
250
252 expected_edit_text = text[edit[3]];
254 SendMessageA(hCombo, CB_SETCURSEL, list[3], 0);
255 ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
256
258 expected_edit_text = text[edit[4]];
260 SendMessageA(hCombo, CB_SETCURSEL, list[4], 0);
261 ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
262
264 DestroyWindow(hCombo);
265}
static LRESULT CALLBACK parent_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: combo.c:748
#define CB_SETCURSEL
Definition: winuser.h:1964
#define VK_UP
Definition: winuser.h:2228
#define VK_DOWN
Definition: winuser.h:2230
#define WM_KEYDOWN
Definition: winuser.h:1718

◆ test_setfont()

static void test_setfont ( DWORD  style)
static

Definition at line 97 of file combo.c.

98{
99 HWND hCombo;
100 HFONT hFont1, hFont2;
101 RECT r;
102 int i;
103
104 if (!is_font_installed("Marlett"))
105 {
106 skip("Marlett font not available\n");
107 return;
108 }
109
110 trace("Style %x\n", style);
111
112 hCombo = build_combo(style);
115
116 GetClientRect(hCombo, &r);
120 todo_wine expect_rect(r, 5, 5, 105, 105);
121
122 /* The size of the dropped control is initially equal to the size
123 of the window when it was created. The size of the calculated
124 dropped area changes only by how much the selection area
125 changes, not by how much the list area changes. */
126 if (font_height(hFont1) == 10 && font_height(hFont2) == 8)
127 {
128 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
129 GetClientRect(hCombo, &r);
130 expect_rect(r, 0, 0, 100, 18);
134
135 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE);
136 GetClientRect(hCombo, &r);
137 expect_rect(r, 0, 0, 100, 16);
141
142 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
143 GetClientRect(hCombo, &r);
144 expect_rect(r, 0, 0, 100, 18);
148 }
149 else
150 {
151 ok(0, "Expected Marlett font heights 10/8, got %d/%d\n",
152 font_height(hFont1), font_height(hFont2));
153 }
154
155 for (i = 1; i < 30; i++)
156 {
158 int height = font_height(hFont);
159
161 GetClientRect(hCombo, &r);
162 expect_eq(r.bottom - r.top, height + 8, int, "%d");
163 SendMessageA(hCombo, WM_SETFONT, 0, FALSE);
165 }
166
167 DestroyWindow(hCombo);
168 DeleteObject(hFont1);
169 DeleteObject(hFont2);
170}
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
pKey DeleteObject()
#define expect_rect(r, _left, _top, _right, _bottom)
Definition: combo.c:42
#define expect_eq(expr, value, type, fmt)
Definition: combo.c:36
static BOOL is_font_installed(const char *name)
Definition: combo.c:66
static int font_height(HFONT hFont)
Definition: combo.c:46
#define DEFAULT_PITCH
Definition: wingdi.h:443
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define FW_DONTCARE
Definition: wingdi.h:368
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define SYSTEM_FONT
Definition: wingdi.h:911
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
#define SYMBOL_CHARSET
Definition: wingdi.h:385
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define HWND_DESKTOP
Definition: winuser.h:1212
#define WM_SETFONT
Definition: winuser.h:1653

Referenced by START_TEST().

◆ test_setitemheight()

static void test_setitemheight ( DWORD  style)
static

Definition at line 74 of file combo.c.

75{
76 HWND hCombo = build_combo(style);
77 RECT r;
78 int i;
79
80 trace("Style %x\n", style);
81 GetClientRect(hCombo, &r);
85 todo_wine expect_rect(r, 5, 5, 105, 105);
86
87 for (i = 1; i < 30; i++)
88 {
89 SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, i);
90 GetClientRect(hCombo, &r);
91 expect_eq(r.bottom - r.top, i + 6, int, "%d");
92 }
93
94 DestroyWindow(hCombo);
95}
#define CB_SETITEMHEIGHT
Definition: winuser.h:1970

Referenced by START_TEST().

◆ test_window_proc()

static LRESULT CALLBACK test_window_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 549 of file combo.c.

550{
551 switch (msg)
552 {
553 case WM_COMMAND:
554 switch (HIWORD(wParam))
555 {
556 case CBN_SETFOCUS:
558 break;
559 case CBN_KILLFOCUS:
561 break;
562 }
563 break;
564 case WM_NEXTDLGCTL:
566 break;
567 }
568 return CallWindowProcA(old_parent_proc, hwnd, msg, wParam, lParam);
569}
#define CBN_SETFOCUS
Definition: winuser.h:1985
HWND WINAPI SetFocus(_In_opt_ HWND)
#define CBN_KILLFOCUS
Definition: winuser.h:1981

◆ test_WM_LBUTTONDOWN()

static void test_WM_LBUTTONDOWN ( void  )
static

Definition at line 278 of file combo.c.

279{
280 HWND hCombo, hEdit, hList;
281 COMBOBOXINFO cbInfo;
282 UINT x, y, item_height;
284 int i, idx;
285 RECT rect;
286 CHAR buffer[3];
287 static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
288 static const CHAR stringFormat[] = "%2d";
289 BOOL ret;
290
291 hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|CBS_DROPDOWN,
292 0, 0, 200, 150, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
293
294 for (i = 0; i < ARRAY_SIZE(choices); i++){
295 sprintf(buffer, stringFormat, choices[i]);
297 ok(result == i,
298 "Failed to add item %d\n", i);
299 }
300
301 cbInfo.cbSize = sizeof(COMBOBOXINFO);
302 SetLastError(0xdeadbeef);
303 ret = GetComboBoxInfo(hCombo, &cbInfo);
304 ok(ret, "Failed to get combobox info structure. LastError=%d\n",
305 GetLastError());
306 hEdit = cbInfo.hwndItem;
307 hList = cbInfo.hwndList;
308
309 trace("hMainWnd=%p, hCombo=%p, hList=%p, hEdit=%p\n", hMainWnd, hCombo, hList, hEdit);
310 ok(GetFocus() == hMainWnd, "Focus not on Main Window, instead on %p\n", GetFocus());
311
312 /* Click on the button to drop down the list */
313 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
314 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
316 ok(result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
317 GetLastError());
318 ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
319 "The dropdown list should have appeared after clicking the button.\n");
320
321 ok(GetFocus() == hEdit,
322 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
323 result = SendMessageA(hCombo, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
324 ok(result, "WM_LBUTTONUP was not processed. LastError=%d\n",
325 GetLastError());
326 ok(GetFocus() == hEdit,
327 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
328
329 /* Click on the 5th item in the list */
330 item_height = SendMessageA(hCombo, CB_GETITEMHEIGHT, 0, 0);
331 ok(GetClientRect(hList, &rect), "Failed to get list's client rect.\n");
332 x = rect.left + (rect.right-rect.left)/2;
333 y = item_height/2 + item_height*4;
335 ok(!result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
336 GetLastError());
337 ok(GetFocus() == hEdit,
338 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
339
341 ok(!result, "WM_MOUSEMOVE was not processed. LastError=%d\n",
342 GetLastError());
343 ok(GetFocus() == hEdit,
344 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
345 ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
346 "The dropdown list should still be visible.\n");
347
349 ok(!result, "WM_LBUTTONUP was not processed. LastError=%d\n",
350 GetLastError());
351 ok(GetFocus() == hEdit,
352 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
353 ok(!SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
354 "The dropdown list should have been rolled up.\n");
355 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
356 ok(idx, "Current Selection: expected %d, got %d\n", 4, idx);
357
358 DestroyWindow(hCombo);
359}
static const WCHAR stringFormat[]
Definition: wordpad.c:55
GLuint64EXT * result
Definition: glext.h:11304
#define sprintf(buf, format,...)
Definition: sprintf.c:55
& rect
Definition: startmenu.cpp:1413
LONG_PTR LRESULT
Definition: windef.h:209
#define CB_GETITEMHEIGHT
Definition: winuser.h:1954
#define WM_MOUSEMOVE
Definition: winuser.h:1778
#define WM_LBUTTONUP
Definition: winuser.h:1780
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_WS_VSCROLL()

static void test_WS_VSCROLL ( void  )
static

Definition at line 772 of file combo.c.

773{
774 HWND hCombo, hList;
776 DWORD style;
777 BOOL ret;
778 int i;
779
780 info.cbSize = sizeof(info);
782
783 SetLastError(0xdeadbeef);
784 ret = GetComboBoxInfo(hCombo, &info);
785 ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());
786 hList = info.hwndList;
787
788 for(i = 0; i < 3; i++)
789 {
790 char buffer[2];
791 sprintf(buffer, "%d", i);
793 }
794
795 style = GetWindowLongA(info.hwndList, GWL_STYLE);
797
798 SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE, 0);
800
802 ok((style & WS_VSCROLL) != 0, "Style does not include WS_VSCROLL\n");
803
804 DestroyWindow(hCombo);
805}
#define WS_VSCROLL
Definition: pedump.c:627
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)

Referenced by START_TEST().

Variable Documentation

◆ edit_window_proc

WNDPROC edit_window_proc
static

Definition at line 535 of file combo.c.

◆ expected_edit_text

LPCSTR expected_edit_text
static

Definition at line 173 of file combo.c.

◆ expected_list_text

LPCSTR expected_list_text
static

Definition at line 174 of file combo.c.

◆ hCBN_KillFocus

HWND hCBN_KillFocus
static

Definition at line 537 of file combo.c.

◆ hCBN_SetFocus

HWND hCBN_SetFocus
static

Definition at line 537 of file combo.c.

◆ hMainWnd

HWND hMainWnd
static

Definition at line 34 of file combo.c.

◆ lparam

UINT WPARAM LPARAM lparam

Definition at line 172 of file combo.c.

◆ msg

UINT msg

Definition at line 172 of file combo.c.

◆ selchange_fired

BOOL selchange_fired
static

Definition at line 175 of file combo.c.

◆ setsel_end

long setsel_end = 1
static

Definition at line 536 of file combo.c.

◆ setsel_start

long setsel_start = 1
static

Definition at line 536 of file combo.c.

◆ wparam

UINT WPARAM wparam

Definition at line 172 of file combo.c.