如何自定义提示窗口(Hint Window)
作者 佚名技术
来源 程序设计
浏览
发布时间 2012-06-30
|
// 自定义 THintWindow 类 class TCcrunHintWindow : public THintWindow { bool FActivating; __fastcall TCcrunHintWindow(TComponent* Owner) : THintWindow(Owner) { Canvas->Font->Name = "宋体"; Canvas->Font->Color = clBlack; Canvas->Font->Size = 9; } void __fastcall Paint( void) { TRect rect = ClientRect; // Hint边框颜色 Canvas->Brush->Color = TColor(0xDBB8BA); Canvas->FillRect(rect); // 绘制整个Hint的边框 Canvas->Pen->Color = TColor(0x69230E); Canvas->Rectangle(rect); // Hint背景的颜色 Color = clWhite; // Hint文字透明 Canvas->Brush->Style = bsClear; // 绘出Hint文字 Canvas->Font->Color = clBlack; Canvas->TextOut(4, int(rect.Bottom / 2) - int(Canvas->TextHeight(Caption) / 2), Caption); } virtual void __fastcall NCPaint(HDC hdc) { // 63 63 72 75 6E 2E 63 6F 6D Invalidate(); } virtual void __fastcall CreateParams(TCreateParams &Params) { // 去掉Hint窗口的边框 Params.Style = Params.Style & ~WS_BORDER; THintWindow::CreateParams(Params); } // Code by ccrun(老妖),做人要厚道,转载请留名 virtual void __fastcall ActivateHint( const TRect &Rect, const String AHint) { FActivating = true; try { Caption = AHint; TRect r = Rect; r.Left -= 10; r.Right += 10; r.Top -= 5; r.Bottom += 5; // 更新区域 UpdateBoundsRect(r); // Hint窗口处于屏幕边缘时的调整 if(r.Top + Height > Screen->DesktopHeight) r.Top = Screen->DesktopHeight - Height; if(r.Left + Width > Screen->DesktopWidth) r.Left = Screen->DesktopWidth - Width; if(r.Left < Screen->DesktopLeft) r.Left = Screen->DesktopLeft; if(r.Bottom < Screen->DesktopTop) r.Bottom = Screen->DesktopTop; // 创建一个矩形 // 63 63 72 75 6E 2E 63 6F 6D HRGN hrgn = CreateRectRgn(0, 0, r.Width(), r.Height()); // HRGN hrgn = CreateRoundRectRgn(0, 0, r.Width(), r.Height(), 4, 4); // 设置指定句柄的窗 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn
为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
|