ImageGear Professional for Windows ActiveX
GUI Palette Control (IGGUIPaletteCtl)

The GUI Palette Control (IGGUIPaletteCtl Control) is used to let the end-user change the colors assigned to individual palette entries for an image. The control will show a grid of color-squares. The end-user will select one of these color-squares by clicking on it. In the ItemClick event handler, the programmer will call for the standard Windows color-chooser dialog to be displayed, then use the PaletteSet property of the IGPageViewCtl Control to change the particular palette entry to the color selected by the user.

To use the IGGUIPaletteCtl Control, you must first make an instance of the control available. In Visual Basic, this is done as follows:

  1. Use the Project/Components menu function to bring up the Components dialog.
  2. Scroll down to the "IGGUIWin 1.0 Type Library" entry under the "Controls" tab.
  3. Check the check-box for that entry.
    The dialog will look like the following image:

  4. Click OK.

You'll then have the IGGUIWin control on your Toolbox. You can then place a copy of the control on your application by double-clicking the control icon in the toolbox. For example, after placing the control on the "PaletteFrm" form in the sample GUIWin program, the Visual Basic editor looks like the following image:

The Toolbar icon for the control is shown in the red box on the left, and the instance of the control (named IGGUIPaletteCtl1) is the big square (with the 256 little white squares) on the dialog.

You can resize the IGGUIPaletteCtl Control by selecting it on the VB Forms designer, and then dragging the drag-handles. The control will automatically re-lay-out the 256 white squares so that an integral number of them fit in the width of the control. You may need to make the control taller in order to see all 256 squares. When the application runs, the control will only display as many squares as there are colors in the image palette (e.g., a 4-bit image will cause only 16 squares to appear).

In order for the IGGUIPaletteCtl Control to function, you must call its SetParentImage subroutine. The VB code to do this is best placed in the Form_Load subroutine. In the sample GUIWin program, it looks like this:

 
Copy Code
Private Sub Form_Load()
    On Error GoTo ErrorHandler
    IGGUIPaletteCtl1.SetParentImage MainFrm.IGCoreCtl1,
MainFrm.IGDisplayCtl1, MainFrm.IGPageDisp,
MainFrm.IGPageViewCtl1.hWnd
    Exit Sub
ErrorHandler:
    MsgBox "ImageGear GUIPalette control returned an error (" +
Hex(Err.Number) + "):" + vbCrLf + Err.Description,
vbExclamation, "IGGUIDlg Error"
    End Sub

Like the other ImageGear GUI controls, IGGUIPaletteCtl Control uses the COM Error object to report errors. VB programmers use the On Error statement to specify how to handle errors. After each call to an IGGUIPaletteCtl Control method, if there was an error, then the program can inspect Err.Number and Err.Description to determine what went wrong. The list of possible Err.Number values is in the enumIGGUIWinCtlErrors enumeration.

Sometimes the error is detected by the ImageGear controls. In that case, the Err.Number and Err.Description values will be those generated by the ImageGear control.

When the application program runs, the IGGUIPaletteCtl Control will appear as a series of colored squares on the VB Form. Here is what it looks like in the GUIWin sample program:

If the Enabled property is True, then the user can click on any of the colored squares to cause the Color chooser dialog to be displayed. The dialog is as follows:

The user can click on any of the Basic Colors, or any of the Custom Colors, or anywhere in the color rainbow to choose a new color. The color will be shown in the "Color/Solid" area. The user can replace one of the Custom Colors with their chosen color (the set of Custom Colors will be maintained as long as the Form containing the IGGUIPaletteCtl Control is visible).

When the user clicks OK, the Color chooser dialog will close, the corresponding colored square will be changed in the IGGUIPaletteCtl Control, and (if the SetParentImage subroutine call specified an hWnd) the image will be redisplayed with the updated color palette.

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback