CtrlList 通过消息后处理通知插入项目

发布于 2024-12-12 12:25:19 字数 495 浏览 10 评论 0原文

所以这是我的问题,我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪是无色的血 2024-12-19 12:25:19

将自定义消息发布到其他窗口,并在其处理程序中添加该项目,然后释放内存。

如果列表控件已经子类化,则不需要其他窗口,消息可以直接发送到控件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文