从C ++ DLL向MFC发布消息 [英] Posting message to MFC from a C++ DLL

查看:55
本文介绍了从C ++ DLL向MFC发布消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的应用程序具有在MFC中开发的GUI. Win32 DLL也在那里,它执行一些文件操作.每个文件操作的阶段,例如打开的文件,读取文件等,都必须在GUI中显示.


my application has a GUI developed in MFC. A Win32 DLL is also there, which does some file operations. The stage of each file operation, like, opened file, reading the file etc has to be displayed in the GUI.
How these messages can be posted from DLL to GUI for displaying, during the file operations?

推荐答案

例如,您可以将GUI窗口句柄传递给DLL函数,以便库可以存储它,然后使用它发布消息.
:)
For instance, you may pass the GUI window handle to a DLL function, so that the library may store it and then use it to post messages.
:)


链接步骤似乎缺少一个库:尝试在链接器选项中添加user32.lib,或在DLL源文件的某处添加以下行:

It seems a missing library on the linking step: try add user32.lib in the linker options, or add the following line somewhere in your DLL source files:

#pragma comment(lib, "user32.lib")


是.你是对的.现在我的问题解决了.成功链接.谢谢..
现在,在运行应用程序时出现了问题.我从MFC调用了一个dll函数来传递Windows句柄.参见下面的代码部分...


yes. u are right. now my that problem is solved. Successfully linked. Thanks..
Now the problem occurred while running the app. i called a dll function to pass the windows handle, from MFC. see the code part below...


 /* get handle to dll */ <br />
   HINSTANCE hGetProcIDDLL = AfxLoadLibrary(_T("Logic.dll")); <br />
<br />
   /* get pointer to the function  in the dll HERE AN EXCEPTION OCCURING*/ <br />
   FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"StartUpdate"); <br />
	<br />
   /* <br />
      Define the Function in the DLL for reuse. This is just prototyping the dll''s function. <br />
      A mock of it. Use "stdcall" for maximum compatibility. <br />
   */ <br />
   typedef void (__stdcall * pICFUNC)(HWND); <br />
   pICFUNC StartUpdate;  /* passes handle, function defined in DLL*/<br />
   StartUpdate= pICFUNC(lpfnGetProcessID); <br />
<br />
   /* The actual call to the function contained in the dll PASSING HANDLE*/ <br />
      StartUpdate(CMyAppDlg::GetSafeHwnd());<br />
<br />
   /* Release the Dll */ <br />
   FreeLibrary(hGetProcIDDLL); 



例外是什么? lpfnGetProcessID中包含0x0000000..



What can be ths exception? lpfnGetProcessID was having 0x0000000 in it..


这篇关于从C ++ DLL向MFC发布消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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