COLORREF类对象的构造

博客主要介绍了COLORREF类对象的构造,参照CDC::Draw3dRect成员函数,给出了该函数两个重载形式的参数说明,包括矩形边界、颜色等参数含义,还提及矩形绘制时不同边的颜色设定,并给出参考示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

COLORREF类对象的构造
参考自: [1]: https://docs.microsoft.com/en-us/cpp/mfc/reference/cdc-class?view=vs-2019#settextcolor
参照 CDC::Draw3dRect 成员函数中COLORREF类对象的构造:
两个重载的CDC::Draw3dRect 成员函数:

void Draw3dRect(
    LPCRECT lpRect,
    COLORREF clrTopLeft,
    COLORREF clrBottomRight);

void Draw3dRect(
    int x,
    int y,
    int cx,
    int cy,
    COLORREF clrTopLeft,
    COLORREF clrBottomRight);

参数:
lpRect
Specifies the bounding rectangle (in logical units). You can pass either a pointer to a RECT structure or a CRect object for this parameter.

clrTopLeft
Specifies the color of the top and left sides of the three-dimensional rectangle.

clrBottomRight
Specifies the color of the bottom and right sides of the three-dimensional rectangle.

x
Specifies the logical x-coordinate of the upper-left corner of the three-dimensional rectangle.

y
Specifies the logical y-coordinate of the upper-left corner of the three-dimensional rectangle.

cx
Specifies the width of the three-dimensional rectangle.

cy
Specifies the height of the three-dimensional rectangle.

Remarks
The rectangle will be drawn with the top and left sides in the color specified by clrTopLeft and the bottom and right sides in the color specified by clrBottomRight.

参考示例:

void CDCView::Draw3dRect(CDC* pDC)
{
   // get the client area
   CRect rect;
   GetClientRect(rect);

   // shrink our rect 20 pixels on all sides
   rect.DeflateRect(20, 20);

   // draw a rectangle with red top and left sides, and
   // green right and bottom sides.
   pDC->Draw3dRect(rect, RGB(255, 0, 0), RGB(0, 255, 0));

   // This call to the four-integer override would draw
   // the same rectangle with a little less convenience:

   // pDC->Draw3dRect(rect.left, rect.top, rect.Width(), rect.Height(),
   //    RGB(255, 0, 0), RGB(0, 255, 0));
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值