Windows App Resolution - c#

I have a windows app that runs correctly in my PC that is 96DPI but when I use it on a PC that has 120DPI the forms transform and all their components scramble.
How can I fix this?
Thanks.

It sounds like you need to use dynamic layout in your forms. You can use AutoSize, Docking/Anchoring, Padding, Margin, TableLayoutPanel, FlowLayoutPanel, etc, to structure your form so the actual positioning of your controls is done at run-time instead of compile-time. That way, your form will retain its layout even when the DPI is different. "Programming Microsoft Windows Forms" by Charles Petzold is a good book on Windows Forms. Chapter 3 of that book is full of information about how to use dynamic layout.

if you mean you have the source for the application (development question) you can check the DPI setting of the display the application is running on and re-format your interface as needed depending on the resolution.
If you mean that you have a compiled application from somewhere else and you don't have the source code for it you can set your resolution to 96 DPI.
Hope that helps.

Related

alignment is not getting proper in different resolution

i am working on visual studio 2010.
i created my master form windows state is Maximized
my system resolution is 1366X768 ,,in one button click i am calling 5 forms together into my master form.. but in my system everything getting correct..
but i installed the same application in my client system,,that system resolution is 1024X768
but here my alignment is not getting proper..now my image is getting like this:
so how i can fit my windows form application in all resolution,,if any one know please help me to find out
You basically have two options:
1) Follow Microsoft's instruction on implementing auotscaling for Windows forms applications. (See http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx)
2) Write your own code to scale the form based on resolution.
============================
Other factors to keep in mind.
If you app is translatable that can affect scaling
A user changing the Windows default font size can have the same affect.
Hope this helps.

UI Changes Size When Installed on Another Computer

I've had a reoccurring issue with my programs' UI: they look fine in design mode and when run on my computer but look different/incorrect (e.g. squished, overlapped controls) when run on other computers.
Any idea what this could be? At first I thought it might be a 32/64-bit issue but it wasn't.
Thanks!
Users can set their text size to be larger than normal, or choose a different font for controls.
Differing DPI settings can affect how things get laid out.
This can potentially be down to several issues.
DPI. Affects the layout of form controls (Thanks to Kristopher Johnson for this one!)
Theme. (Classic, Aero, Luna)...generally speaking Microsoft themes will not have much affect from one to another and neither will well designed custom themes, but badly designed custom themes will suffer. Again as described by Kristopher Johnson, Font size settings in the theme will impact how the form renders. - Consideration: lets say you run your app on a Linux installation of Mono...will it still look the same?
Fonts. If your application uses a font that the other machine does not have, then that machine will substitute it for another "fallback" font. This can have an effect in some controls, for example a label, where the width of the label scales to the width of the text of the given font.
There is a problem with Resolution.
Your machine has a different resolution than other machine, try to make design for resolution 1024X768

Displaced controls in windows forms .net framework

I have a strange problem. I have designed a windows form application in c# and .net framework 3.5. In the runtime, the form and its controls are fine in all the computers except my laptop, where the controls are not in the correct positions.
If I design the form from scratch on my laptop with correct positioning it will result in an invalid shape for other computers.
My efforts:
If I run the windows in Safe Mode the form size and control positions
are correct.
I have uninstalled the Video Driver and used default windows version but the problem still persists.
I used different frameworks like 2.0 and 4.0, and different Visual Studios versions and they all have the same problems.
Actually all the .net framework product from all the companies indicate the same issue.
My computer Settings:
Laptop 1557 Studio DELL
Graphic ATI Radeon HD 4500
When the text size is artificially increased to 125% text and controls that are rather closely placed will wrap around the form and push everything down/over. If this is something you intend to support, you'll simply have to redesign your form to handle the different enlargement levels you care to support and test those enlarged text modes in your app until you're satisfied with their appearance. It's not something you can strictly control, since increased text size is an accessibility feature.
I assume it is due to a screen resolution differences. I believe that the actual location of the controls is identical in both cases, in one the screen is "larger" and therefor your controls appear in a different position on the screen.
try Designing forms to work on different resolutions and aspect ratios on Windows CE
Another thing you can (and should) do is work with WPF, which is the new way to build user interfaces for windows.
I've found a workaround just now.
In the display settings of Windows 7 I have changed the Text size from 125% to 100%. Everything is smaller but in accurate positions and sizes.
Still wondering how it works!!

how to give size of a control in window mobile app

how to give size of a control in window mobile app dynamically,because i have developed one application,when i used to run that application on different emulator's ,the size of that control's in that application differ's for different emulator.so could u plz help me that how we can handle such issue in windows mobile application in which iam using visual studio 2008 and windows mobile6 classical emulator
Your question is a bit ambiguous, but I'll take a stab at it.
Apparent control size (how big it looks to your eye) if affected byt a few things. The obvious are things like Dock and Achor properties, which are well documented online and are the same as for the desktop. What is less obvious is scaling. Some PDAs have a 240x320 display, while others may have 480x640 yet with the same physical dimension screen.
The platform can attempt to have your single Form code work for both by doing "pixel doubling" which essentially just doubles all of your size values. This tends to end up with graininess and I think it was turned off by default starting with WinMo 6.
To adjust this behavior, you can adjust your Form's AutoScaleMode property.

How to set the screen resolution dynamically in Asp.Net application with C# as language

How to set the screen resolution dynamically in Asp.Net application with C# as language
I have created an asp.net app on my machine where the resolution is
set to 1280 x 1024. When my users view the form on their screen, some
of the controls display differently than on my screen. One solution I
have is to use some javascript to determine the resolution of their
screen and redirect them to a duplicate form suited better for their
resolution but I would have to maintain multiple forms. Anybody know
of a better way to handle resolution problems in asp.net? Thanks in
advance
Use CSS and percentage-based widths
You can't set the screen resolution from a web app. A web app runs inside a browser, and it doesn't have access to the client OS functions.
Your best bet is to target a minimum screen resolution, and program your form layout for that.
1024x768 is a safe bet for minimum resolution these days.

Categories