Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   Loading a combobox win32 (http://www.go4expert.com/forums/loading-combobox-win32-t4921/)

adii28 26Jun2007 17:17

Loading a combobox win32
 
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


All times are GMT +5.5. The time now is 20:52.