开发者

ParentWindow in a DLL

开发者 https://www.devze.com 2022-12-22 03:48 出处:网络
I\'m trying to assign a ParentWindow, to a control created in a dll. The control is an editor, I need to process a text file, but this control requires a ParentWindow.

I'm trying to assign a ParentWindow, to a control created in a dll. The control is an editor, I need to process a text file, but this control requires a ParentWindow.

How can I solve this problem, if开发者_开发百科 I create this control in a dll?

I'm using Delphi 5.


also create the TForm (maybe not Visible) inside the dll then the control and add it to the form


This is a common question, and the correct answer is "Don't do that".

The first question I have is "why do you feel the need to create a control in a DLL?" Why not just create it in code or include the control itself in your EXE?

Second, if you want to add a control to a separate binary, but it in a Package. Packages are designed specifically to make exporting controls simple and easy.


You need to get the parent window from somewhere! Typically the host application that loads and calls the DLL would supply a window handle. It looks like your DLL provides a custom control for an application, so of course the application needs to supply a parent window handle.

Also, you typically need a window handle to the entire application as well, which you set as Application.Handle before you do anything else in your DLL.


ok, thaks for your answers, i already solved (a few minutes before first answer).

first, i need explain why i don't embed, and that is because costumer ask me that way.

the solution is send my form handle to my dll as an argument, after testing that way, i got no errors...

only modificate the prototype of my procedure, to recieve a HWND as an argument, to ParentWindow prop of my control (created in memory). that's all.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号