Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to display the window of another application in a Delphi form Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
104
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I would like to have an application (f.e. notepad.exe) to run in a specified frame 
(TPanel,..) within my application.

Answer:

It does not work well but you can try this:

1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7     ComCtrls, StdCtrls, Menus, AppEvnts;
8   
9   type
10    TForm1 = class(TForm)
11      ApplicationEvents1: TApplicationEvents;
12      procedure FormCreate(Sender: TObject);
13      procedure ApplicationEvents1Activate(Sender: TObject);
14    private
15      { Private declarations }
16      FNotepad: HWND;
17    public
18      { Public declarations }
19    end;
20  
21  var
22    Form1: TForm1;
23  
24  implementation
25  
26  {$R *.DFM}
27  
28  procedure TForm1.FormCreate(Sender: TObject);
29  var
30    wnd: HWND;
31    tries: Integer;
32  begin
33    WinExec('notepad.exe', SW_HIDE);
34    tries := 0;
35    repeat
36      wnd := Findwindow('notepad', nil);
37      if wnd = 0 then
38      begin
39        inc(tries);
40        sleep(100);
41      end;
42    until
43      (wnd <> 0) or (tries > 10);
44    if wnd <> 0 then
45    begin
46      windows.setparent(wnd, handle);
47      application.title := 'Notepad';
48      MoveWindow(wnd, 0, 0, clientwidth, clientheight, false);
49      ShowWindow(wnd, SW_SHOW);
50      SetForegroundWindow(wnd);
51      FNotepad := wnd;
52    end
53    else
54      showmessage('Failed');
55  end;
56  
57  procedure TForm1.ApplicationEvents1Activate(Sender: TObject);
58  begin
59    if IsWindow(FNotepad) then
60      SetForegroundWindow(FNotepad)
61    else
62      Close;
63  end;
64  
65  end.


To wire the notepad window to a panel you would simlpy use the panels handle in the SetParent call.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC