?
Solved

Reusing forms as DLLs in non-Delphi applications

Posted on 1997-07-03
3
Medium Priority
?
304 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 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