Form Canvas Strange lazarus / 39-Graphics ---------------------------------------------------------------------- milen_prg · 2025-02-17 18:18 Why this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.FormPaint(Sender: TObject);Begin     Brush.Color := clRed;     Canvas.Rectangle(0, 0, Width div 2, Height);     Brush.Color := clGreen;     Canvas.Rectangle(Width div 2, 0, Width, Height);end;         Do not draw window with left half Red and right half Green? After refresh it draws just one vertical green line at the Form middle. And if I change the last row (for example) from Canvas.Rectangle(Width div 2, 0, Width, Height); to Canvas.Rectangle(Width div 2, 0, Width div 2, Height); The right half become Green, but, the left is White, no Red at all. And this is not what the Rectangle procedure must do! Generally, Help, please! ---------------------------------------------------------------------- olatov · 2025-02-17 18:39 Maybe try assigning the color to the Canvas' brush, that is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Canvas.Brush.Color := clRed;..Canvas.Brush.Color := clGreen;.. ---------------------------------------------------------------------- cdbc · 2025-02-17 18:46 Hi Try this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.FormPaint(Sender: TObject);Begin     Brush.Color := clRed;     Canvas.Rectangle(1, 1, (Width div 2)-1, Height-1);     Brush.Color := clGreen;     Canvas.Rectangle((Width div 2)+1, 1, Width-1, Height-1);end;There are bevels to take into account and if you draw 2 lines with the same coordinates after another, the last one wins... Regards Benny ---------------------------------------------------------------------- wp · 2025-02-17 18:58 Nimbus is right. This works (tested): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormPaint(Sender: TObject);begin  Canvas.Brush.Color := clRed;  Canvas.Rectangle(0, 0, Width div 2, Height);  Canvas.Brush.Color := clGreen;  Canvas.Rectangle(Width div 2, 0, Width, Height);end; ---------------------------------------------------------------------- milen_prg · 2025-02-17 19:07 Quote from: Nimbus on February 17, 2025, 07:39:56 pmMaybe try assigning the color to the Canvas' brush, that is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Canvas.Brush.Color := clRed;..Canvas.Brush.Color := clGreen;..  Yes, Nimbus is right! Thank, you! But WHY the compiler allows this?! Or what actually did the Brush of the Form itself (not its Canvas)?!