Hide

SftTree/DLL 7.5 - Tree Control

Display
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

#if !defined(_WIN32_WCE)
    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
#endif

} 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.

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 */

// 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)
{
    switch (msg) {

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