Form postion on Desktop.

j88
j88 used Ask the Experts™
on
Hi Experts!
  please help me code to set form on start with position: right-bottom of screen (desktop) but above Taskbar

thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Set the form style to fsStayOnTop
and then onShowForm event do this:

Form1.Top:=Screen.Height-Form1.Height;
Form1.Left:=0;

Commented:
sorry I think I misunderstood your question.
If you need to place your form just above the taskbar, you will need to find out the info about the rect that represents the taskbar. For this you need to call this:
var
   wnd:HWND;
   Rct:TRect;
begin
   Wnd:=FindWindow('Shell_TrayWnd', nil);
   GetWindowRect(Wnd,Rct);
// now you have the top and bottom of the TaskBar  rct.top, rct.Bottom
end;

All you need is use them to position your form
Wim ten BrinkSelf-employed developer
Commented:
Just an interesting remark... On my system this would fail. Why? Because I've moved my taskbar from the bottom to the left of my screen, and also made it auto-hide itself.
I've also hidden all icons on my desktop and added a toolbar to my taskbar which holds the desktop items. And because the taskbar is on the left side, it displays quite a bit more icons to me when it's visible. I have over 100 icons on my taskbar!

The code by calinutz should work just fine, though. Just keep in mind that for some users, the taskbar might be in a location where you would not expect it...
Forced accept.

Computer101
EE Admin

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial