编程心得
------调试和错误
今天找了错误找了半天!!起码三个小时!!!就因为下面这一行代码。导致我程序处处有错!!!!
本来可以用 :m_IDGetitemText(Pos,0);这样的重载函数完成的,我非得用下面犯错的那个!!
结果第四个参数搞不懂什么回事,就乱写了一个!谁知道出错了,这个m_ID变量是跟数据库关联的,这个字段的值长度已定为 16,但是我非得弄个20!!!!
最后也是作死,各种错误!!!!!!
m_Grid.GetItemText(Pos,0,(LPTSTR)(LPCTSTR)m_ID,20);//最后一个参数是说明 :缓冲区的长度指向 由第三个参数指向,但是因为
//数据库里面对字段域有限制,所以这里不匹配的话很容易出错的!!!找了大半天
//各种不知名的错误的源头就是它!!!!
CListCtrl::GetItemText |
Retrieves the text of a list view item or subitem.
int GetItemText( int nItem, int nSubItem, LPTSTR lpszText, int nLen ) const; CString GetItemText( int nItem, int nSubItem ) const;
int GetItemText( int nItem, int nSubItem, LPTSTR lpszText, int nLen ) const; CString GetItemText( int nItem, int nSubItem ) const;
The version returning int returns the length of the retrieved string.
The version returning a CString returns the item text.
If nSubItem is zero, this function retrieves the item label; if nSubItem is nonzero, it retrieves the text of the subitem. For more information on the subitem argument, see the discussion of the LVITEM structure in the Windows SDK.