This question already has answers here:
Is the size of a Form in Visual Studio designer limited to screen resolution?
(8 answers)
Closed 8 years ago.
I am working on Windows form application. After deploying the application I am getting screens with different sizes in laptop and desktop. This makes some of my menus to disappear and reports to be not shown properly. Do we have a solution for this?
While changing the resolution of my system my form size also getting changing. I want to prevent this.
Make your app with lowest possible resolution (Like: 800x600) and then
Use Panels and when you add your tools into those panels dock them, that might be helpfull, that's what I am using in all my applications and it is going with screen resolution all the time.
I put this section of code in my Load event method:
this.MaximumSize = this.MinimumSize = this.Size;
When a user attempts to double click on the top of the form to maximise it, it stays in the same size. Therefore, maximising the form in this case is disabled.
Make it small enough to fit in the screen having the smallest resolution. And make your forms WindowState as normal. Then you'll see that it fits all the screens. But if you want Maximized state on all screens then you should first apply my first sentence, with #Nidzaaaa's answer.
Related
I am having an issue with auto scaling while trying to create a Windows forms app. I'm currently running on a Dell laptop with a 3840 x 2160 display (4K). I'm trying to add an image to a picture box, and if I leave the picture at its native size (which is quite small on my display) it appears at a correct autosized scale when I go to run the app. The issue with this is at the native picture's size it is very difficult to lay out all the other items I want to add to the app. If I increase the size of the picture to something that is usable it increase the size of the image to something large enough it doesn't fit on my screen. I know this is likely due to the auto scaling Windows 10 does, but I wanted to see if anyone else might have a work around for this? I've tried to see if there is a way to zoom in the display in the designer window, but I haven't found anything. I have also noticed the size of the windows forms app itself changes depending on where I have items placed on it.
I don't know that I completely understand what you're asking, but I would assume it could have something to do with the pixel units of your elements. Here's an excellent explanation of point-based vs pixel-based sizing
We are building a Windows application in .NET and one of its requirements is touch screen monitor. Other than that, it's a normal windows form based application. But except for making UI items little bigger for touch, I can't find anything I as a developer need to do for the requirement since touch screen is basically mouse operations. Am I missing something?
No, you are not missing anything. Do get the actual hardware hooked up so you can test it, "little bigger" is invariably underestimating the problem of fat fingers. Everything should work from a single click, right-clicks are horribly impractical, double-clicks are best avoided.
The only other thing you'll want to do is go into the Control Panel + Display applet and change the size of standard Windows UI elements. Pick a large window caption font if you want to allow the user to drag or close windows. Make the scrollbars at least twice as wide. And the menu and message box font. Go in the Mouse applet to increase double-click range and time if you want to support that.
If you do not need touch-specific event handling I think it's all you have to do. But touch means more than that and you may want to support it in a better way: http://archive.msdn.microsoft.com/WindowsTouch/Release/ProjectReleases.aspx?ReleaseId=2127
When i write my programs in Visual Studio (2008), they run perfeclty at my computer: program's objects are placed as i did it in designer. But when i run programs on other computers, some objects are placed wrong by few pixels: they touch other object. I suppose it is due to my monitor's resolution (1680x1050). I find that I can use TableLayoutPanel. Any other ideas to solve my problem? Thank you.
Why don't you set the size of your application's window to a desire resolution and see how it is rendered. This should render the GUI as if the application was running in those resolutions.
Another thing you may check is for how the size of the columns/rows on TableLayoutPanel are defined. You can set their size as a relative or absolute size. If you set it to an absolute size the objects should appear always on the same place.
I suggest you write a test application with as few controls possible where you can reproduce the issue.
Then, come back here to SO and describe exactly what situation you have
which controls show that behaviour?
does it only occur with TableLayoutPanel, or with other Panels, or without any Panel?
does it only occur when the user changes the form's size?
Please post some code or screenshots.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
C# WPF resolution independancy?
What is the difference between resolution of monitor and System DPI with relation to WPF resolution independence.
Changing what between the two keeps the size of window same in WPF which was earlier not possible in User32?
EDIT:
The book I am reading "Pro WPF in C Sharp" says that if we create a 1 inch button in 96 DPI and then later change the DPI to 120, due to more pixel density, the button would become small (in winforms).But I tried that and I can see that in both the two cases the button size remains the same !
Why is it so ?
Actually, the so-called resolution independence of WPF doesn't enable you to do anything you couldn't do before in Win32. It's just that it was a lot more work before. So the only real change here is one of develop effort - there's no change in the fundamental capabilities. (And that's true of everything in WPF actually. If you have several years of development time to spare, you can do everything WPF does by programming directly against DirectX APIs...)
WPF automatically takes into account the nominal DPI configuration. In Win32, if you want your application to be sensitive to the nominal DPI, you have to write additional code to make that happen, and you have to deal with various horrible layout issues if you want to avoid problems like text getting cropped with some DPIs. (Although now that we have GDI32-style text rendering in .NET 4, you can opt back into all those problems in WPF apps...)
So the answer to your question is essentially: no difference. WPF makes it much easier to take the DPI into account, but it doesn't enable any new behaviour here.
Fundamentally, WPF runs into exactly the same problems as classic Win32 apps for the simple reason that it has access to exactly the same information as classic Win32 apps. As the pages linked to in other answers here discuss, Windows usually has no idea what the DPI really is. Most of the time it'll tell you that the monitor is 96dpi. Well I've got 3 screens attached to my computer, and Windows is reporting 96dpi for all of them, even though none of them is really 96dpi, and they're not even all the same dpi in reality.
The bottom line is: Windows doesn't usually have any idea what the real DPI of your screen is. There's nothing WPF can do to overcome that. If there were a way for WPF to discover the real DPI, Win32 apps would be able to discover it too.
I want to save and restore the window position of my WPF application. I want to make the code robust to use with multiple monitors who's number and relative location can change (I want to avoid opening my application off-screen when the monitor configuration has changed inbetween invocations).
I know of the Screen class in System.Windows.Forms, but I don't want to take a dependency on that assembly just for this feature.
Windows will keep your application on the screen even if you use corrdinates which are now outside fo the viewable range. Just persist DesktopLocation, Size, and WindowState (to see if the app was maximized). Be sure not to save these settings if the app was closed when minimized.