Hi there,
I'll cut to the chase...I've made a combo box in the little Help->About Menu dialog box that appears as standard on the menu bar.
Here's the code:
Code:
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
const wchar_t* colour[4]
= { L"Blue", L"Red", L"Orange", L"Yellow" };
WPARAM nI;
for (int i = 0; i < 4; i++)
{
nI = SendMessageW(GetDlgItem(hDlg, 1003), (UINT) CB_ADDSTRING, 0, (LPARAM)colour[i]);
}
....etc (rest of message handling function)
switch (message)
{
case WM_INITDIALOG:
..... and so on
This is the bit we're interested in:
Code:
const wchar_t* colour[4]
= { L"Blue", L"Red", L"Orange", L"Yellow" };
WPARAM nI;
for (int i = 0; i < 4; i++)
{
nI = SendMessageW(GetDlgItem(hDlg, 1003), (UINT) CB_ADDSTRING, 0, (LPARAM)colour[i]);
}
All works. Actually looks quite nice too:
Only trouble is for a long while the bottom 3 strings were not showing. Only the first entry 'Blue' was shown. To fix this I had to MANUALLY change the height setting in the resource file where the Combo Box layout and flags are defined.
Sometimes if working with DirectX for example when you're querying an adapter list and the resultant display modes/resolutions etc... there's no way to know how long the list of entries you need for the Combo Box is going to be. Thus surely one needs a way to dynamically resize the box when adding new entries.
I don't know what this is though. I could try messing around in the settings in Visual Studio again but I thought it better to ask here first.
Thanks
Edit: Should also add that the 1003 in the GetDlgItem(hDlg, 1003) call equates to the identifier for the combo box.