Ik wil graag een applicatie IN mijn eigen applicatie mergen, ik heb al behoor wat gegoogled en kwam dit tegen maar daarvoor moet je betalen... Weet iemand een oplossing of een richting hoe ik dit moet aanpakken?
Wat als je de form handle zet na je TPanel of waar het ook in moet? Werkt dat niet? Ik denk dat dan het venster van de app in je panel terecht komt, maar zeker weten doe ik het niet. Heb nu ook geen tijd om het uit te proberen
Zo deed ik het altijd bij mijn Opties dialogen losse forms voor alle "tab bladen"en vervolgens zette ik de parent van het venster na de TPanel... Zie ook mijn code van uhm vijf jaar terug:
Zo deed ik het altijd bij mijn Opties dialogen losse forms voor alle "tab bladen"en vervolgens zette ik de parent van het venster na de TPanel... Zie ook mijn code van uhm vijf jaar terug:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| First of all you need to make a new project, after you have made a new project you place the following controls on the form:
Component Class Company Name
TTreeView TreeView1
TPanel m_Panel
(You need to create some items in TTreeView, the count of items represents the total number of custom clients you created.)
After you have placed these component on the Main Form you should make some client forms that will be placed in m_Panel, then you will place these client forms on the m_Panel. We use one template client form ()this will make it able to show specific things on all the custom clients (TCustomClientForm) too...
In the main form you should use the following code:
1: public
2: { Public declarations }
3: ClientForm : TCustomClientForm;
4: ClientForms: array[0..2] of TCustomClientForm;
In the code above you should change 2 in line 4 with the value that represents the total account of clients forms. After you have the code above you should also link your forms to the array in line 4 from the code above. You can do that as follows in the FormCreate-Event
1: ClientForm := nil;
2: ClientForms[0] := TClientForm1.Create( Self );
3: ClientForms[1] := TClientForm2.Create( Self );
4: ClientForms[2] := TClientForm3.Create( Self );
After this we only need some code that will show the clients forms,
we are using a TTreeView for switching between the clients forms. The StateIndex of a TTreeNode represents the number in the array ClientForms, so when you want to show TClientForm1 you should set the value 0 in StateIndex because 0 represents TClientForm1 in the ClientForms-array (See code above).
After you have set the StateIndex you should add the following code to the OnClick-event of the TTreeView control:
1: If ( TreeView1.Selected <> nil )
2: and ( TreeView1.Selected.StateIndex > -1 ) Then
3: begin
4: { Show the dialog that represents the StateIndex }
5: If Assigned ( ClientForm ) Then ClientForm.Hide
6: { Which form must we show by which StateIndex? }
7: Case TreeView1.Selected.StateIndex of
8: 0: ClientForm := ClientForms[TreeView1.Selected.StateIndex];
9: 1: ClientForm := ClientForms[TreeView1.Selected.StateIndex];
10: 2: ClientForm := ClientForms[TreeView1.Selected.StateIndex];
11: end;
12: { Show the dialog, and set the focus to it! }
13: ClientForm.Show;
14: end;
You may have to add some more Case-checks when you have more ClientForms.
Hopefully you liked this How To Do, also we hope you learned something from it. If you don't want to type this all over you can download it at: How to place an TForm in an TPanel? |
[ Voor 87% gewijzigd door alienfruit op 13-11-2004 14:37 ]
Ik begrijp de code niet helemaal, nergens wordt eigenlijk de parent van de Handle of een panel geset
in die link van je kom ik dit tegen:Megamind schreef op zaterdag 13 november 2004 @ 14:30:
Ik wil graag een applicatie IN mijn eigen applicatie mergen, ik heb al behoor wat gegoogled en kwam dit tegen maar daarvoor moet je betalen... Weet iemand een oplossing of een richting hoe ik dit moet aanpakken?
Had je dat al geprobeert ofzow?Here is some code to launch mspaint and put it inside a delphi form, all you have to do is change the code and set the parent to the panel.
On the second form (the one you want the app to be inside)
1. Declare a global var -
var
PaintHandle : HWND;
2. OnShow of the second form put this code in.
procedure TForm2.FormShow(Sender: TObject);
var
waitFor : longint;
begin
WinExec('c:\winnt\System32\mspaint.exe', sw_hide);//launch it hidden
waitFor := GetTickCount;
PaintHandle := 0;
//give it time to open
while (PaintHandle = 0) or ((GetTickCount - waitFor) < 500) do
begin
//find the handle to the app...
PaintHandle := FindWindow('MSPaintApp',nil);
Application.ProcessMessages;
end;
if PaintHandle = 0 then
begin
showmessage('could not launch the app!');
Exit;
end;
Windows.SetParent(PaintHandle, handle); // Set that window's handle to our handle,
SetWindowPos(PaintHandle, 0, 0, 0, ClientWidth, ClientHeight, SWP_NOZORDER or SWP_SHOWWINDOW); //now show it...
end;
Then, from your first form, just call Form2.Show.
In the app I used it in I then had to run a routine to force the app I had launched to the front. I think it depends on the app youre launching. I also had to move the app up so that it's title bar was not visible on my form. If you need to do any of that I can send you the code.
Cheers