Loading a combobox win32

Discussion in 'Win32' started by adii28, Jun 26, 2007.

  1. adii28

    adii28 New Member

    Joined:
    Jun 26, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I am trying to create a combo box on a dialog using win32 api in vc++ 6.0. I added the combo box control using the dialog resource editor with type as Dropdown and owner draw set to 'No'. Then I add data to it programatically. I have the following classes

    Code:
    class CmbBox: public SimpleControl {
    public:
    	CmbBox (HWND hwndParent, int id, BOOL initialState=TRUE)
    		 : SimpleControl (hwndParent, id, initialState)
    	{}
       void AddItem (char* buf) {
                SendMessage(_hWnd, CB_ADDSTRING, (WPARAM)0, (LPARAM)buf);
          
       }
       void SetString (char buf[20])
    	{
           SendMessage (_hWnd, WM_SETTEXT, 0, (LPARAM) buf);
    	}
    };
    
    Then i create the object for CmbBox in another class Controller

    CmbBox _cmbSetting;

    and the constructor initializes it

    Controller::Controller (HWND hwnd)
    : _cmbSetting (hwnd, IDC_CMBSETTING)

    Then i call

    _cmbSetting.AddItem("Data1");
    _cmbSetting.AddItem("Data2");

    But when i execute the application there is no data in the combobox. I am able to create all other controls like list box and buttons, but combo box comes up without any data.

    Any pointers??
    Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice