Hi ich hab ein Programm angefangen, dass das Fenster, das den Focus hat an den Bildschirmrand andocken soll. An den Rändern klappt es schon, aber will ich es in die Ecke verschieben, dann
"flimmert" es, er verändert seine Position also immer sehr schnell.
Bein manchen Fenstern wird die Breite verändert, was ich ebenfalls nicht verstehe.
Hier der QT
Delphi-Quellcode:
procedure TForm1.Timer1Timer(Sender: TObject);
var
hWindow: HWnd;
r: TRect;
begin
if checkbox1.Checked = false then exit;
hWindow := GetForegroundWindow;
GetWindowRect(hWindow, r);
//Linker Rand
if (r.Left <= spinedit1.Value) AND (r.Left >= -spinedit1.Value)
then MoveWindow(hwindow,0,r.Top,screen.Width-r.left-(screen.Width-r.right),screen.Height-r.top-(screen.Height-r.Bottom),True);
//Rechter Rand
if (r.Right >= (screen.Width-spinedit1.Value)) AND (r.Right <= (screen.Width + spinedit1.Value))
then MoveWindow(hwindow,screen.Width-(screen.Width-r.left-(screen.Width-r.right)),r.Top,screen.Width-left-(screen.Width-r.right),screen.Height-r.top-(screen.Height-r.Bottom),True);
//Oben
if (r.Top <= spinedit1.Value) AND (r.Top >= -spinedit1.Value)
then Movewindow(hwindow,r.Left,0,screen.Width-r.left-(screen.Width-r.right),screen.Height-r.top-(screen.Height-r.Bottom),True);
//Unten
if (r.Bottom >= (screen.height-spinedit1.Value)) AND (r.Bottom <= (screen.Height + spinedit1.Value))
then MoveWindow(hwindow,r.Left,screen.Height-(screen.Height-r.top-(screen.Height-r.bottom)),screen.Width-left-(screen.Width-r.right),screen.Height-r.top-(screen.Height-r.Bottom),True);
end;