0

I'm programming a simple Winforms program which uses a browse button that allows a user to select a file using OpenFileDialog() however the file explorer that is shown is highly pixelated/low in resolution. Looking through the OpenFileDialog properties yielded nothing that could help except a possible property called AutoUpgradeEnabled however this seemed to do nothing to the resolution.

The problem is not major however it makes the program look less professional and as I have seen similar browsing functions working with better resolution on other programs, I know that it is possible to provide a explorer option with higher resolution (however this may be with other programming languages).

The current code I'm using to get the file name is as follows:

public static string GetFile(string path) {
    OpenFileDialog fileExplorer = new OpenFileDialog();
    fileExplorer.Multiselect = false;
    fileExplorer.InitialDirectory = path;
    if (fileExplorer.ShowDialog() == DialogResult.OK) {
        return fileExplorer.SafeFileName;
    }
}

The screen on which I am viewing this has a high DPI with a 1980x1080p screen and I am currently on a Windows 10 Machine - Update 1809.

A picture showing the clear contrast between standard (right) and the Winforms version (left)

Ciaran
  • 35
  • 1
  • 5
  • 1
    https://stackoverflow.com/questions/13228185/how-to-configure-an-app-to-run-correctly-on-a-machine-with-a-high-dpi-setting-e – Hans Passant Sep 23 '19 at 15:55
  • 1
    It might be helpful to see a screesnhot of this – Martin Sep 23 '19 at 15:56
  • The OpenFileDialog class usually just wraps around the Open File Dialog provided by Windows. So there is very little in the way of modificaiton you can do. – Christopher Sep 23 '19 at 16:07

1 Answers1

0

As seen in the posted answer found here, the solution can improve resolution of the winforms process, significantly improving the program look overall

The solution worked and was to make the main Program code similar to the following:

static class Program 
{
    [STAThread]
    static void Main()
    {
        if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern bool SetProcessDPIAware();
}
Ciaran
  • 35
  • 1
  • 5