ReactOS 0.4.16-dev-188-g678aa63
combo.c File Reference
#include <limits.h>
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include "wine/test.h"
#include "v6util.h"
#include "msg.h"
Include dependency graph for combo.c:

Go to the source code of this file.

Macros

#define EDITBOX_SEQ_INDEX   0
 
#define NUM_MSG_SEQUENCES   1
 
#define EDITBOX_ID   0
 
#define COMBO_ID   1995
 
#define expect(expected, got)   ok(got == expected, "Expected %d, got %d\n", expected, got)
 
#define expect_rect(r, _left, _top, _right, _bottom)
 
#define MAX_CHARS   100
 
#define X(f)   p##f = (void*)GetProcAddress(hComCtl32, #f);
 
#define X2(f, ord)   p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);
 

Functions

static BOOL (WINAPI *pSetWindowSubclass)(HWND
 
static void get_combobox_info (HWND hwnd, COMBOBOXINFO *info)
 
static HWND createComboEx (DWORD style)
 
static LONG addItem (HWND cbex, int idx, const char *text)
 
static LONG setItem (HWND cbex, int idx, const char *text)
 
static LONG delItem (HWND cbex, int idx)
 
static LONG getItem (HWND cbex, int idx, COMBOBOXEXITEMA *cbItem)
 
static LRESULT WINAPI editbox_subclass_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static HWND subclass_editbox (HWND hwndComboEx)
 
static void test_comboex (void)
 
static void test_comboex_WM_LBUTTONDOWN (void)
 
static void test_comboex_CB_GETLBTEXT (void)
 
static void test_comboex_WM_WINDOWPOSCHANGING (void)
 
static LRESULT ComboExTestOnNotify (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK ComboExTestWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void init_functions (void)
 
static BOOL init (void)
 
static void cleanup (void)
 
static void test_comboex_subclass (void)
 
static void test_comboex_get_set_item (void)
 
static HWND create_combobox (DWORD style)
 
static int get_font_height (HFONT hFont)
 
static void test_combo_setitemheight (DWORD style)
 
static void test_combo_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_combo_CBN_SELCHANGE (void)
 
static void test_combo_changesize (DWORD style)
 
static void test_combo_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_combo_editselection_focus (DWORD style)
 
static void test_combo_listbox_styles (DWORD cb_style)
 
static void test_combo_WS_VSCROLL (void)
 
static void test_combo_dropdown_size (DWORD style)
 
static void test_combo_ctlcolor (void)
 
 START_TEST (combo)
 

Variables

static struct msg_sequencesequences [NUM_MSG_SEQUENCES]
 
static HWND hComboExParentWnd
 
static HWND hMainWnd
 
static HINSTANCE hMainHinst
 
static const char ComboExTestClass [] = "ComboExTestClass"
 
static HBRUSH brush_red
 
static SUBCLASSPROC
 
static UINT_PTR
 
static DWORD_PTR
 
static chartextBuffer = NULL
 
static BOOL received_end_edit = FALSE
 
static const struct message test_setitem_edit_seq []
 
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 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 38 of file combo.c.

◆ EDITBOX_ID

#define EDITBOX_ID   0

Definition at line 37 of file combo.c.

◆ EDITBOX_SEQ_INDEX

#define EDITBOX_SEQ_INDEX   0

Definition at line 34 of file combo.c.

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %d, got %d\n", expected, got)

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

◆ MAX_CHARS

#define MAX_CHARS   100

Definition at line 57 of file combo.c.

◆ NUM_MSG_SEQUENCES

#define NUM_MSG_SEQUENCES   1

Definition at line 35 of file combo.c.

◆ X

#define X (   f)    p##f = (void*)GetProcAddress(hComCtl32, #f);

◆ X2

#define X2 (   f,
  ord 
)    p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);

Function Documentation

◆ addItem()

static LONG addItem ( HWND  cbex,
int  idx,
const char text 
)
static

Definition at line 76 of file combo.c.

76 {
77 COMBOBOXEXITEMA cbexItem;
78 memset(&cbexItem, 0x00, sizeof(cbexItem));
79 cbexItem.mask = CBEIF_TEXT;
80 cbexItem.iItem = idx;
81 cbexItem.pszText = (char*)text;
82 cbexItem.cchTextMax = 0;
83 return SendMessageA(cbex, CBEM_INSERTITEMA, 0, (LPARAM)&cbexItem);
84}
unsigned int idx
Definition: utils.c:41
const WCHAR * text
Definition: package.c:1794
#define CBEIF_TEXT
Definition: commctrl.h:3791
#define CBEM_INSERTITEMA
Definition: commctrl.h:3831
#define memset(x, y, z)
Definition: compat.h:39
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by test_comboex(), and test_comboex_CB_GETLBTEXT().

◆ BOOL()

static BOOL ( WINAPI pSetWindowSubclass)
static

◆ cleanup()

static void cleanup ( void  )
static

Definition at line 530 of file combo.c.

531{
532 MSG msg;
533
535 while (GetMessageA(&msg,0,0,0)) {
538 }
539
542
545}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
pKey DeleteObject()
static HWND hMainWnd
Definition: combo.c:49
static HWND hComboExParentWnd
Definition: combo.c:49
static HBRUSH brush_red
Definition: combo.c:53
static const char ComboExTestClass[]
Definition: combo.c:51
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define WM_CLOSE
Definition: winuser.h:1624
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

◆ combobox_subclass_proc()

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

Definition at line 1035 of file combo.c.

1036{
1037 if (msg == EM_SETSEL)
1038 {
1041 }
1043}
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)

Referenced by test_combo_editselection_focus(), and test_editselection_focus().

◆ ComboExTestOnNotify()

static LRESULT ComboExTestOnNotify ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 449 of file combo.c.

450{
451 NMHDR *hdr = (NMHDR*)lParam;
452 switch(hdr->code){
453 case CBEN_ENDEDITA:
454 {
455 NMCBEENDEDITA *edit_info = (NMCBEENDEDITA*)hdr;
456 if(edit_info->iWhy==CBENF_DROPDOWN){
458 }
459 break;
460 }
461 case CBEN_ENDEDITW:
462 {
463 NMCBEENDEDITW *edit_info = (NMCBEENDEDITW*)hdr;
464 if(edit_info->iWhy==CBENF_DROPDOWN){
466 }
467 break;
468 }
469 }
470 return 0;
471}
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
static BOOL received_end_edit
Definition: combo.c:60
#define CBEN_ENDEDITW
Definition: commctrl.h:3881
#define CBEN_ENDEDITA
Definition: commctrl.h:3880
#define CBENF_DROPDOWN
Definition: commctrl.h:3895

Referenced by ComboExTestWndProc().

◆ ComboExTestWndProc()

static LRESULT CALLBACK ComboExTestWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 473 of file combo.c.

