CListCtrl 中 cchTextMax 的问题,我现在最多只能写 259 个字符到 item 中,把cchTextMax的值赋得再大也没用

38062708 2005-11-02 04:13:04
如题,请各位试试看,解决了请告诉我

另问,怎样找到 CListCtrl 中函数的原形? 如 SetItem() 的函数原型?
...全文
543 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Zhymax 2005-11-04
  • 打赏
  • 举报
回复
char szTmp[300];
memset(szTmp, '1', 298);
szTmp[298]='a';
szTmp[299]='\0';

LVITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.pszText = szTmp;
ListView_InsertItem(m_hWnd, &lvi);
38062708 2005-11-04
  • 打赏
  • 举报
回复
laiyiling(陌生人 V3.0●猎分) :

我以前搜到过他的 BLOG ,他是读不出长字串,我现在是显示不出 259 长度以上的字串。
我需要看到 至少 300 长度的字串。

BOOL CListCtrl::SetItemText(int nItem, int nSubItem, LPCTSTR lpszText)
{
ASSERT(::IsWindow(m_hWnd));
ASSERT((GetStyle() & LVS_OWNERDATA)==0);
LVITEM lvi;
lvi.iSubItem = nSubItem;
lvi.pszText = (LPTSTR) lpszText;
return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMTEXT, nItem, (LPARAM)&lvi);
}

函数中无长度变量,惨!!

另外,他重载

CString CListCtrl::GetItemText(int nItem, int nSubItem) const

函数还不如用下一个函数

CString CListCtrl::GetItemText(int nItem, int nSubItem) const

直接就有长度的,呵呵
Kudeet 2005-11-04
  • 打赏
  • 举报
回复
http://blog.csdn.net/zhucde/archive/2004/11/11/177690.aspx
38062708 2005-11-04
  • 打赏
  • 举报
回复
我再顶一个
38062708 2005-11-03
  • 打赏
  • 举报
回复
请帮我测试看 LISTCTRL 的每个 ITEM 中能够写入的最大的 TEXT 的大小
力为 2005-11-02
  • 打赏
  • 举报
回复
imp2:

