Solved

Reusing forms as DLLs in non-Delphi applications

Posted on 1997-07-03
3
298 Views
Last Modified: 2010-04-06
am trying to write a Delph-1-DLL with forms which should be opend by a
non-Delphi application as child windows of its client area.

So, I suppose, the

     constructor create(AOwner: TComponent) and the
     procedure CreateParams(var Params: TCreateParams)

of the derived class "TMyForm", have to perform the assignment of the non-Delphi
window to MyForm.Parent and MyForm.Owner. If "Hwnd" is the handle of the non-Delphi
window, the exported DLL procedure has the following form:

Procedure OpenMyForm (Hwnd: handle);
       .
      .
begin
      .
      .
  AOwner  := MakeOwnver (Hwnd);
  MyForm := TMyForm.Create (AOwner);
      .
      .
 
But how can I create a variable of type TComponent, if I only know the handle of this non-Delphi window, that means, how works "MakeOwnver".

If this concept isn't right, please, explain the correct method.

Thanks.
0
Comment
Question by:jt070397
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
fsanchez earned 150 total points
Comment Utility
Try this:

  TMyForm = class(TForm)
  ...
  public
    constructor Create(H: HWnd);
  protected
    HandleParent: HWnd;

    procedure CreateParams(var Params: TCreateParams); override;
  end;


.......

constructor TMyForm.Create(H: HWnd);
begin
  HandleParent := H;
  inherited Create(nil);
end;

procedure TMyForm.CreateParams(var Params: TCreateParams);
begin
  (Self as TWinControl).CreateParams(Params);
  with Params do
  begin
    { You probably will need to play with different Flags here, for example, to hide the border: Style := Style and not WS_BORDER; }
    Style := Style or WS_CHILD;
    WndParent := HandleParent;
  end;
end;

0
 
LVL 1

Expert Comment

by:fsanchez
Comment Utility
Sorry, I have maken a mistake. Substitute the line
   
(Self as TWinControl).CreateParams(Params);

with this:

inherited CreateParams(Params);
0
 

Author Comment

by:jt070397
Comment Utility
MyForm does not become a real child window of the Parent window HWnd.

Painting works correct, it is minimized if its parent is minimized, it receives the messages create, activate and deactivate, but it will not be distroyed if the parent window is
closed.

if borderstyle is none and
Params.Style := Params.Style
                or WS_CHILD OR WS_CLIPSIBLINGS
                or WS_CLIPCHILDREN
the position is at 0,0 of the desktop, even if the parent is moved.

if borderstyle is none and
Params.Style := WS_CHILD OR WS_CLIPSIBLINGS
                or WS_CLIPCHILDREN
the position is elsewhere within the parent window, but not at
defined (left,top).

Only if borderstyle is bsSizeable the position of MyForm is (left,top) relative to the parent.

Please, give more hints!

jt

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now