ReactOS 0.4.16-dev-2528-g7139e57
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 get_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)
 
static void test_combo_ctlcolor (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 HWND lparam_for_WM_CTLCOLOR
 
static HBRUSH brush_red
 
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 33 of file combo.c.

◆ COMBO_YBORDERSIZE

#define COMBO_YBORDERSIZE ( )    2

Definition at line 35 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 39 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 40 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 44 of file combo.c.

45{
46 return CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
47}
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:60
#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:4469

Referenced by test_changesize(), test_combo_ctlcolor(), 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 575 of file combo.c.

576{
577 if (msg == EM_SETSEL)
578 {
581 }
583}
#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:2047
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ get_font_height()

static int get_font_height ( HFONT  hFont)
static

Definition at line 49 of file combo.c.

50{
52 HFONT hFontOld;
53 HDC hDC;
54
56 hFontOld = SelectObject(hDC, hFont);
58 SelectObject(hDC, hFontOld);
60
61 return tm.tmHeight;
62}
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 *)
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)

◆ is_font_installed()

static BOOL is_font_installed ( const char name)
static

Definition at line 69 of file combo.c.

70{
71 HDC hdc = GetDC(NULL);
74 return ret;
75}
return ret
Definition: mutex.c:146
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:64
Definition: name.c:39
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 64 of file combo.c.

65{
66 return 0;
67}

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 199 of file combo.c.

