Click to See Complete Forum and Search --> : [RESOLVED] Combobox items problem


james2432
July 6th, 2009, 07:38 AM
The items aren't showing up in the combobox and I don't know why.. I've tried with the send message and the combobox macro combobox is there, just not the data

even ComboBox_AddString() doesn't work

#include <windows.h>
#include <windowsx.h>
#define cbEntity 301

switch(msg)
{
case WM_CREATE:
{

//Combobox Entity
hwndcbEntity = CreateWindowEx(0,"Combobox",NULL,WS_CHILD|WS_VISIBLE|LBS_STANDARD,12,12,213,24,hwndex,(HMENU)cbEntity,hInstge,NULL);

InitializeComboBox(hwndex);
}
break;
}



void InitializeComboBox(HWND hwnd)
{
datamanager dm;
std::vector<std::string> v_oldEnts;
v_oldEnts=dm.getOld();
HWND hwndcbEntity= GetDlgItem(hwnd,cbEntity);
for(UINT i=0;i<v_oldEnts.size();i++)
{
int AddIndex;
char *temp = new char[v_oldEnts[i].size()+1];
std::strcpy(temp,v_oldEnts[i].c_str());
// AddIndex=SendMessage(hwndcbEntity,CB_ADDSTRING,0,(LPARAM)temp);
//SendMessage(hwndcbEntity,CB_SETITEMDATA,AddIndex,(LPARAM)i);
// ComboBox_AddItemData(hwndcbEntity,"test");
ComboBox_AddItemData(hwndcbEntity,temp);

}
}

VictorN
July 6th, 2009, 08:32 AM
I am not sure it could cause your problem, but LBS_STANDARD is NOT a combobox style. It is a listbox style.

james2432
July 6th, 2009, 08:39 AM
Acutally I found what the problem was.. it's the height of the control. I had it set to something like 24, and when I set it to 100 I can see the items that are inside(without making it look freakishly huge)