Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reusing forms as DLLs in non-Delphi applications

Posted on 1997-07-03
3
Medium Priority
?
306 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
[X]
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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
fsanchez earned 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 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