/// // ---------- Parameter description ---------------------///////////// /////////
// H: the handle of the control in the form (message is prompted on a control) (control handle to be called)
// Text: the text to be prompted
// Cap: the title in the prompt box
// IconType: the icon displayed in the prompt box (three values in total. 1, 2, and 3 are prompts, warnings, and error s)
// T: the message stay time (in milliseconds)
// Left: The left distance between the message frame and the control. If it is set to 0, no
// Top: the distance between the message frame and the control. If it is set to 0, no
Procedure TFrmMain. QiPaoShowMessage (h: HWND; text, cap: string; IconType: integer = 1; t: integer = 1000; left: Integer = 0; top: Integer = 0 );
Var
R: TRect; // a Record that stores the values of four coordinates or two points in the rectangle (two points in the lower right corner of the upper left corner.
HTooltip: Cardinal; // Cardinal is a 32-bit unsigned integer. The value range is 0 to 4294967295.
Ti: TToolInfo;
Begin
HToolTip: = CreateWindow ('tooltips _ class32', nil, $, 0, 0, 0, 0, hInstance, nil );
If hToolTip <> 0 then
Begin
SetWindowPos (hToolTip, HWND_TOPMOST, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE); // set the bubble to the beginning
Ti. cbSize: = SizeOf (TToolInfo );
Ti. uFlags: = TTF_IDISHWND or TTF_TRACK;
Ti. hInst: = hInstance;
Ti. lpszText: = pchar (text );
SendMessage (hToolTip, TTM_ADDTOOL, 0, Integer (@ ti ));
If (IconType> 3) or (IconType <0) then IconType: = 0;
SendMessage (hToolTip, WM_USER + 32, IconType, Integer (pchar (cap )));
GetWindowRect (H, R); // obtain the coordinates of the specified control, such as R. Right, R. Left, R. Bottom, and R. Top.
R. Left: = r. Left-left;
R. Top: = r. Top-top;
// Define the bubble position
SendMessage (hToolTip, TTM_TRACKPOSITION, 0, MAKELONG (r. right-r. left) div 2 + r. left, (r. bottom-r. top) div 2 + r. top); SendMessage (hToolTip, TTM_TRACKACTIVATE, Integer (True), Integer (@ ti ));
Sleep (t );
DestroyWindow (hToolTip );
End;
End;
The result is as follows: