创建父窗口的 DLL 插件无法正确处理消息
我正在创建一个插件框架,我的应用程序在其中加载一系列插件 DLL,然后创建一个新窗口并将此新窗口的句柄传递给插件。 然后,插件可以使用此句柄创建自己的 GUI。
一切似乎都进展顺利。 唯一的问题是,当我在插件小部件(例如编辑框)上按 TAB 时,它不会跳转到另一个小部件。 我发现有些 Windows 消息被传递了,而另一些则没有。 WM_KEYDOWN 被传递给其他键,因为我可以在编辑框中键入,但此消息不处理 TAB 键。
希望有人指点一下。
我使用 Borland VCL 和 CBuilder,但我认为我可以使用 WIN32 下的任何框架来创建这些插件,因为它们永远不知道它们的父窗口是如何创建的。
I'm creating a plugin framework, where my application loads a series of plugin DLL's, then creates a new window and pass this new window's handle to the plugin. The plugin can, then, use this handle to create their own GUI.
Everything seems to be working very well. The only problem is that when I press TAB on a plugin widget (An editbox, for example), it doen't jump to another widget. I figured out that some Windows messages are passed, and some others aren't. The WM_KEYDOWN is passed for other keys, because I can type on the editbox, but this message doesn't handle TAB key.
Hope somebody has a hint.
I'm using Borland VCL with CBuilder, but I think I could use any framework under WIN32 to create these plugins, since they never know how their parent windows were created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我相信您必须采取以下步骤:
确保处理编辑控件是多行的情况,因为您可能希望显示真正的制表符而不是移动到下一个控件。
希望有帮助!
I believe you'll have to take the following steps:
Make sure you handle the case where your edit controls are multiline, as you might want to have a real tab character appear instead of moving to the next control.
Hope that helps!
我相信您的每个 dll 和 exe 中都有不同的 VCL 实例。 dll 中的类与 exe 中的类不同,即使它们的调用方式相同。 此外,全局变量(应用程序、屏幕)在它们之间不共享。 内存也不是,因为它们都有自己的内存管理器。
解决方案是让 dll 和 exe 共享 VCL 库和内存管理器。 我不是 BCB 开发人员,而是 Delphi 开发人员。 在 Delphi 中,我们只使用 rtl 和 vcl 作为运行时包。 也许你可以做 BCB 等价的事情。
I believe you suffer from having a different instance of the VCL in each of your dlls and exes. Classes from the dll are not the same as the ones from your exe, even if they are called the same. Also global variables (Application, Screen) are not shared between them. Neither is the memory since they both have their own memory manager.
The solution is to have the dlls and the exe share the VCL library and the memory manager. I am not a BCB developer, but a Delphi developer. In Delphi we would just use the rtl and the vcl as runtime packages. Maybe you could do the BCB equivalent.
DLL 有其自己的 TApplication 对象。
提供统一的密钥处理。 当 DLL 加载时。
将 DLL::TApplication 分配给 EXE::TApplication
退出时请务必执行相反的操作。
——
迈克尔
A DLL has its own TApplication object.
to provide uniform key handling. when the DLL Loads.
assign the DLL::TApplication to the EXE::TApplication
Be sure to do the reverse on exit.
--
Michael
这确实是一个非常复杂的问题。
当您点击 TAB 时,仅当这些控件属于模态对话框时,焦点才会跳转到另一个控件。 事实上,有一些按钮,如 ESC、LEFT、RIGHT、DOWN、UP、TAB,模态对话框消息函数以特殊方式处理。 如果您希望这些键与非模式对话框或任何其他窗口以类似的方式运行,您应该更改消息处理函数并在内部使用 IsDialogMessage。 您将找到有关 IsDialogMessage 函数的更多信息在 MSDN 中,为了更好地理解这些内容,您也可以检查 对话框部分。
并且,正如之前提到的,您应该设置 WS_TABSTOP 和 WS_GROUP 样式(需要时)。
祝你好运!
It's very complex matter indeed.
When you hit TAB focus jumps to another control only when these controls belong to a Modal Dialog Box. In fact there are some buttons like ESC, LEFT, RIGHT, DOWN, UP, TAB which modal dialog message function treats in a special way. If you want these keys to behave in similar way with modeless dialog box or any other window you should change you message processing function and use IsDialogMessage inside. You'll find more information about IsDialogMessage function in MSDN also to better understand this stuff you may check as well Dialog Boxes section.
And, as was mentioned before, you should set WS_TABSTOP and WS_GROUP styles when needed.
Good luck!