HeaderPane
Main
Hide

SftTree/DLL 8.0 - Tree Control

Share Link
Print

SFTTREE_OWNERDRAW Structure

The SFTTREE_OWNERDRAW structure is used as parameter for an application-supplied owner-draw function of type LPFNSFTTREE_OWNERDRAWPROC, which is called whenever an object needs to be rendered.

typedef struct tagSftTreeOwnerDraw {

#define SFTTREE_OD_CALC 0               // calculate width & height (returned in DrawRect)
#define SFTTREE_OD_PAINT 1              // paint in hDC
    int style;                          // callback function

    int itemType;                       // item to draw
#define SFTTREE_OD_CELL             0
#define SFTTREE_OD_CELLTOOLTIP      1
#define SFTTREE_OD_ROWHEADER        2
#define SFTTREE_OD_COLHEADER        3
#define SFTTREE_OD_COLHEADEREND     4
#define SFTTREE_OD_ROWCOLHEADER     5
#define SFTTREE_OD_ROWCOLFOOTER     6
#define SFTTREE_OD_COLFOOTER        7
#define SFTTREE_OD_COLFOOTEREND     8

    HDC hDC;                            // device context
    RECT DrawRect;                      // drawing rectangle
    int gap;                            // suggested gap size

    long index;                         // entry being painted
    short col;                          // column number
    BOOL fSelected;                     // non-zero if item selected - paint only
    BOOL fFlyby;                        // non-zero if flyby - paint only
    BOOL fFocus;                        // non-zero if item has focus rectangle - paint only

    UINT id;                            // control's ID
    HWND hwndCtl;                       // control's window handle
    BOOL fEnabled;                      // non-zero if window is enabled

    BOOL fThemed;                       // control is themed
    HINSTANCE hThemeDLL;                // UXTHEME dll handle
    HANDLE hThemeHeader;                // header theme
    HANDLE hThemeListview;              // listview theme
    HANDLE hThemeTreeview;              // treeview theme
    HANDLE hThemeButton;                // button theme
    HANDLE hThemeCheckBox;              // checkbox theme
    HANDLE hThemeSpin;                  // spin button theme
    HANDLE hThemeScrollbar;             // scrollbar theme
    HANDLE hThemeFooter;                // footer theme
    BOOL fDarkMode;                      // non-zero if dark mode is active
    int dpi;                             // effective DPI for this paint (per-monitor v2)
    BOOL fHighContrast;                 // non-zero if Windows high-contrast mode is active

    DWORD res1;
} SFTTREE_OWNERDRAW, * LPSFTTREE_OWNERDRAW;
typedef const SFTTREE_OWNERDRAW * LPCSFTTREE_OWNERDRAW;

Members

style

Identifies the object to render.

SFTTREE_OD_CALCThe owner-draw callback is called to calculate the dimensions of the object.
SFTTREE_OD_PAINTThe owner-draw callback is called to paint the object.

itemType

Identifies the object.

SFTTREE_OD_CELLA cell - index and col describe the cell
SFTTREE_OD_CELLTOOLTIPA ToolTip - index and col describe the cell
SFTTREE_OD_ROWHEADERA row header - index describes the item
SFTTREE_OD_COLHEADERA column header - col describes the column
SFTTREE_OD_COLHEADERENDThe column header after the end of the last column (fixed-width only)
SFTTREE_OD_ROWCOLHEADERThe row/column header
SFTTREE_OD_ROWCOLFOOTERThe row/column footer
SFTTREE_OD_COLFOOTERThe column footer - col describes the column
SFTTREE_OD_COLFOOTERENDThe column footer after the end of the last column (fixed-width only)

hDC

The device context.

DrawRect

Modifiable. If style is SFTTREE_OD_CALC, the callback returns the required dimensions in the DrawRect rectangle (the width and height are used). If style is SFTTREE_OD_PAINT, DrawRect describes the available output area where the object must be rendered.

gap

A suggested horizontal gap size, usually used between text and pictures or between the edge of the object and text or pictures.

index

Defines the item.

col

Defines the column.

fSelected

TRUE if the object is selected or pressed.

fFlyby

TRUE if the object should be rendered with flyby highlighting.

