如何将消息处理程序添加到 wndproc [英] How to add a message handler to a wndproc
问题描述
我有一个可以启动线程的 acrobat 插件.从那个线程我不知何故需要回到 UI 线程.我确实有 HWND,但是如果我执行 PostMessage
,我如何让主机应用程序的 WNDPROC 将呼叫银行排序到我拥有的处理程序中.我想我的问题是,无论如何在概念上做一些像
I have an acrobat plugin which spins up a thread. From that thread I somehow need to get back onto the UI thread. I do have the HWND but if I do a PostMessage
how do I get the host application's WNDPROC to sort of call bank into an handler I own. I guess my question is, is there anyway to conceptually do something like
RegisterWndMsgHandler( HWND, MSG, CALLBACK );
推荐答案
您可以通过 SetWindowLongPtr(GWL_WNDPROC)
用您自己的消息处理程序替换 HWND
的子类.确保调用 GetWindowLongPtr(GWL_WNDPROC)
以检索原始处理程序,然后让您的处理程序将任何未处理的消息传递给 CallWindowProc()
,以便原始处理程序可以处理它们.
You can subclass the HWND
by replacing its message handler with your own via SetWindowLongPtr(GWL_WNDPROC)
. By sure to call GetWindowLongPtr(GWL_WNDPROC)
to retreive the original handler, and then have your handler pass any unhandled messages to CallWindowProc()
so the original handler can process them.
这篇关于如何将消息处理程序添加到 wndproc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!