474{
475 switch(msg) {
476
477 case WM_DESTROY:
479 break;
480 case WM_NOTIFY:
482 default:
484 }
485
486 return 0L;
487}
HWND hWnd
Definition: settings.c:17
static LRESULT ComboExTestOnNotify(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: combo.c:449
#define L(x)
Definition: ntvdm.h:50
#define WM_NOTIFY
Definition: richedit.h:61
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DESTROY
Definition: winuser.h:1612

Referenced by init().

◆ create_combobox()

static HWND create_combobox ( DWORD  style)
static

Definition at line 616 of file combo.c.

617{
618 return CreateWindowA(WC_COMBOBOXA, "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
619}
Arabic default style
Definition: afstyles.h:94
#define COMBO_ID
Definition: combo.c:38
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 WC_COMBOBOXA
Definition: commctrl.h:4721
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318

Referenced by test_combo_changesize(), test_combo_ctlcolor(), test_combo_editselection(), test_combo_editselection_focus(), test_combo_listbox_styles(), test_combo_setfont(), test_combo_setitemheight(), test_combo_WS_VSCROLL(), and test_selection().

◆ createComboEx()

static HWND createComboEx ( DWORD  style)
static

Definition at line 71 of file combo.c.

71 {
72 return CreateWindowExA(0, WC_COMBOBOXEXA, NULL, style, 0, 0, 300, 300,
74}
static HINSTANCE hMainHinst
Definition: combo.c:50
#define WC_COMBOBOXEXA
Definition: commctrl.h:3787
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)

Referenced by test_comboex(), test_comboex_CB_GETLBTEXT(), test_comboex_get_set_item(), test_comboex_subclass(), and test_comboex_WM_WINDOWPOSCHANGING().

◆ delItem()

static LONG delItem ( HWND  cbex,
int  idx 
)
static

Definition at line 96 of file combo.c.

96 {
97 return SendMessageA(cbex, CBEM_DELETEITEM, idx, 0);
98}
#define CBEM_DELETEITEM
Definition: commctrl.h:3836

Referenced by test_comboex().

◆ editbox_subclass_proc()

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

Definition at line 109 of file combo.c.

110{
112 static LONG defwndproc_counter = 0;
113 struct message msg = { 0 };
114 LRESULT ret;
115
116 msg.message = message;
117 msg.flags = sent|wparam|lparam;
118 if (defwndproc_counter) msg.flags |= defwinproc;
119 msg.wParam = wParam;
120 msg.lParam = lParam;
121 msg.id = EDITBOX_ID;
122
123 if (message != WM_PAINT &&
125 message != WM_NCPAINT &&
127 message != WM_GETTEXT &&
128 message != WM_GETICON &&
130 {
132 }
133
134 defwndproc_counter++;
136 defwndproc_counter--;
137 return ret;
138}
@ sent
Definition: SystemMenu.c:27
@ defwinproc
Definition: SystemMenu.c:32
#define add_message(msg)
Definition: SystemMenu.c:98
static struct msg_sequence * sequences[NUM_MSG_SEQUENCES]
Definition: combo.c:47
static UINT WPARAM wparam
Definition: combo.c:742
static UINT WPARAM LPARAM lparam
Definition: combo.c:742
#define EDITBOX_SEQ_INDEX
Definition: combo.c:34
#define EDITBOX_ID
Definition: combo.c:37
long LONG
Definition: pedump.c:60
Definition: tftpd.h:60
UINT message
Definition: SystemMenu.c:42
#define GWLP_USERDATA
Definition: treelist.c:63
int ret
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
#define WM_NCHITTEST
Definition: winuser.h:1689
#define WM_GETTEXT
Definition: winuser.h:1621
#define GetWindowLongPtrA
Definition: winuser.h:4831
#define WM_DEVICECHANGE
Definition: winuser.h:1814
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
#define WM_NCPAINT
Definition: winuser.h:1690

Referenced by subclass_editbox().

◆ get_combobox_info()

static void get_combobox_info ( HWND  hwnd,
COMBOBOXINFO info 
)
static

Definition at line 62 of file combo.c.

63{
64 BOOL ret;
65
66 info->cbSize = sizeof(*info);
68 ok(ret, "Failed to get combobox info structure, error %d\n", GetLastError());
69}
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)

Referenced by test_combo_ctlcolor(), test_combo_editselection(), test_combo_editselection_focus(), test_combo_listbox_styles(), test_combo_WS_VSCROLL(), and test_comboex_WM_LBUTTONDOWN().

◆ get_font_height()

static int get_font_height ( HFONT  hFont)
static

Definition at line 621 of file combo.c.

622{
624 HFONT hFontOld;
625 HDC hDC;
626
628 hFontOld = SelectObject(hDC, hFont);
630 SelectObject(hDC, hFontOld);
631 DeleteDC(hDC);
632
633 return tm.tmHeight;
634}
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 test_combo_setfont(), and test_combo_setitemheight().

◆ getItem()

static LONG getItem ( HWND  cbex,
int  idx,
COMBOBOXEXITEMA cbItem 
)
static

Definition at line 100 of file combo.c.

100 {
101 memset(cbItem, 0x00, sizeof(COMBOBOXEXITEMA));
102 cbItem->mask = CBEIF_TEXT;
103 cbItem->pszText = textBuffer;
104 cbItem->iItem = idx;
105 cbItem->cchTextMax = 100;
106 return SendMessageA(cbex, CBEM_GETITEMA, 0, (LPARAM)cbItem);
107}
static char * textBuffer
Definition: combo.c:58
#define CBEM_GETITEMA
Definition: commctrl.h:3834

Referenced by test_comboex().

◆ init()

static BOOL init ( void  )
static

Definition at line 500 of file combo.c.

501{
502 WNDCLASSA wc;
503
505 wc.cbClsExtra = 0;
506 wc.cbWndExtra = 0;
508 wc.hIcon = NULL;
511 wc.lpszMenuName = NULL;
514 RegisterClassA(&wc);
515
516 brush_red = CreateSolidBrush(RGB(255, 0, 0));
517
518 hMainWnd = CreateWindowA(WC_STATICA, "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
520
523 ok(hComboExParentWnd != NULL, "failed to create parent window\n");
524
526
527 return hComboExParentWnd != NULL;
528}
#define RGB(r, g, b)
Definition: precomp.h:71
static LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: combo.c:473
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WC_STATICA
Definition: commctrl.h:4684
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
HCURSOR hCursor
Definition: winuser.h:3172
int cbWndExtra
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3166
LPCSTR lpszMenuName
Definition: winuser.h:3174
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbClsExtra
Definition: winuser.h:3168
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define CS_VREDRAW
Definition: winuser.h:658
#define COLOR_WINDOW
Definition: winuser.h:921
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:778
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2142
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by START_TEST().

◆ init_functions()

static void init_functions ( void  )
static

Definition at line 489 of file combo.c.

490{
491 HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
492
493#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
494#define X2(f, ord) p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);
495 X2(SetWindowSubclass, 410);
496#undef X
497#undef X2
498}
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1268
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define X2(f, ord)

Referenced by START_TEST().

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

749{
750 switch (msg)
751 {
752 case WM_COMMAND:
753 switch (wparam)
754 {
756 {
757 HWND hCombo = (HWND)lparam;
758 char list[20], edit[20];
759 int idx;
760
761 memset(list, 0, sizeof(list));
762 memset(edit, 0, sizeof(edit));
763
764 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
766 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
767
768 ok(!strcmp(edit, expected_edit_text), "edit: got %s, expected %s\n",
769 edit, expected_edit_text);
770 ok(!strcmp(list, expected_list_text), "list: got %s, expected %s\n",
772
774 }
775 break;
776 }
777 break;
778 case WM_CTLCOLOR:
780 case WM_CTLCOLOREDIT:
782 case WM_CTLCOLORBTN:
783 case WM_CTLCOLORDLG:
787 {
788 ok(lparam_for_WM_CTLCOLOR == (HWND)lparam, "Expected %p, got %p\n", lparam_for_WM_CTLCOLOR, (HWND)lparam);
789 return (LRESULT) brush_red;
790 }
791 break;
792 }
793
794 return CallWindowProcA(old_parent_proc, hwnd, msg, wparam, lparam);
795}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Definition: list.h:37
HANDLE HWND
Definition: compat.h:19
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 LPCSTR expected_list_text
Definition: combo.c:744
#define WM_CTLCOLOR
Definition: windowsx.h:29
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
#define CB_GETLBTEXT
Definition: winuser.h:1955
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_CTLCOLORSCROLLBAR
Definition: winuser.h:1774
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1769
#define CBN_SELCHANGE
Definition: winuser.h:1982
#define WM_CTLCOLORBTN
Definition: winuser.h:1772
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1771
#define CB_GETCURSEL
Definition: winuser.h:1946
#define WM_CTLCOLOREDIT
Definition: winuser.h:1770
#define WM_CTLCOLORDLG
Definition: winuser.h:1773

Referenced by test_combo_ctlcolor(), and test_selection().

◆ setItem()

static LONG setItem ( HWND  cbex,
int  idx,
const char text 
)
static

Definition at line 86 of file combo.c.

86 {
87 COMBOBOXEXITEMA cbexItem;
88 memset(&cbexItem, 0x00, sizeof(cbexItem));
89 cbexItem.mask = CBEIF_TEXT;
90 cbexItem.iItem = idx;
91 cbexItem.pszText = (char*)text;
92 cbexItem.cchTextMax = 0;
93 return SendMessageA(cbex, CBEM_SETITEMA, 0, (LPARAM)&cbexItem);
94}
#define CBEM_SETITEMA
Definition: commctrl.h:3835

Referenced by test_comboex().

◆ START_TEST()

START_TEST ( combo  )

Definition at line 1372 of file combo.c.

1373{
1374 ULONG_PTR ctx_cookie;
1375 HANDLE hCtx;
1376
1378
1379 if (!init())
1380 return;
1381
1383
1384 /* ComboBoxEx32 tests. */
1385 test_comboex();
1391
1392 if (!load_v6_module(&ctx_cookie, &hCtx))
1393 {
1394 cleanup();
1395 return;
1396 }
1397
1398 /* ComboBox control tests. */
1416
1417 cleanup();
1418 unload_v6_module(ctx_cookie, hCtx);
1419}
static void init_msg_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:393
static void test_combo_changesize(DWORD style)
Definition: combo.c:862
static void test_combo_ctlcolor(void)
Definition: combo.c:1298
static void test_comboex_CB_GETLBTEXT(void)
Definition: combo.c:367
static void test_combo_setitemheight(DWORD style)
Definition: combo.c:636
static void test_combo_editselection(void)
Definition: combo.c:940
#define NUM_MSG_SEQUENCES
Definition: combo.c:35
static void test_comboex_get_set_item(void)
Definition: combo.c:574
static void test_combo_CBN_SELCHANGE(void)
Definition: combo.c:851
static void test_combo_listbox_styles(DWORD cb_style)
Definition: combo.c:1120
static void test_combo_setfont(DWORD style)
Definition: combo.c:675
static BOOL init(void)
Definition: combo.c:500
static void cleanup(void)
Definition: combo.c:530
static void test_comboex_WM_LBUTTONDOWN(void)
Definition: combo.c:256
static void test_comboex(void)
Definition: combo.c:153
static void test_combo_editselection_focus(DWORD style)
Definition: combo.c:1067
static void test_combo_WS_VSCROLL(void)
Definition: combo.c:1164
static void test_comboex_WM_WINDOWPOSCHANGING(void)
Definition: combo.c:402
static void test_combo_dropdown_size(DWORD style)
Definition: combo.c:1195
static void test_comboex_subclass(void)
Definition: combo.c:547
static void init_functions(void)
Definition: combo.c:489
uint32_t ULONG_PTR
Definition: typedefs.h:65
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:73
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:65
#define CBS_NOINTEGRALHEIGHT
Definition: winuser.h:287
#define CBS_DROPDOWNLIST
Definition: winuser.h:284
#define CBS_SIMPLE
Definition: winuser.h:291
#define CBS_DROPDOWN
Definition: winuser.h:283

◆ subclass_editbox()

static HWND subclass_editbox ( HWND  hwndComboEx)
static

Definition at line 140 of file combo.c.

141{
142 WNDPROC oldproc;
143 HWND hwnd;
144
145 hwnd = (HWND)SendMessageA(hwndComboEx, CBEM_GETEDITCONTROL, 0, 0);
149
150 return hwnd;
151}
static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: combo.c:109
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define CBEM_GETEDITCONTROL
Definition: commctrl.h:3838
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SetWindowLongPtrA
Definition: winuser.h:5357

Referenced by test_comboex_get_set_item().

◆ test_combo_CBN_SELCHANGE()

static void test_combo_CBN_SELCHANGE ( void  )
static

Definition at line 851 of file combo.c.

852{
853 static const char * const text[] = { "alpha", "beta", "" };
854 static const int sel_1[] = { 2, 0, 1, 0, 1 };
855 static const int sel_2[] = { 0, 1, 0, 0, 1 };
856
857 test_selection(CBS_SIMPLE, text, sel_1, sel_2);
858 test_selection(CBS_DROPDOWN, text, sel_1, sel_2);
859 test_selection(CBS_DROPDOWNLIST, text, sel_2, sel_2);
860}
static void test_selection(void)
Definition: trackbar.c:859

Referenced by START_TEST().

◆ test_combo_changesize()

static void test_combo_changesize ( DWORD  style)
static

Definition at line 862 of file combo.c.

863{
864 INT ddheight, clheight, ddwidth, clwidth;
865 HWND hCombo;
866 RECT rc;
867
868 hCombo = create_combobox(style);
869
870 /* get initial measurements */
871 GetClientRect( hCombo, &rc);
872 clheight = rc.bottom - rc.top;
873 clwidth = rc.right - rc.left;
875 ddheight = rc.bottom - rc.top;
876 ddwidth = rc.right - rc.left;
877 /* use MoveWindow to move & resize the combo */
878 /* first make it slightly smaller */
879 MoveWindow( hCombo, 10, 10, clwidth - 2, clheight - 2, TRUE);
880 GetClientRect( hCombo, &rc);
881 ok( rc.right - rc.left == clwidth - 2, "clientrect width is %d vs %d\n",
882 rc.right - rc.left, clwidth - 2);
883 ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
884 rc.bottom - rc.top, clheight);
886 ok( rc.right - rc.left == clwidth - 2, "drop-down rect width is %d vs %d\n",
887 rc.right - rc.left, clwidth - 2);
888 ok( rc.bottom - rc.top == ddheight, "drop-down rect height is %d vs %d\n",
889 rc.bottom - rc.top, ddheight);
890 ok( rc.right - rc.left == ddwidth -2, "drop-down rect width is %d vs %d\n",
891 rc.right - rc.left, ddwidth - 2);
892 /* new cx, cy is slightly bigger than the initial values */
893 MoveWindow( hCombo, 10, 10, clwidth + 2, clheight + 2, TRUE);
894 GetClientRect( hCombo, &rc);
895 ok( rc.right - rc.left == clwidth + 2, "clientrect width is %d vs %d\n",
896 rc.right - rc.left, clwidth + 2);
897 ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
898 rc.bottom - rc.top, clheight);
900 ok( rc.right - rc.left == clwidth + 2, "drop-down rect width is %d vs %d\n",
901 rc.right - rc.left, clwidth + 2);
902 todo_wine {
903 ok( rc.bottom - rc.top == clheight + 2, "drop-down rect height is %d vs %d\n",
904 rc.bottom - rc.top, clheight + 2);
905 }
906
907 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, -1, 0);
908 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
909 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
910 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
911
912 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
913 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
914 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
915 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
916
917 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth - 1, 0);
918 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
919 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
920 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
921
922 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth << 1, 0);
923 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
924 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
925 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
926
927 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
928 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
929 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
930 ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
931
932 ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 1, 0);
933 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
934 ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
935 ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
936
937 DestroyWindow(hCombo);
938}
static HWND create_combobox(DWORD style)
Definition: combo.c:616
#define todo_wine
Definition: custom.c:89
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_combo_ctlcolor()

static void test_combo_ctlcolor ( void  )
static

Definition at line 1298 of file combo.c.

1299{
1300 static const int messages[] =
1301 {
1310 };
1311
1312 HBRUSH brush, global_brush;
1314 unsigned int i;
1315 HWND combo;
1316
1318 ok(!!combo, "Failed to create combo window.\n");
1319
1320 old_parent_proc = (void *)SetWindowLongPtrA(hMainWnd, GWLP_WNDPROC, (ULONG_PTR)parent_wnd_proc);
1321
1322 get_combobox_info(combo, &info);
1323
1324 lparam_for_WM_CTLCOLOR = info.hwndItem;
1325
1326 /* Parent returns valid brush handle. */
1327 for (i = 0; i < ARRAY_SIZE(messages); ++i)
1328 {
1329 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
1330 ok(brush == brush_red, "%u: unexpected brush %p, expected got %p.\n", i, brush, brush_red);
1331 }
1332
1333 /* Parent returns NULL brush. */
1334 global_brush = brush_red;
1335 brush_red = NULL;
1336
1337 for (i = 0; i < ARRAY_SIZE(messages); ++i)
1338 {
1339 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
1340 ok(!brush, "%u: unexpected brush %p.\n", i, brush);
1341 }
1342
1343 brush_red = global_brush;
1344
1346
1347 /* Parent does default processing. */
1348 for (i = 0; i < ARRAY_SIZE(messages); ++i)
1349 {
1350 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
1351 ok(!!brush && brush != brush_red, "%u: unexpected brush %p.\n", i, brush);
1352 }
1353
1355 DestroyWindow(combo);
1356
1357 /* Combo without a parent. */
1358 combo = CreateWindowA(WC_COMBOBOXA, "Combo", CBS_DROPDOWN, 5, 5, 100, 100, NULL, NULL, NULL, 0);
1359 ok(!!combo, "Failed to create combo window.\n");
1360
1361 get_combobox_info(combo, &info);
1362
1363 for (i = 0; i < ARRAY_SIZE(messages); ++i)
1364 {
1365 brush = (HBRUSH)SendMessageA(combo, messages[i], 0, (LPARAM)info.hwndItem);
1366 ok(!brush, "%u: unexpected brush %p.\n", i, brush);
1367 }
1368
1369 DestroyWindow(combo);
1370}
#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 void get_combobox_info(HWND hwnd, COMBOBOXINFO *info)
Definition: combo.c:62
static LRESULT CALLBACK parent_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: combo.c:748

