Change GDI pen colour

倖福魔咒の 提交于 2019-12-12 01:37:42

问题


Is it possible to change the custom pen colour attribute after creating it using this call?

HPEN hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); //Create a solid pen.

or how should i create a pen whose colour colour can be changed.


回答1:


I am afraid that this is not possible using any non-esoteric approach.

I think, however, that you can use the DC_PEN stock object and the SetDCPenColor function, like so:

SelectObject(dc, GetStockObject(DC_PEN));
SetDCPenColor(dc, clGreen);
Rectangle(dc, 10, 10, 200, 200);
SetDCPenColor(dc, clRed);
Rectangle(dc, 300, 300, 500, 500);

in Delphi syntax.



来源:https://stackoverflow.com/questions/3443766/change-gdi-pen-colour

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!