Article

How can I ask a second program to show a dialog box as if it were shown by my first program?

The Old New Thing ·The Old New Thing ·Published 2026-11-17 ·5 min read

This article discusses how to manage dialog boxes between a GUI program and a background program, ensuring that dialog boxes appear correctly in relation to the GUI program's main window. It emphasizes the importance of using the correct window handle for modal dialog boxes.

From the article

Suppose you have two programs, one a GUI program and another a program that runs in the background. The GUI program asks the background program to do some work, and then the background program realizes that it needs to display a dialog box. How do you get that dialog box to appear as if it were shown by the GUI program?

If you have the background program simply try to show a dialog box with no owner, then that dialog box has no relationship to the GUI program’s main window, which means that there is no requirement that the dialog box appear in front of the GUI program’s main window. If the GUI program didn’t disable its main window, then you have the situation where both windows (the GUI program main window and the dialog box) can be clicked on and interacted with. But if the GUI program…


Share this resource


Discovered 2026-11-17 Source The Old New Thing Archive 2026-11 →