Is there a way to make AfxMessageBox() take focus from another program?

87 Views Asked by At

I'm not a newbie, but my programming for Windows is weak. I have multiple programs running on a PC. One is an operator interface, so it usually always has focus.

If an error/warning condition happens on the other programs, I use AfxMessageBox() to generate a popup window for the operator. That's fine is the program generating the popup has focus. My issue is the popup is hidden behind the program with focus.

I'm currently searching the Internet for past cases to point me in a direction, so I've not tried any code changes yet.

Is there a method to make the popup appear over the program with focus so the operator can acknowledge it. The operator can then decide if they need bring up the other program or not.

1

There are 1 best solutions below

0
Mike Nakis On BEST ANSWER

Right before popping up the message box, you can explicitly bring the application that pops up the messagebox to the foreground. You can probably do this by activating the main window of that application.

However, I would advise against that, because nobody likes random applications popping up in front of them while working on something else. Instead, look at how you can pop up a notification bubble in the system tray. That's the proper way of doing something like that.