Hi ppl. I'm trying to which seems impossible... Let me tell the history
behind it. Please be patient.
I'm working on a big project. We want to modularize our code, breaking up
the main system in many medium sized DLL's. We have many reasons to do it,
some technical, some commercial.
We know the that our approach involves some tradeoffs. In particular, the
DLL will contain duplicates of the VCL which will make our system a bit :-)
larger.
Our problem: put some forms in a DLL. We can do it right now, but the result
are some floating forms that we found to be confusing for our customers. We
want to have only one window visible. This seems to lead to an MDI interface.
However, we felt that the MDI interface can be confusing too. Even Microsoft
acknowledges it and is dropping MDI support.
We did some research over the Delphi docs, Windows docs, Internet newsgroups
and Delphi WWW pages. We found that some people before us had the same problem.
The reasons are similar. However, most people chose to follow the MDI approach.
Even if wanted to do it, we can't put an MDI child on a DLL for technical
reasons - you cant do it in Delphi without rewriting some of the VCL code.
However, we can't be defeated that easy. We found that we could open another
form inside the main form. Turn off the border and the main title, and to the
user it seems like a single form. OLE2 inplace editing works this way.
We decided to try to use OLE. It seems simple: write an OLE automation server.
Activate it inside an OLE container, and here is you form inside another form.
But we need to implement a lot of interfaces to do it, and the resulting code
is big and slow.
Then we decided to hack it anyway. We put a simple form with many components
inside another form, using a simple hack. Look at the pseudo code below:
{ MainForm has a panel component called Panel1 }
procedure MainForm.CreateFormInsidePanel;
var Form1 : TForm;
begin
Form1 := TOurForm.Create(MainForm);
Form1.Parent := Self.Panel1;
end;
This way Form1 becomes clipped inside the Panel1 component. The resulting
window has a strange behavior. Everything seems to be fine, but some
components - notably the edit control - cant be selected with the mouse. This
seems to be related to some problem with the message handler of MainForm.
The test seemed promising, but the lack of documentation makes things harder.
We are looking now for alternatives. We have some to enumerate:
- Implement the external forms in DLL's, and open them inside the Panel.
Look at the code of the message dispatcher and hack it until it works.
- Implement the external forms in components, convert these components
in OCX. Use the resulting OCX inside an OLE container. To do it we need
some info about writing an OCX.
- Create the components at runtime inside the panel, Use the definition of
the form that is stored in the DLL. It's simply a matter of loading the
right resources. The tricky part is to associate the event handlers
inside the DLL with the new components create inside the main form.
We are inviting any Delphi programmer to join us to solve this problem. We
think this can be a big step toward the deliverance of modular Delphi apps,
much like you can do today with Power Builder or C++.
Thanks in advance. You can reply to the group or directly to me via email.
Carlos Ribeiro
cribe...@acesso.com.br