200{
201 switch (msg)
202 {
203 case WM_COMMAND:
204 switch (wparam)
205 {
207 {
208 HWND hCombo = (HWND)lparam;
209 int idx;
210 char list[20], edit[20];
211
212 memset(list, 0, sizeof(list));
213 memset(edit, 0, sizeof(edit));
214
215 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
217 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
218
219 ok(!strcmp(edit, expected_edit_text), "edit: got %s, expected %s\n",
220 edit, expected_edit_text);
221 ok(!strcmp(list, expected_list_text), "list: got %s, expected %s\n",
223
225 }
226 break;
227 }
228 break;
229 case WM_CTLCOLOR:
231 case WM_CTLCOLOREDIT:
233 case WM_CTLCOLORBTN:
234 case WM_CTLCOLORDLG:
238 {
239 ok(lparam_for_WM_CTLCOLOR == (HWND)lparam, "Expected %p, got %p\n", lparam_for_WM_CTLCOLOR, (HWND)lparam);
240 return (LRESULT) brush_red;
241 }
242 break;
243 }
244
245 return CallWindowProcA(old_parent_proc, hwnd, msg, wparam, lparam);
246}
Definition: list.h:37
#define TRUE
Definition: types.h:120
unsigned int idx
Definition: utils.c:41
HANDLE HWND
Definition: compat.h:19
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
static HWND lparam_for_WM_CTLCOLOR
Definition: combo.c:746
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 HBRUSH brush_red
Definition: combo.c:53
static LPCSTR expected_list_text
Definition: combo.c:744
#define memset(x, y, z)
Definition: compat.h:39
#define WM_CTLCOLOR
Definition: windowsx.h:29
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define CB_GETLBTEXT
Definition: winuser.h:1981
#define WM_COMMAND
Definition: winuser.h:1768
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETTEXT
Definition: winuser.h:1646
#define WM_CTLCOLORSCROLLBAR
Definition: winuser.h:1799
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1794
#define CBN_SELCHANGE
Definition: winuser.h:2008
#define WM_CTLCOLORBTN
Definition: winuser.h:1797
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1796
#define CB_GETCURSEL
Definition: winuser.h:1972
#define WM_CTLCOLOREDIT
Definition: winuser.h:1795
#define WM_CTLCOLORDLG
Definition: winuser.h:1798

◆ START_TEST()

START_TEST ( combo  )

Definition at line 921 of file combo.c.

922{
923 brush_red = CreateSolidBrush(RGB(255, 0, 0));
924 hMainWnd = CreateWindowA("static", "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
926
944
947}
#define RGB(r, g, b)
Definition: precomp.h:67
pKey DeleteObject()
static void test_combo_ctlcolor(void)
Definition: combo.c:1298
static void test_editselection(void)
Definition: combo.c:472
static void test_listbox_styles(DWORD cb_style)
Definition: combo.c:664
static void test_setitemheight(DWORD style)
Definition: combo.c:77
static void test_setfont(DWORD style)
Definition: combo.c:117
static void test_listbox_size(DWORD style)
Definition: combo.c:712
static void test_editselection_focus(DWORD style)
Definition: combo.c:607
static void test_changesize(DWORD style)
Definition: combo.c:397
static void test_WS_VSCROLL(void)
Definition: combo.c:808
static void test_WM_LBUTTONDOWN(void)
Definition: combo.c:314
static void test_CBN_SELCHANGE(void)
Definition: combo.c:303
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
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:786
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ test_CBN_SELCHANGE()

static void test_CBN_SELCHANGE ( void  )
static

Definition at line 303 of file combo.c.

304{
305 static const char * const text[] = { "alpha", "beta", "" };
306 static const int sel_1[] = { 2, 0, 1, 0, 1 };
307 static const int sel_2[] = { 0, 1, 0, 0, 1 };
308
309 test_selection(CBS_SIMPLE, text, sel_1, sel_2);
310 test_selection(CBS_DROPDOWN, text, sel_1, sel_2);
311 test_selection(CBS_DROPDOWNLIST, text, sel_2, sel_2);
312}
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 397 of file combo.c.

398{
399 HWND hCombo = build_combo(style);
400 RECT rc;
401 INT ddheight, clheight, ddwidth, clwidth;
402 /* get initial measurements */
403 GetClientRect( hCombo, &rc);
404 clheight = rc.bottom - rc.top;
405 clwidth = rc.right - rc.left;
407 ddheight = rc.bottom - rc.top;
408 ddwidth = rc.right - rc.left;
409 /* use MoveWindow to move & resize the combo */
410 /* first make it slightly smaller */
411 MoveWindow( hCombo, 10, 10, clwidth - 2, clheight - 2, TRUE);
412 GetClientRect( hCombo, &rc);
413 ok( rc.right - rc.left == clwidth - 2, "clientrect width is %ld vs %d\n",
414 rc.right - rc.left, clwidth - 2);
415 ok( rc.bottom - rc.top == clheight, "clientrect height is %ld vs %d\n",
416 rc.bottom - rc.top, clheight);
418 ok( rc.right - rc.left == clwidth - 2, "drop-down rect width is %ld vs %d\n",
419 rc.right - rc.left, clwidth - 2);
420 ok( rc.bottom - rc.top == ddheight, "drop-down rect height is %ld vs %d\n",
421 rc.bottom - rc.top, ddheight);
422 ok( rc.right - rc.left == ddwidth -2, "drop-down rect width is %ld vs %d\n",
423 rc.right - rc.left, ddwidth - 2);
424 /* new cx, cy is slightly bigger than the initial values */
425 MoveWindow( hCombo, 10, 10, clwidth + 2, clheight + 2, TRUE);
426 GetClientRect( hCombo, &rc);
427 ok( rc.right - rc.left == clwidth + 2, "clientrect width is %ld vs %d\n",
428 rc.right - rc.left, clwidth + 2);
429 ok( rc.bottom - rc.top == clheight, "clientrect height is %ld vs %d\n",
430 rc.bottom - rc.top, clheight);
432 ok( rc.right - rc.left == clwidth + 2, "drop-down rect width is %ld vs %d\n",
433 rc.right - rc.left, clwidth + 2);
434 todo_wine {
435 ok( rc.bottom - rc.top == clheight + 2, "drop-down rect height is %ld vs %d\n",
436 rc.bottom - rc.top, clheight + 2);
437 }
438
439 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, -1, 0);
440 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
441 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
442 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
443
444 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
445 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
446 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
447 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
448
449 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth - 1, 0);
450 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
451 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
452 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
453
454 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth << 1, 0);
455 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
456 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
457 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
458
459 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
460 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
461 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
462 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
463
464 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 1, 0);
465 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
466 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
467 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
468
469 DestroyWindow(hCombo);
470}
#define todo_wine
Definition: minitest.h:80
static HWND build_combo(DWORD style)
Definition: combo.c:44
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
int32_t INT
Definition: typedefs.h:58
#define CB_SETDROPPEDWIDTH
Definition: winuser.h:1991
#define CB_GETDROPPEDWIDTH
Definition: winuser.h:1975
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define CB_GETDROPPEDCONTROLRECT
Definition: winuser.h:1973
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by START_TEST().

