MKI_DialogCustomListboxColor (Dialogs) Changed in Version 6.60

www.CAD6.com

C++ Syntax

void

MKI_DialogCustomListboxColor(

 const LPDRAWITEMSTRUCT f_pDrawItem,

 MKI_COLORVALUE f_cColor,

 MKI_COLORMODEL f_cColorMode,

 const LPCWSTR f_pszText );

 

Draws a listbox item showing a color field and a following text.

 

Parameters

f_pDrawItem

[const LPDRAWITEMSTRUCT] Address of a structure that contains information about the listbox item.

f_cColor Changed in Version 6.60

[MKI_COLORVALUE] Color to be displayed in a field at the beginning of the item line in the notation defined by ColorMode.

f_cColorMode New in Version 6.60

[BYTE] The value ColorMode determines how the content of Color is to be interpreted (see MKI_COLORMODE_*).

f_pszText

[const LPCWSTR] Address of the text to be displayed following the color field.

 

Comment

This procedure will only use the itemState, hDC and rcItem elements of the DRAWITEMSTRUCT structure. If you need to draw a listbox item outside a standard window or dialog, you can create your own DRAWITEMSTRUCT and fill in those three values.

 

In order to include your own custom controls, use listboxes with the "Owner-Draw" style. Then, inside your dialog window command procedure, place the following code into the main message switch in order to initialize and draw the control:

 

    case WM_MEASUREITEM:

      {

        LPMEASUREITEMSTRUCT pMeasureItemPtr = (LPMEASUREITEMSTRUCT) GET_LPARAM( f_wParam, f_lParam );

        switch( pMeasureItemPtr->CtlID )

        {

          case IDD_CUSTOMCONTROL:

            pMeasureItemPtr->itemHeight = ItemHeight;

            break;

        }

      }

      return( 1 );

 

    case WM_COMPAREITEM:

      {

        LPCOMPAREITEMSTRUCT pCompareItemPtr = (LPCOMPAREITEMSTRUCT) GET_LPARAM( f_wParam, f_lParam );

        switch( pCompareItemPtr->CtlID )

        {

          case IDD_CUSTOMCONTROL:

 

            // Compare two items in order to build a sorted listbox...

 

            break;

        }

      }

      return( 0 );

 

    case WM_DRAWITEM:

      {

        LPDRAWITEMSTRUCT pDrawItemPtr = (LPDRAWITEMSTRUCT) GET_LPARAM( f_wParam, f_lParam );

        switch( pDrawItemPtr->CtlID )

        {

          case IDD_CUSTOMCONTROL:

            MKI_DialogCustomListboxColor( pDrawItemPtr, Color, MKI_COLORMODE_RGB100, Text );

            return( 1 );

        }

      }

      return( 0 );

 

Whether the user selects a listbox item from such a listbox can be checked by including the control's ID in the standard WM_COMMAND case. Such a custom control will behave like any standard listbox.

 

CAD6interface 2026.0 - Copyright 2026 Malz++Kassner® GmbH