如何在dll中创建一个隐藏窗口,以处理主线程中的消息 [英] How to make a hidden window in a dll, that process messages in the main thread

查看:480
本文介绍了如何在dll中创建一个隐藏窗口,以处理主线程中的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试将dll从MFC迁移到纯Win32时遇到问题,我被卡在创建窗口的部分中,我可以创建窗口,但是我需要WndProc方法来在主线程中被调用,因为app(firefox)拒绝从线程对其方法的调用.


在MFC端使用隐藏窗口,但尝试将其迁移到win32是我不了解它是如何工作的,我试图创建一个方法并将CreateWindow代码放在那里,并结束消息循环,但它停止了在那里,我需要它退出该方法,使用它我可以向firefox发送消息并可以正常工作,因为WndProc在主线程中.

我已经尝试过在另一个线程中创建窗口,但是firefox拒绝了对其方法的调用,因为它不是主线程.


MFC如何做到这一点? :(

谢谢

Hi, i am having a problem trying to migrate a dll from MFC to plain Win32, i am stuck in a part that creates a window, i can create the window but i need WndProc method to be called in the mainthread because the app(firefox) denies calls to its methods from a thread.


In MFC side worked with the hidden window, but trying to migrate it to win32 is where i don''t understand how did it worked, i tried to create a method and put the CreateWindow code there and the end the message loop but it stops there and i need it to exit that method, using that i can send messages to firefox and works because WndProc is in the main thread.

I have already tried creating the window in another thread but then firefox denies calls to its methods because is not the main thread.


How does MFC does this? :(

Thanks

推荐答案

如果您确实需要一个窗口,请创建没有 WS_VISIBLE 窗口样式的窗口.

但是,如果只是一个函数,则创建一个DLL文件并导出该函数,
If you really need a window then create the window without WS_VISIBLE window style.

But if it is just a function then create a DLL file and export that function,


这篇关于如何在dll中创建一个隐藏窗口,以处理主线程中的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