◆ test_combo_ctlcolor()

static void test_combo_ctlcolor ( void  )
static

Definition at line 843 of file combo.c.

844{
845 static const int messages[] =
846 {
855 };
856
857 HBRUSH brush, global_brush;
858 unsigned int i, ret;
860 HWND combo;
861
862 combo = build_combo(CBS_DROPDOWN);
863 ok(!!combo, "Failed to create combo window.\n");
864
866
867 info.cbSize = sizeof(COMBOBOXINFO);
868 ret = GetComboBoxInfo(combo, &info);
869 ok(ret, "Failed to get combobox info structure.\n");
870
871 lparam_for_WM_CTLCOLOR = info.hwndItem;
872
873 /* Parent returns valid brush handle. */
874 for (i = 0; i < ARRAY_SIZE(messages); ++i)
875 {
876 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
877 ok(brush == brush_red, "%u: unexpected brush %p, expected got %p.\n", i, brush, brush_red);
878 }
879
880 /* Parent returns NULL brush. */
881 global_brush = brush_red;
882 brush_red = NULL;
883
884 for (i = 0; i < ARRAY_SIZE(messages); ++i)
885 {
886 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
887 ok(!brush, "%u: unexpected brush %p.\n", i, brush);
888 }
889
890 brush_red = global_brush;
891
893
894 /* Parent does default processing. */
895 for (i = 0; i < ARRAY_SIZE(messages); ++i)
896 {
897 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
898 ok(!!brush && brush != brush_red, "%u: unexpected brush %p.\n", i, brush);
899 }
900
902 DestroyWindow(combo);
903
904 /* Combo without a parent. */
905 combo = CreateWindowA("ComboBox", "Combo", CBS_DROPDOWN, 5, 5, 100, 100, NULL, NULL, NULL, 0);
906 ok(!!combo, "Failed to create combo window.\n");
907
908 info.cbSize = sizeof(COMBOBOXINFO);
909 ret = GetComboBoxInfo(combo, &info);
910 ok(ret, "Failed to get combobox info structure.\n");
911
912 for (i = 0; i < ARRAY_SIZE(messages); ++i)
913 {
914 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
915 ok(!!brush && brush != brush_red, "%u: unexpected brush %p.\n", i, brush);
916 }
917
918 DestroyWindow(combo);
919}
#define ARRAY_SIZE(A)
Definition: main.h:20
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 LRESULT CALLBACK parent_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: combo.c:748
#define GWLP_WNDPROC
Definition: treelist.c:66
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define SetWindowLongPtrA
Definition: winuser.h:5511
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
struct tagCOMBOBOXINFO COMBOBOXINFO

◆ test_editselection()

static void test_editselection ( void  )
static

Definition at line 472 of file combo.c.

