I am currently developing a Winforms Application that will run on a very specific tablet PC.
My development environment uses dual-17" monitors which are far bigger than the tablet screen size of 10.4" (1024x768).
Due to the purchasing department at my company the delivery of the tablet will not be until well into the design cycle.
Is it possible to mimic the tablet size so that I can adjust my forms to match?
You have couple of options:
set one of your screens to the tablet resolution. You might need to move your taskbar to that screen to get the proper-sized workspace.
install Virtual PC and create a VM with the tablet resolution.
set your main form size explicitly to the tablet PC resolution. For best results size it to the proper workspace size, not the desktop size.
Note that your form will have to still be relatively flexible, since users might configure their taskbar to be at a different position, or different size, thus affecting the available workspace for your app.
The fact that you have 1024x768 on 10.4" means the pixels are denser than your typical PC monitor. That means that text 10 pixels high on your monitor might look fine, but 10 pixels high on the tablet PC may be tiny and almost unreadable (even without loss of resolution).
Unless you can find a monitor with similar pixel density, I don't think you can properly mimic it. Even if you can shrink the application to a 10.4" section of the monitor, now you're probably dealing with sub-pixel shading which will look blurrier than on the tablet PC.
The best you can probably do is setting one of your monitors to 1024x768 (without stretching to fill the screen!), or just set your app to that size and eyeball it to take into account that it will actually be smaller.
You could try hosting your main form inside a user control or another form limited to the relevant size. However, the form is then not a "top level" form, but fairly closely looks and behaves like one.
You can perform normal form actions (minimise / maximise / move / resize / etc) so you can get a feel for what it is like and a certain size.
However in this instance, its best to always design the UI for the minimum resolution you have to target, and have it scale upwards on larger monitors.
very easy - if you're concerned about size, or users have to use the touch screen, start your form out with 10pt+ font
very cool - design the form size as, oh, 950x650. Experiment with the anchor property of each control. Allows you to make basically totally resizable controls (if you get creative with the anchor on groupboxes/panels and the controls inside them).
then set your form to maximize itself on the tablet PC (or e.g., if screen size is <= 1280x1024 - the Anchor property has its limitations as to what size increase looks reasonable).
Related
I am new to Stackoverflow as well as UWP (My English is regular too). I apologize in advance for my bad writing.
I am developing a windows application in UWP/C#. My monitor size is 23' and it is set to 1920x1080 (100%) resolution.
As seen in image 1, I have configured the application in such a way that the size of the main frame is 1920x1080, therefore, when I run the application on my computer it looks perfectly (see image 2).
However, when I run the application on another computer with a smaller screen size (17 "), it looks like in image 3, where it can be seen that the application does not fit this size. It seems to keep the original size and mi application "does not fit on the screen".
My question is: how do I program the application so that it does not lose its shape, distribution, aspect ratio, or proportion when it is run on screens that are different in size from the computer on which it was programmed? In this way, it automatically adjusts to the resolution and scale of the screen, without losing the original proportion and distribution with which it was programmed and designed.
Thank you very much for your help and understanding.
EDIT 1: I am not looking for the content of the application to fit a change of the window, but rather to fit screens of different sizes. That is, the same content, distribution and proportion are scaled to fit on any screen size, as evidenced in image 3 that does not happen. (see Image 4)
I don't want the image 3 to happen.
The control doing exactly what you want is called ViewBox, but as people already suggested above, it would be better to design adaptive UI using triggers or at least grids.
I am writing this application and it has a size of (800 X 400). The problem is, it resizes when I run it on different monitor resolutions and all the objects get bigger. Is there a way to fix its size for all monitor resolution without maximizing?
In general, if your form is defined with a fixed size of (800 x 400) then it will generally appear larger on the same screen if you change the resolution to say (800 x 600).
The screen resolution defines how many pixels make up the view port. changing to a high resolution will make all apps, not just yours appear smaller. Changing to a low resolution can make all apps, again not just yours appear larger.
Changing the screen resolution is changing the DPI
Windows and WinForms do provide some mechanisms for scaling your app so the interface can be more proportional on different screens, but it can be a bit more hit and miss to take advantage of in WinForms compared to other technologies like WPF/UWP, especially if you have an older application or code base.
If the scaling is not what you expect, first check that the users have turned scaling in their display settings back to 100%, many laptops and tablets have the set to 125% OOTB. When you have not correctly defined your interfaces to take advantage of font scaling it can look a bit funky.
Setting windows font scaling back to 100% means your app will only have to contend with DPI scaling issues rather than both font and DPI scaling that windows might impose.
font scaling in the display settings, in windows 10 looks like this:
Have a read over:
Automatic scaling in Windows Forms
The key to getting it right is that all forms and controls in your app must be configured to use DPI based scaling OR Font based scaling. When the two concepts are confused the UI can look like a mess as some elements will resize and others may not.
This scaling behaviour is defined in the form as the AutoScaleMode:
- This defaults to Font in new apps.
Many 3rd part components however may be set to DPI mode, especially if they have any drawing canvases or their display logic is referenced by pixels (which is pretty common in WinForms custom painting.)
For this reason, setting your forms to use DPI scaling might solve your issue
Also check out some of these posts in SO that might help explain your observations:
How to write WinForms code that auto-scales to system font and dpi settings?
How to control the font DPI in .NET WinForms app
How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?
I am having issues with some applications (mainly dashboard) that some user uses windows display scaling to make their icons bigger but this cause huge problems in my software. I am looking for a way to disable completely the scaling on my application and leave the application scaled to the pixels of the display resolution instead.
I have found this thread but it is 8 years old and windows 10 didn't exist at the time and another user gave an answer but it doesn't work either.
A simple example of the behavior happen mostly on dashboards as there is a lot of controls and widget on these kind of screens and they are critical for thing like robot machinery controller.
One example dashboard window is in it's minimum possible size 1900 x 980 (could be 4-5 pixel smaller in both direction but we rounded up to get rounded positions XY values). This resolution is just shy of 1920 x 1080. It Cannot be smaller but you can make it larger if you have a bigger screen like 4K and all you gain is more date in treeviews, better display in the 3d Engine renderer etc.
So some users have small laptop screen such as 15 inches that have a maximum resolution of 1920 x 1080 resolution but they use 150% scaling so my screen minimum size become 2850 x 1470 in their screen which make the application bigger than the screen and goes outside the screen.
An another example if i use a Windows Surface Pro which have a 2736 x 1824 resolution which is about 80% bigger than 1920 x 1080 the window does indeed still take the original 1900 x 980 pixels on the screen which make it look quite small so if you full screen it you see much more information in all controls. But then if you change scaling to 150% the screen now take again 2850 x 1470 pixels on the screen which is fitting perfectly on the height but on the width i am short by 100 pixels, and 100 pixels that's enough to loose the right part of my screen and you either cannot see the left most part or the right most part of the screen.
I tried the 3 auto scaling mode : DPI, Font and None and it doesn't work at all. It still stretch the screen no matter what. Changing the font of the forms doesn't help either, i manage to make it once work for few labels directly in the form but anything inside group box fail to change or grow twice in size compare to the rest.
Important points :
Project are .net 4.5 and 4.6 but there is no problem compiling them in 4.7if i need to for specific features.
WPF is out of the question. We took 3 years to implement it and ended up quickly with very bad performance with third party DLL and 3D Cad performance were simply abysmal.
Screens are already optimized with the least amount of controls possible. out of the couple hundreds of screen and thousands of user controls about half of them are very close to the limit of 1920 x 1080 which is around 90% of our clients
I have received a suggestion of running a Virtual Machine on the client computer with 100% scaling which is not affected by the host computer. It is probably my last resort as it's very difficult to handle dedicated video card through VM especially CAD card such as Quadro and FireGL.
Half the users use touch screen and we tried putting everything in a panel with 2 scrollbar and god it's awful and works once in a blue moon. So it's only good for mouse users and these users all have desktop AFAIK so 99% of them doesn't use scaling so they don't have the issue.
So is there anything nowadays that can fix or work around this issue ?
Did you try making your Process DPI aware?
You can either do it through a pinvoke:
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
and call
SetProcessDPIAware();
in your Main or create a Manifest and add
<dpiAware>true</dpiAware>
There is a tutorial here.
Declearing it DPIAware should stop windows from scaling by its own.
I have build a UWP project in 12" tablet size (which I chose from options provided when I design the UI in designer)
However when I run the application, it is shown too big on my screen, my design could not shown completely on the screen.
For example, I have 2 buttons in my design form top to down, only the top one is shown but the below one is missing due to my screen is not big enough to show them. But my laptop screen is 15.6", and previously the program was run in another desktop with a 24" monitor and it shows correctly.
Is there anything I can do to change the resolution/scale of my application on the laptop screen? My laptop resolution is 1920x1080.
Thank you.
I think the resolution is 2160*1440 for 12" 150% scale, my laptop resolution is only 1920*1080, how do I change the resolution?
Windows automatically selects a scale factor for each display based on its DPI (dots-per-inch) and the viewing distance of the device. So that the scale factor is defined by the windows. Details please reference Effective pixels and scale factor.
Users can override the default value and by going to Settings >System> Display > Scale and layout settings page. You could change the scale to 100% for your laptop.
I have a Winforms application that is working correctly on various versions of windows and various resolutions. When the application runs on a Motion CL900 tablet, however, the layouts are completely messed up; mainly caused by panel controls that are perfectly sized on other computers now being too small and causing scrollbars. The Motion devices are running Windows 7 Professional.
I have read on a few posts on stackoverflow that Windows machines have a standard DPI of 96, but this device clearly isn't 96 DPI. Is the fact that this device is "non-standard" a result of it's screen or is it caused by a setting in it's OEM version of Windows 7? I have read that I must set AutoScalingDimensions for my form to reflect the DPI of the PC I am developing on. But how do I even know what DPI my machine/screen is that I am developing on?
I have the following in my designer file for the form that has the layout issues:
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
I would appreciate anyone who has had experience with working with Winforms at various DPI resolutions shedding some light on this question, and maybe give some guidelines for .Net developers how to successfully handle non-standard DPIs.
There's indeed two different uses of the term here:
The display device's native resolution. This is actually how many pixels are within 2.54 cm. Larger values mean obviously a clearer, but smaller picture overall.
The OS' scaling of fonts and widgets. 96 dpi is the "native" size for Windows for example. That is, if you have a display that also has 96 dpi, then the controls are the size they should be when you look at them. Also point sizes for fonts are exactly the right size, then. If you have a display with, say, 120 dpi and set the OS to that measure too and then put both side by side you could measure with a ruler and find widgets and fonts in both cases to be the same size.
Nowadays the second measure mostly controls widget size if your eyes are not capable of working with too small controls. And plenty of applications have problems displaying correctly if you change it, although it's far better since Vista.
Dot per inch are related to the monitor/video card/resolution and just means how many points (or pixels) are shown in the length unit (inch).
Clearly is not related to the OS because you can have same values in all OS (Windows, Linux, Mac)...
DPI is dots per inch and it is a setting you can set in your OS. However, it is a characteristic of the monitor.
Since you are on Windows 7, to change DPI settings, you would want to do:
Control Panel
Appearance and Personalization
Display
Set Custom Text Size (DPI) - (on side bar)
Just change it till you get to 96 DPI (100% usually).
Windows 7 has an option in the Display properties called "Set custom text size (DPI)" if this is set to more than 100% it can impact how elements appear in an application, and can cause layout problems. I'd recommend keeping this at 100%, which is 96 DPI in Windows terms.
Note: the actual DPI resolution is determined by your monitor.