Pop-up bubble message in Delphi

Source: Internet
Author: User

 

/// // ---------- 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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.