C++ My form should stay on top of every kind of windows
I have a main form. This main form generate another form. This new form should be fill before having access to other window. I used Myform.ShowDialog() to make this form modal.
I would like that my form will be on top of every type of other windows even if these windows are not part o开发者_如何学编程f my application (for example: Internet explorer page, opened Word document...).
Do you any solution ??
Thanks,
It sounds like you're using .NET
In which case you can use the Form.TopMost property
myForm->TopMost = true;
myForm->ShowDialog();
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.topmost.aspx
Using Form.TopMost will make the window appear above any other window in your application, but it does not work other applications.
While I have seen apps that make their window float on top of all other windows, I don't think you can make a modal dialog box that prevents you from using other applications.
A really dirty hack would be to have a timer the forces your window to the foreground every second. It means that users would not be able to use any other application in a meaningful way, but they will definitely hate you for it.
You could also try simulating the Windows Vista/7 -style UAC dialog by taking a snapshot of the desktop, making a full-screen window with that image in it, and then rendering your window on top. However, experience shows that users don't like those UAC dialogs either.
won't form->DoModal() do the trick? (works in MFC anyways?)
Raymond Chen proved why it's impossible:
Imagine if it was possible for applications to do this, you did, and another application did this too. Now obviously that application would be on top of every windows, including yours, yet your application would be on top of every other window, including theirs. It's a logical impossibility that your window is on top of theirs AND their window is on top of yours. Hence it follows logically that it is not possible for any application to claim the topmost window.
精彩评论