Referenced by START_TEST().

◆ test_combo_dropdown_size()

static void test_combo_dropdown_size ( DWORD  style)
static

Definition at line 1195 of file combo.c.

1196{
1197 static const char wine_test[] = "Wine Test";
1198 HWND hCombo, hList;
1199 COMBOBOXINFO cbInfo;
1200 int i, test, ret;
1201
1202 static const struct list_size_info
1203 {
1204 int num_items;
1205 int height_combo;
1206 int limit;
1207 } info_height[] = {
1208 {33, 50, -1},
1209 {35, 100, 40},
1210 {15, 50, 3},
1211 };
1212
1213 for (test = 0; test < ARRAY_SIZE(info_height); test++)
1214 {
1215 const struct list_size_info *info_test = &info_height[test];
1216 int height_item; /* Height of a list item */
1217 int height_list; /* Height of the list we got */
1218 int expected_height_list;
1219 RECT rect_list_client;
1220 int min_visible_expected;
1221
1222 hCombo = CreateWindowA(WC_COMBOBOXA, "Combo", CBS_DROPDOWN | WS_VISIBLE | WS_CHILD | style, 5, 5, 100,
1223 info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
1224
1225 min_visible_expected = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0);
1226 ok(min_visible_expected == 30, "Unexpected number of items %d.\n", min_visible_expected);
1227
1228 cbInfo.cbSize = sizeof(COMBOBOXINFO);
1229 ret = SendMessageA(hCombo, CB_GETCOMBOBOXINFO, 0, (LPARAM)&cbInfo);
1230 ok(ret, "Failed to get combo info, %d\n", ret);
1231
1232 hList = cbInfo.hwndList;
1233 for (i = 0; i < info_test->num_items; i++)
1234 {
1235 ret = SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test);
1236 ok(ret == i, "Failed to add string %d, returned %d.\n", i, ret);
1237 }
1238
1239 if (info_test->limit != -1)
1240 {
1241 int min_visible_actual;
1242 min_visible_expected = info_test->limit;
1243
1244 ret = SendMessageA(hCombo, CB_SETMINVISIBLE, min_visible_expected, 0);
1245 ok(ret, "Failed to set visible limit.\n");
1246 min_visible_actual = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0);
1247 ok(min_visible_expected == min_visible_actual, "test %d: unexpected number of items %d.\n",
1248 test, min_visible_actual);
1249 }
1250
1251 ret = SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE,0);
1252 ok(ret, "Failed to show dropdown.\n");
1253 ret = SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
1254 ok(ret, "Unexpected dropped state.\n");
1255
1256 GetClientRect(hList, &rect_list_client);
1257 height_list = rect_list_client.bottom - rect_list_client.top;
1258 height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0);
1259
1261 {
1262 RECT rect_list_complete;
1263 int list_height_nonclient;
1264 int list_height_calculated;
1265 int edit_padding_size = cbInfo.rcItem.top; /* edit client rect top is the padding it has to its parent
1266 We assume it's the same on the bottom */
1267
1268 GetWindowRect(hList, &rect_list_complete);
1269
1270 list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top)
1271 - (rect_list_client.bottom - rect_list_client.top);
1272
1273 /* Calculate the expected client size of the listbox popup from the size of the combobox. */
1274 list_height_calculated = info_test->height_combo /* Take height we created combobox with */
1275 - (cbInfo.rcItem.bottom - cbInfo.rcItem.top) /* Subtract size of edit control */
1276 - list_height_nonclient /* Subtract list nonclient area */
1277 - edit_padding_size * 2; /* subtract space around the edit control */
1278
1279 expected_height_list = min(list_height_calculated, height_item * info_test->num_items);
1280 if (expected_height_list < 0)
1281 expected_height_list = 0;
1282
1283 ok(expected_height_list == height_list, "Test %d, expected list height to be %d, got %d\n",
1284 test, expected_height_list, height_list);
1285 }
1286 else
1287 {
1288 expected_height_list = min(info_test->num_items, min_visible_expected) * height_item;
1289
1290 ok(expected_height_list == height_list, "Test %d, expected list height to be %d, got %d\n",
1291 test, expected_height_list, height_list);
1292 }
1293
1294 DestroyWindow(hCombo);
1295 }
1296}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLint limit
Definition: glext.h:10326
HWND hList
Definition: livecd.c:10
#define min(a, b)
Definition: monoChain.cc:55
#define CB_GETMINVISIBLE
Definition: commctrl.h:4727
#define CB_SETMINVISIBLE
Definition: commctrl.h:4726
#define test
Definition: rosglue.h:37
Definition: main.c:45
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define CB_SHOWDROPDOWN
Definition: winuser.h:1973
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1944
#define LB_GETITEMHEIGHT
Definition: winuser.h:2045
#define CB_ADDSTRING
Definition: winuser.h:1939
struct tagCOMBOBOXINFO COMBOBOXINFO
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1948

Referenced by START_TEST().

◆ test_combo_editselection()

static void test_combo_editselection ( void  )
static

Definition at line 940 of file combo.c.

