I'm using the standard recommendation for creating a Window and having it display on a secondary monitor:
I use the following to get the screens available:
Screen[] availableScreens = Screen.AllScreens;
Extract the working area of the target screen (second screen in my case, not the primary screen):
secondaryScreenWorkingArea = availableScreens[1].WorkingArea;
When creating the window, set the location properties based on the working area (before calling Show()):
Left = secondaryScreenWorkingArea.Left;
Top = secondaryScreenWorkingArea.Top;
Width = secondaryScreenWorkingArea.Width;
Height = secondaryScreenWorkingArea.Height;
Some other things to note about the window:
It is a fullscreen window that is intended to span the entire second
display
It is not the main application window
It is hidden from the taskbar, it is intended to be supplemental to
the main application window
WindowState = WindowState.Maximized;
ShowInTaskbar="False"
WindowStyle = WindowStyle.None;
Running on Windows 10 Enterprise V 1809
Below is a rundown is different configurations that I've tested, and only one of them is not behaving correctly:
When I run this on a workstation setup with two 1920x1080 displays, 100% display scaling, it works as expected.
When I run this on a workstation setup with two 1920x1080 displays, 150% display scaling, it works as expected.
When I run this on a workstation setup with a 1920x1080 display and a secondary USB display (800x480) connected, 100% display scaling, it works
When I run this on a workstation setup with a 1920x1080 display and a secondary USB display (800x480) connected, 150% display scaling, it works
When I run this on a Microsoft Surface Go with the main surface display (1800x1200) and a secondary USB display (800x480) connected to the surface dock, 100% display scaling, it works
When I run this on a Microsoft Surface Go with the main surface display (1800x1200) and a secondary USB display (800x480) connected to the surface dock, 150% display scaling, it DOES NOT work. Instead, once Window.Show() is called, this is triggering the window to relocate to the primary display (The surface go screen). I noticed this because I am receiving a LocationChanged event for the window during my call to Window.Show() and see the Width and Height properties have updated to the sizing of the Surface Go display (1800x1200). But, curiously, the Top and Left properties are NOT updated even though the window has moved.
As you can see from the cases above, it seems to be an issue with Display scaling + the Surface Go. On my workstation, I forced the same resolution as the Surface go (1800x1200) and set display scaling to 150%, but could not replicate the issue from the Surface Go
Furthermore, I performed some testing with another USB display with a slightly higher resolution (1024x600) and have noticed that the same issue occurs, only on the Surface Go, but this time it required me pushing the display scaling to 200% before the issue began to occur in that configuration.
Several things I've tried, but none produced any solutions to this issue:
Tried various configurations of dpiAware and dpiAwareness. These changed the scaling of the coordinates I received when grabbing the AvailableScreens, but using scaled/unscaled coordinates had not affect on this issue
Restarting the Surface Go after changing the display scaling option (per the "Some apps won't respond to scaling changes until you sign of" message displayed in the Display Settings
Tried setting WindowState = WindowState.Maximized both before and after the Loaded event and both yielded the same result.
Any help or other ideas for things to try would be appreciated, not sure if this is a WPF, Windows 10 or a Microsoft Surface Go issue.
Related
My WPF application window is not scaled on the second monitor, running Windows 10.1607. The built-in monitor runs at 200% (high DPI) and the external monitor at 100% scaling. Most other program windows change their size and internal scaling when they are moved between monitors, but mine does not. It appears huge on the external monitor, and has double the icon and text size compared to correct scaling.
The application targets .NET Framework 4.0 and the app.manifest file contains the relevant entries for Windows 10 support and dpiAwareness. Even if I remove these entries, it doesn't change. I don't know whether this has worked before, I couldn't find an old version that does.
What do I need to do to let Windows scale my window on a different-DPI monitor just as any other window? I don't currently expect it to be sharp (.NET 4.6.2 has news to that), blurry rescaling is okay. But it just needs to do anything and not render the window at 200% on a 100% monitor.
Seems to be a Windows/Surface bug. Every time I resume the Surface Pro 4 (all updates installed) from standby, a number of applications are not rescaled when moved to another monitor. After a logoff and logon, it works normally again.
I have a computer with Windows 7. I have got 3D simulator installed. This simulator provides window. I want to place transparent window on top of simulator's window (with my extra drawing).
Problem is that simulator's window switches to "full screen exclusive mode" on mouse click. That makes hardware work faster. But that hides the rest of windows (even topmost) including mine transparent window.
Is the a way to disable full screen mode?
This is very interesting post (and it is related to my question):
Detect if user has any application running in fullscreen
Here is a little tip from me: if you are using Presagis Vega Prime then you can switch full screen exclusive mode on and off using acf-file (Full Screen checkbox at Pipeline\Window).
In my case I switched Full Screen off and configured Coordinates so result 3D simulator's window still covers full screen ("fake" Full Screen Mode).
After that there are no problems with my transparent window.
I have just started looking into D3D9 using SlimDX.
I have a device created off the primary display adapter and device.present only flips the backbuffer onto the primary monitor. When the window is moved to the secondary display, the surface is no longer updated. That is expected.
What I'm trying to do though, is that if the window is moved across to the secondary display (fully across to secondary display or partially, occupying both primary and secondary displays), the same rendered image gets presented.
What do I need to do to achieve this (someone suggested CreateAdditionalSwapChain here and here, but I'm not getting the bigger picture of how this could work)?
I only intend to support multi-head cards.
I found the reason it wasn't showing on the secondary screen.
I (or more appropriately, the sample code) had PresentFlags.DeviceClip set when creating the D3D9 device. Removing it allows it to work across the screens.
So here is my form onstartUp event code:
int height = Screen.PrimaryScreen.Bounds.Height;
int width = Screen.PrimaryScreen.Bounds.Width;
this.StartPosition = FormStartPosition.Manual;
this.Size = new Size(width, height);
this.WindowState = FormWindowState.Maximized;
the code works fine and the form starts up maximized. After distributing the applications to the user. A user complained and sent a screen shot with the form buttons on the RHS not appearing on the screen!!!
I figured what the problem is, but i don't know how to fix it. The problem is with windows fonts, Control Panel\Appearance and Personalization\Display\ font size on the development machine is small, on the customers it's medium.
how to accommodate for this in code?
The problem is with windows fonts
Not exactly. It is not the font size you are changing, it is the video adapter's dots-per-inch (DPI) setting. The legacy setting is 96 dpi, since Vista it got a lot easier to change this setting. Common other choices are 120 dpi (125%) and 144 dpi (150%), they are directly accessible from the Display applet with a radio button.
Monitor resolutions have been stuck for a very long time, ducking Moore's Law for a good 30 years already. That's finally changing, in no small part due to Apple's push for "retina" displays. The latest MacBook Pro has 2560 x 1600 pixels on a 13 inch screen, about 230 dpi.
That does come with a problem, any program that creates a, say, 1024x768 window has its UI turned into a postage stamp on such a display. The UI just becomes unusable without a magnifying glass. What is needed is for such a program to become aware of the video DPI setting and create a larger window, proportionally larger by the increase of the DPI setting compared to the way the window was originally designed.
This is automatic both in WPF and in Winforms. WPF gets it by default since all of its locations and sizes are expressed in inches, with a unit of 1/96". Winforms still works with pixels, but it has automatic scaling built-in through its AutoScaleMode property.
Which is what is happening on that user's machine, he's got the video DPI setting at a larger value than your machine. However, without also having a larger number of pixels available on his screen. Somewhat typically picked by someone that has a vision impairment, a side-effect of increasing the DPI setting is that fonts get larger and thus easier to read. But with the inevitable problem that any controls that you put near the right and bottom edge of your window are going to fall off, the screen just isn't big enough.
You address this kind of problem by making your window layout adjustable. Or in other words, by making your UI design work with any window size. A very common feature of Windows programs. Just try it on Visual Studio. Drag the bottom right window corner around and observe how it deals with having less space available but still staying usable. Lots of Winforms features to help you doing this, like the Control.Anchor and Dock properties, FlowLayoutPanel and TableLayoutPanel controls, the Resize event for tough cases.
The Q&D fix for this is the Form.AutoScroll property. Set it to True to permit the UI to still be usable, the scrollbars allows the user to still get to controls that are off the window.
The code you posted has nothing to do with the problem. You designed the form in a higher screen resolution than the screen resolution of the user and didn't consider docking/anchoring the controls inside the form.
I am total newbie in .Net programming so be patient, please ;-).
I have problem with resizing window. I want to resize from my app other app's window and take screenshot of it. I do resizing based on this example: http://blogs.geekdojo.net/richard/archive/2003/09/24/181.aspx. But I have a problem. I work on a laptop with 1024x640 pixels screen resolution but I want to resize my window to 1200x1600 px. I can't do that couse display limitations. Is there any tricky solution to resize window for this resolution and take a screenshot of whole window? I've alos tried Sdesk program witch is suggested here: Create Window larger than desktop (display resolution). Any help?
I would suggest you find a way to set a virtual resolution larger than your physical resolution (basically what sDesk does), and then let your application run normally on that large desktop. Depending on your video card, you might be able to configure the virtual resolution directly in the video driver, without using any additional utility.
No it is not possible. In fact you can't resize in any way the windows greater then the display size.
Just try it by position a window in normal mode (not minimized or maximized) somewhere on the left. Grab the right border of it and increase the width till the end of your screen. Now move the window, by grabbing the title bar, some more to the left. Repeat this procedure several times. At some point you're not able to get the window any wider anymore. If you now try to move the window till the right border hits the right side of your desktop, you'll see that the left border is direct at the left desktop side.