唉!不要乱用函数哦,特别是你不熟悉的!

来源:互联网 发布:gta4优化代码 编辑:程序博客网 时间:2024/05/09 10:02



                                      编程心得

                                                                                                            ------调试和错误

      今天找了错误找了半天!!起码三个小时!!!就因为下面这一行代码。导致我程序处处有错!!!!

      本来可以用   :m_IDGetitemText(Pos,0);这样的重载函数完成的,我非得用下面犯错的那个!!

      结果第四个参数搞不懂什么回事,就乱写了一个!谁知道出错了,这个m_ID变量是跟数据库关联的,这个字段的值长度已定为  16,但是我非得弄个20!!!!

      最后也是作死,各种错误!!!!!!

  m_Grid.GetItemText(Pos,0,(LPTSTR)(LPCTSTR)m_ID,20);//最后一个参数是说明 :缓冲区的长度指向   由第三个参数指向,但是因为
                                                       //数据库里面对字段域有限制,所以这里不匹配的话很容易出错的!!!找了大半天
                                                       //各种不知名的错误的源头就是它!!!!


CListCtrl::GetItemTextVisual Studio 2010



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;
Parameters

nItem

The index of the item whose text is to be retrieved.

nSubItem

Specifies the subitem whose text is to be retrieved.

lpszText

Pointer to a string that is to receive the item text.

nLen

Length of the buffer pointed to by lpszText.

Return Value

The version returning int returns the length of the retrieved string.

The version returning a CString returns the item text.

Remarks

If nSubItem is zero, this function retrieves the item label; ifnSubItem is nonzero, it retrieves the text of the subitem. For more information on the subitem argument, see the discussion of theLVITEM structure in the Windows SDK.

Requirements
0 0
原创粉丝点击