Delphi 窗口置顶的方法
有几种窗口置顶的方法,简单的有:
ShowWindow(窗口句柄,sw_ShowNormal);
SetWindowPos(窗口句柄,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOV OR SWP_NOSIZE OR SWP_SHOWWINDOW);
另一种方式是:
function ForceForegroundWindow(hwnd: THandle): boolean;
const
SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
var
ForegroundThreadID: DWORD;
ThisThreadID : DWORD;
timeout : DWORD;
begin
if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE);
// Windows 98/2000 doesn't want to foreground a window when some other
// window has keyboard focus
if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4))
or
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
(Win32MinorVersion > 0)))) then begin
// Code from Karl E. Peterson, www.mvps.org/vb/sample.htm
// Converted to Delphi by Ray Lischner
// Published in The Delphi Magazine 55, page 16
Result := false;
ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow,nil);
ThisThreadID := GetWindowThreadPRocessId(hwnd,nil);
if AttachThreadInput(ThisThreadID, ForegroundThreadID, true) then begin
BringWindowToTop(hwnd); // IE 5.5 related hack
SetForegroundWindow(hwnd);
AttachThreadInput(ThisThreadID, ForegroundThreadID, false);
Result := (GetForegroundWindow = hwnd);
end;
if not Result then begin
// Code by Daniel P. Stasinski
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0), SPIF_SENDCHANGE);
BringWindowToTop(hwnd); // IE 5.5 related hack
SetForegroundWindow(hWnd);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE);
end;
end
else begin
BringWindowToTop(hwnd); // IE 5.5 related hack
SetForegroundWindow(hwnd);
end;
Result := (GetForegroundWindow = hwnd);
end;
Delphi 窗口置顶的方法的更多相关文章
- 将窗口置顶的方法:SetWindowPos、AttachThreadInput、SwitchToThisWindow
将窗口置顶的方法:SetWindowPos.AttachThreadInput.SwitchToThisWindow [转]http://hi.baidu.com/neil_danky/item/f9 ...
- 解析Delphi 窗口置顶,及非主窗口置顶
方法一: procedure TForm1.Button2Click(Sender: TObject);begin Form2.Show; Application.NormalizeTopMosts; ...
- WinForm SetWindowPos窗口置顶使用说明
就是有时候窗口不能够成功置顶,这时需要重新切换下标签,就可以置顶了,本文介绍C# SetWindowPos实现窗口置顶的方法: [DllImport("user32.dll", C ...
- win api 窗口操作-窗口置顶与寻找与激活
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos https://docs.micr ...
- 窗口置顶 - 仿TopWind
前置学习:低级鼠标hook,获得鼠标状态. 这个在原来获得鼠标状态的基础上,加上一个事件处理即可. TopWind就是一个可以置顶窗口的文件,避免复制粘贴的时候的来回切换(大窗口与小窗口),算是一个实 ...
- QT 窗口置顶功能
Qt中,保持窗口置顶的设置为: Qt::WindowFlags m_flags = windowFlags(); setWindowFlags(m_flags | Qt::WindowStaysOnT ...
- VC++实现窗口置顶
最近在跟着Visual C++网络编程开发与实战视频教程做HttpSourceViewer这个MFC项目时,可以看我Github上的项目HttpSourceViewer,目前基本实现了所有功能,就是关 ...
- ahk之路:利用ahk在window7下实现窗口置顶
操作系统:win7 64位 ahk版本:autohotkey_L1.1.24.03 今天安装了AutoHotkey_1.1.24.03.SciTE.PuloversMacroCreator,重新开始我 ...
- QT窗口置顶/真透明/背景模糊/非矩形/跳过任务栏分页器/无边框/无焦点点击/焦点穿透
qt 窗口置顶/真透明/背景模糊/非矩形/跳过任务栏分页器/无边框/无焦点点击/焦点穿透 窗口置顶qt 里是 setWindowFlags(Qt::WindowStaysOnTopHint)kde 里 ...
随机推荐
- 2019-9-25-如何让-USB-设备不显示安全删除硬件弹出选项
title author date CreateTime categories 如何让 USB 设备不显示安全删除硬件弹出选项 lindexi 2019-09-25 11:58:19 +0800 20 ...
- 安装php 在阿里云yum源的环境
yum -y install httpd mysql mysql-server php php-mysql postgresql postgresql-server php-postgresql ph ...
- 本地项目上传github
(1)github上面新建仓库 (2) 1. git init //初始化仓库 2. git add .(文件name) //添加文件到本地仓库 3. git commit -m "firs ...
- 一起看下Apache1.3.22版本改进和修正了啥?
Apache 1.3.20 - 1.3.22主要改进: 安全弱点: 1.在Apache1.3.20的win32平台上发现了一个漏洞.如果客户端发送一个非常长的URI可能导致用目录列表来代替缺省主页.4 ...
- 单源最短路径问题1 (Bellman-Ford算法)
/*单源最短路径问题1 (Bellman-Ford算法)样例: 5 7 0 1 3 0 3 7 1 2 4 1 3 2 2 3 5 2 4 6 3 4 4 输出: [0, 3, 7, 5, 9] */ ...
- delphi DBGrid简单自绘(字体颜色、背景等)
delphi DBGrid简单自绘(字体颜色.背景等) 从网上找的代码 应该是C#写的,其实delphi 的操作类似: 1 2 3 4 5 6 7 8 9 10 11 12 13 void __fa ...
- TPCx-BB官宣最新世界纪录,阿里巴巴计算力持续突破
2019年9月17日,TPC官宣Alibaba Cloud MaxCompute认证结果.同月26日,杭州云栖大会阿里巴巴宣布了这一成绩,飞天大数据平台计算引擎MaxCompute成为全球首个TPCx ...
- 约数个数求和+线性筛约数——bzoj3994
这题首先要会线性筛约数个数,并求出前缀和 bool vis[maxn]; int mm,mu[maxn],prime[maxn],num[maxn],sum[maxn],d[maxn],sum1[ma ...
- Array类型中的检测数组,转换方法,栈方法,队列方法
我的新博客==> http://www.suanliutudousi.com/2017/08/24/array%E7%B1%BB%E5%9E%8B%E4%B8%AD%E7%9A%84%E6%A3 ...
- python包下载路径
python所有包.模块镜像站 https://www.lfd.uci.edu/~gohlke/pythonlibs/