SetWindowPos
其中参数的窗体句柄设为想要居顶端的窗体句柄var
h:Integer;
p:Tpoint;
begin
GetCursorPos(p);
h:=windowfrompoint(p);
SetWindowPosh,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE);
end;
其中参数的窗体句柄设为想要居顶端的窗体句柄var
h:Integer;
p:Tpoint;
begin
GetCursorPos(p);
h:=windowfrompoint(p);
SetWindowPosh,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE);
end;
可以了。如果只是临时将窗口带到最顶端,可以用
SetForegroundWindow(Handle);
BringWindowToTop(Handle);
SetSysFocus(Self.Handle);
ShowWindow(Self.Handle, sw_normal);
Handled := True;函数原型为:
function SetSysFocus(hwnd: integer): integer; //ÉèÖÃij´°¿ÚΪ»î¶¯´°¿Ú
var
hOtherWin, OtherTHreadID, hFocusWin: integer;
begin hOtherWin := GetForegroundWindow;
OtherThreadID := GetWindowThreadProcessID(hOtherWin, nil);
if AttachThreadInput(GetcurrentThreadID, OtherThreadID, True) then
begin
hFocusWin := GetFocus;
result := SetFocus(hwnd);
//SendMessage(hwnd,WM_COPY,0,0);
if hFocusWin <> 0 then
try
//SendMessage(GetFocus,WM_COPY,0,0);
finally
AttachThreadInput(GetCurrentTHreadID, OtherTHreadID, False);
end;
end
else
result := SetFocus(hwnd);
end;
ShowWindow(Self.Handle, sw_normal);
Handled := True;这三句我是写在application.onmessage事件中的,所以有handled变量
我用
SetForegroundWindow(Handle);
BringWindowToTop(Handle);
窗口图标只是闪动提示我,它并没有显示在最前面。
SetForegroundWindow(Handle);
这样再试试看。
哈哈,看到我了吧。