473{
474 HWND hCombo;
475 INT start,end;
476 HWND hEdit;
477 COMBOBOXINFO cbInfo;
478 BOOL ret;
479 DWORD len;
480 char edit[20];
481
482 /* Build a combo */
483 hCombo = build_combo(CBS_SIMPLE);
484 cbInfo.cbSize = sizeof(COMBOBOXINFO);
485 SetLastError(0xdeadbeef);
486 ret = GetComboBoxInfo(hCombo, &cbInfo);
487 ok(ret, "Failed to get combobox info structure. LastError=%ld\n",
488 GetLastError());
489 hEdit = cbInfo.hwndItem;
490
491 /* Initially combo selection is empty*/
492 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
493 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
494 ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
495
496 /* Set some text, and press a key to replace it */
497 edit[0] = 0x00;
498 SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason1");
499 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
500 ok(strcmp(edit, "Jason1")==0, "Unexpected text retrieved %s\n", edit);
501
502 /* Now what is the selection - still empty */
504 ok(start==0, "Unexpected start position for selection %d\n", start);
505 ok(end==0, "Unexpected end position for selection %d\n", end);
506 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
507 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
508 ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
509
510 /* Give it focus, and it gets selected */
511 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
513 ok(start==0, "Unexpected start position for selection %d\n", start);
514 ok(end==6, "Unexpected end position for selection %d\n", end);
515 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
516 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
517 ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
518
519 /* Now emulate a key press */
520 edit[0] = 0x00;
521 SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
522 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
523 ok(strcmp(edit, "A")==0, "Unexpected text retrieved %s\n", edit);
524
525 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
526 ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
527 ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
528
529 /* Now what happens when it gets more focus a second time - it doesn't reselect */
530 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
531 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
532 ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
533 ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
534 DestroyWindow(hCombo);
535
536 /* Start again - Build a combo */
537 hCombo = build_combo(CBS_SIMPLE);
538 cbInfo.cbSize = sizeof(COMBOBOXINFO);
539 SetLastError(0xdeadbeef);
540 ret = GetComboBoxInfo(hCombo, &cbInfo);
541 ok(ret, "Failed to get combobox info structure. LastError=%ld\n",
542 GetLastError());
543 hEdit = cbInfo.hwndItem;
544
545 /* Set some text and give focus so it gets selected */
546 edit[0] = 0x00;
547 SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason2");
548 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
549 ok(strcmp(edit, "Jason2")==0, "Unexpected text retrieved %s\n", edit);
550
551 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
552
553 /* Now what is the selection */
555 ok(start==0, "Unexpected start position for selection %d\n", start);
556 ok(end==6, "Unexpected end position for selection %d\n", end);
557 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
558 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
559 ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
560
561 /* Now change the selection to the apparently invalid start -1, end -1 and
562 show it means no selection (ie start -1) but cursor at end */
563 SendMessageA(hCombo, CB_SETEDITSEL, 0, -1);
564 edit[0] = 0x00;
565 SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
566 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
567 ok(strcmp(edit, "Jason2A")==0, "Unexpected text retrieved %s\n", edit);
568 DestroyWindow(hCombo);
569}
#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
UINT_PTR WPARAM
Definition: minwindef.h:174
#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
#define WM_SETFOCUS
Definition: winuser.h:1641
#define WM_SETTEXT
Definition: winuser.h:1645
#define CB_SETEDITSEL
Definition: winuser.h:1992
#define WM_CHAR
Definition: winuser.h:1745
#define CB_GETEDITSEL
Definition: winuser.h:1976

Referenced by START_TEST().

◆ test_editselection_focus()

static void test_editselection_focus ( DWORD  style)
static

Definition at line 607 of file combo.c.

