Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

c++ - How to force AfxMessageBox to center on mainframe and not whatever child window that currently has focus

I'm developing an MDI application, the primary document is maximized in the MDI frame. I create a non-modal dialog pop-up to display secondary information to the user while they work in the main window. However, when the user moves the pop-up it takes focus which is expected. The problem occurs when this window has focus and an event which generates an AfxMessageBox occurs in the mainframe. I would expect the AfxMessageBox to pop-up centered on the mainframe. Currently, it pops up centered on the non-modal dialog pop-up window which, by chance, had focus at that time.

Is there a way to force AfxMessageBox to always pop-up centered on the mainframe? Or at least force it to pop-up centered on the window in which it was called. For example, if in my non-modal dialog an error occurs, i would want the AfxMessageBox to appear centered on that dialog because it's intuitive that the error occurred there. Alternatively, if I'm working with the non-modal dialog and an error occurs in the mainframe or document then I would like the AfxMessageBox to appear centered on it's view/frame despite the fact that I'm currently working with the child window.

I hope that's clear enough.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the CWnd::MessageBox() method instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...