Solved

showing a dll form in a panel in main app

Posted on 2004-03-22
11
937 Views
Last Modified: 2011-04-14
My form A will call another TCustomForm from a DLL and place it on a panel in the main program.
But when I do this my dbgrids don't behave like they should. I can't navigate with my up_key and down_key.

I know that if rewrite the code and shows the tcustomform in the dll as showmodal the dbgrids behave perfect.
How can I do this when the form is hooked to the panel in the mainform too?

In Main (where I call the form):

ShowDllIRForm(MainForm.Handle).ParentWindow := MainPanel.Handle;
ShowDllIRForm(MainForm.Handle).Show;


In DLL (returns the form):

function ShowDllIRForm(hApp: THandle): TCustomForm; stdcall;
begin
 Application.Handle := hApp;
  if not assigned(IRForm) then
    IRForm := TIRForm.Create(Application);
  result := IRForm;
end;
0
Comment
Question by:Darth_helge
  • 2
  • 2
  • 2
  • +4
11 Comments
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 100 total points
ID: 10648425
is your dllForm borderless??
0
 
LVL 5

Author Comment

by:Darth_helge
ID: 10648463
yes
0
 
LVL 5

Accepted Solution

by:
delphized earned 100 total points
ID: 10649571
I tried a similar way to do things, but I had a lot of strange problems. So I decided that you can't do things that are not supposed to be done with Delphi. I think this is due to Borland attitude towards the encapsulation of windows functions, that sometime is done in a odd and stupid way (see printer.pas for reference).

anyway goodluck ;-P
0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 100 total points
ID: 10655676
Hi,

If it's suitable to you I would suggest using packages instead of dlls.

http://community.borland.com/article/0,1410,27178,00.html

Regards, Geo
0
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 100 total points
ID: 10663403
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Assisted Solution

by:michaenh
michaenh earned 100 total points
ID: 10666736
Hi

How to support the keyboard for forms that are stored in a DLL and are docked on a control of the application? It seem that it can not get focus on any components or use the Tab, Arrow key in the dll form that have been docked or used as show instead of showmodal?

One could use pakages or frames instead of dll(as GEO mention.. ).
ex. frames:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20431534.html

I am also interested if anyone have any solution to the dll's problem in delphi.
kretzschmar, GEO.. :)

cheers,
mha
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10666788
well,

i myelf didn't done a form in a dll,
therefore i can't point directly to thats it.

i know there are problems to embed bordered forms,
thats why i asked, if it is a borderless form.

as it is a borderless form, i'm out of ideas

will do a bit recherche

meikl ;-)
0
 
LVL 5

Author Comment

by:Darth_helge
ID: 10667009
the borderstyle is bsnone and the formstyle is fsnormal
0
 
LVL 1

Expert Comment

by:Extase
ID: 11282039
the use of SetParent API could solve the focus & keys problems,
SetParent(DLLForm.Handle, MainPanel.Handle);

0
 

Expert Comment

by:michaenh
ID: 11293598
Hi I believe I have tried setparent...

Could you show a small example of the code.. ?
Have you tried it?

cheers,
mha
0
 
LVL 1

Expert Comment

by:Extase
ID: 11295839
here's some snippets from a project i'm working on

IProjectMgr = interface
  ['{B5427304-4D62-478A-99DF-3228F2185038}']
   function CreatePluginForm(const PluginClass:TPluginFormClass;const AOwner:TComponent;
                                             const AParent:TWinControl;const Sender:TObject):TPluginForm;
end;

IProjectMgr is implemented in TProjectMgrForm as follows:

function TProjectMgrForm.CreatePluginForm(const PluginClass:TPluginFormClass;const AOwner:TComponent;
                                             const AParent:TWinControl;const Sender:TObject):TPluginForm;
begin
  Result:=PluginClass.Create(AOwner) as TPluginForm;
  with Result do
  begin
     BorderStyle:=bsNone;//can be set at design time
     Windows.SetParent(Handle, AParent.Handle);
     Align:=alClient;
     Show;
  end;//with
end;

the Application(Host Application) is passed to the plugin DLL in the exported register procedure, so the plugin can get the interface IProjectMgr and calls CreatePluginForm passing to the Host App the PluginClass,and the creation of the pluginform is handled in the host application.

//still have only one problem ,. the align property of child controls in the plugin form, does'nt work correctly.
//everything else is OK
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 264
Machine not responding during CopyFile() 3 89
add combobox item based on numbers 9 125
Delphi inherited method 6 63
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…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now