608{
609 HWND hCombo, hEdit, hButton;
610 COMBOBOXINFO cbInfo;
611 BOOL ret;
612 const char wine_test[] = "Wine Test";
613 char buffer[16] = {0};
614 DWORD len;
615
616 hCombo = build_combo(style);
617 cbInfo.cbSize = sizeof(COMBOBOXINFO);
618 SetLastError(0xdeadbeef);
619 ret = GetComboBoxInfo(hCombo, &cbInfo);
620 ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %lu\n", GetLastError());
621 hEdit = cbInfo.hwndItem;
622
623 hButton = CreateWindowA("Button", "OK", WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
624 5, 50, 100, 20, hMainWnd, NULL,
626
629
630 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
631 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
632 todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
633 ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
634 ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
635
637 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
638 todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
639 ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
640 ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
641
644 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
645 todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
646 ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
647 ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
648 SendMessageA(hCombo, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
649 ok(!strcmp(buffer, wine_test), "Unexpected text in edit control; got '%s'\n", buffer);
650
652 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
653 todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
654 ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
655 ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
656 len = SendMessageA(hCombo, CB_GETEDITSEL, 0, 0);
657 ok(len == 0, "Unexpected text selection; start: %u, end: %u\n", LOWORD(len), HIWORD(len));
658
660 DestroyWindow(hButton);
661 DestroyWindow(hCombo);
662}
#define INT_MAX
Definition: limits.h:26
GLuint buffer
Definition: glext.h:5915
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
HWND WINAPI GetFocus(void)
Definition: window.c:1863
#define GetWindowLongPtrA
Definition: winuser.h:4982
#define GWLP_HINSTANCE
Definition: winuser.h:867
#define WM_NEXTDLGCTL
Definition: winuser.h:1671
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014

Referenced by START_TEST().

◆ test_listbox_size()

static void test_listbox_size ( DWORD  style)
static

Definition at line 712 of file combo.c.

713{
714 HWND hCombo, hList;
715 COMBOBOXINFO cbInfo;
716 UINT x, y;
717 BOOL ret;
718 int i, test;
719 const char wine_test[] = "Wine Test";
720
721 static const struct list_size_info
722 {
723 int num_items;
724 int height_combo;
725 BOOL todo;
726 } info_height[] = {
727 {2, 24, FALSE},
728 {2, 41, TRUE},
729 {2, 42, FALSE},
730 {2, 50, FALSE},
731 {2, 60},
732 {2, 80},
733 {2, 89},
734 {2, 90},
735 {2, 100},
736
737 {10, 24, FALSE},
738 {10, 41, TRUE},
739 {10, 42, FALSE},
740 {10, 50, FALSE},
741 {10, 60, FALSE},
742 {10, 80, FALSE},
743 {10, 89, TRUE},
744 {10, 90, FALSE},
745 {10, 100, FALSE},
746 };
747
748 for(test = 0; test < ARRAY_SIZE(info_height); test++)
749 {
750 const struct list_size_info *info_test = &info_height[test];
751 int height_item; /* Height of a list item */
752 int height_list; /* Height of the list we got */
753 int expected_count_list;
754 int expected_height_list;
755 int list_height_nonclient;
756 int list_height_calculated;
757 RECT rect_list_client, rect_list_complete;
758
759 hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100,
760 info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
761
762 cbInfo.cbSize = sizeof(COMBOBOXINFO);
763 SetLastError(0xdeadbeef);
764 ret = GetComboBoxInfo(hCombo, &cbInfo);
765 ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %lu\n", GetLastError());
766
767 hList = cbInfo.hwndList;
768 for (i = 0; i < info_test->num_items; i++)
770
771 /* Click on the button to drop down the list */
772 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
773 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
774 ret = SendMessageA(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
775 ok(ret, "WM_LBUTTONDOWN was not processed. LastError=%ld\n",
776 GetLastError());
777 ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
778 "The dropdown list should have appeared after clicking the button.\n");
779
780 GetClientRect(hList, &rect_list_client);
781 GetWindowRect(hList, &rect_list_complete);
782 height_list = rect_list_client.bottom - rect_list_client.top;
783 height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0);
784
785 list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top)
786 - (rect_list_client.bottom - rect_list_client.top);
787
788 /* Calculate the expected client size of the listbox popup from the size of the combobox. */
789 list_height_calculated = info_test->height_combo
790 - (cbInfo.rcItem.bottom + COMBO_YBORDERSIZE())
791 - list_height_nonclient
792 - 1;
793
794 expected_count_list = list_height_calculated / height_item;
795 if(expected_count_list < 0)
796 expected_count_list = 0;
797 expected_count_list = min(expected_count_list, info_test->num_items);
798 expected_height_list = expected_count_list * height_item;
799
800 todo_wine_if(info_test->todo)
801 ok(expected_height_list == height_list,
802 "Test %d, expected list height to be %d, got %d\n", test, expected_height_list, height_list);
803
804 DestroyWindow(hCombo);
805 }
806}
#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
#define d
Definition: ke_i.h:81
HWND hList
Definition: livecd.c:10
#define todo_wine_if(is_todo)
Definition: minitest.h:81
BOOL todo
Definition: filedlg.c:313
BOOL expected
Definition: store.c:2000
#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:4116
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define LB_GETITEMHEIGHT
Definition: winuser.h:2071
#define CB_ADDSTRING
Definition: winuser.h:1965
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1974

Referenced by START_TEST().

◆ test_listbox_styles()

static void test_listbox_styles ( DWORD  cb_style)
static

Definition at line 664 of file combo.c.

