Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DrawFocusRectColor

Windows Mobile 6.5
4/8/2010

This function is used to draw a focus rectangle in a style and color that are based on the current theme.


BOOL DrawFocusRectColor (
   HDC hdc,
   const RECT* lprc,
   UINT uFlags
);

hdc

[in] Handle to the device context.

lprc

[in] Pointer to a RECT structure that specifies the coordinates of the bounding rectangle for the window.

uFlags

[in] Flags specifying the properties of the focus rectangle.

Value Description

DFRC_FOCUSCOLOR

DrawFocusRectColor will use the brush obtained from GetSysColorBrush, with the color index set to COLOR_HIGHLIGHT, to render the focus rectangle. This means that the focus color will be based on the theme setting.

DFRC_SELECTEDBRUSH

DrawFocusRectColor will use the brush that is selected into the device context using SelectObject. Users can change the brush to the desired style and color. In addition, the brush can be used to erase this focus rectangle by using background color and the same style.

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError function.

The following code example demonstrates how to use DrawFocusRectColor.

Bb431704.note(en-us,MSDN.10).gifNote:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
LRESULT DlgProcOwnerDrawnFocus(HWND hDlg, UINT msg, UINT wParam, LONG lParam)
{
    // One of the children of this dialog is an owner drawn button
    LPDRAWITEMSTRUCT lpdis;
    LRESULT lRet = FALSE;
    
    switch (msg)
    {
        case WM_DRAWITEM:
            // State of owner drawn button has changed and we need to update it
            lpdis = (LPDRAWITEMSTRUCT) lParam;
            // Fill button background
            FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
            
            if (lpdis->itemState & ODS_FOCUS)
            {
                // If button has focus, we want to draw a focus rect in
                // a color appropriate for theme
                DrawFocusRectColor(lpdis->hDC, &lpdis->rcItem, DFRC_FOCUSCOLOR);
            }
            // Do more drawing code
            // Tell system that we handled the message
            lRet = TRUE;
            break;
        // Handling for other messages
    }
    return lRet;
}

Headeraygshell.h
Libraryaygshell.lib
Windows Embedded CEWindows Embedded CE 6.0 and later

Community Additions

Show:
© 2014 Microsoft