#include "l_bitmap.h"
L_LTDLG_API L_INT L_DlgCustomizePalette(hWndOwner, pDlgParams)
Displays the Customize Palette dialog box. This dialog box allows you to create, save, load, or edit custom palettes.
Handle of the window which owns the dialog.
Pointer to a CUSTOMIZEPALETTEDLGPARAMS structure to be updated with the values entered by the user, through the dialog. Set members of this structure, before calling this function, to set the dialogs initial values.
Value | Meaning |
---|---|
SUCCESS_DLG_OK | The "OK" button was pressed, and the dialog exited successfully. |
SUCCESS_DLG_CLOSE | The dialog exits successfully after pressing the "Close" button. |
SUCCESS_DLG_CANCEL | The "Cancel" button was pressed, and the dialog exited successfully. |
< 1 | An error occurred. Refer to Return Codes. |
This dialog has the following fields:
The Palette List provides you with some standard palettes:
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:
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
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:
✎ NOTE
- 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 CUSTOMIZEPALETTEDLGPARM 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
The Remove Options button (the down arrow button to the right of the Remove button) activates a menu that allows you to set whether to be notified by a warning message when an item is about to be removed. The options included in this menu are as follows:
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 CUSTOMIZEPALETTEDLGPARM 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:
✎ NOTE
"Sort" is displayed only if DLG_CUSTOMIZEPALETTE_SHOW_SORT flag is passed through the CUSTOMIZEPALETTEDLGPARM structure.
When you pass the DLG_CUSTOMIZEPALETTE_GENERATE_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 CUSTOMIZEPALETTEDLGPARM 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 CUSTOMIZEPALETTEDLGPARM 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 CUSTOMIZEPALETTEDLGPARM 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 CUSTOMIZEPALETTEDLGPARM 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
L_INT ShowDlgCustomizePaletteExample(HWND hWnd)
{
L_INT nRet;
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 ;
nRet = L_DlgInit ( DLG_INIT_COLOR ) ;
if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED)
return nRet;
nRet = L_DlgCustomizePalette ( hWnd, &DlgParams ) ;
if(nRet < 1)
return nRet;
nRet = L_DlgFree () ;
if(nRet != SUCCESS)
return nRet;
return SUCCESS;
}