665{
666 HWND combo;
668 DWORD style, exstyle, expect_style, expect_exstyle;
669 BOOL ret;
670
672 if (cb_style == CBS_SIMPLE)
673 {
675 expect_exstyle = WS_EX_CLIENTEDGE;
676 }
677 else
678 {
680 expect_exstyle = WS_EX_TOOLWINDOW;
681 }
682
683 combo = build_combo(cb_style);
684 info.cbSize = sizeof(COMBOBOXINFO);
685 SetLastError(0xdeadbeef);
686 ret = GetComboBoxInfo(combo, &info);
687 ok(ret, "Failed to get combobox info structure.\n");
688
689 style = GetWindowLongW( info.hwndList, GWL_STYLE );
690 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
691 ok(style == expect_style, "%08lx: got %08lx\n", cb_style, style);
692 ok(exstyle == expect_exstyle, "%08lx: got %08lx\n", cb_style, exstyle);
693
694 if (cb_style != CBS_SIMPLE)
695 expect_exstyle |= WS_EX_TOPMOST;
696
697 SendMessageW(combo, CB_SHOWDROPDOWN, TRUE, 0 );
698 style = GetWindowLongW( info.hwndList, GWL_STYLE );
699 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
700 ok(style == (expect_style | WS_VISIBLE), "%08lx: got %08lx\n", cb_style, style);
701 ok(exstyle == expect_exstyle, "%08lx: got %08lx\n", cb_style, exstyle);
702
704 style = GetWindowLongW( info.hwndList, GWL_STYLE );
705 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
706 ok(style == expect_style, "%08lx: got %08lx\n", cb_style, style);
707 ok(exstyle == expect_exstyle, "%08lx: got %08lx\n", cb_style, exstyle);
708
709 DestroyWindow(combo);
710}
#define expect_style(window, style)
#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 CB_SHOWDROPDOWN
Definition: winuser.h:1999
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:863
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GWL_EXSTYLE
Definition: winuser.h:862

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 248 of file combo.c.

250{
251 INT idx;
252 HWND hCombo;
253
254 hCombo = build_combo(style);
255
256 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[0]);
257 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[1]);
258 SendMessageA(hCombo, CB_SETCURSEL, -1, 0);
259
261
262 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
263 ok(idx == -1, "expected selection -1, got %d\n", idx);
264
265 /* keyboard navigation */
266
268 expected_edit_text = text[edit[0]];
270 SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
271 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
272
274 expected_edit_text = text[edit[1]];
276 SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
277 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
278
280 expected_edit_text = text[edit[2]];
282 SendMessageA(hCombo, WM_KEYDOWN, VK_UP, 0);
283 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
284
285 /* programmatic navigation */
286
288 expected_edit_text = text[edit[3]];
290 SendMessageA(hCombo, CB_SETCURSEL, list[3], 0);
291 ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
292
294 expected_edit_text = text[edit[4]];
296 SendMessageA(hCombo, CB_SETCURSEL, list[4], 0);
297 ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
298
300 DestroyWindow(hCombo);
301}
#define CB_SETCURSEL
Definition: winuser.h:1990
#define VK_UP
Definition: winuser.h:2261
#define VK_DOWN
Definition: winuser.h:2263
#define WM_KEYDOWN
Definition: winuser.h:1743

◆ test_setfont()

static void test_setfont ( DWORD  style)
static

Definition at line 117 of file combo.c.

118{
119 HWND hCombo;
120 HFONT hFont1, hFont2;
121 RECT r;
122 int i;
123
124 if (!is_font_installed("Marlett"))
125 {
126 skip("Marlett font not available\n");
127 return;
128 }
129
130 trace("Style %lx\n", style);
131
132 hCombo = build_combo(style);
135
136 GetClientRect(hCombo, &r);
140 todo_wine expect_rect(r, 5, 5, 105, 105);
141
142 /* The size of the dropped control is initially equal to the size
143 of the window when it was created. The size of the calculated
144 dropped area changes only by how much the selection area
145 changes, not by how much the list area changes. */
146 if (get_font_height(hFont1) == 10 && get_font_height(hFont2) == 8)
147 {
148 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
149 GetClientRect(hCombo, &r);
150 expect_rect(r, 0, 0, 100, 18);
154
155 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE);
156 GetClientRect(hCombo, &r);
157 expect_rect(r, 0, 0, 100, 16);
161
162 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
163 GetClientRect(hCombo, &r);
164 expect_rect(r, 0, 0, 100, 18);
168 }
169 else
170 {
171 ok(0, "Expected Marlett font heights 10/8, got %d/%d\n",
172 get_font_height(hFont1), get_font_height(hFont2));
173 }
174
175 for (i = 1; i < 30; i++)
176 {
179
181 GetClientRect(hCombo, &r);
182 expect_eq(r.bottom - r.top, height + 8, int, "%d");
183 SendMessageA(hCombo, WM_SETFONT, 0, FALSE);
185 }
186
187 DestroyWindow(hCombo);
188 DeleteObject(hFont1);
189 DeleteObject(hFont2);
190}
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
#define expect_rect(r, _left, _top, _right, _bottom)
Definition: combo.c:42
static int get_font_height(HFONT hFont)
Definition: combo.c:621
#define expect_eq(expr, value, type, fmt)
Definition: combo.c:39
static BOOL is_font_installed(const char *name)
Definition: combo.c:69
#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:1220
#define WM_SETFONT
Definition: winuser.h:1678

