如何在OLE控件中使用OLE_COLOR数据类型


诸如COleControl : : GetFortColor和COleControl : : GetBackColor等函数返回OLE _COLOR数据类型的颜色,而GDI对象诸如笔和刷子使用的是COLORREF数据类型,调用COleControl : : TranslateColor可以很容易地将OLE_COLOR类型改为COLORREF类型。下例创建了一个当前背景颜色的刷子:

void CSampleControl : : OnDraw (CDC* pdc
 const Crect& rcBounds , const Crect& rcInvalid
)
{
 //Create a brush of the cuttent background color.
 CBrush brushBack (TranslateColor (GetBackColor () ) )

 //Paint the background using the current backgroundcolor .
 pdc—> FilllRect (rcBounds , &brushBack)

 //other drawign commands

 …
}

[返回“一学网www.onestudy.net”首页]