■ Form 클래스를 사용해 높은 DPI에서 흐릿하게 출력되는 것을 방지하는 방법을 보여준다.
※ 실제로 작동되지 않는 것 같으나 참고용 코드이다.
• 디자이너 모드에서 MainForm을 선택하고 AutoScaleMode 속성을 아래와 같이 설정한다.
▶ Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace TestProject { /// <summary> /// 프로그램 /// </summary> static class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Import ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 프로세스 DPI 인식 설정하기 - SetProcessDPIAware() /// <summary> /// 프로세스 DPI 인식 설정하기 /// </summary> /// <returns>처리 결과</returns> [DllImport("user32")] private static extern bool SetProcessDPIAware(); #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 프로그램 시작하기 - Main() /// <summary> /// 프로그램 시작하기 /// </summary> [STAThread] private static void Main() { if(Environment.OSVersion.Version.Major >= 6) { SetProcessDPIAware(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } #endregion } } |