Referenced by START_TEST().

◆ test_setitemheight()

static void test_setitemheight ( DWORD  style)
static

Definition at line 77 of file combo.c.

78{
79 HWND hCombo = build_combo(style);
80 int i, font_height, height;
82 RECT r;
83
84 trace("Style %lx\n", style);
85 GetClientRect(hCombo, &r);
89 todo_wine expect_rect(r, 5, 5, 105, 105);
90
91 for (i = 1; i < 30; i++)
92 {
93 SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, i);
94 GetClientRect(hCombo, &r);
95 expect_eq(r.bottom - r.top, i + 6, int, "%d");
96 }
97
98 DestroyWindow(hCombo);
99
100 /* Set item height below text height, force resize. */
101 hCombo = build_combo(style);
102
103 hFont = (HFONT)SendMessageA(hCombo, WM_GETFONT, 0, 0);
104 font_height = get_font_height(hFont);
105 SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, font_height / 2);
106 height = SendMessageA(hCombo, CB_GETITEMHEIGHT, -1, 0);
108 ok(height == font_height / 2, "Unexpected item height %d, expected %d.\n", height, font_height / 2);
109
110 SetWindowPos(hCombo, NULL, 10, 10, 150, 5 * font_height, SWP_SHOWWINDOW);
111 height = SendMessageA(hCombo, CB_GETITEMHEIGHT, -1, 0);
112 ok(height > font_height, "Unexpected item height %d, font height %d.\n", height, font_height);
113
114 DestroyWindow(hCombo);
115}
#define CB_GETITEMHEIGHT
Definition: winuser.h:1980
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_GETFONT
Definition: winuser.h:1679
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define CB_SETITEMHEIGHT
Definition: winuser.h:1996

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 585 of file combo.c.

586{
587 switch (msg)
588 {
589 case WM_COMMAND:
590 switch (HIWORD(wParam))
591 {
592 case CBN_SETFOCUS:
594 break;
595 case CBN_KILLFOCUS:
597 break;
598 }
599 break;
600 case WM_NEXTDLGCTL:
602 break;
603 }
604 return CallWindowProcA(old_parent_proc, hwnd, msg, wParam, lParam);
605}
#define CBN_SETFOCUS
Definition: winuser.h:2011
HWND WINAPI SetFocus(_In_opt_ HWND)
#define CBN_KILLFOCUS
Definition: winuser.h:2007

◆ test_WM_LBUTTONDOWN()

static void test_WM_LBUTTONDOWN ( void  )
static

Definition at line 314 of file combo.c.

