I'm using dualview setup in my OS (1 view extended across 2 screens). In my winforms application I can move particular window to secondary screen, e.g.:
foreach (Screen s in Screen.AllScreens)
{
if (!s.Primary) {
myform.Bounds = s.Bounds;
break;
}
}
Everything is fine, when I can see this secondary screen. If I see it, I'm able to use any functionality such window form provides, e.g. I can close it by clicking the appropriate button.
But what if I cannot see this secondary screen, e.g. this is a projected image displayed on a wall in another room ? I cannot use my forsaken form then. How to cope with such uncomfortable situation (moving to the same room is not an option) ?
What I want is to make an exact duplicate of such form to be shown both on my primary screen and the secondary one. I'd really like to have multiple instances of the same window, exact copy, where one instance reflects changes at the other one and and vice versa. I could control the secondary screen (react on some popup information, etc) using the main one placed in remote location. I have no idea how to implement something like this in .Net with the usage of winforms. How to do it ?
BTW: If this is hard to achieve, what can be done from the conceptual point of view ? I know I can define some keyboard shortcuts but this is not what I'd like to have. Any ideas?
Conceptually, you could use a second window (call it a "Mirror form") to duplicate the primary form. Capture the screen for the primary form and display the captured portion on the mirror form.
That part is the easy part. If you want to be able to actually interact with the Mirror form, you'll need to capture all user input such as mouse move, hover, click events, and keyboard events and replay them onto the main form.
You might be able to do that with the event handlers on the Mirror form by capturing all of them and replaying them them on the primary form. However, I'd look into capturing the messages on the mirror form. That is probably more comprehensive and probably a cleaner way code wise to "monitor" the events and send them over to the primary form. You can also "eat" messages going to the mirror form that would cause focus to change (e.g. there may be an issue if input focus suddenly shifts from the primary form to the mirror form while the user thinks they're interacting with the primary form).
For more info on Messages look into overriding then WndProc of the Form (which is really Control.WndProc) and here. A nice overview article is Deliver The Power Of Spy++ To Windows Forms With Our New Tool. It also deals with cross-process communication which isn't relevant but explains a lot of the detail on messages and intercepting them.
Related
So I'm sure there's an easy way to do this but I don't know the exact terminology for what I'm wanting.
Essentially in my C# xaml uwp app I have a couple objects that need to have details added to them, kind of like file properties. I have a button that I would like to open up another window (still part of the app), just to enter in the properties. I just don't know the terminology to look up what this window would be called or find documentation for it. So the exact same as when you're in a file browser and you open the properties of a file; it opens in a little extra window that you can drag around.
I don't want to be able to use the main window while the properties window is open, and of course they need to be able to transfer data between one another.
In my previous apps I've simply made a grid that appears over everything else in the middle of the app and shaded the outer area. A workaround as I didn't know how to do this.
Can anyone help me out?
Maybe you can use Dialog refer to https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/dialogs-and-flyouts/dialogs.
Dialog controls are modal UI overlays that provide contextual app information. They block interactions with the app window until being explicitly dismissed. They often request some kind of action from the user.
I would like to know if it is possible to, while running a WPF window application in Visual Studio, wait for the user to click anywhere on the screen (not necessarily inside the window of my application - for the purpose of my application, the click would most likely occur inside a browser page) and then gather the information about the click (like inside the window of which application the user clicked, or the selector of the html element the user clicked)? I know this question might be very confunsing but this is basically my last resort since researching on the Internet hasn't helped me much. Just to provide a better idea of what I seek, it's like what the 'Extract Structured Data' Activity does in UiPath. Oh and I'm using C# by the way.
You can try and use this external library called GlobalMouseHook.
This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
Here is what you can do with this library:
Mouse coordinates
Mouse buttons clicked
Mouse drag actions
Mouse wheel scrolls
Key presses and releases
Special key states
Hope this helps.
In a WPF window I implemented a component that gives an indication of all active errors in the system.
The component is located in the task bar and
If one hovers over the component a tool-tip is shown with summary info
If one clicks on the control, a panel is the activated that is showing a detailed list.
In the application we also use wizards implemented as modal windows.
Now, here's my problem: if a new event occurs in the system during an active wizard, the component in the task bar is updated however I cannot use the hover event to see a summary. Both events (hover and click) are not usable due to the modal dialog that hides the parents message loop.
Is their a way (or what's the best solution/suggestion) to have at least the hover message active while the modal wizard is present.
Thanks.
They don't call it "modal" for nothin' :-)
Humor aside, depending on your exact scenario, here's two options and a third option that's a bit more involved and you probably don't need it but it can handle a wider range of scenarios:
Option 1. It sounds like you have a normal app that does not show its MainWindow and is using only its taskbar presence. If this is the case then you don't need a dialog at all, simply use the MainWindow itself as the "dialog".
Option 2. If you are already using the MainWindow visibly then use a pseudo-modal approach whereby you don't actually use a dialog but all other controls except the control acting as your "dialog" control are hidden/collapsed.
Option 3. Use two separate processes. Basically, this is two separate apps - one is your taskbar component and the other is your main app. Use IPC to link the two - e.g. I have used a Windows pipe for such a thing and it works fine.
Backgound :
I want to create moveable toolbars just like paint.NET or any other Designing application. A Toolbar which can be moved, closed and shown from the menubar.
i know how a toolstrip works but its permanent sort of thing. There is another way explained in some articles which uses panels to make toolbars.
While doing experiments on the toolstrip, idea came up in my mind to make two forms(one big size form and other small form) and run them simultaneously , one will act as main form and the other small form will act as a toolbar but it also didnot work. I am only able to run one form.
Requirement:
I just want to make an application look like Paint.net having different tools in a toolbar which can be used on drawing area.and when application starts, toolbar and drawing area both should be running just like in all graphics editing softwares.
Questions:
How to make a moveable toolbar that can be closed and viewed again?
How to run two forms of different sizes run simultaneously at the same time when application starts?
Note:
Need Guidance as well if i am not in the right direction, u can set my direction towards the right side.
Thanks
We have a WPF application that has a main window, and 1 child window shown by ShowDialog with ShowInTaskBar set to false.
We save their positions on close, and set Window.Left and Top when re-opened.
Problem is, when you remote desktop into a computer with multiple monitors and then open the child window with a saved position offscreen, there is no way to bring it onto the single monitor.
Is there a something we can change on the child window to make windows handle this issue? The main window doesn't have this issue (I thought it might be related to ShowInTaskBar or the fact it is the main window).
Is there a better way for us to store the window location?
There is no default way within WPF to access any available screen other then the primary screen.
WPF does have SystemParameters.PrimaryScreenHeight and SystemParameters.PrimaryScreenWidth to work with the primary screen however to get information on screens excpluding the primary you would have to make use of the System.Windows.Forms.Screen class.
If you went the System.Windows.Forms.Screen class route you could save relevant data about the window based on the screen at which it resides. Then upon reading the values in you can force the window to the desired screen based on the number of screens residing in the System.Windows.Forms.Screen.AllScreens array. It gives you flexibility for placement as you can take advantage of all available screen within the system versus just the primary.
EDIT:
If you are not concerned with getting the screen information in a modular manner (information per screen versus the aggregate of all available screens) and do not want to make use of the System.Windows.Forms.Screen class you can make use of the SystemParameters.VirtualScreen* properties which will provide the aggregate of available screens.
It should always be possible to get any window back on screen. The following steps hook the currently active window to the mouse cursor:
Press Alt+Space to open the system menu
Press M for 'Move'
Press the right arrow key
now move the mouse