Rounded corners in control lazarus / 31-LCL ---------------------------------------------------------------------- deck · 2012-12-22 12:03 I am using this code to manually draw cells in the grid in DBGrid1DrawColumnCell event. I want to get the rounded corner look like this in the pictures from oracle forms. Currently the cells are looking like ordinary rectangles (image1.jpg) but I want them to have this rounded look like in the forms (orascr.jpg), so what I need to change in the event code to do that? Code: [Select]procedure Tf_search.DBGrid1DrawColumnCell(Sender: TObject;   const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);   var hulp : TRect; begin // this sets up a new, smaller rectangle to send to the // DefaultDrawDataCell methode so that it doesn't overwrite // our EditBox appearance BorderWidth := 1; hulp := rect; { rect is the rectangle of the cell } inc(hulp.top,BorderWidth+1); {so let's make it a bit smaller} inc(hulp.Left,BorderWidth+1); dec(hulp.Right,BorderWidth+1); dec(hulp.Bottom,BorderWidth+2); // this draw a rectangle to get some distance between the "EditBoxes" //DBGrid1.Canvas.Pen.Color := $00C1DDD0; DBGrid1.Canvas.Pen.Color := $00D1E5DC; DBGrid1.Canvas.Pen.Width := BorderWidth*2; DBGrid1.Canvas.RoundRect(rect,2,2); DBGrid1.Canvas.Font.Color:=clBlack; //DBGrid1.Canvas.Brush.Color:=clWhite; DBGrid1.Canvas.Rectangle(rect.Left,rect.top,rect.Right,rect.Bottom); // The following draws the first dark line at the top and left of our "EditBox" DBGrid1.Canvas.Pen.Width := 1; DBGrid1.Canvas.Pen.Color := clBtnShadow; DBGrid1.Canvas.MoveTo(rect.Right-BorderWidth-2,rect.Top+BorderWidth); DBGrid1.Canvas.LineTo(rect.Left+BorderWidth,rect.Top+BorderWidth); DBGrid1.Canvas.LineTo(rect.Left+BorderWidth,rect.Bottom- BorderWidth-1); // This will draw the single gray line at the bottom and right DBGrid1.Canvas.Pen.Color := clBtnFace; DBGrid1.Canvas.MoveTo(Rect.Left+BorderWidth+1,rect.Bottom- BorderWidth-2); DBGrid1.Canvas.LineTo(rect.Right-BorderWidth-2,rect.Bottom- BorderWidth-2); DBGrid1.Canvas.LineTo(rect.Right-BorderWidth-2,rect.Top+BorderWidth); // This draws the second, even darker, line at the top and Right DBGrid1.Canvas.Pen.Color := cl3DDkShadow; DBGrid1.Canvas.MoveTo(rect.Right- BorderWidth-3,rect.Top+BorderWidth+1); DBGrid1.Canvas.LineTo(rect.Left+BorderWidth+1,rect.Top+BorderWidth+1); DBGrid1.Canvas.LineTo(rect.Left+BorderWidth+1,rect.Bottom- BorderWidth-2); // put your own code ABOVE this line DBGrid1.DefaultDrawColumnCell(hulp,DataCol,Column,State); end; ---------------------------------------------------------------------- kdtop · 2012-12-22 22:49 If you are using lines and rectangles to draw, then you are always going to get square corners.  If you want to round in the corner, I guess you could either manually draw some pixels there, or you could draw a rounded rectangle. http://www.delphipages.com/forum/showthread.php?t=195099 kt ---------------------------------------------------------------------- Blaazen · 2012-12-22 23:36 Top left corner can be rounded very simply (1 line added, 1 line modified): Code: [Select]// The following draws the first dark line at the top and left of our "EditBox"   DBGrid1.Canvas.Pen.Width := 1;   DBGrid1.Canvas.Pen.Color := clBtnShadow;   DBGrid1.Canvas.MoveTo(rect.Right- BorderWidth-2,rect.Top+BorderWidth);   DBGrid1.Canvas.LineTo(rect.Left+BorderWidth,rect.Top+BorderWidth+1);  //MODIFIED   DBGrid1.Canvas.LineTo(rect.Left+BorderWidth,rect.Bottom- BorderWidth-1);   // This will draw the single gray line at the bottom and right   DBGrid1.Canvas.Pen.Color := clBtnFace;   DBGrid1.Canvas.MoveTo(rect.Left+BorderWidth+1,rect.Bottom- BorderWidth-2);   DBGrid1.Canvas.LineTo(rect.Right-BorderWidth-2,rect.Bottom- BorderWidth-2);   DBGrid1.Canvas.LineTo(rect.Right- BorderWidth-2,rect.Top+BorderWidth);   // This draws the second, even darker, line at the top and Right   DBGrid1.Canvas.Pen.Color := cl3DDkShadow;   DBGrid1.Canvas.MoveTo(rect.Right- BorderWidth-3,rect.Top+BorderWidth+1);   DBGrid1.Canvas.LineTo(rect.Left+BorderWidth+1,rect.Top+BorderWidth+1);   DBGrid1.Canvas.LineTo(rect.Left+BorderWidth+1,rect.Bottom- BorderWidth-2);   DBGrid1.Canvas.Pixels[rect.Left+BorderWidth+2,rect.Top+BorderWidth+2 ]:=clBtnShadow;    //ADDED