fFocus

TRUE if the tree control has the input focus.

id

The window ID of the tree control.

hwndCtl

The window handle of the tree control.

fEnabled

TRUE if the tree control is enabled.

fThemed

TRUE if Windows themes are used to render the tree control.

hThemeDLL

The module handle of the already loaded Dll UxTheme.dll. This Dll contains all Windows theme rendering support offered by Windows and can be used to dynamically load entry points using GetProcAddress, if desired. If Windows themes are not used, this value is NULL.

hThemeHeader

An HTHEME handle of theme data for the Header class. If Windows themes are not used, this value is NULL.

hThemeListview

An HTHEME handle of theme data for the ListView class. If Windows themes are not used, this value is NULL.

hThemeTreeview

An HTHEME handle of theme data for the TreeView class. If Windows themes are not used, this value is NULL.

hThemeButton

An HTHEME handle of theme data for the Button class. If Windows themes are not used, this value is NULL.

hThemeCheckBox

An HTHEME handle of theme data for the CheckBox class. If Windows themes are not used, this value is NULL.

hThemeSpin

An HTHEME handle of theme data for the Spin class. If Windows themes are not used, this value is NULL.

hThemeScrollbar

An HTHEME handle of theme data for the Scrollbar class. If Windows themes are not used, this value is NULL.

hThemeFooter

An HTHEME handle of theme data for the Header class. If Windows themes are not used, this value is NULL. Windows does not define a Footer class so the Header class is used by default.

fDarkMode

TRUE if the tree control is currently rendering with the dark color palette. See SetDarkMode. Owner-draw code is responsible for its own dark-mode compliance - the tree control's default render path handles non-owner-drawn areas automatically.

dpi

The effective DPI (dots-per-inch) for the monitor the tree control is currently displayed on. 96 represents 100% scaling, 144 represents 150%, 192 represents 200%. Owner-draw code should read this value on every paint and must not cache pixel metrics across callbacks. See GetDPI.

fHighContrast

TRUE if Windows High Contrast rendering is currently active on the tree control. See SetHighContrastMode. Owner-draw code is responsible for its own high contrast compliance - the tree control's default render path remaps colors to system-palette values automatically, but owner-drawn output must do the equivalent remap itself.

Comments

The SFTTREE_OWNERDRAW structure is used as parameter for an application-supplied owner-draw function of type LPFNSFTTREE_OWNERDRAWPROC, which is called whenever an object needs to be rendered.

The callback receives control when an object needs to be rendered. The callback can then perform application specific rendering of the object. An application can render cells, cell ToolTips, row headers, column headers and the row/column header using the owner-draw function.

The SetOwnerDrawCallback function defines an application-supplied owner-draw function, which is called whenever an object needs to be rendered.

Examples

C

HFONT g_hFontVertical;                  /* Vertical font */
HBITMAP g_hBitmap;                      /* Sample bitmap */
HBITMAP g_hBitmapDark;                  /* Sample bitmap (dark mode) */

// Miscellaneous bitmaps
SFT_PICTURE m_aThreeItemPictures[3];    /* Three default item pictures, see SetPictures in online help */
//SFT_PICTURE m_OtherItemPicture;       /* Another item picture, see SetItemPicture in online help */

BOOL CALLBACK Tree_OwnerDrawCallback(HWND hwnd, LPSFTTREE_OWNERDRAW lpInfo, SFTTREE_DWORD_PTR UserData);

/**********************************************************************/
/*                          Frame Window Proc                         */
/**********************************************************************/

LRESULT CALLBACK SDI_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

C++

        m_Tree.RecalcHorizontalExtent(0, FALSE);/* Update horizontal scroll bar */
    }
}

/**********************************************************************/
/*                         Ownerdraw Callback                         */
/**********************************************************************/

void CSampleView::OwnerDraw_Column_Header(LPSFTTREE_OWNERDRAW lpInfo)
{
    // This function paints the column header using a vertical font
    // it even takes themes into consideration, so it's a bit more complicated
    // than the average application.

    // get general information about tree control and columns
    LPSFTTREE_COLUMN_EX lpCol;

See Also C/C++ API | Categories | Notifications