Click here to Skip to main content
15,902,447 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Programming of all types of visual c++ Pin
David Crow18-Aug-05 2:53
David Crow18-Aug-05 2:53 
QuestionRemembering Detail view setting in File open dialog? Pin
Tejan Zad18-Aug-05 0:06
Tejan Zad18-Aug-05 0:06 
Generallist registered OCX components Pin
Marc Soleda17-Aug-05 23:55
Marc Soleda17-Aug-05 23:55 
GeneralRe: list registered OCX components Pin
geo_m18-Aug-05 19:28
geo_m18-Aug-05 19:28 
GeneralAdding a new header in ISAPI filter (onPreProc) Pin
Vasudevan Deepak Kumar17-Aug-05 23:37
Vasudevan Deepak Kumar17-Aug-05 23:37 
GeneralListView Header Color Pin
Nishad S17-Aug-05 23:33
Nishad S17-Aug-05 23:33 
GeneralRe: ListView Header Color Pin
Aamir Butt18-Aug-05 1:52
Aamir Butt18-Aug-05 1:52 
GeneralAccess Violation During adding items in List Control ( CXListCtrl ).... Pin
Ravi Sankar S17-Aug-05 23:22
Ravi Sankar S17-Aug-05 23:22 
Hello All,

I am developing a sample SDI application in VC++ 6.0 on Windows 2000 Professional. My view class is derived from "CFormView". I am using this List control taken from http://www.codeproject.com/listctrl/xlistctrl.asp on my Form.

Creation and initial display are proper and when i try to add an Item it gives access violation.
Here is the code used to update the List control.

BOOL CMyView::UpdateList (int l_iRow, CInfo *l_oInfo)<br />
{<br />
	CString l_strTemp;<br />
	int l_iRowCount = 0;<br />
<br />
	// ID<br />
	l_strTemp.Format ("%d", l_oInfo->m_lID);<br />
<br />
<br />
	if (l_iRow == -1) { // add at the end of the list<br />
<br />
		l_iRow = m_oTabList.GetItemCount ();<br />
		m_oTabList.InsertItem(l_iRow, l_strTemp, RGB(255, 0, 0), RGB(255, 255, 255));<br />
	} else {<br />
		l_iRow--;<br />
		m_oTabList.SetItemText (l_iRow, l_iRowCount, l_strTemp);<br />
	}<br />
	l_iRowCount++;<br />
....<br />
<br />


If I debug and see the above function is executing fine. but it fails while drawing the items in Line Number 842 of XListCtrl.cpp in Function "DrawText

<br />
	m_HeaderCtrl.GetItem(nSubItem, &hditem);<br />



In the GetItem the m_hWnd is NULL so code in AFXCMN.INL gives Access Violation

<br />
_AFXCMN_INLINE BOOL CHeaderCtrl::GetItem(int nPos, HDITEM* pHeaderItem) const<br />
	{ ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nPos, (LPARAM)pHeaderItem); }<br />


Since ASSERT won't execute in Release mode it is working fine in Release mode.

The code used to insert column is below

<br />
	m_oList.SetExtendedStyle(m_oList.GetStyle() | <br />
		LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);<br />
<br />
	// Insert the columns for the list control<br />
	m_oList.InsertColumn (0, _T("ID"), LVCFMT_CENTER, 40);<br />
	m_oList.InsertColumn (1, _T("No"), LVCFMT_CENTER, 80);<br />
	m_oList.InsertColumn (2, _T("Time"), <br />
		LVCFMT_CENTER, 120);<br />
<br />


After this code I am inserting new items.

Can any one suggest what may be the problem.

Thanks in Advance
Ravi
GeneralRe: Access Violation During adding items in List Control ( CXListCtrl ).... Pin
Rage18-Aug-05 0:13
professionalRage18-Aug-05 0:13 
GeneralCombobox control Pin
mikobi17-Aug-05 23:13
mikobi17-Aug-05 23:13 
GeneralRe: Combobox control Pin
toxcct17-Aug-05 23:21
toxcct17-Aug-05 23:21 
GeneralDLL spying Pin
Imtiaz Murtaza17-Aug-05 23:10
Imtiaz Murtaza17-Aug-05 23:10 
GeneralRe: DLL spying Pin
Cedric Moonen17-Aug-05 23:17
Cedric Moonen17-Aug-05 23:17 
GeneralRe: DLL spying Pin
Imtiaz Murtaza17-Aug-05 23:27
Imtiaz Murtaza17-Aug-05 23:27 
GeneralRe: DLL spying Pin
BlackDice18-Aug-05 3:06
BlackDice18-Aug-05 3:06 
GeneralRe: DLL spying Pin
Blake Miller18-Aug-05 4:51
Blake Miller18-Aug-05 4:51 
GeneralRe: DLL spying Pin
fat_boy19-Aug-05 4:12
fat_boy19-Aug-05 4:12 
GeneralRe: DLL spying Pin
fat_boy19-Aug-05 4:13
fat_boy19-Aug-05 4:13 
Generalunicode Pin
hamidreza_buddy17-Aug-05 23:03
hamidreza_buddy17-Aug-05 23:03 
GeneralRe: unicode Pin
toxcct17-Aug-05 23:10
toxcct17-Aug-05 23:10 
GeneralRe: unicode Pin
hamidreza_buddy17-Aug-05 23:45
hamidreza_buddy17-Aug-05 23:45 
GeneralRe: unicode Pin
toxcct17-Aug-05 23:57
toxcct17-Aug-05 23:57 
GeneralRe: unicode Pin
hamidreza_buddy18-Aug-05 5:15
hamidreza_buddy18-Aug-05 5:15 
GeneralRe: unicode Pin
try8818-Aug-05 6:53
try8818-Aug-05 6:53 
GeneralRe: unicode Pin
Jose Lamas Rios18-Aug-05 2:35
Jose Lamas Rios18-Aug-05 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.