comdlg32: Implement SetControlItemState for combo boxes.

oldstable
Vincent Povirk 2015-08-18 15:13:45 -05:00 committed by Alexandre Julliard
parent 068a6c7a5f
commit 8d8e75849f
2 changed files with 46 additions and 15 deletions

View File

@ -3675,9 +3675,11 @@ static HRESULT WINAPI IFileDialogCustomize_fnAddControlItem(IFileDialogCustomize
case IDLG_CCTRL_COMBOBOX: case IDLG_CCTRL_COMBOBOX:
{ {
UINT index; UINT index;
cctrl_item* item;
if(get_combobox_index_from_id(ctrl->hwnd, dwIDItem) != -1) hr = add_item(ctrl, dwIDItem, pszLabel, &item);
return E_INVALIDARG;
if (FAILED(hr)) return hr;
index = SendMessageW(ctrl->hwnd, CB_ADDSTRING, 0, (LPARAM)pszLabel); index = SendMessageW(ctrl->hwnd, CB_ADDSTRING, 0, (LPARAM)pszLabel);
SendMessageW(ctrl->hwnd, CB_SETITEMDATA, index, dwIDItem); SendMessageW(ctrl->hwnd, CB_SETITEMDATA, index, dwIDItem);
@ -3719,19 +3721,21 @@ static HRESULT WINAPI IFileDialogCustomize_fnRemoveControlItem(IFileDialogCustom
{ {
case IDLG_CCTRL_COMBOBOX: case IDLG_CCTRL_COMBOBOX:
{ {
UINT i, count = SendMessageW(ctrl->hwnd, CB_GETCOUNT, 0, 0); cctrl_item* item;
if(!count || (count == CB_ERR)) DWORD position;
return E_FAIL;
for(i = 0; i < count; i++) item = get_item(ctrl, dwIDItem, CDCS_VISIBLE|CDCS_ENABLED, &position);
if(SendMessageW(ctrl->hwnd, CB_GETITEMDATA, i, 0) == dwIDItem)
{
if(SendMessageW(ctrl->hwnd, CB_DELETESTRING, i, 0) == CB_ERR)
return E_FAIL;
return S_OK;
}
return E_UNEXPECTED; if ((item->cdcstate & (CDCS_VISIBLE|CDCS_ENABLED)) == (CDCS_VISIBLE|CDCS_ENABLED))
{
if(SendMessageW(ctrl->hwnd, CB_DELETESTRING, position, 0) == CB_ERR)
return E_FAIL;
}
list_remove(&item->entry);
item_free(item);
return S_OK;
} }
case IDLG_CCTRL_MENU: case IDLG_CCTRL_MENU:
{ {
@ -3788,6 +3792,7 @@ static HRESULT WINAPI IFileDialogCustomize_fnGetControlItemState(IFileDialogCust
switch(ctrl->type) switch(ctrl->type)
{ {
case IDLG_CCTRL_COMBOBOX:
case IDLG_CCTRL_MENU: case IDLG_CCTRL_MENU:
{ {
cctrl_item* item; cctrl_item* item;
@ -3821,6 +3826,34 @@ static HRESULT WINAPI IFileDialogCustomize_fnSetControlItemState(IFileDialogCust
switch(ctrl->type) switch(ctrl->type)
{ {
case IDLG_CCTRL_COMBOBOX:
{
cctrl_item* item;
BOOL visible, was_visible;
DWORD position;
item = get_item(ctrl, dwIDItem, CDCS_VISIBLE|CDCS_ENABLED, &position);
if (!item)
return E_UNEXPECTED;
visible = ((dwState & (CDCS_VISIBLE|CDCS_ENABLED)) == (CDCS_VISIBLE|CDCS_ENABLED));
was_visible = ((item->cdcstate & (CDCS_VISIBLE|CDCS_ENABLED)) == (CDCS_VISIBLE|CDCS_ENABLED));
if (visible && !was_visible)
{
SendMessageW(ctrl->hwnd, CB_INSERTSTRING, position, (LPARAM)item->label);
SendMessageW(ctrl->hwnd, CB_SETITEMDATA, position, dwIDItem);
}
else if (!visible && was_visible)
{
SendMessageW(ctrl->hwnd, CB_DELETESTRING, position, 0);
}
item->cdcstate = dwState;
return S_OK;
}
case IDLG_CCTRL_MENU: case IDLG_CCTRL_MENU:
{ {
TBBUTTON tbb; TBBUTTON tbb;

View File

@ -1970,7 +1970,6 @@ static void test_customize(void)
ok(hr == E_FAIL, "got 0x%08x.\n", hr); ok(hr == E_FAIL, "got 0x%08x.\n", hr);
ok(selected == -1, "got %d.\n", selected); ok(selected == -1, "got %d.\n", selected);
todo_wine {
cdstate = 0xdeadbeef; cdstate = 0xdeadbeef;
hr = IFileDialogCustomize_GetControlItemState(pfdc, i, 0, &cdstate); hr = IFileDialogCustomize_GetControlItemState(pfdc, i, 0, &cdstate);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
@ -1987,7 +1986,6 @@ static void test_customize(void)
hr = IFileDialogCustomize_GetControlItemState(pfdc, i, 0, &cdstate); hr = IFileDialogCustomize_GetControlItemState(pfdc, i, 0, &cdstate);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
ok(cdstate == CDCS_ENABLEDVISIBLE, "got 0x%08x.\n", cdstate); ok(cdstate == CDCS_ENABLEDVISIBLE, "got 0x%08x.\n", cdstate);
}
for(j = 0; j < 10; j++) for(j = 0; j < 10; j++)
{ {