gpt4 book ai didi

c++ - 如何设置方边线api窗口

转载 作者:行者123 更新时间:2023-11-30 19:12:38 25 4
gpt4 key购买 nike

我在 Windows 上使用 api(不是 gdi),我想知道如何做方形边缘线。

MoveToEx(hdc, x1, y1, NULL);
LineTo(hdc, x2, y2);

我当前的行输出:

Current output

我想要这一行:

Desired output

谢谢,有代码

最佳答案

您可以修改用于绘制线条的笔样式,特别是 PS_ENDCAP_SQUARE 并在设备上下文中选择该笔,请阅读 CPen 的文档:

 LOGBRUSH logBrush;//you need to use LOGBRUSH structure to specifiy brush attributes of the pen when the pen has PS_GEOMETRIC style
logBrush.lbStyle = BS_SOLID;
logBrush.lbColor = RGB(255,0,0);
CPen pen( PS_GEOMETRIC | PS_ENDCAP_SQUARE,10,&logBrush);//creates a pen with a square end caps and width of 10 pixels

SelectObject(hdc,pen.GetSafeHandle());//select the above pen into the device context
MoveToEx(hdc,x1,y1,NULL);
LineTo(hdc,x2,y2);

关于c++ - 如何设置方边线api窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36808946/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com