当前位置: 首页 > 工具软件 > Glossy Button > 使用案例 >

Button Styles

冯胤
2023-12-01

 Button Styles 简称BS

BS_OWNERDRAW   Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.

 

 

1.Owner Draw

当Button控件被设置成OwnerDraw属性时,父窗体就会接受到WM_DRAWITEMWM_MEASUREITEMWM_COMPAREITEMWM_DELETEITEM四个消息。

除了Button空间外,还有ListBox控件设置CBS_OWNERDRAWVARIABLE属性。

The WM_DRAWITEM message is sent to the owner window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed.

在MFC中,已经将这个4个消息反射到子控件的类中,如

void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
int  CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);

 

CButton::DrawItem

Called by the framework when a visual aspect of an owner-drawn button has changed.

 
virtual void DrawItem(
   LPDRAWITEMSTRUCT lpDrawItemStruct 
);

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.

Also see the BS_ style values.

 

 类似资料:

相关阅读

相关文章

相关问答