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.
form2.setfocus;
// 1. Press Windows Key
keybd_event(VK_LWIN, 0, 0, 0);
// 2. Press Left Arrow
keybd_event(VK_LEFT, 0, 0, 0);
// 3. Release Left Arrow
keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0);
// 4. Release Windows Key
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);