» Back to Documentation

This is something that is frequently required when writing plugins. Max.NET has an interface called IColPick which can be used to create a new color picker dialog (available through IColorPicker interface). You can also pass a Plugins.HSVCallback- drived class to get lice updates as user edits the color.

Here is sample code demonstrating this:

void PickColor()
{

IGlobal global = GetMaxGlobal();
IColorPicker maxColorPicker =  global.CurColPick.CreateColorPicker( global.COREInterface.MAXHWnd,
                ToMaxAColor( currentValue ), global.IPoint2NS.Create( Cursor.Position.X, Cursor.Position.Y ), new HSVCallback(), "Pick a Color", false );

}

 

class HSVCallback : global::Autodesk.Max.Plugins.HSVCallback
{
            public override void BeingDestroyed( IIPoint2 pos )           
            {
                    // Do nothing
            }

            public override void ColorChanged( IAColor col, bool ButtonUp )
            {
                // Handle color changing, new color is in 'col'
                base.ColorChanged( col, ButtonUp );
            }

            public override void OnOK()
            {
                // Handle dialog being closed through OK
                base.OnOK();
            }

            public override void OnCancel()
            {
                // Handle dialog being closed through Cancel
                base.OnCancel();
            }
}