The Color Dialog Object
By Matt Galanto

Index

Disclaimer

The author of this extension makes no claims concerning the fitness of this extension for any purpose whatsoever, and makes no gurantees, written or implied, of its level of security and safety to authors or to end users in any respect. You agree to use this extension at your own risk and to hold the author harmless in any event.

The Basics

The Color Dialog Object allows you to use the standard Windows color dialog. This dialog allows users to select from a list of specific colors or allows them to create custom colors. Additionally, this object allows you to convert among various color representations.

Conditions

Dialog is Closed by OK
This condition will return true if the color dialog is closed by the OK button. Events with this condition will be executed as soon as the dialog is closed.

Dialog is Closed by Cancel
This condition will return true if the color dialog is closed by the Cancel button or by otherwise closing the dialog without OK. Events with this condition will be executed as soon as the dialog is closed.

Has an Error Occurred?
This condition will return true if an error has occured in an action or in a condition. Events with this condition will be executed as soon as an error occurs in the object. The error code for the error will only be available to events with this condition. For getting errors in expressions, use the 'Get Expression Error Code' expression.

Actions

Open the Color Dialog
This action opens the color dialog at the position at which it was last closed.

Open the Color Dialog at Position
This action opens the color dialog at the specified position. The position is relative to the top-left corner of the monitor display, not the top-left corner of the frame.

Set Selected Color by RGB
This action sets the selected to color to the specified color, given by its RGB values. The selected color is the color selected in the color dialog.

Set Selected Color by Color Reference
This action sets the selected to color to the specified color, given by its color reference. The selected color is the color selected in the color dialog.

Set Dialog Window's Title
This action sets the title of the color dialog window to the specified text.

Restore Custom Colors on Cancel
This action sets this option to the specified state. State 0 means this option is disabled. Otherwise, it is enabled. When this option is enabled, changes to custom colors made by the user are not saved when the dialog is closed by cancel. This is contrary to the Windows standard functioning of the color dialog.

Dialog Fully Open by Default
This action sets this option to the specified state. State 0 means this option is disabled. Otherwise, it is enabled. When this option is enabled, the color dialog is fully open when the color dialog is opened. A fully opened dialog cannot be shrunk by the user.

Cannot Fully Open Dialog
This action sets this option to the specified state. State 0 means this option is disabled. Otherwise, it is enabled. When this option is enabled, the color dialog cannot be fully opened by the user, preventing them from editing the custom colors.

Round to Solid Colors (256 color mode)
This action sets this option to the specified state. State 0 means this option is disabled. Otherwise, it is enabled. When this option is enabled, colors not native to 256 color mode are rounded to the nearest native color. If it is disabled, non-native colors are simulated.

Set a Custom Color by RGB
This action sets the specified custom color to the specified color, given by its RGB values. The custom color is specified by its index, which may range from 1 to 16.

Set a Custom Color by Color Reference
This action sets the specified custom color to the specified color, given by its color reference. The custom color is specified by its index, which may range from 1 to 16.

Back-up Current Custom Colors
This action stores the current custom colors so that they can be restored later.

Restore Current Custom Colors
This action restores the custom colors last backed-up.

Clear Expression Error Code
This action sets the current expression error code to 0.

Expressions

Get Selected Color
SelectedColor("Color Dialog")
This expression returns the color reference of the selected color. The selected color is the color selected in the color dialog.

Get a Custom Color
CustomColor("Color Dialog",Index)
This expression returns the color reference of the specified custom color. Index specifies the custom color. It must range from 1 to 16.

Get Last State of Dialog Openness
DialogLastOpen("Color Dialog")
This expression returns 0 if the dialog was not fully open when the color dialog was last closed. It returns 1 if the dialog was fully open when the color dialog was last closed

Get Dialog Window's Title
DialogTitle$("Color Dialog")
This expression returns the current title of the color dialog window.

Get State of 'Restore Custom Colors on Cancel'
RestoreState("Color Dialog")
This expression returns 0 if the option is disabled. It returns 1 if it is enabled.

Get State of 'Dialog Fully Open by Default'
FullOpenState("Color Dialog")
This expression returns 0 if the option is disabled. It returns 1 if it is enabled.

Get State of 'Cannot Fully Open Dialog'
NoFullOpenState("Color Dialog")
This expression returns 0 if the option is disabled. It returns 1 if it is enabled.

Get State of 'Round to Solid Colors (256 color mode)'
SolidColorsState("Color Dialog")
This expression returns 0 if the option is disabled. It returns 1 if it is enabled.

Convert RGB values to Color Reference
RGBToRef("Color Dialog",Red,Green,Blue)
This expression returns color reference of the color described by Red, Green, and Blue.

Get Red Value from Color Reference
RefToRed("Color Dialog",Reference)
This expression returns the red value of Reference.

Get Green Value from Color Reference
RefToGreen("Color Dialog",Reference)
This expression returns the green value of Reference.

Get Blue Value from Color Reference
RefToBlue("Color Dialog",Reference)
This expression returns the blue value of Reference.

Get Name of Color from Color Reference
RefToName$("Color Dialog",Reference)
This expression returns the name of the color specified by Reference. If the specified color does not have a name, the expressions returns "".
Color Names List

Get Color Reference from Name of Color
NameToRef("Color Dialog",Name)
This expression returns the reference of the color specified by Name. If Name is not a color, the expressions returns -1.
Color Names List

Convert Color Reference to Hex String
RefToHex$("Color Dialog",Reference)
This expression returns the hex string of the color specified by Reference. A hex string has the form ######, where the first two digits are the hexadecimal code for the red value, the next two for the green value, and the third two for the blue value.

Convert Hex String to Color Reference
HexToRef("Color Dialog",HexString)
This expression returns the color reference of the color specified by HexString. A hex string has the form ######, where the first two digits are the hexadecimal code for the red value, the next two for the green value, and the third two for the blue value.

Get Name of Color from RGB Values
RGBToName$("Color Dialog",Red,Green,Blue)
This expression returns the name of the color specified by Red, Green, and Blue. If the specified color does not have a name, the expressions returns "".
Color Names List

Convert RGB values to Hex String
RGBToHex$("Color Dialog",Red,Green,Blue)
This expression returns the hex string of the color specified by Red, Green, and Blue. A hex string has the form ######, where the first two digits are the hexadecimal code for the red value, the next two for the green value, and the third two for the blue value.

Get Red Value from Hex String
HexToRed("Color Dialog",HexString)
This expression returns the red value of the color specified by HexString. A hex string has the form ######, where the first two digits are the hexadecimal code for the red value, the next two for the green value, and the third two for the blue value.

Get Green Value from Hex String
HexToGreen("Color Dialog",HexString)
This expression returns the green value of the color specified by HexString. A hex string has the form ######, where the first two digits are the hexadecimal code for the red value, the next two for the green value, and the third two for the blue value.

Get Blue Value from Hex String
HexToBlue("Color Dialog",HexString)
This expression returns the blue value of the color specified by HexString. A hex string has the form ######, where the first two digits are the hexadecimal code for the red value, the next two for the green value, and the third two for the blue value.

Get Error Code
Error("Color Dialog")
This expression returns the current error code resulting from an error in an action or condition, which is only meaningful when the event has an "Has an Error Occurred?" condition.
Error Codes:
0: No errors
1: Invalid custom color index

Get Expression Error Code
ExpressionError("Color Dialog")
This expression returns the current error code resulting from an error in an expression. The same codes apply here as above.