LDialogColor::DoModalCustomizePalette

#include "ltwrappr.h"

virtual L_INT LDialogColor::DoModalCustomizePalette(hWndOwner)

Displays the Customize Palette dialog box. This dialog box allows you to create, save, load, or edit custom palettes.

Parameters

HWND hWndOwner

Handle of the window which owns the dialog.

Returns

Value Meaning
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.

The Customize Palette dialog.

This dialog has the following fields:

Palettes List:

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.

Left Pane:

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.

Right Pane:

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.

Color Value Display:

The RGB components and corresponding HTML form of the currently selected color are displayed at the bottom of the dialog.

Color Model Button:

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:

Replace Button:

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.

Add and Add Options:

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 image\HandClosed.gif when dragging item(s). If the cursor is not in a valid insert area, the cursor will turn into image\PalEdit_Stop.gif.

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 CUSTOMIZEPALETTEDLGPARAM structure.

Remove and Remove Options:

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 image\PalEdit_Trash.gif 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:

Find Closest Button:

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.

Sort:

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 CUSTOMIZEPALETTEDLGPARAM structure.

Apply When Exit Check box:

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.

New:

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.

Open:

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.

Save:

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.

Save as:

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.

Close:

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

See Also

Functions

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; 
} 
Help Version 20.0.2019.9.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Common Dialog C++ Class Library Help