Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:58:48+00:00 2026-05-30T04:58:48+00:00

I have two projects which run as separate processes, but belong to the same

  • 0

I have two projects which run as separate processes, but belong to the same application:

  • Master (contains TMasterMainForm and TMasterModalForm)
  • Slave (contains TSlaveForm)

The typical way to use this application is like this:

  1. Master is started and shows the TMasterMainForm.
  2. The user can run the slave by clicking a button in TMasterMainForm.
  3. Master starts the Slave process.
  4. Slave shows the TSlaveForm.
  5. Master sends the TForm.Handle of TMasterMainForm to Slave. (via IPC = WM_COPYDATA)

Step 5 is done so that when Slave is closing it can set the foreground window back to TMasterMainForm. This is done to improve the user experience.

This worked fine until we introduced TMasterModalForm.

TMasterModalForm can be started using another button in TMasterMainForm. It is a separate window, but is shown modal and has the TMasterMainForm as its explicit popup parent.

Now when the TSlaveForm is closed the Slave application calls SetForegroundWindow on the handle of the TMasterMainForm, but this is not correct anymore since there is a modal form (TMasterModalForm) on top of it.

So the question is:

How do I manage setting the foreground window in this non trivial situation?

PS: This is a simplified description, the real application is also doing this foreground window stuff the other way around.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:58:49+00:00Added an answer on May 30, 2026 at 4:58 am

    You cannot set the foreground window to the master main form because it is disabled. It is disabled because you are showing a modal form whose owner is that main form.

    The obvious solution is to set the foreground window to be the modal form rather than the main form. Since your slave app presumably cannot easily know which window is active, you should re-work your IPC to allow the slave app to ask the master app which window is active, and then make that the foreground window.

    A more elegant solution would be to let the master app call SetForegroundWindow. In fact it would probably be simpler just to call Application.BringToFront from the master process. Of course, the slave process would still need to send a message to the master in order to invoke this. The final piece in the puzzle is dealing with the focus-stealing restrictions but you can do that using AllowSetForegroundWindow. You need your slave process to call this passing the ID of the master process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two projects, a Cocoa iPhone application and a static library which it
I have an solution in VS 2008 which contains two class library projects and
I have two distinct Django projects, which I want to run on a single
I have two web application projects which are related. One is the website itself
I have two projects, the DLL project which has all my logic and data
I have a two projects, AI and Core , which used to hold a
I have two projects: A/B. Project A is the project that contains all of
I have two projects in the same server, their settings conflict in the session.auto_start,
I'm using eclipse, and I have two android projects which have different topics. And
This is probably a basic question. I have two projects: A web application project,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.