941{
942 COMBOBOXINFO cbInfo;
943 INT start, end;
944 char edit[20];
945 HWND hCombo;
946 HWND hEdit;
947 DWORD len;
948
949 /* Build a combo */
950 hCombo = create_combobox(CBS_SIMPLE);
951
952 get_combobox_info(hCombo, &cbInfo);
953 hEdit = cbInfo.hwndItem;
954
955 /* Initially combo selection is empty*/
956 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
957 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
958 ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
959
960 /* Set some text, and press a key to replace it */
961 edit[0] = 0x00;
962 SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason1");
963 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
964 ok(strcmp(edit, "Jason1")==0, "Unexpected text retrieved %s\n", edit);
965
966 /* Now what is the selection - still empty */
968 ok(start==0, "Unexpected start position for selection %d\n", start);
969 ok(end==0, "Unexpected end position for selection %d\n", end);
970 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
971 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
972 ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
973
974 /* Give it focus, and it gets selected */
975 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
977 ok(start==0, "Unexpected start position for selection %d\n", start);
978 ok(end==6, "Unexpected end position for selection %d\n", end);
979 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
980 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
981 ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
982
983 /* Now emulate a key press */
984 edit[0] = 0x00;
985 SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
986 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
987 ok(strcmp(edit, "A")==0, "Unexpected text retrieved %s\n", edit);
988
989 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
990 ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
991 ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
992
993 /* Now what happens when it gets more focus a second time - it doesn't reselect */
994 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
995 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
996 ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
997 ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
998 DestroyWindow(hCombo);
999
1000 /* Start again - Build a combo */
1001 hCombo = create_combobox(CBS_SIMPLE);
1002 get_combobox_info(hCombo, &cbInfo);
1003 hEdit = cbInfo.hwndItem;
1004
1005 /* Set some text and give focus so it gets selected */
1006 edit[0] = 0x00;
1007 SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason2");
1008 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
1009 ok(strcmp(edit, "Jason2")==0, "Unexpected text retrieved %s\n", edit);
1010
1011 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
1012
1013 /* Now what is the selection */
1015 ok(start==0, "Unexpected start position for selection %d\n", start);
1016 ok(end==6, "Unexpected end position for selection %d\n", end);
1017 len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
1018 ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
1019 ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
1020
1021 /* Now change the selection to the apparently invalid start -1, end -1 and
1022 show it means no selection (ie start -1) but cursor at end */
1023 SendMessageA(hCombo, CB_SETEDITSEL, 0, -1);
1024 edit[0] = 0x00;
1025 SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
1026 SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
1027 ok(strcmp(edit, "Jason2A")==0, "Unexpected text retrieved %s\n", edit);
1028 DestroyWindow(hCombo);
1029}
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
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_SETFOCUS
Definition: winuser.h:1616
#define WM_SETTEXT
Definition: winuser.h:1620
#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_combo_editselection_focus()

static void test_combo_editselection_focus ( DWORD  style)
static

Definition at line 1067 of file combo.c.

1068{
1069 static const char wine_test[] = "Wine Test";
1070 HWND hCombo, hEdit, hButton;
1071 char buffer[16] = {0};
1072 COMBOBOXINFO cbInfo;
1073 DWORD len;
1074
1075 hCombo = create_combobox(style);
1076 get_combobox_info(hCombo, &cbInfo);
1077 hEdit = cbInfo.hwndItem;
1078
1080 5, 50, 100, 20, hMainWnd, NULL,
1082
1085
1086 SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
1087 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
1088 todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
1089 ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
1090 ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
1091
1093 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
1094 todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
1095 ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
1096 ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
1097
1100 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
1101 todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
1102 ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
1103 ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
1104 SendMessageA(hCombo, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
1105 ok(!strcmp(buffer, wine_test), "Unexpected text in edit control; got '%s'\n", buffer);
1106
1108 ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
1109 todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
1110 ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
1111 ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
1112 len = SendMessageA(hCombo, CB_GETEDITSEL, 0, 0);
1113 ok(len == 0, "Unexpected text selection; start: %u, end: %u\n", LOWORD(len), HIWORD(len));
1114
1116 DestroyWindow(hButton);
1117 DestroyWindow(hCombo);
1118}
GLuint buffer
Definition: glext.h:5915
#define INT_MAX
Definition: limits.h:40
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
#define WC_BUTTONA
Definition: commctrl.h:4627
HWND WINAPI GetFocus(void)
Definition: window.c:1865
#define GWLP_HINSTANCE
Definition: winuser.h:859
#define WM_NEXTDLGCTL
Definition: winuser.h:1646

Referenced by START_TEST().

◆ test_combo_listbox_styles()

static void test_combo_listbox_styles ( DWORD  cb_style)
static

Definition at line 1120 of file combo.c.

1121{
1122 DWORD style, exstyle, expect_style, expect_exstyle;
1124 HWND combo;
1125
1127 if (cb_style == CBS_SIMPLE)
1128 {
1130 expect_exstyle = WS_EX_CLIENTEDGE;
1131 }
1132 else
1133 {
1135 expect_exstyle = WS_EX_TOOLWINDOW;
1136 }
1137
1138 combo = create_combobox(cb_style);
1139 get_combobox_info(combo, &info);
1140
1141 style = GetWindowLongW( info.hwndList, GWL_STYLE );
1142 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
1143 ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
1144 ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
1145
1146 if (cb_style != CBS_SIMPLE)
1147 expect_exstyle |= WS_EX_TOPMOST;
1148
1149 SendMessageW(combo, CB_SHOWDROPDOWN, TRUE, 0 );
1150 style = GetWindowLongW( info.hwndList, GWL_STYLE );
1151 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
1152 ok(style == (expect_style | WS_VISIBLE), "%08x: got %08x\n", cb_style, style);
1153 ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
1154
1155 SendMessageW(combo, CB_SHOWDROPDOWN, FALSE, 0 );
1156 style = GetWindowLongW( info.hwndList, GWL_STYLE );
1157 exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
1158 ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
1159 ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
1160
1161 DestroyWindow(combo);
1162}
#define FALSE
Definition: types.h:117
#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)
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_combo_setfont()

static void test_combo_setfont ( DWORD  style)
static

Definition at line 675 of file combo.c.

676{
677 HFONT hFont1, hFont2;
678 HWND hCombo;
679 RECT r;
680 int i;
681
682 hCombo = create_combobox(style);
685
686 GetClientRect(hCombo, &r);
690 todo_wine expect_rect(r, 5, 5, 105, 105);
691
692 /* The size of the dropped control is initially equal to the size
693 of the window when it was created. The size of the calculated
694 dropped area changes only by how much the selection area
695 changes, not by how much the list area changes. */
696 if (get_font_height(hFont1) == 10 && get_font_height(hFont2) == 8)
697 {
698 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
699 GetClientRect(hCombo, &r);
700 expect_rect(r, 0, 0, 100, 18);
704
705 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE);
706 GetClientRect(hCombo, &r);
707 expect_rect(r, 0, 0, 100, 16);
711
712 SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
713 GetClientRect(hCombo, &r);
714 expect_rect(r, 0, 0, 100, 18);
718 }
719 else
720 {
721 ok(0, "Expected Marlett font heights 10/8, got %d/%d\n",
722 get_font_height(hFont1), get_font_height(hFont2));
723 }
724
725 for (i = 1; i < 30; i++)
726 {
729
731 GetClientRect(hCombo, &r);
732 ok((r.bottom - r.top) == (height + 8), "Unexpected client rect height.\n");
733 SendMessageA(hCombo, WM_SETFONT, 0, FALSE);
735 }
736
737 DestroyWindow(hCombo);
738 DeleteObject(hFont1);
739 DeleteObject(hFont2);
740}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define expect_rect(r, _left, _top, _right, _bottom)
Definition: combo.c:42
static int get_font_height(HFONT hFont)
Definition: combo.c:621
#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_combo_setitemheight()

