Class ColorPicker

3DS Max Plug-In SDK

Class ColorPicker

See Also: Class HSVCallback, COLORREF - DWORD, Class IPoint2.

class ColorPicker : public InterfaceServer

Description:

This class allows a plug-in to create a modeless color picker dialog box.

 

Developers may also create a modal version of this dialog box. The function available below is defined for this purpose. Note that this is not a class method but a global function.

To use these APIs you need to #include "hsv.h".

 

Prototype:

int HSVDlg_Do(HWND hwndOwner, DWORD *lpc,IPoint2 *spos, HSVCallback *callBack, TCHAR *name);

Remarks:

This method puts up the modal HSV color picker dialog box. This dialog appears below:

image\dlgcsel.gif

Parameters:

HWND hwndOwner

Owner window handle.

DWORD *lpc

Pointer to color to be edited. See COLORREF.

IPoint2 *spos

The starting position of the upper left corner of the dialog window. This is set to the ending position when the user is done. You may pass NULL to get the default location.

HSVCallback *callBack

Callback object whose procs are called when the color changes. See Class HSVCallback.

TCHAR *name

The name of color being edited to appear in the title bar.

Return Value:

Returns TRUE if the user exists the dialog with OK, otherwise returns FALSE.

The following functions are also available

Prototype:

ColorPicker *CreateColorPicker(HWND hwndOwner, DWORD initColor,IPoint2* spos, HSVCallback *pcallback, TCHAR *name, int objClr=0);

Remarks:

Call this function to bring up the modeless color picker.

Parameters:

HWND hwndOwner

The owner window handle.

DWORD initColor

The initial color for the color picker.

IPoint2* spos

The initial screen position of the upper left corner. NULL may be passed for the default location.

HSVCallback *pcallback

The callback object to respond to color change events.

TCHAR *name

The title string in the dialog.

int objClr=0

A BOOLEAN used to indicate that the ColorPicker is being used to set the object color from the control panel. In all other cases, the default value of 0 should be used.

Return Value:

A pointer to a ColorPicker object.

Prototype:

void SetCPInitPos(IPoint2 &pos);

Remarks:

Establishes the color picker initial screen position.

Parameters:

IPoint2 &pos

The upper left corner screen coordinate for the color picker.

Prototype:

IPoint2 GetCPInitPos();

Remarks:

Retrieves the color picker initial screen position.

Return Value:

The screen coordinates of the color picker. This is the coordinate of the upper left corner.

Methods:

Prototype:

ColorPicker();

Remarks:

Constructor.

Prototype:

virtual ~ColorPicker();

Remarks:

Destructor.

Prototype:

virtual void ModifyColor(DWORD color)=0;

Remarks:

This method changes the current color in the color picker, but does not change the "reset" color.

Parameters:

DWORD color

The current color.

Prototype:

virtual void SetNewColor(DWORD color, TCHAR *name)=0;

Remarks:

Sets a new color as current in the dialog.

Parameters:

DWORD color

The color to set.

TCHAR *name

A new name to display in the title bar.

Prototype:

virtual DWORD GetColor()=0;

Remarks:

Returns the current color.

Prototype:

virtual IPoint2 GetPosition()=0;

Remarks:

Returns the screen position of the upper left corner of the dialog as a IPoint2.

Prototype:

virtual void Destroy()=0;

Remarks:

This is called when the parent is going away.

Prototype:

virtual void InstallNewCB(DWORD col, HSVCallback *pcb, TCHAR *name)=0;

Remarks:

This method is used to add a different callback, set a new initial color and update the title string.

Parameters:

DWORD col

The new initial color.

HSVCallback *pcb

The new callback.

TCHAR *name

The new title string.

Prototype:

virtual void RefreshUI();

Remarks:

This method is available in release 4.0 and later only.

This method is called when the display gamma changes.