Delphi的Hint入门指导
作者 凌众技术
来源 互联网
浏览
发布时间 2012-01-14
s, ExtCtrls; type TwdHintWnd = class(THintWindow) private FWndBmp: TBitmap; //窗口位图 FHintBmp: TBitmap; //提示信息位图 protected procedure CreateParams(var Params: TCreateParams); override; procedure Paint; override; procedure NCPaint(DC: HDC); override; {画提示的图象} procedure DrawHintImg(Bmp:TBitmap; AHint: string); {取得提示窗口对应的桌面区域的图象} procedure GetDesktopImg(Bmp: TBitmap; R: TRect); {对桌面区域图象作处理,使其看起来像一块玻璃且带有一点阴影} procedure EffectHandle(WndBmp, HintBmp: TBitmap); public constructor Create(Aowner: TComponent); override; destructor Destroy; override; procedure ActivateHint(Rect: TRect; const AHint: string); override; end; implementation { TwdHintWnd } procedure TwdHintWnd.ActivateHint(Rect: TRect; const AHint: string); var P: TPoint; begin //在这里取得一个适当的尺寸显示文字 FHintBmp.Width := Rect.Right - Rect.Left; FHintBmp.Height := Rect.Bottom - Rect.Top + 4; DrawHintImg(FHintBmp, AHint); FWndBmp.Width := Rect.Right - Rect.Left + 23; FWndBmp.Height := Rect.Bottom - Rect.Top + 27; Inc(Rect.Right, 23); Inc(Rect.Bottom, 27); BoundsRect := Rect; if Left < Screen.DesktopLeft then Left := Screen.DesktopLeft; if Top < Screen.DesktopTop then Top := Screen.DesktopTop; if Left + Width > Screen.DesktopWidth then Left := Screen.DesktopWidth - Width; if Top + Height > Screen.DesktopHeight then Top := Screen.DesktopHeight - Height; GetDesktopImg(FWndBmp, BoundsRect); EffectHandle(FWndBmp, FHintBmp); P := ClientToScreen(Point(0, 0)); SetWindowPos(Handle, HWND_TOPMOST, P.X, P.Y, 0, 0, SWP_SHOWWINDOW or SWP_NOACTIVATE or SWP_NOSIZE); end; constructor TwdHintWnd.Create(Aowner: TComponent); begin inherited; FWndBmp := TBitmap.Create; FWndBmp.PixelFormat := pf24bit; FHintBmp := TBitmap.Create; end; procedure TwdHintWnd.CreateParams(var Params: TCreateParams); begin inherited; //去掉窗口边框 Params.Style := Params.Style and not WS_BORDER; end; destructor TwdHintWnd.Destroy; begin |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: Delphi&BCB一线程序员开发经验下一篇: Delphi情结——永不消逝的精灵
关于Delphi的Hint入门指导的所有评论