static void test_combo_setitemheight ( DWORD  style)
static

Definition at line 636 of file combo.c.

637{
638 HWND hCombo = create_combobox(style);
639 int i, font_height, height;
640 HFONT hFont;
641 RECT r;
642
643 GetClientRect(hCombo, &r);
647 todo_wine expect_rect(r, 5, 5, 105, 105);
648
649 for (i = 1; i < 30; i++)
650 {
651 SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, i);
652 GetClientRect(hCombo, &r);
653 ok((r.bottom - r.top) == (i + 6), "Unexpected client rect height.\n");
654 }
655
656 DestroyWindow(hCombo);
657
658 /* Set item height below text height, force resize. */
659 hCombo = create_combobox(style);
660
661 hFont = (HFONT)SendMessageA(hCombo, WM_GETFONT, 0, 0);
663 SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, font_height / 2);
664 height = SendMessageA(hCombo, CB_GETITEMHEIGHT, -1, 0);
666 ok(height == font_height / 2, "Unexpected item height %d, expected %d.\n", height, font_height / 2);
667
668 SetWindowPos(hCombo, NULL, 10, 10, 150, 5 * font_height, SWP_SHOWWINDOW);
669 height = SendMessageA(hCombo, CB_GETITEMHEIGHT, -1, 0);
670 ok(height > font_height, "Unexpected item height %d, font height %d.\n", height, font_height);
671
672 DestroyWindow(hCombo);
673}
static int font_height(HFONT hFont)
Definition: combo.c:46
#define CB_GETITEMHEIGHT
Definition: winuser.h:1954
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_GETFONT
Definition: winuser.h:1654
#define SWP_SHOWWINDOW
Definition: winuser.h:1251
#define CB_SETITEMHEIGHT
Definition: winuser.h:1970

Referenced by START_TEST().

◆ test_combo_WS_VSCROLL()

static void test_combo_WS_VSCROLL ( void  )
static

Definition at line 1164 of file combo.c.

1165{
1166 HWND hCombo, hList;
1168 DWORD style;
1169 int i;
1170
1172
1173 get_combobox_info(hCombo, &info);
1174 hList = info.hwndList;
1175
1176 for (i = 0; i < 3; i++)
1177 {
1178 char buffer[2];
1179 sprintf(buffer, "%d", i);
1180 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)buffer);
1181 }
1182
1183 style = GetWindowLongA(info.hwndList, GWL_STYLE);
1185
1186 SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE, 0);
1187 SendMessageA(hCombo, CB_SHOWDROPDOWN, FALSE, 0);
1188
1190 ok((style & WS_VSCROLL) != 0, "Style does not include WS_VSCROLL\n");
1191
1192 DestroyWindow(hCombo);
1193}
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#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().

◆ test_comboex()

static void test_comboex ( void  )
static

Definition at line 153 of file combo.c.