_AFXCMN_INLINE BOOL CListCtrl::EnsureVisible(int nItem, BOOL bPartialOK)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0)); }
_AFXCMN_INLINE BOOL CListCtrl::Scroll(CSize size)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SCROLL, size.cx, size.cy); }
_AFXCMN_INLINE BOOL CListCtrl::RedrawItems(int nFirst, int nLast)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_REDRAWITEMS, nFirst, nLast); }
_AFXCMN_INLINE BOOL CListCtrl::Arrange(UINT nCode)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_ARRANGE, nCode, 0L); }
_AFXCMN_INLINE CEdit* CListCtrl::EditLabel(int nItem)
{ ASSERT(::IsWindow(m_hWnd)); return (CEdit*)CWnd::FromHandle( (HWND)::SendMessage(m_hWnd, LVM_EDITLABEL, nItem, 0L)); }
_AFXCMN_INLINE CEdit* CListCtrl::GetEditControl() const
{ ASSERT(::IsWindow(m_hWnd)); return (CEdit*)CWnd::FromHandle( (HWND)::SendMessage(m_hWnd, LVM_GETEDITCONTROL, 0, 0L)); }
_AFXCMN_INLINE BOOL CListCtrl::GetColumn(int nCol, LVCOLUMN* pColumn) const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn); }
_AFXCMN_INLINE BOOL CListCtrl::SetColumn(int nCol, const LVCOLUMN* pColumn)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn); }
_AFXCMN_INLINE int CListCtrl::InsertColumn(int nCol, const LVCOLUMN* pColumn)
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); }
_AFXCMN_INLINE BOOL CListCtrl::DeleteColumn(int nCol)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0); }
_AFXCMN_INLINE int CListCtrl::GetColumnWidth(int nCol) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0); }
_AFXCMN_INLINE BOOL CListCtrl::SetColumnWidth(int nCol, int cx)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0)); }
_AFXCMN_INLINE BOOL CListCtrl::GetViewRect(LPRECT lpRect) const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect); }
_AFXCMN_INLINE COLORREF CListCtrl::GetTextColor() const
{ ASSERT(::IsWindow(m_hWnd)); return (COLORREF) ::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0, 0L); }
_AFXCMN_INLINE BOOL CListCtrl::SetTextColor(COLORREF cr)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr); }
_AFXCMN_INLINE COLORREF CListCtrl::GetTextBkColor() const
{ ASSERT(::IsWindow(m_hWnd)); return (COLORREF) ::SendMessage(m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L); }
_AFXCMN_INLINE BOOL CListCtrl::SetTextBkColor(COLORREF cr)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr); }
_AFXCMN_INLINE int CListCtrl::GetTopIndex() const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETTOPINDEX, 0, 0); }
_AFXCMN_INLINE int CListCtrl::GetCountPerPage() const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0); }
_AFXCMN_INLINE BOOL CListCtrl::GetOrigin(LPPOINT lpPoint) const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint); }
_AFXCMN_INLINE BOOL CListCtrl::Update(int nItem)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_UPDATE, nItem, 0L); }
_AFXCMN_INLINE BOOL CListCtrl::SetItemState(int nItem, LVITEM* pItem)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem); }
_AFXCMN_INLINE UINT CListCtrl::GetItemState(int nItem, UINT nMask) const
{ ASSERT(::IsWindow(m_hWnd)); return (UINT) ::SendMessage(m_hWnd, LVM_GETITEMSTATE, nItem, nMask); }
_AFXCMN_INLINE void CListCtrl::SetItemCount(int nItems)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, 0); }
_AFXCMN_INLINE BOOL CListCtrl::SortItems(PFNLVCOMPARE pfnCompare, DWORD dwData)
{ ASSERT(::IsWindow(m_hWnd)); ASSERT((GetStyle() & LVS_OWNERDATA)==0); return (BOOL) ::SendMessage(m_hWnd, LVM_SORTITEMS, dwData, (LPARAM)pfnCompare); }
_AFXCMN_INLINE UINT CListCtrl::GetSelectedCount() const
{ ASSERT(::IsWindow(m_hWnd)); return (UINT) ::SendMessage(m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L); }
力为 2005-11-02
  • 打赏
  • 举报
回复
imp 1:

