Certain controls don't draw correctly lazarus / 31-LCL ---------------------------------------------------------------------- pcurtis · 2021-05-01 14:57 I'm having problems drawing a TPagecontrol. Drop a TButton on a form. Add this procedure 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 BoxAround(aControl : TWinControl; aOffset : integer);var  Left : integer;  Top : integer;  Right : integer;  Bottom : integer;  aCanvas : TCanvas;begin  Top := aControl.Top - aOffset;  Left := aControl.Left - aOffset;  Bottom := (aControl.Top + aControl.Height) + (aOffset - 1);  Right := aControl.Width + aControl.Left + (aOffset - 1);   aCanvas := (aControl.Parent as TForm).Canvas;   aCanvas.Pen.Color := clBlack;  aCanvas.Pen.Width := 1;   aCanvas.Line(Left, Top, Right, Top);  aCanvas.Line(Left, Top, Left, Bottom);  aCanvas.Line(Left, Bottom, Right, Bottom);  aCanvas.Line(Right, Bottom, Right, Top);end; In the forms OnPaint event add 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 BoxAround(Button1, 1); the result is a box around the button. All OK. Change the button for a TPagecontrol and you can see that the pagecontrol doesn't draw correctly (look at the bottom right corner). What am I missing? ---------------------------------------------------------------------- jamie · 2021-05-01 15:17 are you talking about something like 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.Button1Click(Sender: TObject);Var  R:TRect;begin  R := PageControl1.BoundsRect;  InflateRect(R, 5,5);  With Form1.Canvas do   Begin    Pen.Color := clRed;    Pen.Style := psSolid;    Pen.Width := 4;    Frame(R);   end;end; ---------------------------------------------------------------------- pcurtis · 2021-05-01 15:29 No, does the same thing. Look at the top and bottom corners. The spacing is different. ---------------------------------------------------------------------- jamie · 2021-05-01 15:49 Looks normal here.. Please post an image of what you have.. ---------------------------------------------------------------------- lucamar · 2021-05-01 15:52 I see nothing wrong here either, but I'm on Linux-gtk2 x86_64. YMMV. ETA: After looking more closely ... do you mean the top-right corner? That might be the "normal" artifact of lines not reaching the last point. You don't se it on the other lines because the one starts at the end (or start) of the other, but the top and right ones both end in the same "non-painted" point. I didn't test with a button, though, to see if it's different ... ---------------------------------------------------------------------- Martin_fr · 2021-05-01 16:03 The bottom right corner looks fine (win64 Laz 2.1 and Laz 2.0.12) The bottom top corner is missing a pixel (same as in lucamar's pic). But it's the same around a button. ---------------------------------------------------------------------- pcurtis · 2021-05-01 16:03 OK. ---------------------------------------------------------------------- Martin_fr · 2021-05-01 16:08 I think what you need 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       aCanvas.Pen.Cosmetic := False;      aCanvas.Pen.EndCap := pecSquare; ---------------------------------------------------------------------- pcurtis · 2021-05-01 16:19 No, the issue is the pixel gap, 2 instead of 1.   The control doesn't  fill it's bounds correctly. ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-05-01 16:24 Hey Lucamar, Quote from: lucamar on May 01, 2021, 05:52:57 pmETA: [snip] This has been bugging me to no end... What is your meaning for ETA? For me it's Estimated Time of Arrival and it's throwing me in a spin trying to guess what you mean by this acronym. LOL Cheers, Gus PS: I deeply apologise for the blatant off topic !!! But the not knowing is just pulling me apart ---------------------------------------------------------------------- jamie · 2021-05-01 16:25 what you are seeing is a widget problem.. The PageControl is a windows control and the sheets within the page control have their own border hugging the main frame. THat is most likely what you are seeing.. using more manually drawn controls may yield a different results like the TnoteBook joined with a TtabControl etc.. but I really don't think its worth the trip. ---------------------------------------------------------------------- wp · 2021-05-01 16:36 I think he means the distance between the pagecontrol and the custom- drawn border which is different at the top and bottom, and at the left and at the right - see screenshot. But Delphi does the same. The pagecontrol is not drawn by Lazarus nor by Delphi, but by Windows. Therefore, there's nothing we can do against it. Except for this: if you really need uniform distance to your manual margin then take care of it when drawing your borders: 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 BoxAroundAdj(aControl : TWinControl; aOffset : integer);var  Left : integer;  Top : integer;  Right : integer;  Bottom : integer;  aCanvas : TCanvas;begin  Top := aControl.Top - aOffset;  Left := aControl.Left - aOffset - 2;  Bottom := (aControl.Top + aControl.Height) + aOffset;  Right := aControl.Width + aControl.Left + aOffset - 1;   aCanvas := (aControl.Parent as TForm).Canvas;   aCanvas.Pen.Color := clBlack;  aCanvas.Pen.Width := 1;  aCanvas.Pen.Cosmetic := false;  aCanvas.Pen.EndCap := pecSquare;   aCanvas.Line(Left, Top, Right, Top);  aCanvas.Line(Left, Top, Left, Bottom);  aCanvas.Line(Left, Bottom, Right, Bottom);  aCanvas.Line(Right, Bottom, Right, Top);end; But you should be aware that these manual corrections will have to change probably when Microsoft once will decide to fix the painting of the pagecontrol, or do it differently... Better to keep your hands off of this. The best advice is: if you need a border accurate at the pixel level then use a completely customdrawn pagecontrol such as the one in ATFlatControls. ---------------------------------------------------------------------- Martin_fr · 2021-05-01 16:41 Quote from: pcurtis on May 01, 2021, 06:19:55 pmNo, the issue is the pixel gap, 2 instead of 1.   The control doesn't  fill it's bounds correctly. Actually, no... First, set the Forms color to some other value. So you can see what part is painted by whom. You will see that the PageControl has some pixels on its outside that are colored like the form. Before continuing.... Note that an aOffest = 1 => means the box has no gap at all. With Offset = 1 you draw at "Left - 1" => no gap. That actually works correct for the page control (ignore the top / see below). It's the button that leaves a gap, where it should not. It seems the button leaves a transparent pixel in it's WinControls space. I took my screen-grabber ("ShareX") and it detects both (button and PageControl) to be exactly in the drawn black border. Back to the PageControl. If it has no pages, then there is a gap on the top. It seems windows still reserves 2 pixels, and keeps them transparent (the area for the tabs, is always transparent / put some tabs on, and you will see the form color, on the right to the tabs). So to me it seems to all work. But Windows seems to have its own rules how much of the space of a WinControl it actually paints on. ---------------------------------------------------------------------- pcurtis · 2021-05-01 16:44 Well that sucks. {$IFDEF WINDOWS} HopeForTheBest; {$ENDIF} ---------------------------------------------------------------------- Martin_fr · 2021-05-01 16:53 Just one more thing, that came to (my) mind. If you think about hardcoding adjustments for pagecontrols => the gaps may be theme depending (whatever windows theme you or the user selected), and maybe depend on the existence and/or version of a manifest. I have not tested any of that.... ---------------------------------------------------------------------- jamie · 2021-05-01 17:00 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.Button1Click(Sender: TObject);Var  R:TRect;  C:TCanvas;  P:TTabSheet;begin  C:= TCanvas.Create;  P := PageControl1.ActivePage;  C.Handle := GetDC(P.Handle);  R := R.Create(0,0,P.Width-1, P.Height-1);  With C do   Begin    Pen.Color := clRed;    Pen.Style := psSolid;    Pen.Width := 1;    Frame(R);   end;   ReleaseDC(P.Handle,C.handle); C.Free;end;                             That is drawing on the sheet itself .. ---------------------------------------------------------------------- pcurtis · 2021-05-02 00:41 @jamie - thanks ---------------------------------------------------------------------- pcurtis · 2021-05-02 01:45 That said, it opens another can of worms. The tabsheet doesn't fill the pagecontrol completely. There is an uneven border around the tabsheet