c# open explorer window ont top - c#

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

Related

How to place windows form on top of given window (known by handle) in C#

I'm trying to overlay child window of some application with a form.
I have handle to that window so I successfully used GetWindowRect()
to get coordinates and correctly place my winform on the screen.
However I have problem with order of application's windows and my winform.
With TopMost parameter set to true my form overlays menu drop lists of the main window of the application and generally doesn't look very elegant. With this paramter set to false, my form hides below all windows and is invisible.
Is it possible to place my winform above only one, specific window (to which I have the handle) and maintain order of all other windows (keep it below them)?
To illustrate it. Now I have this order of visibillity(?):
My form (on top)
Application main window
Application child window
I want:
Application main window
My form
Application child window
Please keep in mind, that this another application is 3rd part product. Everything I have is the handle to the window which I want to overlay.

unable to find the control that opens in background in codedui

I am currently working on AX form for automation . In one of the forms, I am trying to click a button , which opens another form and on this form I need to perform some action.
The window which I am opening on button click sometime opens in background and few times pop up in the foreground above the window where I have clicked the button.
I would want my window to open in the foreground so that I can perform operation , since it is opening in background the codedui playback is searching for the controls on the main window/parent window, which making test case fail
This is making my test case fails multiple times. I am using SetFocus property and SearchInMinimizedwindow options but none of them is working
Is there any solution to always get the window on foreground in codedui or in c#
I would suspect the popup window has some of the same automation properties as the parent window. If not able to fix this code side by using a different AutomationId, you may be able to workaround this by specifiying this is a different window instance.
SecondWindow.SearchProperties["Instance"] = 2;
SecondWindow.SetFocus();
The window that opens when you click the button, is that the child window of the Main window or does it exist on its own? Based on that, you will have to search on the parent (Main Window or Desktop).

How to force the OpenFileDialog to be opened at a certain location across all the OS from my WPF application

Is it possible, from my WPF application, to set the prefered location that the Windows OpenFileDialog will be opened at, no matter which application will fire it, if it possible how can I achieve that ?
Open Dialog position can not set in WPF so you need to create the custom open Dialog box in a WPF form and then you can set the position or margins of the WPF form accordingly.
If you are using the Microsoft.Win32.OpenFileDialog, you can set the InitialDirectory property on the dialog before opening.

how to open a dialog over topmost form window in 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?)

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