Thanks David,
That did the trick along with the following code to handle the taskbar.
I'm going top share my code to help out others who wish to do this.
procedure TfrmMain.FormShow(Sender: TObject);
//* Uses ShellAPI
function IsTaskbarAutoHideOn: Boolean;
var
ABData: TAppBarData;
begin
ABData.cbSize := SizeOf(ABData);
Result := (SHAppBarMessage(ABM_GETSTATE, ABData) and ABS_AUTOHIDE) > 0;
end;
function TaskBarHeight: integer;
var
hTB: HWND; // taskbar handle
TBRect: TRect; // taskbar rectangle
begin
hTB:= FindWindow('Shell_TrayWnd', '');
if hTB = 0 then
Result := 0
else begin
GetWindowRect(hTB, TBRect);
Result := TBRect.Bottom - TBRect.Top;
end;
end;
begin
//* This code will force the window to the lower right corner of the
screen
//* taking into account if the user autohides the taskbar or not.
frmMain.Left := (Screen.Width - frmMain.Width);
if IsTaskbarAutoHideOn then
frmMain.Top := (Screen.Height - frmMain.Height)
else
frmMain.Top := (Screen.Height - frmMain.Height) - TaskBarHeight;
end;
Thanks,
Mike
----- Original Message -----
From: "David J Taylor" <david-tay...@blueyonder.co.uk>
To: "Delphi - Talk" <delphi-talk@elists.org>
Sent: Saturday, March 19, 2011 2:18 AM
Subject: Re: Force a Delphi form to lower right corner of the screen.
Greetings All,
Delphi 2010
I have a Delphi executable with a very small main window and instead of
it being placed screen centered I would like it to be place in the lower
right corner of the screen just above the system tray.
Anyone have any example code on how to accomplish this?
Thanks to all who reply.
Mike
Not tested, but in FormCreate, something like:
Left := Screen.Width - Width;
Top := Screen.Height - Height;
See:
http://delphi.about.com/od/vclusing/a/tscreen.htm
You may need to subtract the taskbar height as well - I have the taskbar
minimised so I don't see the difference!
Cheers,
David
--
SatSignal software - quality software written to your requirements
Web: http://www.satsignal.eu
Email: david-tay...@blueyonder.co.uk
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk
--
MailScanner Virus/Spam/Malware: PASS (GZ)
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk