Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Reusing forms as DLLs in non-Delphi applications

Posted on 1997-07-03
3
301 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
ID: 1338106
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
ID: 1338107
Sorry, I have maken a mistake. Substitute the line
   
(Self as TWinControl).CreateParams(Params);

with this:

inherited CreateParams(Params);
0
 

Author Comment

by:jt070397
ID: 1338108
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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