简体   繁体   English

LVCOLUMN.cchTextMax和LVITEM.cchTextMax的目的是什么?

[英]What is the purpose of LVCOLUMN.cchTextMax and LVITEM.cchTextMax?

I have tried to set the values of LVCOLUMN.cchTextMax and LVITEM.cchTextMax to a random value (less than the corresponding string length) and it worked, did it work by mistake or these fields are not necessary to set? 我尝试将LVCOLUMN.cchTextMaxLVITEM.cchTextMax的值设置为随机值(小于相应的字符串长度),并且可以正常工作,是否错误地工作了,或者没有必要设置这些字段?

I have also seen examples that do not use these fields, for example: http://www.codeproject.com/Articles/9148/C-functions-to-insert-columns-items-and-subitems-i 我也看到了不使用这些字段的示例,例如: http : //www.codeproject.com/Articles/9148/C-functions-to-insert-columns-items-and-subitems-i

The documentation for the LVITEM structure has the following to say on the cchTextMax member: LVITEM结构的文档在cchTextMax成员上有以下说法:

This member is only used when the structure receives item attributes. 仅当结构接收项目属性时才使用此成员。 It is ignored when the structure specifies item attributes. 当结构指定项目属性时,它将被忽略。 For example, cchTextMax is ignored during LVM_SETITEM and LVM_INSERTITEM . 例如,cchTextMax定义中被忽略LVM_SETITEMLVM_INSERTITEM It is read-only during LVN_GETDISPINFO and other LVN_ notifications. LVN_GETDISPINFO和其他LVN_通知期间,它是只读的。

Unless you are using this structure to retrieve item information, this member is ignored. 除非您使用此结构来检索项目信息,否则将忽略此成员。 When receiving data you have to pass a pointer to a buffer to pszText , and communicate its size through the cchTextMax member. 接收数据时,您必须将指针传递到pszText的缓冲区,并通过cchTextMax成员传递其大小。

This is a common pattern throughout the Windows API, where the same structure is used to set and query values. 这是整个Windows API的通用模式,其中使用相同的结构来设置和查询值。 The semantics of the individual members depend on the direction. 各个成员的语义取决于方向。 Other common structures, that are used in a similar fashion include TVITEM or MENUITEMINFO , for example. 以类似方式使用的其他常见结构包括例如TVITEMMENUITEMINFO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM