我用下面的代码为什么没有效果?var
pt: TPoint;
h: HWND;
rc: TRect;
begin
GetCursorPos(pt);
h := WindowFromPoint(pt);
h := GetNextWindow(h, GW_HWNDPREV);
GetWindowRect(h, rc);
SetWindowPos(Self.Handle, h, rc.Left, rc.Top, 0, 0, SWP_NOSIZE);
end;
pt: TPoint;
h: HWND;
rc: TRect;
begin
GetCursorPos(pt);
h := WindowFromPoint(pt);
h := GetNextWindow(h, GW_HWNDPREV);
GetWindowRect(h, rc);
SetWindowPos(Self.Handle, h, rc.Left, rc.Top, 0, 0, SWP_NOSIZE);
end;
这样就可以了
SWP_NOACTIVATE + SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW);
啥意图?置顶: form1.formStyle := fsStayOnTop;
然后:
var
pt: TPoint;
h: HWND;
rc: TRect;
begin
GetCursorPos(pt);
h := WindowFromPoint(pt);
//h := GetNextWindow(h, GW_HWNDPREV);
if h = Self.Handle then Exit;
GetWindowRect(h, rc);
SetWindowPos(Self.Handle, 0, rc.Left, rc.Top, rc.Right - rc.Left,rc.Bottom - rc.Top, SWP_SHOWWINDOW);
end