CtrlList 通过消息后处理通知插入项目
所以这是我的问题,我有一个 CtrlList
,我想通过 PostMessage
(异步)插入项目,因此消息 LVM_INSERT_MESSAGE
正在轮到他时进行处理,但问题是我需要为 LVITEM 分配内存,这样我在插入项目之前就不会丢失它。但是在退出函数后我失去了指向已分配项目的指针。由于插入项会创建另一个项,因此我发现很难释放为 LVITEM 分配的内存。
我的解决方案是因为 LVM_INSERT_MESSAGE
发送 LVN_INSERT_MESSAGE
通知,在该通知上调用函数,但获取 lvitem 的唯一方法是抛出 lparam,但 on_notify 有 (NMHDR *pNMHDR,LRESULT *pResult
)参数。你能给我一个释放该内存的解决方案吗?我必须用 postmessage 插入它,不要告诉我使用 send message 或函数 insertitem 。谢谢。
So here is my problem, i have a CtrlList
, and I want to insert items via PostMessage
(asyncron) therefore the message LVM_INSERT_MESSAGE
, is going to be processed when it is his turn, but the problem is i need to allocate memory for LVITEM
, so that i don't loose it before i insert the item. But after i loose the pointer to the allocated item after exiting the function. And since insert item creates another item, i find it hard to deallocate the memory i allocate for LVITEM
.
My solution was since LVM_INSERT_MESSAGE
sends LVN_INSERT_MESSAGE
notification, on that notification to call a function, but the only way to get the lvitem is throw an lparam, but on_notify has (NMHDR *pNMHDR, LRESULT *pResult
) parameters. Can you give me a solution for deallocating that memory, i must insert it with postmessage, don't tell me to use send message or the function insertitem . Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将自定义消息发布到其他窗口,并在其处理程序中添加该项目,然后释放内存。
如果列表控件已经子类化,则不需要其他窗口,消息可以直接发送到控件。
Post a custom message to some other window, and in its handler add the item then free memory.
If the list control is already subclassed, there is no need for other window and the message can be sent directly to the control.