unit pbHint;

interface

uses
Windows, Controls, Forms, Graphics; type
TPBHint=class(THintWindow) //要自定义提示窗口类,必须从THintWindow类继承
private
FRegion:THandle; //保存当前提示窗口的区域句柄,用来设置窗口的形状
procedure FreeCurrentRegion; //释当前的区域句柄
procedure SetRegion(Rect:TRect);
public
Destructor Destroy;override; //复盖析构函数
procedure ActivateHint(Rect:TRect;const AHint:String);override; //复盖该方法,在提示窗口弹出前,设置窗口的形状
procedure CreateParams(var params:TCreateParams);override; //复盖该方法,去掉WS_Border属性
procedure Paint;override; //复盖该方法,改变画笔的颜色,然后再画出提示内容
end; implementation { TPBHint } procedure TPBHint.ActivateHint(Rect: TRect; const AHint: String);
begin
with Rect do
begin
Right:=Right+Canvas.TextWidth('WWWW'); //这一句是为了让提示窗口的宽度增大4个字符
Bottom:=Bottom+Canvas.TextHeight('WWWWWW');
end;
SetRegion(Rect);
inherited;
end; procedure TPBHint.CreateParams(var params: TCreateParams);
begin
inherited;
params.Style:=params.Style and (not WS_BORDER);
end; destructor TPBHint.Destroy;
begin
FreeCurrentRegion;
inherited;
end; procedure TPBHint.FreeCurrentRegion;
begin
if FRegion<> then
begin
SetWindowRgn(Self.Handle,,true);
DeleteObject(FRegion);
FRegion:=;
end;
end; procedure TPBHint.Paint;
var tempRect:TRect;
begin
tempRect:=ClientRect;
Inc(tempRect.top,);
Canvas.Font.Color:=clRed;
Canvas.Brush.Color:=clWhite;
DrawText(Canvas.Handle,PChar(Caption),Length(Caption),tempRect,DT_NOPREFIX or DT_WORDBREAK or DT_CENTER or DT_VCENTER);
end; procedure TPBHint.SetRegion(Rect: TRect);
var tempRgn:HRGN;
begin
BoundsRect:=Rect;
FreeCurrentRegion;
with BoundsRect do
begin
FRegion:=CreateRoundRectRgn(,,Width,Height,,);
tempRgn:=CreateRectRgn(,,Width div -,);
CombineRgn(FRegion,FRegion,tempRgn,RGN_DIFF);
tempRgn:=CreateRectRgn(Width div +,,Width,);
CombineRgn(FRegion,FRegion,tempRgn,RGN_DIFF);
end;
if FRegion<> then
SetWindowRgn(Self.Handle,FRegion,true);
end; initialization
Application.ShowHint:=false; //先禁止提示窗口
HintWindowClass:=TPBHint; //将自定义的提示窗口类赋值给全局变量HintWindowClass,就可以替换掉原来的提示窗口了
Application.ShowHint:=true; //开启提示窗口
Application.HintColor:=clBlue; //改变提示窗口的背景颜色 end.

Delphi笔记-自定义提示窗口的更多相关文章

  1. delphi笔记之nativeXml 转

    delphi笔记之nativeXml   使用 CreateName 建立可直接指定根节点的名称 var XmlDoc: TnativeXml; Node:TxmlNode; Begin XmlDoc ...

  2. iOS学习笔记-自定义过渡动画

    代码地址如下:http://www.demodashi.com/demo/11678.html 这篇笔记翻译自raywenderlick网站的过渡动画的一篇文章,原文用的swift,由于考虑到swif ...

  3. html5+css3+javascript 自定义提示窗口

    效果图: 源码: 1.demo.jsp <%@ page contentType="text/html;charset=UTF-8" language="java& ...

  4. Angular JS 学习笔记(自定义服务:factory,Promise 模式异步请求查询:$http,过滤器用法filter,指令:directive)

    刚学没多久,作了一个小项目APP,微信企业号开发与微信服务号的开发,使用的是AngularJS开发,目前项目1.0版本已经完结,但是项目纯粹为了赶工,并没有发挥AngularJS的最大作用,这几天项目 ...

  5. delphi 可以自定义边框的文本框TSkinNormalEdit思路(QQ2011风格)

    需求: QQ我的资料中基本资料窗体中的文本框: 正常状态下,文本框只有一条看起来只有一个像素的边框,边框的颜色从上到下由深到浅的渐变,当鼠标定位到该文本框时,其边框会变粗,而且边框的颜色加亮显示 如下 ...

  6. [Java] JSP笔记 - 自定义标签

    自定义标签的创建步骤: 自定义标签的四大功能: 自定义标签的类结构: 在 1.0 中呢, 可以将 <body-content> 的值设置为 JSP, 2.0中则不允许在自定义标签体中出现j ...

  7. iOS阶段学习第33天笔记(自定义标签栏(UITabBar)介绍)

    iOS学习(UI)知识点整理 一.自定义标签栏 1.方法一 单个创建标签栏 #import "AppDelegate.h" #import "SecondViewCont ...

  8. AngularJS笔记--自定义指令

    在前端开发中, 我们会遇到很多地方都会用到同一种类型的控件.AngularJS提供了自定义指令功能,我们可以在指令里面定义特定的html模板.提供给前台html调用. 一. 指令的简单定义.  下面定 ...

  9. JavaScript学习笔记-自定义集合类

    //集合类Set( ES6标准才有的类,目前兼容性较差)//自定义集合类:extend = function (o,p){ //定义一个复制对象属性的类函数 for(var x in p){ o[x] ...

随机推荐

  1. python3 urllib

    1.获取页面内容 第一种方式: import urllib.request url = 'https://www.baidu.com/' r = urllib.request.urlopen(url) ...

  2. 实际用户ID和有效用户ID (一) *****

    在Unix进程中涉及多个用户ID和用户组ID,包括如下: 1.实际用户ID和实际用户组ID:标识我是谁.也就是登录用户的uid和gid,比如我的Linux以simon登录,在Linux运行的所有的命令 ...

  3. WPF Demo1

    <Window x:Class="Demo1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/ ...

  4. EINTR与ERESTARTSYS

    驱动中如果down_interruptible之类的函数被信号中断,驱动可以返回-EINTR或-ERESTARTSYS. 区别在于: 若返回-EINTR,应用程序执行的系统调用会返回表示错误的值,且e ...

  5. bzoj4697: 猪

    Description 红学姐和黄学长是好朋友.红学姐有一只宠物,叫魔法猪.黄学长也有一只宠物,叫小奇.有 n 个猪圈排成一排 ,魔法猪藏在某个猪圈中.为了找到魔法猪,小奇会向你询问一些猪圈中猪的个数 ...

  6. spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情

    <spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情> <服务网关zu ...

  7. poj 3255 Roadblocks 次短路(两次dijksta)

    Roadblocks Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total S ...

  8. 1044 Shopping in Mars (25 分)

    1044 Shopping in Mars (25 分) Shopping in Mars is quite a different experience. The Mars people pay b ...

  9. 1038 Recover the Smallest Number (30 分)

    1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to r ...

  10. Mac parallels desktop安装windows,linux

    前言 这款软件你就看作是虚拟机vm,如果你要安装win10系统,请下载ios镜像文件 下载准备工作 Parallels Desktop 13 破解版本 联系站长所要 win10 iso镜像文件    ...