Wednesday, March 25, 2009

Create A Combo Box on a Toolbar

const int nDropHeight = 100;


Create a dummy button on a toolbar. Separator style recommended.

Command identifier associated with the button:

button.idCommand = CM_DUMMY;

Get the button size:

RECT rect;
SendMessage(g_hToolBar, TB_GETITEMRECT, 8, (LPARAM)&rect);
rect.top = 1;
rect.bottom = rect.top + nDropHeight;


Create a combo box window:

HWND hCombo = CreateWindowEx(0, szComboBox, NULL,
WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|CBS_AUTOHSCROLL,
rect.left, rect.top, 100,50,
hwndToolBar, (HMENU)1100, hInst, NULL);

if(hCombo == NULL)
{
MessageBox(0, "Combo Creation Failed!", "Error!",

MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
}

No comments:

Post a Comment