Recent

Author Topic: Send form to true left and top edges  (Read 363 times)

user5

  • Sr. Member
  • ****
  • Posts: 419
Send form to true left and top edges
« on: February 12, 2026, 03:34:43 pm »
    I need to send a form to the exact absolute left and top of the computer display screen. All usual methods for doing this such as Form2.Left := 0 or TMonitor stuff result in the unacceptable screen capture image shown in the attached file example1.jpg.
    The code below does better but even it resulted in the equally unacceptable image shown in example2.jpg and it additionally resized the form. Any attempt to add size constraints or to use Form2.BorderStyle := bsSingle etc. causes the code not to work. Also, if I try to resize the form in the same procedure as the virtual Windows Key + Left Arrow Key click then the code again fails to work. I had to resize the image back to its original size with a different button.
    I have a failsafe method for moving the form to the true border of the display which uses a series of screen captures but it is not invisible as it searches out and finds the edges and it takes about 2 sec. Is there a better way of doing this? I need something that will work on all displays with their own peculiarities.

Code: Pascal  [Select][+][-]
  1.   form2.setfocus;
  2.  
  3.   // 1. Press Windows Key
  4.   keybd_event(VK_LWIN, 0, 0, 0);
  5.  
  6.   // 2. Press Left Arrow
  7.   keybd_event(VK_LEFT, 0, 0, 0);
  8.  
  9.   // 3. Release Left Arrow
  10.   keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0);
  11.  
  12.   // 4. Release Windows Key
  13.   keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);  

mas steindorff

  • Hero Member
  • *****
  • Posts: 566
Re: Send form to true left and top edges
« Reply #1 on: February 13, 2026, 02:39:34 am »
it's been a long time ago but I believe I used Screen.DesktopLeft or another screen call to position the form. check help to see how to use this unless someone has used it in the last 20 has more info.
good luck 
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

 

TinyPortal © 2005-2018