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 07-Aug-2009, 17:16
thefoo thefoo is offline
New Member
 
Join Date: Aug 2009
Posts: 1
thefoo is on a distinguished road

problem using CListCtrl


As I'm a beginner in MFC I'm trying to develop a simple MFC application. I've prepared main application class, and tried to use CListCtrl. So I've used resource editor: added a dialog and a CListCtrl. Finaly I've bound m_listMain of type CListCtrl to the list using "right->add variable". And here comes the problem. Whenever i want use any method related to m_listMain (i.e. InsertItem, SetExtendedStyle) debug assertion comes up, saying that it failed on ASSERT(::IsWindow(m_hWnd)); Does anyone know any probable explanation? Am I missing something important(an initialization or what...)?

main.cpp
CPP / C++ / C Code:
#include "headers.h"
#include "MainDialog.h"

class Whatsup : public CWinApp
{
	MainDialog *m_dlgMain;

public:
	BOOL InitInstance()
	{
		m_dlgMain = new MainDialog();
		m_pMainWnd = m_dlgMain;
		m_dlgMain->DoModal();
		return TRUE;
	}
};

Whatsup hwnd;

MainDialog.cpp
CPP / C++ / C Code:
#include "headers.h"
#include "MainDialog.h"

IMPLEMENT_DYNAMIC(MainDialog, CDialog)

MainDialog::MainDialog(CWnd* pParent /*=NULL*/)
	: CDialog(MainDialog::IDD, pParent)
{

}

MainDialog::~MainDialog()
{

}

void MainDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_listMain);
}

BOOL MainDialog::OnInitDialog()
{
	m_listMain.SetExtendedStyle(m_listMain.GetExtendedStyle() | LVS_EX_CHECKBOXES);
	LVITEM lvItem;

	lvItem.mask = LVIF_TEXT;
	lvItem.iItem = 0;
	lvItem.iSubItem = 0;
	lvItem.pszText = "TestString";
	m_listMain.InsertItem(&lvItem);
	return TRUE;
}

MainDialog.h
CPP / C++ / C Code:
#pragma once
#include "resource.h"
#include "headers.h"


class MainDialog : public CDialog
{
	DECLARE_DYNAMIC(MainDialog)
public:
	MainDialog(CWnd* pParent = NULL);   // standard constructor
	virtual ~MainDialog();
	BOOL OnInitDialog();
	CListCtrl m_listMain;

// Dialog Data
	enum { IDD = IDD_MAIN };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
};

headers.h: just inclusion of afxwin.h and afxcmn.h
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

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
Apache Web Server newbie problem niss3 Apache Web Server Forum 1 13-Apr-2009 18:38
CListCtrl Problem rag84dec MS Visual C++ / MFC Forum 0 28-Apr-2008 23:14
Checkbox in CListCtrl problem rag84dec MS Visual C++ / MFC Forum 0 29-Jan-2008 03:59
MFC CListCtrl, problem selecting item kte MS Visual C++ / MFC Forum 5 01-Feb-2005 11:15

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

All times are GMT -6. The time now is 16:08.


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