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);
}
}
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);
}
}