none
Fix monitor resolution. RRS feed

  • Question

  • Hi everyone, I'm trying WES7 to run on top of it a multi-monitor application.

    With WES2009 and FBWF, after resealing, fix all monitor's resolution to 1024x768 and enabling FBWF, when a user connects monitors their resolution remain fixed to 1024x768, unregarding of their singolar native resolution. With the same configuration in WES 7, when a user connect monitors their resolution switches to the reccomended resolution for it and my application doesn't function correctly. I've set the TMM key to 0 in registry (HKLM\Software\Microsoft\TMM) and this resolves but, if monitor's brand/types changes, all return to reccomended resolutions. Is there a way to fix it?

    Thanks in advance, Andrea Valori.

    Monday, May 19, 2014 3:28 PM

All replies

  • Maybe running a utility like this one: http://www.nirsoft.net/utils/multi_monitor_tool.html when the application starts might fix the resolution each and every time.

    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WE8S, Pro Guide to WES 7, Pro Guide to POS for .NET

    Monday, May 19, 2014 11:43 PM
    Moderator
  • Hi Sean, that tool works perfect for me. After fixing resolution, another problem arises: the WES 7 default screen scaling is set to 'mantain aspect ratio' so monitors in some cases have black blocks on screen to fit screen. After some investigations with ProcessMonitor from technet/sysinternals and the Intel video driver, I found keys in registry interested by that; so with a self written little console program in .NET first I change the scaling parameter to 3 (fit to full screen), after I run this tool to rearrange resolution and all is done. If someone wants the code please request here.

    Thanks again, Andrea Valori.

    Saturday, May 24, 2014 6:43 AM
  • is the code something you can post here?

    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WE8S, Pro Guide to WES 7, Pro Guide to POS for .NET

    Sunday, May 25, 2014 7:49 PM
    Moderator
  • Hi Sean, below the code. Please note the project is a Console application. Best regards, Andrea Valori.

    using System;
    using System.Collections.Generic;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Microsoft.Win32.RegistryKey keyStart = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\");
                string searchValue = "Scaling";
                IEnumerable<Microsoft.Win32.RegistryKey> subKeys = GetSubKeys(keyStart);
                foreach (var item in subKeys)
                {
                    //4 means 'Mantain aspect ratio', 3 means 'Scale to full screen'.
                    if (Microsoft.Win32.Registry.GetValue(item.Name, searchValue, null) != null)
                        Microsoft.Win32.Registry.SetValue(item.Name, searchValue, 3, Microsoft.Win32.RegistryValueKind.DWord);
                }
            }

            /// <summary>
            /// Given a registry key, get a list of child sub-keys. This function recursively calls itself.
            /// </summary>
            /// <param name="keyParentArg">A registry key</param>
            /// <returns>An IEnumerable List of subkeys under the keyParentArg.</returns>
            static IEnumerable<Microsoft.Win32.RegistryKey> GetSubKeys(Microsoft.Win32.RegistryKey keyParentArg)
            {
                List<Microsoft.Win32.RegistryKey> keysFound = new List<Microsoft.Win32.RegistryKey>();
                try
                {
                    if (keyParentArg.SubKeyCount > 0)
                    {
                        foreach (string strKeyChild in keyParentArg.GetSubKeyNames())
                        {
                            try
                            {
                                Microsoft.Win32.RegistryKey keyChild = keyParentArg.OpenSubKey(strKeyChild);
                                if (keyChild != null)
                                {
                                    keysFound.Add(keyChild);
                                    IEnumerable<Microsoft.Win32.RegistryKey> keyGrandChildren = GetSubKeys(keyChild);
                                    if (keyGrandChildren != null)
                                    {
                                        keysFound.AddRange(keyGrandChildren);
                                    }
                                    else
                                    {
                                        System.Diagnostics.Debug.Assert(false);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                //useful for debug purposes.
                                System.Diagnostics.Debug.WriteLine(ex.Message + Environment.NewLine + " failed trying " + strKeyChild + " in " + keyParentArg);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //useful for debug purposes.
                    System.Diagnostics.Debug.WriteLine(ex.Message + Environment.NewLine + " failed trying " + keyParentArg);
                }
                return keysFound;
            }
        }
    }

    Tuesday, May 27, 2014 1:14 PM
  • Is there an option within the graphics card manufacture settings to fix the resolution so it does not change each time ? I know that some graphics card manufactures support this.
    Tuesday, May 27, 2014 1:39 PM
  • I think depends on how the card manufacturer implements drivers. By my knowledge, another tedious problem is  that when display is unplugged, the video in display settings goes to disabled. Some video cards, like Matrox Parelia or VideoUfo, mantain resolution and video on fixed, regardless of monitor informations.
    Wednesday, May 28, 2014 8:18 AM