How to customize the Prompt window (Hint windows)
Last Update:2017-02-27
Source: Internet
Author: User
Custom Thintwindow Class Class Tccrunhintwindow:public Thintwindow { BOOL factivating; __fastcall Tccrunhintwindow (tcomponent* Owner) : Thintwindow (Owner) { Canvas->font->name = "Song Body"; Canvas->font->color = Clblack; Canvas->font->size = 9; } void __fastcall Paint (void) { Trect rect = clientrect; Hint Border color Canvas->brush->color = TColor (0XDBB8BA); Canvas->fillrect (rect); Draw the entire hint border Canvas->pen->color = TColor (0x69230e); Canvas->rectangle (rect); Color of hint background Color = Clwhite; Hint Text transparency Canvas->brush->style = Bsclear; Draw the hint text Canvas->font->color = Clblack; Canvas->textout (4, int (rect). BOTTOM/2) -Int (Canvas->textheight (Caption)/2), Caption); } virtual void __fastcall ncpaint (HDC HDC) { 6E 2E 6F 6D Invalidate (); } virtual void __fastcall createparams (tcreateparams ¶ms) { Remove the border from the hint window Params.style = Params.style & ~ws_border; Thintwindow::createparams (Params); } Code by Ccrun (old demon), a person to be kind, reprint please be remembered 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; Update area Updateboundsrect (R); Adjust the hint window when it is on the edge of the screen 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; Create a rectangle 6E 2E 6F 6D Hrgn hrgn = createrectrgn (0, 0, r.width (), R.height ()); Hrgn hrgn = createroundrectrgn (0, 0, r.width (), R.height (), 4, 4); Sets the window shape of the specified handle SetWindowRgn (Handle, Hrgn, true); Change the position of the window, Z order, and some other attributes SetWindowPos (Handle, Hwnd_topmost, R.left, R.top, R.width (), R.height (), Swp_showwindow | Swp_noactivate); Repaint window Invalidate (); } __finally { Factivating = false; } } };
//--------------------------------------------------------------------------- // 实现代码 __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { HintWindowClass = __classid(TCcrunHintWindow); // ShowHint = true; Button1->Hint = "这是一个按钮"; Edit1->Hint = "这是一个文本框"; }