315{
316 HWND hCombo, hEdit, hList;
317 COMBOBOXINFO cbInfo;
318 UINT x, y, item_height;
320 int i, idx;
321 RECT rect;
322 CHAR buffer[3];
323 static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
324 static const CHAR stringFormat[] = "%2d";
325 BOOL ret;
326
327 hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|CBS_DROPDOWN,
328 0, 0, 200, 150, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
329
330 for (i = 0; i < ARRAY_SIZE(choices); i++){
331 sprintf(buffer, stringFormat, choices[i]);
333 ok(result == i,
334 "Failed to add item %d\n", i);
335 }
336
337 cbInfo.cbSize = sizeof(COMBOBOXINFO);
338 SetLastError(0xdeadbeef);
339 ret = GetComboBoxInfo(hCombo, &cbInfo);
340 ok(ret, "Failed to get combobox info structure. LastError=%ld\n",
341 GetLastError());
342 hEdit = cbInfo.hwndItem;
343 hList = cbInfo.hwndList;
344
345 trace("hMainWnd=%p, hCombo=%p, hList=%p, hEdit=%p\n", hMainWnd, hCombo, hList, hEdit);
346 ok(GetFocus() == hMainWnd, "Focus not on Main Window, instead on %p\n", GetFocus());
347
348 /* Click on the button to drop down the list */
349 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
350 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
352 ok(result, "WM_LBUTTONDOWN was not processed. LastError=%ld\n",
353 GetLastError());
354 ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
355 "The dropdown list should have appeared after clicking the button.\n");
356
357 ok(GetFocus() == hEdit,
358 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
359 result = SendMessageA(hCombo, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
360 ok(result, "WM_LBUTTONUP was not processed. LastError=%ld\n",
361 GetLastError());
362 ok(GetFocus() == hEdit,
363 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
364
365 /* Click on the 5th item in the list */
366 item_height = SendMessageA(hCombo, CB_GETITEMHEIGHT, 0, 0);
367 ok(GetClientRect(hList, &rect), "Failed to get list's client rect.\n");
368 x = rect.left + (rect.right-rect.left)/2;
369 y = item_height/2 + item_height*4;
371 ok(!result, "WM_LBUTTONDOWN was not processed. LastError=%ld\n",
372 GetLastError());
373 ok(GetFocus() == hEdit,
374 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
375
377 ok(!result, "WM_MOUSEMOVE was not processed. LastError=%ld\n",
378 GetLastError());
379 ok(GetFocus() == hEdit,
380 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
381 ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
382 "The dropdown list should still be visible.\n");
383
385 ok(!result, "WM_LBUTTONUP was not processed. LastError=%ld\n",
386 GetLastError());
387 ok(GetFocus() == hEdit,
388 "Focus not on ComboBox's Edit Control, instead on %p\n", GetFocus());
389 ok(!SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
390 "The dropdown list should have been rolled up.\n");
391 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
392 ok(idx, "Current Selection: expected %d, got %d\n", 4, idx);
393
394 DestroyWindow(hCombo);
395}
static const WCHAR stringFormat[]
Definition: wordpad.c:55
GLuint64EXT * result
Definition: glext.h:11304
#define sprintf
Definition: sprintf.c:45
& rect
Definition: startmenu.cpp:1413
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define WM_LBUTTONUP
Definition: winuser.h:1805
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_WS_VSCROLL()

static void test_WS_VSCROLL ( void  )
static

Definition at line 808 of file combo.c.

809{
810 HWND hCombo, hList;
812 DWORD style;
813 BOOL ret;
814 int i;
815
816 info.cbSize = sizeof(info);
818
819 SetLastError(0xdeadbeef);
820 ret = GetComboBoxInfo(hCombo, &info);
821 ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %lu\n", GetLastError());
822 hList = info.hwndList;
823
824 for(i = 0; i < 3; i++)
825 {
826 char buffer[2];
827 sprintf(buffer, "%d", i);
829 }
830
831 style = GetWindowLongA(info.hwndList, GWL_STYLE);
833
834 SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE, 0);
836
838 ok((style & WS_VSCROLL) != 0, "Style does not include WS_VSCROLL\n");
839
840 DestroyWindow(hCombo);
841}
#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

◆ brush_red

HBRUSH brush_red
static

Definition at line 197 of file combo.c.

◆ edit_window_proc

WNDPROC edit_window_proc
static

Definition at line 571 of file combo.c.

◆ expected_edit_text

LPCSTR expected_edit_text
static

Definition at line 193 of file combo.c.

◆ expected_list_text

LPCSTR expected_list_text
static

Definition at line 194 of file combo.c.

◆ hCBN_KillFocus

HWND hCBN_KillFocus
static

Definition at line 573 of file combo.c.

◆ hCBN_SetFocus

HWND hCBN_SetFocus
static

Definition at line 573 of file combo.c.

◆ hMainWnd

HWND hMainWnd
static

Definition at line 37 of file combo.c.

◆ lparam

UINT WPARAM LPARAM lparam

Definition at line 192 of file combo.c.

◆ lparam_for_WM_CTLCOLOR

HWND lparam_for_WM_CTLCOLOR
static

Definition at line 196 of file combo.c.

◆ msg

UINT msg

Definition at line 192 of file combo.c.

◆ selchange_fired

BOOL selchange_fired
static

Definition at line 195 of file combo.c.

◆ setsel_end

long setsel_end = 1
static

Definition at line 572 of file combo.c.

◆ setsel_start

long setsel_start = 1
static

Definition at line 572 of file combo.c.

◆ wparam

UINT WPARAM wparam

Definition at line 192 of file combo.c.