_AFXCMN_INLINE CListCtrl::CListCtrl()
{ }
_AFXCMN_INLINE COLORREF CListCtrl::GetBkColor() const
{ ASSERT(::IsWindow(m_hWnd)); return (COLORREF) ::SendMessage(m_hWnd, LVM_GETBKCOLOR, 0, 0L); }
_AFXCMN_INLINE BOOL CListCtrl::SetBkColor(COLORREF cr)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETBKCOLOR, 0, cr); }
_AFXCMN_INLINE CImageList* CListCtrl::GetImageList(int nImageListType) const
{ ASSERT(::IsWindow(m_hWnd)); return CImageList::FromHandle((HIMAGELIST) ::SendMessage(m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L)); }
_AFXCMN_INLINE CImageList* CListCtrl::SetImageList(CImageList* pImageList, int nImageList)
{ ASSERT(::IsWindow(m_hWnd)); return CImageList::FromHandle((HIMAGELIST) ::SendMessage(m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)pImageList->GetSafeHandle())); }
_AFXCMN_INLINE int CListCtrl::GetItemCount() const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L); }
_AFXCMN_INLINE BOOL CListCtrl::GetItem(LVITEM* pItem) const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); }
_AFXCMN_INLINE BOOL CListCtrl::SetItem(const LVITEM* pItem)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); }
_AFXCMN_INLINE BOOL CListCtrl::SetItemData(int nItem, DWORD dwData)
{ ASSERT(::IsWindow(m_hWnd)); return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData); }
_AFXCMN_INLINE int CListCtrl::InsertItem(const LVITEM* pItem)
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem); }
_AFXCMN_INLINE int CListCtrl::InsertItem(int nItem, LPCTSTR lpszItem)
{ ASSERT(::IsWindow(m_hWnd)); return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); }
_AFXCMN_INLINE int CListCtrl::InsertItem(int nItem, LPCTSTR lpszItem, int nImage)
{ ASSERT(::IsWindow(m_hWnd)); return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0); }
_AFXCMN_INLINE BOOL CListCtrl::DeleteItem(int nItem)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_DELETEITEM, nItem, 0L); }
_AFXCMN_INLINE BOOL CListCtrl::DeleteAllItems()
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L); }
_AFXCMN_INLINE UINT CListCtrl::GetCallbackMask() const
{ ASSERT(::IsWindow(m_hWnd)); return (UINT) ::SendMessage(m_hWnd, LVM_GETCALLBACKMASK, 0, 0); }
_AFXCMN_INLINE BOOL CListCtrl::SetCallbackMask(UINT nMask)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETCALLBACKMASK, nMask, 0); }
_AFXCMN_INLINE int CListCtrl::GetNextItem(int nItem, int nFlags) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0)); }
_AFXCMN_INLINE POSITION CListCtrl::GetFirstSelectedItemPosition() const
{ ASSERT(::IsWindow(m_hWnd)); return (POSITION) (1+GetNextItem(-1, LVIS_SELECTED)); }
_AFXCMN_INLINE int CListCtrl::GetNextSelectedItem(POSITION& pos) const
{ ASSERT(::IsWindow(m_hWnd)); int nOldPos = (int)pos-1; pos = (POSITION) (1+GetNextItem(nOldPos, LVIS_SELECTED)); return nOldPos; }
_AFXCMN_INLINE int CListCtrl::FindItem(LVFINDINFO* pFindInfo, int nStart) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo); }
_AFXCMN_INLINE int CListCtrl::HitTest(LVHITTESTINFO* pHitTestInfo) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo); }
_AFXCMN_INLINE BOOL CListCtrl::SetItemPosition(int nItem, POINT pt)
{ ASSERT(::IsWindow(m_hWnd)); ASSERT((GetStyle() & LVS_OWNERDATA)==0); return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt); }
_AFXCMN_INLINE BOOL CListCtrl::GetItemPosition(int nItem, LPPOINT lpPoint) const
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint); }
_AFXCMN_INLINE int CListCtrl::GetStringWidth(LPCTSTR lpsz) const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz); }
力为 2005-11-02
  • 打赏
  • 举报
回复
define:

/////////////////////////////////////////////////////////////////////////////
// CListCtrl

