none
How to use the System.Drawing.Design.ColorEditor class properly?

    Question

  • The System.Drawing.Design.ColorEditor class is very unclear.

    I don't understand and I don't figure out how to use the System.Drawing.Design.ColorEditor class properly and Google doesn't give me any minimal, simple, easy and clear example C# code that demonstrates the proper usage of System.Drawing.Design.ColorEditor class.

    All what I need is a minimal, simple, easy and clear example C# code that demonstrates the proper usage of System.Drawing.Design.ColorEditor class.

    This will be enough for me.

    Saturday, May 25, 2019 9:06 AM

Answers

  • I quickly debugged it and it works better for me by commenting this line :

    // MsgWaitForMultipleObjects(1, IntPtr.Zero, 1, 5, 0xff);

    with :
    ColorPicker cp = new ColorPicker();
    cp.Color = System.Drawing.Color.Cyan;
    cp.Location = new System.Drawing.Point(10, 10);
    cp.Name = "Test Color Picker";
    cp.Size = new System.Drawing.Size(200, 30);
    
    this.Controls.Add(cp);

    Saturday, May 25, 2019 2:18 PM

All replies

  • You can find samples from Google, like : ColorPicker.cs

    (Just for the idea because this one crashes on my OS (Windows 10) and I did not try to debug it)

    The operating system of my home computer is also Windows 10.

    I just created an empty project and in the Main method, I create an instance of System.Windows.Forms.Form class, an instance of ColorPicker class, set the Size property of the ColorPicker instance to new Size(100,100), add the ColorPicker instance to the Controls of the System.Windows.Forms.Form instance, call the ShowDialog method of the System.Windows.Forms.Form class and then run the code.

    What happens is that the window of the System.Windows.Forms.Form instance appears on the screen and also the ColorPicker instance shows a Black color.

    When I try to change this Black color to any other color, the application is freezing, but not crashing and also it slows down my home computer a lot and this takes down to stop the running of the application.

    This ColorPicker.cs is bad.

    Why do people upload and show bad code to the internet?

    Saturday, May 25, 2019 1:27 PM
  • I quickly debugged it and it works better for me by commenting this line :

    // MsgWaitForMultipleObjects(1, IntPtr.Zero, 1, 5, 0xff);

    I don't find this line anywhere in ColorPicker.cs.

    Where exactly did you find this line in ColorPicker.cs?

    Saturday, May 25, 2019 3:40 PM
  • Line 293  MsgWaitForMultipleObjects(1, IntPtr.Zero, 1, 5, 0xff);

    Thank you! I found it! I just commented this line and the ColorPicker control is working properly!

    I also commented the DllImport line and the extern line.

    Why did he/she wrote these lines at all?

    Saturday, May 25, 2019 4:04 PM