3

I have the need to embed the user interface (UI) of a secondary application into a primary application. I can easily host the secondary application main form into the primary application using SetParent. i'm using a named pipe to communicate between the two application. I can even resolve tabbing issues using AttachThreadInput API in the secondary application with the help of a dummy TEdit in the primary application. So far so good.

I cannot solve the following: Any modal form in the secondary application is not seen as modal for the primary application and this cause major trouble.

btw: Don't tell me to use a DLL, OCX nor ActiveX. I have two plain exe files.

Any help / hint appreciated.

1 Answer 1

5

Modal forms work as follows:

  1. When the modal form is shown, it disables its owner window.
  2. This has the effect of making interaction with the owner impossible.
  3. When the modal window closes, it re-enables the owner.

But in your scenario modal windows in the secondary application won't be disabling the windows in the primary app. So to solve your problem you need to make sure that your secondary app reaches out to the primary app and disables the appropriate windows whilst the modal form is shown.

Modality is a somewhat tricky area. It's easy to get it wrong with all sorts of bad consequences. It took at least 10 releases of the VCL to get the handling of modality and window owner anywhere close to correct! Raymond Chen wrote a great serious of articles on modality and I'm sure you'll find them useful:

Sign up to request clarification or add additional context in comments.

8 Comments

David, where do you store all this knowledge? I have trouble remembering what I had for lunch yesterday.
@Leonardo I can't remember what I had for lunch either!! ;-) Look at my profile and see my collection of useful links. Recently added is the Raymond Chen modality opus.
Well good luck with all that. It's hard enough to get it right within a single process!
I confirm it works by intercepting WM_ENABLE message in the secondary application and sending the information via the pipe to the primary application which execute EnableWindow API.
@Warren The program I run that crashes the most is Chrome. Going per processes doesn't guarantee you won't screw up.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.