Hi, I am having some problems to populate the list of a combo box. Everything shows up fine, except that the data populated would not show up (I am using VS 2005 and I used the "data" field under properties to enter values, but it doesn't work). I tried the following but they don't work either :
CWnd* dialog = GetDlgItem(IDC_COMBO3);
HWND dlg = dialog->m_hWnd;
dialog->SendMessage(CB_ADDSTRING,0,(LPARAM)"3");
dialog->UpdateWindow();
AddString doesn't work either and gives me Assertion Failure. Anybody know what's wrong ?
*******************************************************
********************MyPage.h****************************
*******************************************************
#if !defined(AFX_MYPAGE_H__17E500E6_1616_11D4_8F4E_002078136998__INCLUDED_)
#define AFX_MYPAGE_H__17E500E6_1616_11D4_8F4E_002078136998__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyPage.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMyPage dialog
class CMyPropertySheet ;
class CMyPage : public CPropertyPage
{
DECLARE_DYNCREATE(CMyPage)
friend CMyPropertySheet ;
// Construction
public:
CMyPage();
~CMyPage();
// Dialog Data
//{{AFX_DATA(CMyPage)
enum { IDD = IDD_PROPPAGE_LARGE };
CComboBox m_comboList;
BOOL m_Feature1;
BOOL m_Feature2;
CString m_Edit1;
int m_Radio;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CMyPage)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
public:
void New(void) ;
void SetStartPoint(void) ;
protected:
bool m_bDirty ;
//copy of data, used for creating history difference
CComboBox mA_combo1;
BOOL mA_Feature1;
BOOL mA_Feature2;
CString mA_Edit1;
int mA_Radio;
void SetupAuditValues(void) ;
// Generated message map functions
//{{AFX_MSG(CMyPage)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnCbnDropdownCombo3();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYPAGE_H__17E500E6_1616_11D4_8F4E_002078136998__INCLUDED_)
*******************************************************
********************MyPage.cpp**************************
*******************************************************
// MyPage.cpp : implementation file
//
#include "stdafx.h"
#include "InProcessCOM_DLL.h"
#include "MyPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyPage property page
IMPLEMENT_DYNCREATE(CMyPage, CPropertyPage)
CMyPage::CMyPage() : CPropertyPage(CMyPage::IDD)
{
//{{AFX_DATA_INIT(CMyPage)
m_bDirty = false ;
}
CMyPage::~CMyPage()
{
}
void CMyPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyPage)
DDX_Control(pDX, IDC_COMBO4, m_comboList);
//}}AFX_DATA_MAP
if (pDX->m_bSaveAndValidate)
{
//otherwise we are taking from the dialog controls and transfering it into data
//WriteDatabase() ;
}
else
{
//set up enable fields if we are turning data into dialog controls
SetupAuditValues() ;
}
}
BEGIN_MESSAGE_MAP(CMyPage, CPropertyPage)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyPage message handlers
void CMyPage::New(void)
{
m_bDirty = false ;
}
BOOL CMyPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
//GetDlgItem(IDC_COMBO4)->SetFocus();
//m_comboList.AddString(_T("1"));
CWnd* dialog = GetDlgItem(IDC_COMBO3);
HWND dlg = dialog->m_hWnd;
dialog->UpdateWindow();
//dialog->SendMessage(CB_ADDSTRING,0,(LPARAM)"3");
// Initalize all the values required by the differencing tool
SetupAuditValues() ; //called in the above OnInitDialog ???
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//=============================================================================
// Make the list of Auditable Variables.
//=============================================================================
void CMyPage::SetupAuditValues(void)
{
}
void CMyPage::SetStartPoint(void)
{
//mA_combo1 = m_comboList;
mA_Feature1 = m_Feature1 ;
mA_Feature2 = m_Feature2 ;
//mA_Edit1 = m_Edit1 ;
mA_Radio = m_Radio ;
}
void CMyPage::OnCbnDropdownCombo3()
{
//m_comboList->AddString("tet");
//SendMessage(CB_ADDSTRING,0,(LPARAM)"2");
// IDC_COMBO7->AddString("ben");
// TODO: Add your control notification handler code here
}
*********************************************************
*********************************************************
*********************************************************