Balloontip usually appears on the icon in the lower-right corner of the screen, such as the bubble prompt when you plug or remove the USB device. This function is located in shell32 and is implemented by calling the following API function: bool shell_policyicon (DWORD dwmessage, ppolicyicondata lpdata). This function is used to control trayicon and a balloontip is displayed. However, it can only be limited to the tray position. In the QQ chat dialog box, we found that if you try to send a message without entering the content, such a tip will pop up on the button. Therefore, I wrote a similar window in C #, which can be surfaced at any location. The effect is as follows:
This is a testProgram. In implementation, I slightly referred to the process of simulating MSN surfaced windows on codeproject.Code. The main trouble involved is how to handle the layout of elements in the window to provide flexible enough interfaces. For the sake of simplicity, only the layout of the arrow in the lower right corner is provided. (Obviously, this arrow can have a total of eight dock locations ).
(1) In the pop-up, do not take away the focus of other windows. Therefore, the showwindow function of the API is used: showwindow (this. Handle, sw_shownoactivate );
(2) The form contains four main items: icon, title, content text, and close button. Users can configure them. For example, they can select an icon (which can be set externally or using a built-in icon), whether to display the close button, and whether to automatically close it (if the timeoutmilliseconds attribute is set to a negative number, it will not automatically close, can only be closed through closebutton), various colors, fonts, etc. A balloonclick event is provided to notify external users of click events.
(3) When drawing a closebutton bitmap, because the figure has a transparent color, you need to specify a transparent color during painting, which is equivalent to the mask. Otherwise, the transparent color will be drawn to the form, causing the form to be transparent.
(4) This window is displayed, mainly using the showat () function. Some parameters are required. You can set other attributes separately.
Source codeDownload link:
Http://files.cnblogs.com/hoodlum1980/JDL.UILib_BalloonTip_VS7.rar