How can I draw a rectangle that has two round corners and the opposite corners are rectangular corners. The shape must be closed so it can be filled with the Brush color. The Polyline method doesn't draw curved lines. Can I add the points of an Arc to the polyline points? I tried to draw a RoundRect using Canvas method and then, overlapping a rectangle over the lower round corners, but I couldn't figure out how to erase the upper line of the rectangle when drawign just the border of the shape without filling it. Note: if you think is relevant, I can add the code I used.
Sample of the desired shape:
Sample of what I got with Delphi:
You don't have to fill the shape at the same time you draw it. You can use a series of TCanvas.LineTo()
and TCanvas.ArcTo()
/TCanvas.AngleArc()
calls first to create the shape, then call TCanvas.FloodFill()
afterwards to fill it.
Otherwise, you can overlap TCanvas.Rectangle()
on top of TCanvas.RoundRect()
with the same fill color, and then use TCanvas.MoveTo()
/TCanvas.LineTo()
to draw over the dividing line with the same fill color.
Another option would be to forget using TCanvas
drawing methods and just use Win32 API calls instead. Use CreateRoundRectRgn()
, CreateRectRgn()
, and CombineRn()
to create a HRGN
that has your desired shape, then use FillRgn()
and FrameRgn()
to draw on your TCanvas
using that HRGN
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments