Class IColorSwatch

3DS Max Plug-In SDK

Class IColorSwatch

See Also: Class ICustomControl, Custom Controls, COLORREF.

class IColorSwatch : public ICustomControl

Description:

The color swatch control puts up the standard 3ds max modeless color selector when the control is clicked on. The plug-in may be notified as the user interactively selects new colors.

image\colorsw.gif

To initialize the pointer to the control call:

Prototype:

IColorSwatch *GetIColorSwatch(HWND hCtrl, COLORREF col, TCHAR *name);

For example:

custCSw = GetIColorSwatch(GetDlgItem(hDlg, IDC_CSWATCH),  RGB(255,255,255), _T("New Wireframe Color"));

This returns the pointer to the control, sets the initial color selected, and displays the text string passed in the title bar of the selection dialog.

To release the control call:

Prototype:

ReleaseIColorSwatch(IColowSwatch *ics);

The value to use in the Class field of the Custom Control Properties dialog is: ColorSwatch

This message is sent as the color is being adjusted in the ColorPicker.

CC_COLOR_CHANGE

lParam = pointer to ColorSwatchControl

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 1 if button UP, or 0 if mouse drag.

This message is sent if the color has been clicked on, before bringing up the color picker.

CC_COLOR_SEL

lParam contains a pointer to the ColorSwatch Control.

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 0.

This message is sent if another color swatch has been dragged and dropped on this swatch.

CC_COLOR_DROP

lParam contains a pointer to the ColorSwatch Control.

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 0.

 

This message is sent when the color picker is closed.

CC_COLOR_CLOSE

 

 lParam contains a pointer to the ColorSwatch Control.

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 0.

 

Methods:

Prototype:

virtual COLORREF SetColor(COLORREF c, int notify=FALSE)=0;

Remarks:

This method sets the current color value.

Parameters:

COLORREF c

You can pass specific RGB values in using the RGB macro. For example, to pass in pure blue you would use RGB(0,0,255).

int notify=FALSE

If you pass TRUE for this parameter, the dialog proc for the dialog will receive the CC_COLOR_CHANGE message each time the color is changed.

Return Value:

This method returns the old color.

Prototype:

virtual COLORREF GetColor()=0;

Remarks:

This method may be used to retrieve the color selected by the user.

Return Value:

The COLORREF structure returned may be broken down into individual RGB values by using the GetRValue(color), GetGValue(color), and GetBValue(color) macros.

Prototype:

virtual void ForceDitherMode(BOOL onOff)=0;

Remarks:

This method sets if the color shown in the color swatch is dithered on not.

Parameters:

BOOL onOff

TRUE to force the color to be dithered; otherwise FALSE.

Prototype:

virtual void SetModal()=0;

Remarks:

Call this method to have the color selector comes up in a modal dialog. This forces the user to select OK before the user may operate the rest of the program.

Prototype:

virtual void Activate(int onOff)=0;

Remarks:

This method is called to indicate that the color swatch is in a dialog that has been become active or inactive. A color swatch that is in an inactive dialog will be drawn as dithered due to the limited number of color registers available on an 8-bit display.

Parameters:

int onOff

If TRUE the color swatch is in an active dialog. If FALSE the control is in an inactive dialog.

Prototype:

virtual void EditThis(BOOL startNew=TRUE)=0;

Remarks:

If there is already a color picker up for a color swatch, this method switches it over to edit the color swatch on which EditThis() was called.

Parameters:

BOOL startNew=TRUE

If there was no color picker up, if this parameter is set to TRUE, then a color picker is created. If this parameter is set to FALSE, and there was no color picker up, then nothing happens.