CButton按钮设计相关

virtual void CButton::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
 
Parameters:
lpDrawItemStruct
A long pointer to a DRAWITEMSTRUCT structure. The structure contains information about the item to be drawn and the type of drawing required.
 
Remarks:
Called by the framework when a visual aspect of an owner-drawn button has changed. An owner-drawn button has the BS_OWNERDRAW style set. Override this member function to implement drawing for an owner-drawn CButton object. The application should restore all graphics device interface (GDI) objects selected for the display context supplied in lpDrawItemStruct before the member function terminates.
 
The DRAWITEMSTRUCT structure has the following form:
 
typedef struct tagDRAWITEMSTRUCT {
    UINT   CtlType;
    UINT   CtlID;
    UINT   itemID;
    UINT   itemAction;
    UINT   itemState;
    HWND   hwndItem;
    HDC    hDC;
    RECT   rcItem;
    DWORD  itemData;
} DRAWITEMSTRUCT;
 
The DRAWITEMSTRUCT structure provides information the owner window must have to determine how to paint an owner-drawn control or menu item. The owner window of the owner-drawn control or menu item receives a pointer to this structure as the lParam parameter of the WM_DRAWITEM message.
 
CtlType
The control type. The values for control types are as follows:
ODT_BUTTON   Owner-drawn button
ODT_COMBOBOX   Owner-drawn combo box
ODT_LISTBOX   Owner-drawn list box
ODT_MENU   Owner-drawn menu
ODT_LISTVIEW   List view control
ODT_STATIC   Owner-drawn static control
ODT_TAB   Tab control
 
CtlID
The control ID for a combo box, list box, or button. This member is not used for a menu.
 
 
itemID
The menu-item ID for a menu or the index of the item in a list box or combo box. For an empty list box or combo box, this member is a negative value, which allows the application to draw only the focus rectangle at the coordinates specified by the rcItem member even though there are no items in the control. The user can thus be shown whether the list box or combo box has the input focus. The setting of the bits in the itemAction member determines whether the rectangle is to be drawn as though the list box or combo box has input focus.
 
 
itemAction
Defines the drawing action required. This will be one or more of the following bits:
ODA_DRAWENTIRE   This bit is set when the entire control needs to be drawn.
ODA_FOCUS   This bit is set when the control gains or loses input focus. The itemState member should be checked to determine whether the control has focus.
ODA_SELECT   This bit is set when only the selection status has changed. The itemState member should be checked to determine the new selection state.
 
itemState
Specifies the visual state of the item after the current drawing action takes place. That is, if a menu item is to be dimmed, the state flag ODS_GRAYED will be set. The state flags are as follows:
ODS_CHECKED   This bit is set if the menu item is to be checked. This bit is used only in a menu.
ODS_DISABLED   This bit is set if the item is to be drawn as disabled.
ODS_FOCUS   This bit is set if the item has input focus.
ODS_GRAYED   This bit is set if the item is to be dimmed. This bit is used only in a menu.
ODS_SELECTED   This bit is set if the item’s status is selected.
ODS_COMBOBOXEDIT   The drawing takes place in the selection field (edit control) of an ownerdrawn combo box.
ODS_DEFAULT   The item is the default item.
 
hwndItem
Specifies the window handle of the control for combo boxes, list boxes, and buttons. Specifies the handle of the menu (HMENU) that contains the item for menus.
 
 
hDC
Identifies a device context. This device context must be used when performing drawing operations on the control.
 
 
rcItem
A rectangle in the device context specified by the hDC member that defines the boundaries of the control to be drawn. Windows automatically clips anything the owner draws in the device context for combo boxes, list boxes, and buttons, but it does not clip menu items. When drawing menu items, the owner must not draw outside the boundaries of the rectangle defined by the rcItem member.
 
 
itemData
For a combo box or list box, this member contains the value that was passed to the list box by one of the following:
 
 
 
 
 
 
 
 
The GetSysColor function retrieves the current color of the specified display element. Display elements are the parts of a window and the display that appear on the system display screen.
 
 
DWORD GetSysColor(
  int nIndex   // display element
);
 
Parameters:
nIndex
Specifies the display element whose color is to be retrieved. This parameter must be one of the following values:
COLOR_3DDKSHADOW      
Dark shadow for three-dimensional display elements.
COLOR_3DFACE, COLOR_BTNFACE         
Face color for three-dimensional display elements.
COLOR_3DHILIGHT, COLOR_3DHIGHLIGHT, COLOR_BTNHILIGHT, COLOR_BTNHIGHLIGHT    
Highlight color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DLIGHT          
Light color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DSHADOW, COLOR_BTNSHADOW       
Shadow color for three-dimensional display elements (for edges facing away from the light source).
COLOR_ACTIVEBORDER    
Active window border.
COLOR_ACTIVECAPTION   
Active window title bar.
Windows NT 5.0 and Windows 98: Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled.
 
COLOR_APPWORKSPACE
Background color of multiple document interface (MDI) applications.
 
COLOR_BACKGROUND, COLOR_DESKTOP
Desktop.
COLOR_BTNTEXT
Text on push buttons.
COLOR_CAPTIONTEXT
Text in caption, size box, and scroll bar arrow box.
COLOR_GRADIENTACTIVECAPTION
Windows NT 5.0 and Windows 98: Right side color in the color gradient of an active window's title bar. COLOR_ACTIVECAPTION specifies the left side color. Use SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to determine whether the gradient effect is enabled.
COLOR_GRADIENTINACTIVECAPTION
Windows NT 5.0 and Windows 98: Right side color in the color gradient of an inactive window's title bar. COLOR_INACTIVECAPTION specifies the left side color. 
COLOR_GRAYTEXT
Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.
COLOR_HIGHLIGHT Item(s)
selected in a control.
COLOR_HIGHLIGHTTEXT
Text of item(s) selected in a control.
COLOR_HOTLIGHT
Windows NT 5.0 and Windows 98: Color for a hot-tracked item. Single clicking a hot-tracked item executes the item.
COLOR_INACTIVEBORDER
Inactive window border.
COLOR_INACTIVECAPTION
Inactive window caption.
Windows NT 5.0 and Windows 98: Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled.
 
COLOR_INACTIVECAPTIONTEXT
Color of text in an inactive caption.
COLOR_INFOBK
Background color for tooltip controls.
COLOR_INFOTEXT
Text color for tooltip controls.
COLOR_MENU
Menu background.
COLOR_MENUTEXT
Text in menus.
COLOR_SCROLLBAR
Scroll bar gray area.
COLOR_WINDOW
Window background.
COLOR_WINDOWFRAME
Window frame.
COLOR_WINDOWTEXT
Text in windows.
 
Return Values:
The return value is the red, green, blue (RGB) color value that specifies the color of the given element.
If the function fails, the return value is zero. To get extended error information, callGetLastError.