154{
155 HWND myHwnd = 0;
156 LONG res;
157 COMBOBOXEXITEMA cbexItem;
158 static const char *first_item = "First Item",
159 *second_item = "Second Item",
160 *third_item = "Third Item",
161 *middle_item = "Between First and Second Items",
162 *replacement_item = "Between First and Second Items",
163 *out_of_range_item = "Out of Range Item";
164
165 /* Allocate space for result */
167
168 /* Basic comboboxex test */
170
171 /* Add items onto the end of the combobox */
172 res = addItem(myHwnd, -1, first_item);
173 ok(res == 0, "Adding simple item failed (%d)\n", res);
174 res = addItem(myHwnd, -1, second_item);
175 ok(res == 1, "Adding simple item failed (%d)\n", res);
176 res = addItem(myHwnd, 2, third_item);
177 ok(res == 2, "Adding simple item failed (%d)\n", res);
178 res = addItem(myHwnd, 1, middle_item);
179 ok(res == 1, "Inserting simple item failed (%d)\n", res);
180
181 /* Add an item completely out of range */
182 res = addItem(myHwnd, 99, out_of_range_item);
183 ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
184 res = addItem(myHwnd, 5, out_of_range_item);
185 ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
186 /* Removed: Causes traps on Windows XP
187 res = addItem(myHwnd, -2, "Out Of Range Item");
188 ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res);
189 */
190
191 /* Get an item completely out of range */
192 res = getItem(myHwnd, 99, &cbexItem);
193 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
194 res = getItem(myHwnd, 4, &cbexItem);
195 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
196 res = getItem(myHwnd, -2, &cbexItem);
197 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
198
199 /* Get an item in range */
200 res = getItem(myHwnd, 0, &cbexItem);
201 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
202 ok(strcmp(first_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
203
204 res = getItem(myHwnd, 1, &cbexItem);
205 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
206 ok(strcmp(middle_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
207
208 res = getItem(myHwnd, 2, &cbexItem);
209 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
210 ok(strcmp(second_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
211
212 res = getItem(myHwnd, 3, &cbexItem);
213 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
214 ok(strcmp(third_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
215
216 /* Set an item completely out of range */
217 res = setItem(myHwnd, 99, replacement_item);
218 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
219 res = setItem(myHwnd, 4, replacement_item);
220 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
221 res = setItem(myHwnd, -2, replacement_item);
222 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
223
224 /* Set an item in range */
225 res = setItem(myHwnd, 0, replacement_item);
226 ok(res != 0, "Setting first item failed (%d)\n", res);
227 res = setItem(myHwnd, 3, replacement_item);
228 ok(res != 0, "Setting last item failed (%d)\n", res);
229
230 /* Remove items completely out of range (4 items in control at this point) */
231 res = delItem(myHwnd, -1);
232 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
233 res = delItem(myHwnd, 4);
234 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
235
236 /* Remove items in range (4 items in control at this point) */
237 res = delItem(myHwnd, 3);
238 ok(res == 3, "Deleting using out of range index failed (%d)\n", res);
239 res = delItem(myHwnd, 0);
240 ok(res == 2, "Deleting using out of range index failed (%d)\n", res);
241 res = delItem(myHwnd, 0);
242 ok(res == 1, "Deleting using out of range index failed (%d)\n", res);
243 res = delItem(myHwnd, 0);
244 ok(res == 0, "Deleting using out of range index failed (%d)\n", res);
245
246 /* Remove from an empty box */
247 res = delItem(myHwnd, 0);
248 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
249
250
251 /* Cleanup */
253 DestroyWindow(myHwnd);
254}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
GLuint res
Definition: glext.h:9613
static LONG getItem(HWND cbex, int idx, COMBOBOXEXITEMA *cbItem)
Definition: combo.c:100
static LONG addItem(HWND cbex, int idx, const char *text)
Definition: combo.c:76
static LONG delItem(HWND cbex, int idx)
Definition: combo.c:96
static HWND createComboEx(DWORD style)
Definition: combo.c:71
#define MAX_CHARS
Definition: combo.c:57
static LONG setItem(HWND cbex, int idx, const char *text)
Definition: combo.c:86
#define CB_ERR
Definition: winuser.h:2438

Referenced by START_TEST().

◆ test_comboex_CB_GETLBTEXT()

static void test_comboex_CB_GETLBTEXT ( void  )
static

Definition at line 367 of file combo.c.

368{
369 HWND hCombo;
370 CHAR buff[1];
372 LRESULT ret;
373
375
376 /* set text to null */
377 addItem(hCombo, 0, NULL);
378
379 buff[0] = 'a';
380 item.mask = CBEIF_TEXT;
381 item.iItem = 0;
382 item.pszText = buff;
383 item.cchTextMax = 1;
384 ret = SendMessageA(hCombo, CBEM_GETITEMA, 0, (LPARAM)&item);
385 ok(ret != 0, "CBEM_GETITEM failed\n");
386 ok(buff[0] == 0, "\n");
387
388 ret = SendMessageA(hCombo, CB_GETLBTEXTLEN, 0, 0);
389 ok(ret == 0, "Expected zero length\n");
390
391 ret = SendMessageA(hCombo, CB_GETLBTEXTLEN, 0, 0);
392 ok(ret == 0, "Expected zero length\n");
393
394 buff[0] = 'a';
395 ret = SendMessageA(hCombo, CB_GETLBTEXT, 0, (LPARAM)buff);
396 ok(ret == 0, "Expected zero length\n");
397 ok(buff[0] == 0, "Expected null terminator as a string, got %s\n", buff);
398
399 DestroyWindow(hCombo);
400}
static unsigned char buff[32768]
Definition: fatten.c:17
static ATOM item
Definition: dde.c:856
#define CB_GETLBTEXTLEN
Definition: winuser.h:1956
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_comboex_get_set_item()

static void test_comboex_get_set_item ( void  )
static

Definition at line 574 of file combo.c.

575{
576 char textA[] = "test";
577 HWND hComboEx;
579 BOOL ret;
580
582
583 subclass_editbox(hComboEx);
584
586
587 memset(&item, 0, sizeof(item));
588 item.mask = CBEIF_TEXT;
589 item.pszText = textA;
590 item.iItem = -1;
591 ret = SendMessageA(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
592 expect(TRUE, ret);
593
595
596 /* get/set lParam */
597 item.mask = CBEIF_LPARAM;
598 item.iItem = -1;
599 item.lParam = 0xdeadbeef;
600 ret = SendMessageA(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
601 expect(TRUE, ret);
602 ok(item.lParam == 0, "Expected zero, got %lx\n", item.lParam);
603
604 item.lParam = 0x1abe11ed;
605 ret = SendMessageA(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
606 expect(TRUE, ret);
607
608 item.lParam = 0;
609 ret = SendMessageA(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
610 expect(TRUE, ret);
611 ok(item.lParam == 0x1abe11ed, "Expected 0x1abe11ed, got %lx\n", item.lParam);
612
613 DestroyWindow(hComboEx);
614}
#define ok_sequence(exp, contx, todo)
Definition: SystemMenu.c:275
static void flush_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:99
static const char textA[]
Definition: registrar.c:40
static HWND subclass_editbox(HWND hwndComboEx)
Definition: combo.c:140
static const struct message test_setitem_edit_seq[]
Definition: combo.c:567
#define expect(expected, got)
Definition: combo.c:40
#define CBEIF_LPARAM
Definition: commctrl.h:3796

Referenced by START_TEST().

◆ test_comboex_subclass()

static void test_comboex_subclass ( void  )
static

Definition at line 547 of file combo.c.

548{
549 HWND hComboEx, hCombo, hEdit;
550
552
553 hCombo = (HWND)SendMessageA(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
554 ok(hCombo != NULL, "Failed to get internal combo\n");
555 hEdit = (HWND)SendMessageA(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
556 ok(hEdit != NULL, "Failed to get internal edit\n");
557
558 if (pSetWindowSubclass)
559 {
560 ok(GetPropA(hCombo, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
561 ok(GetPropA(hEdit, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
562 }
563
564 DestroyWindow(hComboEx);
565}
#define CBEM_GETCOMBOCONTROL
Definition: commctrl.h:3837
HANDLE WINAPI GetPropA(_In_ HWND, _In_ LPCSTR)

Referenced by START_TEST().

◆ test_comboex_WM_LBUTTONDOWN()

static void test_comboex_WM_LBUTTONDOWN ( void  )
static

Definition at line 256 of file combo.c.

257{
258 HWND hComboEx, hCombo, hEdit, hList;
259 COMBOBOXINFO cbInfo;
260 UINT x, y, item_height;
262 UINT i;
263 int idx;
264 RECT rect;
265 WCHAR buffer[3];
266 static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
267 static const WCHAR stringFormat[] = {'%','2','d','\0'};
268
269 hComboEx = CreateWindowExA(0, WC_COMBOBOXEXA, NULL,
270 WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150,
272
273 for (i = 0; i < ARRAY_SIZE(choices); i++){
274 COMBOBOXEXITEMW cbexItem;
275 wsprintfW(buffer, stringFormat, choices[i]);
276
277 memset(&cbexItem, 0x00, sizeof(cbexItem));
278 cbexItem.mask = CBEIF_TEXT;
279 cbexItem.iItem = i;
280 cbexItem.pszText = buffer;
281 cbexItem.cchTextMax = 0;
282 ok(SendMessageW(hComboEx, CBEM_INSERTITEMW, 0, (LPARAM)&cbexItem) >= 0,
283 "Failed to add item %d\n", i);
284 }
285
286 hCombo = (HWND)SendMessageA(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
287 hEdit = (HWND)SendMessageA(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
288
289 get_combobox_info(hCombo, &cbInfo);
290 hList = cbInfo.hwndList;
291
293 "Focus not on Main Window, instead on %p\n", GetFocus());
294
295 /* Click on the button to drop down the list */
296 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
297 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
299 ok(result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
300 GetLastError());
301 ok(GetFocus() == hCombo ||
302 broken(GetFocus() != hCombo), /* win98 */
303 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
304 GetFocus());
305 ok(SendMessageA(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
306 "The dropdown list should have appeared after clicking the button.\n");
307 idx = SendMessageA(hCombo, CB_GETTOPINDEX, 0, 0);
308 ok(idx == 0, "For TopIndex expected %d, got %d\n", 0, idx);
309
310 result = SendMessageA(hCombo, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
311 ok(result, "WM_LBUTTONUP was not processed. LastError=%d\n",
312 GetLastError());
313 ok(GetFocus() == hCombo ||
314 broken(GetFocus() != hCombo), /* win98 */
315 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
316 GetFocus());
317
318 /* Click on the 5th item in the list */
319 item_height = SendMessageA(hCombo, CB_GETITEMHEIGHT, 0, 0);
320 ok(GetClientRect(hList, &rect), "Failed to get list's client rect.\n");
321 x = rect.left + (rect.right-rect.left)/2;
322 y = item_height/2 + item_height*4;
324 ok(!result, "WM_MOUSEMOVE was not processed. LastError=%d\n",
325 GetLastError());
326 ok(GetFocus() == hCombo ||
327 broken(GetFocus() != hCombo), /* win98 */
328 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
329 GetFocus());
330
332 ok(!result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
333 GetLastError());
334 ok(GetFocus() == hCombo ||
335 broken(GetFocus() != hCombo), /* win98 */
336 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
337 GetFocus());
338 ok(SendMessageA(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
339 "The dropdown list should still be visible.\n");
340
342 ok(!result, "WM_LBUTTONUP was not processed. LastError=%d\n",
343 GetLastError());
344 todo_wine ok(GetFocus() == hEdit ||
345 broken(GetFocus() == hCombo), /* win98 */
346 "Focus not on ComboBoxEx's Edit Control, instead on %p\n",
347 GetFocus());
348
349 result = SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
350 ok(!result ||
351 broken(result != 0), /* win98 */
352 "The dropdown list should have been rolled up.\n");
353 idx = SendMessageA(hComboEx, CB_GETCURSEL, 0, 0);
354 ok(idx == 4 ||
355 broken(idx == -1), /* win98 */
356 "Current Selection: expected %d, got %d\n", 4, idx);
357 ok(received_end_edit, "Expected to receive a CBEN_ENDEDIT message\n");
358
360 ok( GetFocus() == hComboExParentWnd, "got %p\n", GetFocus() );
361 SetFocus( hComboEx );
362 ok( GetFocus() == hEdit, "got %p\n", GetFocus() );
363
364 DestroyWindow(hComboEx);
365}
#define broken(x)
Definition: atltest.h:178
static const WCHAR stringFormat[]
Definition: wordpad.c:55
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint64EXT * result
Definition: glext.h:11304
unsigned int UINT
Definition: ndis.h:50
#define CBEM_INSERTITEMW
Definition: commctrl.h:3846
& rect
Definition: startmenu.cpp:1413
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define WM_MOUSEMOVE
Definition: winuser.h:1778
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_LBUTTONUP
Definition: winuser.h:1780
#define CB_GETTOPINDEX
Definition: winuser.h:1958
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_comboex_WM_WINDOWPOSCHANGING()

static void test_comboex_WM_WINDOWPOSCHANGING ( void  )
static

Definition at line 402 of file combo.c.

403{
404 HWND hCombo;
405 WINDOWPOS wp;
406 RECT rect;
407 int combo_height;
408 int ret;
409
411 ok(hCombo != NULL, "createComboEx failed\n");
412 ret = GetWindowRect(hCombo, &rect);
413 ok(ret, "GetWindowRect failed\n");
414 combo_height = rect.bottom - rect.top;
415 ok(combo_height > 0, "wrong combo height\n");
416
417 /* Test height > combo_height */
418 wp.x = rect.left;
419 wp.y = rect.top;
420 wp.cx = (rect.right - rect.left);
421 wp.cy = combo_height * 2;
422 wp.flags = 0;
423 wp.hwnd = hCombo;
425
426 ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
427 ok(ret == 0, "expected 0, got %x\n", ret);
428 ok(wp.cy == combo_height,
429 "Expected height %d, got %d\n", combo_height, wp.cy);
430
431 /* Test height < combo_height */
432 wp.x = rect.left;
433 wp.y = rect.top;
434 wp.cx = (rect.right - rect.left);
435 wp.cy = combo_height / 2;
436 wp.flags = 0;
437 wp.hwnd = hCombo;
439
440 ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
441 ok(ret == 0, "expected 0, got %x\n", ret);
442 ok(wp.cy == combo_height,
443 "Expected height %d, got %d\n", combo_height, wp.cy);
444
445 ret = DestroyWindow(hCombo);
446 ok(ret, "DestroyWindow failed\n");
447}
HWND hwnd
Definition: winuser.h:3591
UINT flags
Definition: winuser.h:3597
HWND hwndInsertAfter
Definition: winuser.h:3592
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1664

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

798{
799 HWND hCombo;
800 INT idx;
801
802 hCombo = create_combobox(style);
803
804 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[0]);
805 SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[1]);
806 SendMessageA(hCombo, CB_SETCURSEL, -1, 0);
807
809
810 idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
811 ok(idx == -1, "expected selection -1, got %d\n", idx);
812
813 /* keyboard navigation */
814
816 expected_edit_text = text[edit[0]];
818 SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
819 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
820
822 expected_edit_text = text[edit[1]];
824 SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
825 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
826
828 expected_edit_text = text[edit[2]];
830 SendMessageA(hCombo, WM_KEYDOWN, VK_UP, 0);
831 ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
832
833 /* programmatic navigation */
834
836 expected_edit_text = text[edit[3]];
838 SendMessageA(hCombo, CB_SETCURSEL, list[3], 0);
839 ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
840
842 expected_edit_text = text[edit[4]];
844 SendMessageA(hCombo, CB_SETCURSEL, list[4], 0);
845 ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
846
848 DestroyWindow(hCombo);
849}
#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_window_proc()

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

Definition at line 1045 of file combo.c.

1046{
1047 switch (msg)
1048 {
1049 case WM_COMMAND:
1050 switch (HIWORD(wParam))
1051 {
1052 case CBN_SETFOCUS:
1054 break;
1055 case CBN_KILLFOCUS:
1057 break;
1058 }
1059 break;
1060 case WM_NEXTDLGCTL:
1062 break;
1063 }
1064 return CallWindowProcA(old_parent_proc, hwnd, msg, wParam, lParam);
1065}
#define CBN_SETFOCUS
Definition: winuser.h:1985
#define CBN_KILLFOCUS
Definition: winuser.h:1981

Referenced by test_combo_editselection_focus(), and test_editselection_focus().

Variable Documentation

◆ brush_red

HBRUSH brush_red
static

Definition at line 53 of file combo.c.

Referenced by cleanup(), init(), parent_wnd_proc(), and test_combo_ctlcolor().

◆ ComboExTestClass

const char ComboExTestClass[] = "ComboExTestClass"
static

Definition at line 51 of file combo.c.

Referenced by cleanup(), and init().

◆ DWORD_PTR

Definition at line 55 of file combo.c.

◆ edit_window_proc

WNDPROC edit_window_proc
static

◆ expected_edit_text

LPCSTR expected_edit_text
static

Definition at line 743 of file combo.c.

Referenced by parent_wnd_proc(), and test_selection().

◆ expected_list_text

LPCSTR expected_list_text
static

Definition at line 744 of file combo.c.

Referenced by parent_wnd_proc(), and test_selection().

◆ hCBN_KillFocus

HWND hCBN_KillFocus
static

◆ hCBN_SetFocus

HWND hCBN_SetFocus
static

◆ hComboExParentWnd

HWND hComboExParentWnd
static

Definition at line 49 of file combo.c.

Referenced by cleanup(), createComboEx(), init(), and test_comboex_WM_LBUTTONDOWN().

◆ hMainHinst

HINSTANCE hMainHinst
static

Definition at line 50 of file combo.c.

Referenced by createComboEx(), init(), and test_comboex_WM_LBUTTONDOWN().

◆ hMainWnd

◆ lparam

UINT WPARAM LPARAM lparam

Definition at line 742 of file combo.c.

Referenced by editbox_subclass_proc(), and parent_wnd_proc().

◆ lparam_for_WM_CTLCOLOR

HWND lparam_for_WM_CTLCOLOR
static

Definition at line 746 of file combo.c.

Referenced by parent_wnd_proc(), and test_combo_ctlcolor().

◆ msg

UINT msg

Definition at line 742 of file combo.c.

◆ received_end_edit

BOOL received_end_edit = FALSE
static

Definition at line 60 of file combo.c.

Referenced by ComboExTestOnNotify(), and test_comboex_WM_LBUTTONDOWN().

◆ selchange_fired

BOOL selchange_fired
static

Definition at line 745 of file combo.c.

Referenced by parent_wnd_proc(), and test_selection().

◆ sequences

Definition at line 47 of file combo.c.

Referenced by editbox_subclass_proc(), START_TEST(), and test_comboex_get_set_item().

◆ setsel_end

long setsel_end = 1
static

◆ setsel_start

long setsel_start = 1
static

◆ SUBCLASSPROC

SUBCLASSPROC

Definition at line 55 of file combo.c.

◆ test_setitem_edit_seq

const struct message test_setitem_edit_seq[]
static
Initial value:
= {
{ 0 }
}
GLuint id
Definition: glext.h:5910

Definition at line 567 of file combo.c.

Referenced by test_comboex_get_set_item().

◆ textBuffer

char* textBuffer = NULL
static

Definition at line 58 of file combo.c.

Referenced by CDockSite::Exec(), getItem(), CDockSite::Initialize(), and test_comboex().

◆ UINT_PTR

Definition at line 55 of file combo.c.

◆ wparam

UINT WPARAM wparam

Definition at line 742 of file combo.c.

Referenced by editbox_subclass_proc(), and parent_wnd_proc().