class CListCtrl : public CWnd
{
DECLARE_DYNAMIC(CListCtrl)

// Constructors
public:
CListCtrl();
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

// Attributes
COLORREF GetBkColor() const;
BOOL SetBkColor(COLORREF cr);
CImageList* GetImageList(int nImageList) const;
CImageList* SetImageList(CImageList* pImageList, int nImageListType);
int GetItemCount() const;
BOOL GetItem(LVITEM* pItem) const;
BOOL SetItem(const LVITEM* pItem);
BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
int nImage, UINT nState, UINT nStateMask, LPARAM lParam);
UINT GetCallbackMask() const;
BOOL SetCallbackMask(UINT nMask);
int GetNextItem(int nItem, int nFlags) const;
POSITION GetFirstSelectedItemPosition() const;
int GetNextSelectedItem(POSITION& pos) const;
BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const;
BOOL SetItemPosition(int nItem, POINT pt);
BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const;
int GetStringWidth(LPCTSTR lpsz) const;
CEdit* GetEditControl() const;
BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const;
BOOL SetColumn(int nCol, const LVCOLUMN* pColumn);
int GetColumnWidth(int nCol) const;
BOOL SetColumnWidth(int nCol, int cx);
BOOL GetViewRect(LPRECT lpRect) const;
COLORREF GetTextColor() const;
BOOL SetTextColor(COLORREF cr);
COLORREF GetTextBkColor() const;
BOOL SetTextBkColor(COLORREF cr);
int GetTopIndex() const;
int GetCountPerPage() const;
BOOL GetOrigin(LPPOINT lpPoint) const;
BOOL SetItemState(int nItem, LVITEM* pItem);
BOOL SetItemState(int nItem, UINT nState, UINT nMask);
UINT GetItemState(int nItem, UINT nMask) const;
CString GetItemText(int nItem, int nSubItem) const;
int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const;
BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText);
void SetItemCount(int nItems);
BOOL SetItemData(int nItem, DWORD dwData);
DWORD GetItemData(int nItem) const;
UINT GetSelectedCount() const;
BOOL SetColumnOrderArray(int iCount, LPINT piArray);
BOOL GetColumnOrderArray(LPINT piArray, int iCount = -1);
CSize SetIconSpacing(CSize size);
CSize SetIconSpacing(int cx, int cy);
CHeaderCtrl* GetHeaderCtrl();
HCURSOR GetHotCursor();
HCURSOR SetHotCursor(HCURSOR hc);
BOOL GetSubItemRect(int iItem, int iSubItem, int nArea, CRect& ref);
int GetHotItem();
int SetHotItem(int iIndex);
int GetSelectionMark();
int SetSelectionMark(int iIndex);
DWORD GetExtendedStyle();
DWORD SetExtendedStyle(DWORD dwNewStyle);
int SubItemHitTest(LPLVHITTESTINFO pInfo);
void SetWorkAreas(int nWorkAreas, LPRECT lpRect);
BOOL SetItemCountEx(int iCount, DWORD dwFlags = LVSICF_NOINVALIDATEALL);
CSize ApproximateViewRect(CSize sz = CSize(-1, -1), int iCount = -1) const;
BOOL GetBkImage(LVBKIMAGE* plvbkImage) const;
DWORD GetHoverTime() const;
void GetWorkAreas(int nWorkAreas, LPRECT prc) const;
BOOL SetBkImage(HBITMAP hbm, BOOL fTile = TRUE, int xOffsetPercent = 0, int yOffsetPercent = 0);
BOOL SetBkImage(LPTSTR pszUrl, BOOL fTile = TRUE, int xOffsetPercent = 0, int yOffsetPercent = 0);
BOOL SetBkImage(LVBKIMAGE* plvbkImage);
DWORD SetHoverTime(DWORD dwHoverTime = (DWORD)-1);
UINT GetNumberOfWorkAreas() const;
BOOL GetCheck(int nItem) const;
BOOL SetCheck(int nItem, BOOL fCheck = TRUE);

// Operations
int InsertItem(const LVITEM* pItem);
int InsertItem(int nItem, LPCTSTR lpszItem);
int InsertItem(int nItem, LPCTSTR lpszItem, int nImage);
BOOL DeleteItem(int nItem);
BOOL DeleteAllItems();
int FindItem(LVFINDINFO* pFindInfo, int nStart = -1) const;
int HitTest(LVHITTESTINFO* pHitTestInfo) const;
int HitTest(CPoint pt, UINT* pFlags = NULL) const;
BOOL EnsureVisible(int nItem, BOOL bPartialOK);
BOOL Scroll(CSize size);
BOOL RedrawItems(int nFirst, int nLast);
BOOL Arrange(UINT nCode);
CEdit* EditLabel(int nItem);
int InsertColumn(int nCol, const LVCOLUMN* pColumn);
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading,
int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1);
BOOL DeleteColumn(int nCol);
CImageList* CreateDragImage(int nItem, LPPOINT lpPoint);
BOOL Update(int nItem);
BOOL SortItems(PFNLVCOMPARE pfnCompare, DWORD dwData);

// Overridables
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);

// Implementation
public:
int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState,
UINT nStateMask, int nImage, LPARAM lParam);
virtual ~CListCtrl();
protected:
void RemoveImageList(int nImageList);
virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
protected:
//{{AFX_MSG(CListCtrl)
afx_msg void OnNcDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