Form for creating a rounded rectangle:
01. Procedure tportform. formcreate (Sender: tobject );
02. var HR: thandle;
03. Begin
04. HR: = createroundrectrgn (0, 0, width, height, 20, 20 );
05. setjavaswrgn (handle, HR, true );
06. end;
If you do not want an external box, use:
01. Procedure tportform. formcreate (Sender: tobject );
02. var HR: thandle;
03. Begin
04. HR: = createroundrectrgn (1, 1, width-2, height-2, 20, 20 );
05. setjavaswrgn (handle, HR, true );
06. end;
Because of the window made by the first code, there is no border in the rounded corner. Use the following code to create a border:
01. Procedure tform1.formpaint (Sender: tobject );
02. var
03. DC: HDC;
04. Pen: Hpen;
05. oldpen: Hpen;
06. oldbrush: hbrush;
07. Begin
08. DC: = getwindowdc (handle );
09. Pen: = createpen (ps_solid, 1, clgray );
10. oldpen: = SelectObject (DC, pen); // load the custom paint brush and save the original paint brush.
11. oldbrush: = SelectObject (DC, getstockobject (null_brush); // load an empty paint brush and save the original paint brush
12. roundrect (DC, 0, 0, width-1, height-1, 21,21); // draw a border
13. SelectObject (DC, oldbrush); // load the original paint brush
14. SelectObject (DC, oldpen); // load the original paint brush
15. deleteobject (PEN );
16. releasedc (handle, DC );
17. end;