ShowCustomizePaletteDlg Example for Visual Basic

    Dim nRet As Integer
    Dim i As Integer

   RasterColorDlg.UserPaletteCount = 256
   For i = 0 To 255
       RasterColorDlg.UserPalette(i) = RGB(i, i, i)
   Next i

   RasterColorDlg.UIFlags = CUSTOMIZEPALETTE_SHOW_SORT Or _
                            CUSTOMIZEPALETTE_SHOW_FINDCLOSEST Or _
                            CUSTOMIZEPALETTE_SHOW_ADDOPTION Or _
                            CUSTOMIZEPALETTE_SHOW_REMOVEOPTION Or _
                            CUSTOMIZEPALETTE_SHOW_RGBLEFTPAN Or _
                            CUSTOMIZEPALETTE_SHOW_HTMLLEFTPAN Or _
                            CUSTOMIZEPALETTE_SHOW_INDEXLEFTPAN Or _
                            CUSTOMIZEPALETTE_SHOW_RGBRIGHTPAN Or _
                            CUSTOMIZEPALETTE_SHOW_HTMLRIGHTPAN Or _
                            CUSTOMIZEPALETTE_SHOW_INDEXRIGHTPAN Or _
                            CUSTOMIZEPALETTE_SHOW_NEW Or _
                            CUSTOMIZEPALETTE_SHOW_OPEN Or _
                            CUSTOMIZEPALETTE_SHOW_SAVE Or _
                            CUSTOMIZEPALETTE_SHOW_SAVEAS Or _
                            CUSTOMIZEPALETTE_GENERATE_PALETTE
    
   RasterColorDlg.Bitmap = LEAD1.Bitmap
    
   nRet = RasterColorDlg.ShowCustomizePaletteDlg(hWnd)
   If (nRet = 0 And RasterColorDlg.DialogStatus = DLG_OK) Then

      If (RasterColorDlg.ApplyPaletteWhenExit) Then
         MsgBox "True"
      Else
         MsgBox "False"
      End If
      For i = 0 To 255
         LEAD1.UserPalette(i) = RasterColorDlg.GeneratedPalette(i)
      Next i
   End If