how to open a dialog over topmost form window in C# - c#

i have a C# program that i made that uses forms to display the control for the user.
the main form open other forms on top of it, each new form is set to topmost
in the program i call for PDFCreator in order to make a new PDF file, but i can't see the dialog becouse of the form that is set to "topmost"
is there a solution to this out the

Yes, there is.
Don't set the topmost flag on your forms.
There is no way to say "Stay on top of all forms, except ...".
Stay on top really means stay on top, if you don't want that, don't use it.

You may want to use .ShowDialog() instead of .Show() without TopMost. This will basically mean that new Forms created by your app will have to be closed if you would like to get to the bottom form (I guess that's why you use TopMost - to prevent doing stuff on forms that were opened before?)

Related

How to show a form infront of all windows interfaces (start screen)

I want to make a WinForms with make it in Front of Many thing (in Windows 8, it in front of Start Screen, even make it can leave desktop while desktop Snapping).
for example, A Magnifier (magnify.exe) dialog in Windows 8 are top most than Start Screen.
It is Possible to make this Happen (In VB or C#)?
This Image is Example for what I ask for, so far I didn't find any SDK do this, and this image are edited (none of many application do this except magnifier (magnify.exe))
http://i.stack.imgur.com/1UxCX.png
alternative :
https://docs.google.com/uc?authuser=0&id=0B0xI21kQ3jxrLWw4cll6X3NJSTA&export=download
You can make the form modal by calling Form.ShowDialog()
Don't forget to set Form.DialogResult accordingly on your modal form.
An easy example could be like the following:
Form f = new Form();
f.ShowDialog(this);
The other option is to set the form's TopMost property to true.
Finally, you have the Modal property which will block all other no modal forms from click or keyboard events.
But given that WinForms is a desktop app, you will be able to show it in the desktop of windows 8, but not the new Metro interface.

c# open explorer window ont top

I'm using
System.Diagnostics.Process.Start("explorer", Application.StartupPath);
To open the applications path with a button press, but the window opens behind my application, how can I get it on top?
It may be due to TopMost property of the form may be true, or any of the properties of the form is making your application to stay on top. Just try to change the form properties and you will get the required result

C# TopMost and Tray

I have a WinForms application which shows a new small Form (with TopMost set to true) when a hotkey is pressed.
However when I send my main Form to the tray, the second Form is still displayed on the desktop.
How can I set my Form always to display on top of all applications, or just on top of the currently focused application?
Reference: Form.TopMost.
Form.TopMost will work unless the other program is creating topmost windows. There is no way to create a window that is not covered by new topmost windows of another process.
"How do I create a window that is never covered by any other windows, not even other topmost windows?"
Imagine Ans. if this were possible and imagine if two programs did this. Program A creates a window that is "super-topmost" and so does Program B. Now the user drags the two windows so that they overlap. What happens? You've created yourself a logical impossibility. One of those two windows must be above the other, contradicting the imaginary "super-topmost" feature.

when a form is set as topmost detecting desktop or other windows show?

I have noticed however that a form that is set as Topmost does not actually stay
displayed when the show desktop button is pressed!
I want to detect other form over the topmost event.
Do you mean "doesn't" rather than "does"? It sounds like you want a form that always stays on top regardless of what the user or other app want.
If so, it can't be done.

Controlling many forms at the same time

Suppose, I have the following task.
There is a main application form with numerous buttons; when you click on each of these buttons, you get one more form. The second click on the button should close the opened form.
These forms should not be shown in taskbar, because they are auxiliary. They should not be dialog, because that will block the main application form and prevent user from performing some other operations with the main window or with other forms like the one that is opened. They should be shown above the main form, but not above other windows (so TopMost doesn't suite). When such forms are closed, the main form should be notified, and when the main form is minimized, they should be minimized as well.
How would you solve this problem?
The current solution is based on using hooks. It's not very easy to understand and very difficult to maintain (mainly because I am not experienced in win32). It works fine for about 90% of situations, but in 10% it doesn't.
Maybe, the requirements to forms behavior are to strict?
I would recomment using some window-manager, so each button will tell the window-manager to toggle visibility of form X, if X is not there it will be shown, if it is, it will be closed.
You should be able to configure the windows such that they will not show up in the taskbar.
For the visibility, I am not sure what you mean. When you open a form via a button, it will usually go to front, which should be ok. If you switch the window then, what do you expect? Should the main window always stay in the background or is it allowed to come to the front when focused?
Whenever I have seen applications change such standard behaviors, they failed in some way. Either wrong windows showed up or some were not accessible anymore or the user was just confused because these windows didn't act like all other windows.
It's not a problem. Use the Show(owner) overload to display the form.
An owned form is always on top of its owner. It minimizes automatically when you minimize the main window. No need for ShowInTaskbar. Another window model supported by winforms is MDI, check out the MdiParent property. The child windows are confined inside the bounds of the main window. Also consider using UserControls instead of a form, you can swap them in and out as needed. Or a tabbed interface, using TabControl. Weifenluo's DockPanel suite is a very popular implementation of the Visual Studio style windowing model, supporting windows that can be docked and floating within the main window. Plenty of choices here :)
Here's how most of your requirements can be accomplished:
Set the Owner of each child Form to be the Main Form.
MSDN Quote:
When a form is owned by another form,
it is closed or hidden with the owner
form. For example, consider a form
named Form2 that is owned by a form
named Form1. If Form1 is closed or
minimized, Form2 is also closed or
hidden. Owned forms are also never
displayed behind their owner form. You
can use owned forms for windows such
as find and replace windows, which
should not disappear when the owner
form is selected. To determine the
forms that are owned by a parent form,
use the OwnedForms property.
For stoping a form from appearing in task bar you need to set the ShowInTaskBar property

Categories

Resources