Mega Code Archive

 
Categories / Delphi / Forms
 

How to move window so it isnt underover taskbar (and is onscreen)

Title: How to move window so it isnt under/over taskbar (and is onscreen) Question: How do I move the window so it isnt under/over taskbar (and is onscreen)? Answer: procedure TMainFrm.MoveTheWindow(); var Hand : hWnd; Area : TRect; begin Hand := findWindow ('Shell_TrayWnd', nil); If Hand 0 then getWindowRect (Hand, Area); if Area.Top 0 then begin //do not remove the begin and end - needed to clarify ifs for compiler!! If (Top + Height) Area.Top then Top := Area.Top - Height; end else If (Top + Height) Screen.Height then Top := Screen.Height - Height; If (Left + Width) Screen.Width then Left := Screen.Width - Width; If Left end; tested with d5 and win2k/98/95/NT4