简体   繁体   中英

Modal Dialogs do not open as topmost window

Our company is selling two different applications both written in C++ with the MFC 8.0

In both application we create and open modal dialogs like this:

dlg_options myOptions;
myOptions. DoModal();

This is the way we do it for almost 10 years. We have some hundred customers with a wide range of Windows Version (XP to 8.1) and it always worked well this way.

A few weeks ago we had a customer where the modal dialogs of the application did not open as the topmost window. They stayed in the background and you had to activate them manually to bring them to front.

I could not fix this problem but on his machine (Win 8.1) the customer had installed some extensions to Windows like a different start menu so I found something to blame. In fact the system was messed up. There was even more than one start menu application! After reinstalling Windows all was fine.

Today I had the same problem again with a different application and a different customer. His system was Window 8.1 again but this time I could not find any Windows extension.

There was one thing both systems had in common. You weren't able to switch between applications with the tab + alt keys. Even when our software wasn't running you could not switch. When our application was running you could use tab + alt to bring the modal dialog from the background back to the foreground. That was very nice but the window should be in the foreground right from the start.

I have no idea what is going on there and no way to find this error. Does anyone has a similar experience? What is going on here?

I have found a similar question here: Focus on Modal Dialog (MFC)

It appears to be a problem with dialog's parent. You may try declaring it as follows:

CMyDlg dlg(this);

I hope it helps.

您应该通过以下方式进行此操作:

SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM