Positioning a control lazarus / 31-LCL ---------------------------------------------------------------------- Bart · 2019-01-23 18:07 Hi, I'm trying to position a control so that it's top is the same as the top of another control. The controls are on different containers, so I can't use anchors for that. btnCopy is on a TPanel, the panel has Align = alLeft. btnStartCopy is on a TTabSheet, which is on a TPageControl, which has Align = alClient and has ShowTabs = False. I tried with 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   P := Classes.Point(btnCopy.Left, btnCopy.Top);  P := ClientToScreen(P); //transform to screen-coördinates  btnStartCopy.Top := ScreenToClient(P).y; Obviously this is the wrong approach, since on screen the Top of btnStartCopyis a few pizels below the Top of btnCopy (see attached image). Note that when I calculate ClientToScreen() on both buttons (after executing the code above), Top for both will be the same. How to do it the right way? Bart ---------------------------------------------------------------------- ASerge · 2019-01-23 18:30 Quote from: Bart on January 23, 2019, 07:07:47 pmObviously this is the wrong approach, since on screen the Top of btnStartCopyis a few pizels below the Top of btnCopy (see attached image). Note that when I calculate ClientToScreen() on both buttons (after executing the code above), Top for both will be the same. 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 btnStartCopy.Top := btnStartCopy.Parent.ScreenToClient(btnCopy.ClientToScreen(Point(0, 0))).Y; ---------------------------------------------------------------------- Bart · 2019-01-23 21:25 Quote from: ASerge on January 23, 2019, 07:30:21 pmTry 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 btnStartCopy.Top := btnStartCopy.Parent.ScreenToClient(btnCopy.ClientToScreen(Point(0, 0))).Y; Yeah, that works. But why (and why did my previous code not)? Bart ---------------------------------------------------------------------- ASerge · 2019-01-23 22:23 Quote from: Bart on January 23, 2019, 10:25:45 pmBut why (and why did my previous code not)? Parent.ScreenToClient not Form.ScreenToClient ---------------------------------------------------------------------- Bart · 2019-01-23 22:32 I think I see it now. I solved it as follows (a bit more readable to me): 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   P1 := btn Copy.Parent.ClientToScreen(Classes.Point(btnCopy.Left,btnCopy.Top));  P2 := btnStartCopy.Parent.ScreenToClient(P1);  btnStartCopy.Top := P2.y; Thanks for the help (your mentioned in my svn log now). Bart ---------------------------------------------------------------------- jamie · 2019-01-23 23:17 Don't forget that in Trunk the Screen/Client functions no longer add the Scrollbar offset to the return values for something that is sitting on a TScrollingWinControl, you must add this offset if you have scrollbars.  This is Delphi and windows compliant