Public Member Functions

IColorSwatch Class Reference

This reference page is linked to from the following overview topics: Methods and Classes of Custom Controls.


Search for all occurrences

Detailed Description

See also:
Class ICustomControl, Custom Controls, COLORREF.

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.

colorsw.gif
To initialize the pointer to the control call:
*GetIColorSwatch(HWND hCtrl, COLORREF col, MCHAR *name);

For example: custCSw = GetIColorSwatch(GetDlgItem(hDlg, IDC_CSWATCH), RGB(255,255,255), _M("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: 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.

#include <custcont.h>

Inheritance diagram for IColorSwatch:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual COLORREF  SetColor (COLORREF c, int notify=FALSE)=0
COLORREF  SetColor (Color c, int notify=FALSE)
virtual AColor  SetAColor (AColor c, int notify=FALSE)=0
virtual COLORREF  InitColor (COLORREF c, int notify=FALSE)=0
COLORREF  InitColor (Color c, int notify=FALSE)
virtual AColor  InitAColor (AColor c, int notify=FALSE)=0
virtual void  SetUseAlpha (BOOL onOff)=0
virtual BOOL  GetUseAlpha ()=0
virtual COLORREF  GetColor ()=0
virtual AColor  GetAColor ()=0
virtual void  ForceDitherMode (BOOL onOff)=0
virtual void  SetModal ()=0
virtual void  Activate (int onOff)=0
virtual void  EditThis (BOOL startNew=TRUE)=0
virtual void  SetKeyBrackets (BOOL onOff)=0
virtual void  SetNotifyAfterAccept (BOOL onOff)=0
virtual BOOL  GetNotifyAfterAccept ()=0

Member Function Documentation

virtual COLORREF SetColor ( COLORREF  c,
int  notify = FALSE 
) [pure virtual]
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.
Returns:
This method returns the old color.
COLORREF SetColor ( Color  c,
int  notify = FALSE 
) [inline]
{return SetColor(c.toRGB(), notify);}  // returns old color
virtual AColor SetAColor ( AColor  c,
int  notify = FALSE 
) [pure virtual]
virtual COLORREF InitColor ( COLORREF  c,
int  notify = FALSE 
) [pure virtual]
COLORREF InitColor ( Color  c,
int  notify = FALSE 
) [inline]
{return InitColor(c.toRGB(), notify);}  // returns old color
virtual AColor InitAColor ( AColor  c,
int  notify = FALSE 
) [pure virtual]
virtual void SetUseAlpha ( BOOL  onOff ) [pure virtual]
virtual BOOL GetUseAlpha ( ) [pure virtual]
virtual COLORREF GetColor ( ) [pure virtual]
Remarks:
This method may be used to retrieve the color selected by the user.
Returns:
The COLORREF structure returned may be broken down into individual RGB values by using the GetRValue(color), GetGValue(color), and GetBValue(color) macros.
virtual AColor GetAColor ( ) [pure virtual]
virtual void ForceDitherMode ( BOOL  onOff ) [pure virtual]
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.
virtual void SetModal ( ) [pure virtual]
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.
virtual void Activate ( int  onOff ) [pure virtual]
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.
virtual void EditThis ( BOOL  startNew = TRUE ) [pure virtual]
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.
virtual void SetKeyBrackets ( BOOL  onOff ) [pure virtual]
virtual void SetNotifyAfterAccept ( BOOL  onOff ) [pure virtual]
Remarks:
This method controls when change notifications are sent, while the color picker is open.
Parameters:
BOOL onOff

If you pass FALSE for this parameter, the dialog proc for the dialog will receive multiple CC_COLOR_CHANGE messages as the user makes changes interactively in the color picker. If you pass TRUE for this parameter, the dialog proc for the dialog will receive only one CC_COLOR_CHANGE message, when the color picker is closed, and only if the user clicks OK instead of Cancel.
virtual BOOL GetNotifyAfterAccept ( ) [pure virtual]
Remarks:
This methods indicates how change notifications are sent, while the color picker is open.
Returns:
FALSE indicates the dialog proc for the dialog receives multiple CC_COLOR_CHANGE messages as the user makes changes interactively in the color picker. TRUE indicates the dialog proc for the dialog receives only one CC_COLOR_CHANGE message, when the color picker is closed, and only if the user clicks OK instead of Cancel.

IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch
IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch IColorSwatch