GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Jul-2007, 13:34
benbuleong benbuleong is offline
New Member
 
Join Date: Jul 2007
Posts: 1
benbuleong is on a distinguished road

Combo box problem.


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 :

CPP / C++ / C Code:
	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 ?

CPP / C++ / C Code:
*******************************************************
********************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_)

CPP / C++ / C Code:
*******************************************************
********************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
}

*********************************************************
*********************************************************
*********************************************************
Last edited by LuciWiz : 14-Jul-2007 at 07:13. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
 
 

Recent GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
Limit combo box and date time picker choice according to database created in folder shinyhui C++ Forum 0 22-Feb-2005 20:16
Limit combo box and date time picker choice according to database created in folder shinyhui MS Visual C++ / MFC Forum 0 22-Feb-2005 02:13
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
combo box select problem zuzupus MySQL / PHP Forum 2 23-Jul-2003 11:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:56.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.