Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color Picking Error in Windows 10 #12

Open
KaustubhPatange opened this issue Oct 31, 2017 · 8 comments
Open

Color Picking Error in Windows 10 #12

KaustubhPatange opened this issue Oct 31, 2017 · 8 comments
Labels

Comments

@KaustubhPatange
Copy link

Actually, I used your library for making a Color Picking basic application in C#. OK.. Works great in Windows 8,8.1,7. But now when I upgrade my PC to Win 10, the same application I made using your lib giving error in color picking, I mean when I point the picker to white color it gives me black color.. and such things.. is happening. Plzz help !

Thanks in Advance !

@cyotek
Copy link
Owner

cyotek commented Oct 31, 2017

You're going to have to provide more information.

Firstly, have you tested the demo program to see if you can reproduce the problem using that? If so, please provide the details on how to reproduce. If not, then check your application and see if there's any issues with that.

While I can't categorically state there are no bugs with the software in regards to Windows 10, I've been using them in my own applications on Windows 10 since it was originally released without any issues.

Regards;
Richard Moss

@KaustubhPatange
Copy link
Author

KaustubhPatange commented Nov 2, 2017

OK... I've clicked a video about my problem. Check it out and you will find out what I am trying to say.
Video is wrapped in .zip archieve coz, github is won't allowing mp4 to be upload directly.

Edit : (My Lappy config)

Windows 10
RAM 8GB
Graphics Amd R5 Series
Dell Inspiron 15 5000 series i7
(true color is enabled, tried using in disabled condition still same problem)

attach.zip

@cyotek
Copy link
Owner

cyotek commented Nov 2, 2017

Hello,

Thanks for providing the video, that demonstrates the issue quite nicely. You are correct in that this is a bug - your new system is using display scaling but the ScreenColorPicker doesn't understand this and is treating it as unscaled, hence it picking up the wrong color. I haven't noticed as I generally disable display scaling as I can't abide the awful blurriness of much older applications.

I'll take a look at getting this resolved, but I wonder if there is a workaround - try modifying the demonstration program to add a manfiest which states it supports high DPI. For example

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <assemblyIdentity version="1.0.0.0" name="cyowcopy.app" />
  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true/PM</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the 
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            Specifying requestedExecutionLevel node will disable file and registry virtualization.
            If you want to utilize File and Registry Virtualization for backward 
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- Windows 10 -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
      <!-- Windows 8.1 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
      <!-- Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
      <!-- Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
      <!-- Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
    </application>
  </compatibility>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
    </dependentAssembly>
  </dependency>
</asmv1:assembly>

If this doesn't make sense, I'll take a look at it myself but it may not be until the weekend.

@cyotek cyotek added the bug label Nov 2, 2017
@KaustubhPatange
Copy link
Author

KaustubhPatange commented Nov 2, 2017

Alright i'll try to modify manifest as u said

Edit : Can u tell me how to change my display settings to unscaled as u said... For urs it worked!

@cyotek
Copy link
Owner

cyotek commented Nov 3, 2017

Hello,

I tested the demonstration program on a Surface Pro 2 which has display scaling set to 150%. Without the manifest, I was able to reproduce the bug you've reported. With the manifest, the bug was resolved. So if you can add a manifest to your application then this might be a good approach to resolve the issue. (It might not be suitable in all cases, for example the main menu of the demonstration program is laid out incorrectly in high DPI with the manifest).

I'll see if I can get this fixed though so it'll work as expected regardless of display scaling.

As for turning it off, it's probably a good idea to leave it enabled for devices like tablets or laptops especially if they are touch based. But to disable it you can right click the Desktop, choose Display Settings and then configure the options in Scale and layout.

Regards;
Richard Moss

@KaustubhPatange
Copy link
Author

Okay..I will !

@KaustubhPatange
Copy link
Author

Hey Thanks, Your Solution Works well. Also in accordance to it, we have to set dpiAware in program.cs also.

Final code looks like this :

using System;
using System.Windows.Forms;

namespace Cyotek.Windows.Forms.ColorPicker.Demo
{
  // Cyotek Color Picker controls library
  // Copyright © 2013-2015 Cyotek Ltd.
  // http://cyotek.com/blog/tag/colorpicker

  // Licensed under the MIT License. See license.txt for the full text.

  // If you use this code in your applications, donations or attribution are welcome

  internal static class Program
  {
    #region Static Methods

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    private static void Main()
        {
            int gt1 = Environment.OSVersion.Version.Major;
            if (gt1 >= 6)
                SetProcessDPIAware();
            Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      Application.Run(new MainForm());
    }
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool SetProcessDPIAware();
        #endregion
    }
}

@UweKeim
Copy link

UweKeim commented Mar 22, 2021

For me, this is not a valid solution, as we intentionally do not want/can our application to be DPI aware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants