LDialogColor::DoModalCustomizePalette
#include "ltwrappr.h"
virtual L_INT LDialogColor::DoModalCustomizePalette(hWndOwner)
HWND hWndOwner; |
/* handle of the window which owns the dialog */ |
Displays the Customize Palette dialog box. This dialog box allows you to create, save, load, or edit custom palettes.
Parameter |
Description |
hWndOwner |
Handle of the window which owns the dialog. |
Returns
SUCCESS_DLG_OK |
The "OK" button was pressed, and the dialog exited successfully. |
SUCCESS_DLG_CANCEL |
The "Cancel" button was pressed, and the dialog exited successfully. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
LDialogColor::SetCustomizePaletteParams must be called before using this function to set the initial values for the dialog. You can get the updated CUSTOMIZEPALETTEDLGPARAMS with the values entered by the user through the dialog by using LDialogColor::GetCustomizePaletteParams.
This dialog has the following fields:
The Palette List provides you with some standard palettes:
- System Colors This palette contains colors used by MS Windows when the screen mode is 256-colors.
- Netscape Palette This is the palette used by Netscape browsers.
- MSIE Palette This is the palette used by Microsoft Internet Explorer browsers.
- Gray Scale Palette This palette contains 256 shades of gray (such as the shades found in a "black & white" photograph).
- Standard VGA Palette This is the palette used by VGA monitors.
- Uniform Palette This palette contains a set of colors uniformly distributed across the set of all 16 million 24-bit colors.
If you pass a palette to the dialog the "Image Colors" item is added to the palette list to view the current colors in the passed palette.
The Left Pane of the Customize Palette dialog displays the colors that you can add to your palette. This pane is not editable and it has two modes of display; it either displays lists of individual colors (palettes), or continuous colors based on a particular color model. When displaying palettes, you can select multiple individual colors using the <Ctrl> key, and a range of consecutive colors using the <Shift> key.
The Right Pane of the Customize Palette displays the list of colors that you have chosen. (It is empty until you begin to choose colors). After selecting a single color or a group of colors in the left pane, you can add them to your list of chosen colors in the right pane by clicking the Add button or by dragging them into the right pane. You can re-arrange the colors in the right pane by clicking and dragging them to their new position, or by using one of the pre-defined sort methods listed in the Sort drop-down list box.
The RGB components and corresponding HTML form of the currently selected color are displayed at the bottom of the dialog.
The Color Model button will list the color models available for the left pane and can switch the display mode in the left pane.
Clicking this button will activate a menu with the following options:
- Palette. This option is the default. Choosing this option will activate the Palette drop-down list box and display the available colors in the Left Pane.
- HSB-Hue Based Choosing this option will open the HSB-Hue Based Model in the Left Pane.
- HSB-Wheel Based Choosing this option will open the HSB-Wheel Based Model in the Left Pane.
- HSB-Brightness Based Choosing this option will open the HSB-Brightness Based Model in the Left Pane.
- RGB-3D Additive Choosing this option will open the RGB-3D Additive Model in the Left Pane.
- CMY-3D Subtractive Choosing this option will open the CMY-3D Subtractive Model in the Left Pane.
- CMYK-3D Subtractive Choosing this option will open the CMYK-3D Subtractive Model in the Left Pane.
- Lab-Device Independent Choosing this option will open the Lab-Device Independent Model in the Left Pane.
The Replace button replaces a number of selected items in the Right pane with the same number and order of selected items from the Left pane.
The Add button adds an item or a group of items selected in the Left pane into the Right pane. Items can also be added from the Left pane to the Right pane by dragging them. Notice that the mouse cursor changes into a hand when dragging item(s). If the cursor is not in a valid insert area, the cursor will turn into .
The Add Options button (the down arrow button to the right of the Add button) activates a menu that contains options indicating where those items should be added. The default is "At the end". The options included in this menu are as follows:
- At the End Add all insertions at the end of the list in the Right Pane.
- After Selected Add all insertions after the selected item. Notice that if no items are selected in the Right Pane the Add operation will fail and an error message will appear. This will also occur if more than one item is selected in the Right Pane.
- Before Selected Add all insertions before the selected item. Notice that if no items are selected in the Right Pane the Add operation will fail and an error message will appear. This will also occur if more than one item is selected in the Right Pane.
Notes: |
If "After Selected" or "Before Selected" is chosen, the add operation will only be performed if there is exactly one item selected in the right pane. |
|
"Add Options" is displayed only if the DLG_CUSTOMIZEPALETTE_SHOW_ADDOPTION flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure. |
The Remove button removes the selected item(s) from the Right Pane. Items can also be removed by dragging them out of the Right Pane. Notice that the mouse cursor changes into to indicate the item is about to be deleted.
The Remove Options button (the down arrow button to the right of the Remove button) activates a menu that allows you to set whether or not to be notified by a warning message when an item is about to be removed. The options included in this menu are as follows:
- Confirm When this option is checked a confirmation message will appear whenever you remove an item.
The Find Closest button highlights the item in the Right Pane that is the closest match to the item selected in the Left Pane. This button is displayed only if the DLG_CUSTOMIZEPALETTE_SHOW_FINDCLOSEST flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure.
The Sort button allows you to choose a method for sorting items in the right pane depending on their color components. Clicking the button will activate a menu with the following options:
- HSB Clicking this option will sort all items in the Right Pane according to their HSB color components.
- HUE Clicking this option will sort all items in the Right Pane according to the Hue value of their HSB color components.
- Saturation Clicking this option will sort all items in the Right Pane according to the Saturation value of their HSB color components.
- Brightness Clicking this option will sort all items in the Right Pane according to the Brightness value of their HSB color components.
- RGB Clicking this option will sort all items in the Right Pane according to their RGB color components.
- Reverse Clicking this option will invert the order of all items in the Right Pane.
Note: |
"Sort" is displayed only if DLG_CUSTOMIZEPALETTE_SHOW_SORT flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure. |
When you pass the DLG_CUSTOMIZEPALETTE_GENARATE_PALETTE flag, you can prompt the user to use the palette generated or not by using the DLG_CUSTOMIZEPALETTE_SHOW_APPLYPALETTEWHENEXIT flag which shows/hides the Apply When Exit checkbox.
Use the New button to empty the Right Pane. This button is displayed only if the DLG_CUSTOMIZEPALETTE_SHOW_NEW flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure.
Use the Open button to open a previously saved palette file; palette files have the extension "ltp". This button is displayed only if the DLG_CUSTOMIZEPALETTE_SHOW_OPEN flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure.
Use the Save button to save your palette. If you are starting a new file, the save command will prompt you for the file location and name. This button is displayed only if the DLG_CUSTOMIZEPALETTE_SHOW_SAVE flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure.
Use the Save as command to save a palette to a new filename. If you are starting a new file, the save command will prompt you for the file location and name. This button is displayed only if the DLG_CUSTOMIZEPALETTE_SHOW_SAVEAS flag is passed through the CUSTOMIZEPALETTEDLGPARAM structure.
Use the Close button to end the dialog. If there are changes unsaved on the Right Pane, a prompt message will appear.
Required DLLs and Libraries
LTDLGCLR For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
See Also
Functions: |
LDialogBase::Initialize, LDialogColor::DoModalColorRes, LBitmapBase::ColorRes, LBitmapBase::SetPalette, LBitmapBase::DupPalette, LBitmapBase::GetFixedPalette |
Topics: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example
L_INT LDialogColor_DoModalCustomizePaletteExample(LBitmap * pBitmap, HWND hWnd) { L_INT nRet; LDialogColor DlgColor; nRet = DlgColor.Initialize(DLG_INIT_COLOR ); if(nRet != SUCCESS) return nRet; DlgColor.SetBitmap(pBitmap); CUSTOMIZEPALETTEDLGPARAMS DlgParams ; memset ( &DlgParams, 0, sizeof ( CUSTOMIZEPALETTEDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( CUSTOMIZEPALETTEDLGPARAMS ) ; DlgParams.uDlgFlags = DLG_CUSTOMIZEPALETTE_SHOW_SORT | DLG_CUSTOMIZEPALETTE_SHOW_FINDCLOSEST | DLG_CUSTOMIZEPALETTE_SHOW_ADDOPTION | DLG_CUSTOMIZEPALETTE_SHOW_REMOVEOPTION | DLG_CUSTOMIZEPALETTE_SHOW_COLORMODEL | DLG_CUSTOMIZEPALETTE_SHOW_RGBLEFTPAN | DLG_CUSTOMIZEPALETTE_SHOW_HTMLLEFTPAN | DLG_CUSTOMIZEPALETTE_SHOW_INDEXLEFTPAN | DLG_CUSTOMIZEPALETTE_SHOW_RGBRIGHTPAN | DLG_CUSTOMIZEPALETTE_SHOW_HTMLRIGHTPAN | DLG_CUSTOMIZEPALETTE_SHOW_INDEXRIGHTPAN | DLG_CUSTOMIZEPALETTE_SHOW_NEW | DLG_CUSTOMIZEPALETTE_SHOW_OPEN | DLG_CUSTOMIZEPALETTE_SHOW_SAVE | DLG_CUSTOMIZEPALETTE_SHOW_SAVEAS | DLG_CUSTOMIZEPALETTE_GENERATE_PALETTE ; DlgColor.EnableCallBack (FALSE); DlgColor.EnablePreview(TRUE); DlgColor.EnableAutoProcess(TRUE); DlgColor.EnableToolbar(TRUE); nRet = DlgColor.SetCustomizePaletteParams(&DlgParams) ; if(nRet != SUCCESS) return nRet; nRet = DlgColor.DoModalCustomizePalette(hWnd); if(nRet < 1) return nRet; // Gets the updated values for the structure nRet = DlgColor.GetCustomizePaletteParams(&DlgParams, sizeof(DlgParams)) ; if(nRet != SUCCESS) return nRet; nRet = DlgColor.Free(); if(nRet != SUCCESS) return nRet; return nRet; }