Solved

showing a dll form in a panel in main app

Posted on 2004-03-22
11
927 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

10 Experts available now in Live!

Get 1:1 Help Now