Posted on 2004-09-10
Last Modified: 2010-04-04
I am loading MDI from DLL, but Tab Key not working for control.

Why & What is solution.
Question by:smartvanl5
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
LVL 13

Expert Comment

ID: 12028126
I have seen this question answered a lot throughout the years... and I haven't seen an answer, neither have I tried (never needed)... the closest thing to an answer (from several TeamB members) I have seen is this:

"Dll's have their own copies of the Application object and other VCL global
objects.  If you instead switched to packages this would all go away.  That is a
main reason packages were developed in the first place.  Build both your app and
the package with packages and you won't have these problems."

what version of Delphi are you using? this problem arised when switching from Delphi 4 to 5, I don't know if it still exists in 7...
LVL 13

Expert Comment

ID: 12028371
I meant "I have seen this question asked..."
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12028467
I've had to deal with this problem too and never found a solution. You have a similar problem when you're adding ActiveForms to your application. AFAIK, this seems to be a flaw in the way Delphi applications have been designed and it's probably never going to be solved. My solution was a nasty hack, though. Just add one more control to your MDI form. Make it as small as possible and whenever it gets focus, send an event to the owner of the form to focus a control on the mainform...

But that solution I don't have available anymore... :-(
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 12028552
I am using Delphi 7, My requirement is make EXE file as small as possible and split the application in form of DLLs.

Is there any other solutions or Component available which can be use for same.

Author Comment

ID: 12029182

Can you show some example for specified solution.
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12036122
Don't put the forms in the DLL's. Put the business logic in the DLL's. The forms are just for the user interface so all they have to do is display stuff.

Author Comment

ID: 12042923
But what about the validation and database connections. It has to put with the forms
LVL 17

Accepted Solution

Wim ten Brink earned 50 total points
ID: 12044702
Not really... Even that logic can be arranged from the DLL's, albeit a bit more complicated than you're used to do. The biggest problems with DLL's is keeping track of all the memory management, worrying about where memory is allocated and making sure it gets freed propertly again. Which is why I like to use lots of interfaces while working with DLL's. (Thus, many methods in my DLL's return an interface, not a class.) With interfaces memory gets allocated and deallocated in the proper context/location.

But remember also that you might decrease the size of the executable, your whole application just becomes bigger because of the additional DLL's. An executable size between 1 and 2 megabytes isn't unusual. Paint Shop Pro 8, for example, is almost 6 megabytes in size for the main executable alone. And a lot more for all the separate DLL's. Dividing a project in multiple DLL's just to keep the main executable small isn't a good solution. (Because the gain you get from the smaller EXE is lost again by the size of the DLL's...)

If you want to make the executable smaller, you could consider using a TClientDataset (Midas) instead. Then the real database logic could be moved to a separate DLL. And that's a start for creating multi-tier applications. Or replace Midas with ADO, using TADODatasets only in your project, that connect to a DLL that provides the recordsets to your executable. Basically, it means splitting the business logic from the user interface.

It is possible to create very small executables, though. Unfortunately this means you cannot use the Delphi VCL in your code. A new console unit that doesn't use any units will be around 20 KB. If you include the SysUtils unit, it grows to about 45 KB. Add the Classes unit instead and it grows to almost 100 kb. If you include just the forms unit, and not one other unit, your executable will already be around the 300 KB, basically doing nothing. It's most likely that you've included DBTables in your project, somewhere, thus your exe is a minimum size between 500 and 600 KB...
One way to reduce the size is by checking the uses clause of all your own sources and remove those units that you don't use. With a bit of luck, this will save on some additional overhead. Problem with Delphi is if you add some component to a form, save the project, then remove the component, the unit of this component will still be listed amonst the other units, adding more bytes to the final exe. Remove it, check if the code still works and you could save quite a few bytes.

Having all your forms in one exe will increase it's size, true. But if you can keep all other logic outside of these forms, you can keep the main exe a lot smaller.

One question, though. Why are you so concerned about having a small executable?

Author Comment

ID: 12052622
Hi Workshop_Alex,

Thanks a lot, for giving me all the detail information, I want to create very big Financial Package, which includes different modules, I was first like to DLL to split my project in different modules like plugin but MDI not working properly.

I already created a Financial Software but it executable is very big approx. 15 MB so my of my clients complaines that the software takes time to execute and even on LAN it is taking too much time as I was using PARADOX database, Now I am using MYSQL and MYDACSQL component to access database.

So I am more convern about EXE size and spliting application in small modules which work like plugins.

If you have any other good suggession or idea about spliting project in moduls, kindly share with me.

Thanks & Regards,

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Suggested Courses
Course of the Month5 days, 17 hours left to enroll

626 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