SetBounds lazarus / 34-Windows ---------------------------------------------------------------------- RAW · 2016-12-31 12:01 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.FormKeyDown(Sender: TObject; Var Key: Word;                           Shift: TShiftState); Begin  // SCREEN WIDTH  If (Key = Ord('W')) And (ssShift In Shift)  Then SetBounds(0, Top, (Screen.WorkAreaWidth-14), Height);   // STANDARD WIDTH  If (Key = Ord('W')) And (ssCtrl In Shift)  Then SetBounds((Screen.WorkAreaWidth -Self.Width)  Div 2,                 (Screen.WorkAreaHeight- Self.Height) Div 2,                  500, 500); End;  If I move the window to different positions on the screen and press "CTRL + W", then it appears in the middle of the screen as expected. But if I use "SHIFT + W" first and after that "CTRL + W", then the window appears not in the middle of the screen. The same if I maximize the window or if I dock the window to the left or right side of the screen and press "CTRL + W". If I press "CTRL + W" a second time then it's working correct. Obviously I miss something here ! ??? Why is it sometimes working and sometimes not? ---------------------------------------------------------------------- ASerge · 2016-12-31 13:06 Quote from: RAW on December 31, 2016, 01:01:36 pmObviously I miss something here ! ??? Why is it sometimes working and sometimes not? All right. After Shift+W form becomes the width of almost the whole work area, you set its position based on the width of the remaining part, i.e. slightly to the left, but set a new width, so it looks like not in the middle. ---------------------------------------------------------------------- RAW · 2016-12-31 16:52 @ASerge Thanks a lot... stupid me! I can't believe 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.FormKeyDown(Sender: TObject; Var Key: Word;                           Shift: TShiftState); Begin  // SCREEN WIDTH  If (Key = Ord('W')) And (ssShift In Shift)  Then SetBounds(0, Top, (Screen.WorkAreaWidth-14), Height);   // STANDARD WIDTH  If (Key = Ord('W')) And (ssCtrl In Shift)  Then   Begin    If WindowState   = wsMaximized    Then WindowState:= wsNormal;     SetBounds((Screen.WorkAreaWidth -500) Div 2,              (Screen.WorkAreaHeight-500) Div 2,               500, 500);   End; End;  The next computer I buy is a computer that is able to punch me on the back of my head every 2 hours. Maybe that helps in similar situations in the future. I need a drink...