Delphi实现窗口一直在桌面工作区内显示(重写WM_WINDOWPOSCHANGING消息)
有的时候我们要实现一个悬浮窗口,并使该窗口一直显示在桌面的工作区内。即整个窗口要一直显示在屏幕上,不能超出屏幕的上下左右边缘。此功能的实现也不难,我们需要自己写代码来响应窗口的WM_WINDOWPOSCHANGING消息,话不多说,详细代码如下供参考:
新建一个工程,并把下面代码拷贝到工程中,运行……
Delphi/Pascal
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
inherited;
if (Message.WindowPos.y + Message.WindowPos.cy > Screen.WorkAreaHeight) then begin
Message.WindowPos.Y := Screen.WorkAreaHeight - Height ;
end;
if (Message.WindowPos.x + Message.WindowPos.cx > Screen.WorkAreaWidth) then begin
Message.WindowPos.X := Screen.WorkAreaWidth - Width ;
end;
if Message.WindowPos.x < 0 then
Message.WindowPos.x := 0;
if Message.WindowPos.y < 0 then
Message.WindowPos.y := 0;
end;
end.
|
http://bcoder.com/delphi/make-the-window-always-shows-in-desktop-workarea-in-delphi
Delphi实现窗口一直在桌面工作区内显示(重写WM_WINDOWPOSCHANGING消息)的更多相关文章
- 有谁知道Delphi中"窗口"的创建过程?
求助:有谁知道Delphi中窗口的创建过程,此“窗口”不仅仅指 TForm 类型, 还包括一般的窗口控件,如TButton,TEdit等等,希望有能够十分详细的运作 过程,比如说CreatPara ...
- 简简单单安装debian桌面工作环境
linux一般给人的影响是对使用者的要求偏高, 使用者需要自行配置很多相应的系统工作参数,因此,从一定的程度上阻碍了用户去使用它.而本文所介绍的是, 使用者完全可以消除这个障碍,非常简单地安装好自己的 ...
- 安装完CentOS 7 Minimal之后,从头打造桌面工作环境
安装完CentOS 7 Minimal之后,从头打造桌面工作环境 U盘装CentOS 7 DVD版不能引导的解决办法 更改root密码 SSH登录 增加除root之外的常规用户 装完CentOS 7之 ...
- WM_ERASEBKGND官方解释(翻译),以及Delphi里所有的使用情况(就是绘制窗口控件背景色,并阻止进一步传递消息)
#define WM_ERASEBKGND 0x0014 Parameters wParam A handle to the device context. // ...
- Delphi 悬浮窗口、浮动窗口的实现
源:Delphi 悬浮窗口.浮动窗口的实现 浮动窗体的实现 http://blog.tianya.cn/blogger/post_show.asp?BlogID=68097&PostID=80 ...
- delphi xe6 窗口 visible 不能隐藏 解决
delphi xe6 窗口 visible 不能隐藏 解决 在工程代码里面加上 Application.ShowMainForm := false;
- dwExStyle和dwStyle的说明(Delphi SDK窗口)
dwExStyle: :指定窗口的扩展风格.该参数可以是下列值: WS_EX_ACCEPTFILES:指定以该风格创建的窗口接受一个拖拽文件. WS_EX_APPWINDOW:当窗口可见时,将一个顶层 ...
- C#/.NET基于Topshelf创建Windows服务的守护程序作为服务启动的客户端桌面程序不显示UI界面的问题分析和解决方案
本文首发于:码友网--一个专注.NET/.NET Core开发的编程爱好者社区. 文章目录 C#/.NET基于Topshelf创建Windows服务的系列文章目录: C#/.NET基于Topshelf ...
- 窗体的Alpha通道透明色支持(一旦 Form 被定义为利用 LayeredWindow ,窗口的绘图不再响应沿用多年的 WM_Paint 消息)
参考: http://www.delphibbs.com/delphibbs/dispq.asp?lid=2190768 Windows 2000后,为了支持类似MAC界面的Alpha通道混合效果,提 ...
随机推荐
- 京香julia_百度百科
京香julia_百度百科 京香julia
- Machine Learning #Lab1# Linear Regression
Machine Learning Lab1 打算把Andrew Ng教授的#Machine Learning#相关的6个实验一一实现了贴出来- 预计时间长度战线会拉的比較长(毕竟JOS的7级浮屠还没搞 ...
- Win8.1应用开发之动态磁贴
using demo02.Common; using System; using System.Collections.Generic; using System.IO; using System.L ...
- 怎样从 Google Play 下载 Android 程序到电脑上
想必非常多朋友也有须要通过电脑下载Google Play的apk到电脑端的时候,事实上非常easy,推荐一个站点:APK Downloader APK Downloader 是一个能直接从网页下载Go ...
- 在webform中调用JS的技巧
一,执行删除操作,点击按钮时弹出对话框询问是否确认删除,点击确定,删除并在删除完成后弹出删除成功:点击取消不删除 1.在aspx源 代码中加入JavaScript代码 <script langu ...
- tq2440+fedora安装qt4.5
1. make[1]: arm-none-linux-gnueabi-g++:命令未找到 make[1]: *** [.obj/release-shared-emb-arm/qatomic_arm.o ...
- Qt控件精讲一:按钮
原地址:http://blog.csdn.net/yuxikuo_1/article/details/17397109 Qt Creater提供6种Button控件.如图1. Button控件介绍 控 ...
- CF 552C 进制转换
http://codeforces.com/problemset/problem/552/C C. Vanya and Scales time limit per test 1 second memo ...
- ASP.NET - 跳转页面
1. Response.Redirect("../Manager/AddBookInfoImages.aspx?id=" + Server.UrlEncode(ReturnValu ...
- RGB HSV HLS三种色彩模式转换(C语言实现)
Android项目上处理图像的代码(注释全部去掉) ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...