3

So I've been coding a program for a little over a month now, and I've encountered a problem that I have no idea how to tackle. For a while now, I've always been confused when I opened up my program on other computer, and my window size was different. I chalked it up to a different resolution, and figured the problem would be easy to solve later. Then I imported a custom font to my program, and was confused when I noticed the letters where not clear and where blurry. I figured that this was something caused by my specified font size that I was using, and left it as is. Today however, as I was doing some testing I was annoyed by the blurry text enough to go and search online for the problem and solution, only to find out my problem lay within my DPI settings (125% on the computer I had mostly programmed on.)

I have no idea what I can do about this. I started programming a little while ago, and it was hard enough figuring out how to get the custom text working, but I just have no idea where to take this.

I've been coding this program in Visual Studio C# 2010 since it's the only version I've got that won't expire, so I can't use anything that might be in the 2011 or 2012 version.

All I want is for objects to be on the same place on one computer as another with a different DPI. Is there a very simple step-by-step tutorial somewhere that I can read or watch to figure this out?

  • Hmm, no, blurry text occurs when the operating system takes over the scaling instead of leaving it up to the app. That happens at values *larger* than 125%. Custom fonts rarely have good hinting, tend to not support ClearType and only look good at large point sizes. Avoid freeware, a good font from a reputable type foundry costs money. – Hans Passant Mar 17 '14 at 18:23
  • Related: http://stackoverflow.com/questions/22735174/how-to-write-winforms-code-that-auto-scales-to-system-font-and-dpi-settings – Denise Skidmore Jul 10 '14 at 22:11
  • 1
    For some newer tooling, Visual Studio Community 2013 is free: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx – Sami Kuhmonen Apr 21 '15 at 08:14

1 Answers1

2

This code snipshet worked perfectly for me.

http://urenjoy.blogspot.it/2008/11/make-resolution-independent-windows-app.html

(Using Visual Studio Express 2013)

It is required that windows app should have same layout at different resolutions means there should be no effect on layout of app on changing resolution. Here are the steps to do this.

  • Use table layout panel
  • Drag control in cell of tablelayoutpanel and set anchor and dock property.
  • Set rowspan and colspan properties of dragged control to merge cells
  • Set margin and padding of dragged control with respect to cell.
  • drag all controls and follow same steps, complete design using tablelayoutpanel
  • Now set all columns and rows size of tablelayoutpanel = autosize (or in %)
  • Set tablelayoutpanel properties autosize = true,autosizemode = grow and shrink
  • Set Forms properties autosize = true,autosizemode = grow and shrink
  • Run windows app If your windows app opens in maximum state then set tablelayoutpanel dock property =fill.
luca76
  • 813
  • 1
  • 10
  • 20