CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    31

    [RESOLVED] Combobox items problem

    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
    Code:
    #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;
    }
    Code:
    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);
    		
    	}	
    }
    Last edited by james2432; July 6th, 2009 at 07:43 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Combobox items problem

    I am not sure it could cause your problem, but LBS_STANDARD is NOT a combobox style. It is a listbox style.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2009
    Posts
    31

    Re: Combobox items problem

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured