XBalloonMsg - a non-MFC balloon-shaped message box

简介:
原文链接:XBalloonMsg - a non-MFC balloon-shaped message box
只需要调用下面两个函数:

Function

Description

void Show()

显示气泡状信息

void Destroy()

从屏幕上删除气泡状信息


复制代码
//=============================================================================
// special symbol for title string - replaced with module name
#define LPCTSTR_DEFAULT_TITLE    ((LPCTSTR)-1L)

//=============================================================================
class CXBalloonMsg
//=============================================================================
{
// Construction
public:
    CXBalloonMsg();
    virtual ~CXBalloonMsg();

// Attributes
public:
    static HWND m_hWndBalloon;

// Operations
public:
    static void Show(LPCTSTR lpszTitle, 
                     LPCTSTR lpszMsg, 
                     HWND hCtrl, 
                     HWND hParent,
                     HINSTANCE hInstance,
                     UINT nIcon = TTI_INFO,
                     BOOL bUseBalloonTips = TRUE,
                     UINT nTimeOutSeconds = 0,
                     LPRECT pRect = NULL);
    static void Destroy();

// Implementation
protected:
    static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
    static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
    static LRESULT __stdcall DefWindowProcX(HWND hWnd,
                                UINT message,
                                WPARAM wParam,
                                LPARAM lParam);
    static void CALLBACK TimerProcX(HWND hwnd,
                                UINT message,
                                UINT_PTR nIdEvent,
                                DWORD dwTime);
    static BOOL GetEnableBalloonTips();
    static void GetStrings(LPCTSTR lpszTitle, LPCTSTR lpszMsg, HINSTANCE hInstance);
    static TCHAR * GetModuleName(HINSTANCE hInstance);
    static void PositionBalloon(LPRECT pRect, LPRECT pNewRect, BOOL bBalloon);

    static BOOL            m_bInit;            // TRUE = initialization finished
    static BOOL            m_bUseBalloonTips;    // TRUE = use balloon tips if possible
    static BOOL            m_bBalloon;            // TRUE = balloon tips not disallowed in 
                                            // registry
    static HINSTANCE    m_hInstance;        // app instance
    static UINT            m_nIcon;            // icon to use
    static UINT            m_nLastMessage;        // last message received
    static UINT            m_nTimeOutSeconds;    // message timeout in seconds;
                                            // 0 = no timeout
    static UINT            m_nTimerId;            // timer id returned by SetTimer()
    static LPRECT        m_pRect;            // NULL = use control rect
    static HWND            m_hWnd;                // hwnd of CXBalloonMsg
    static HWND            m_hParent;            // parent hwnd
    static HWND            m_hCtrl;            // control hwnd
    static WNDPROC        m_wndProc;            // window proc for parent subclassing
    static HHOOK        m_hKeyboardHook;    // keyboard hook
    static HHOOK        m_hMouseHook;        // mouse hook
    static TCHAR        m_szTitle[500];        // title string
    static TCHAR        m_szMsg[4000];        // message string
};

复制代码

实现代码
显示API详解

      Show函数创建,显示并操作一个气泡状的消息对话框。这个消息对话框包含一个消息字段和标题,一个关闭按钮,和一个可选的图标。
 

void Show(

LPCTSTR lpszTitle,
LPCTSTR lpszMsg,
HWND hCtrl,
HWND hParent,
HINSTANCE hInstance,
UINT nIcon = TTI_INFO,
BOOL bUseBalloonTips = TRUE,
UINT nTimeOutSeconds = 0,
LPRECT pRect = NULL

); 

Parameters 

lpszTitle

[in] Pointer to a null-terminated string that contains the balloon message title. If this parameter is NULL, no title and no icon will be displayed. The special symbol LPCTSTR_DEFAULT_TITLE may be used; it will cause the executable module name to be displayed.


lpszMsg

[in] Pointer to a null-terminated string that contains the balloon message to be displayed. Must not be null. Text callbacks (LPSTR_TEXTCALLBACK) are not used, so the text string can be as long as you want, up to the size of the internal text buffer m_szMsg.


hCtrl

[in] Handle to the control that the message is being displayed for. Must not be null.


hParent

[in] Handle to the parent window of the control. Must not be null.


hInstance

[in] Handle to the instance of the module that contains the string resource. May be null if string resource is not used.


nIcon

[in] Specifies the icon to associate with the balloon message. This can be one of the following values:

Value

Meaning

TTI_ERROR

Use the error icon

TTI_INFO

Use the information icon

TTI_NONE

Use no icon

TTI_WARNING

Use the warning icon

This parameter may also be the handle of an icon obtained from LoadIcon or LoadImage functions. If not present, this parameter defaults to TTI_INFO.

bUseBalloonTips

[in] Specifies whether balloon tips are to be used to display the message. If this parameter is TRUE, balloon tips will be used unless disabled in the registry. If this parameter is FALSE, regular tooltips will be used, regardless of value of registry key. If not present, this parameter defaults to TRUE.


nTimeOutSeconds

[in] Specifies the number of seconds before the balloon message is automatically closed. If this parameter is zero, the balloon message will not be automatically closed. If not present, this parameter defaults to zero.


pRect

[in] Pointer to a RECT struct that contains position where balloon message is to be displayed. May be null if default position should be used. If not present, this parameter defaults to null.




本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/06/26/1230745.html,如需转载请自行联系原作者
目录
相关文章
使用系统托盘图标,显示 Balloon Tooltip 的 MASM32 演示代码
使用系统托盘图标,显示 Balloon Tooltip 的 MASM32 演示代码
|
7月前
【qt】Tool Box组件
【qt】Tool Box组件
80 0
|
4月前
|
容器
【Qt 学习笔记】Qt常用控件 | 容器类控件 | Group Box的使用及说明
【Qt 学习笔记】Qt常用控件 | 容器类控件 | Group Box的使用及说明
368 3
|
4月前
【Qt 学习笔记】Qt常用控件 | 按钮类控件 | Check Box的使用及说明
【Qt 学习笔记】Qt常用控件 | 按钮类控件 | Check Box的使用及说明
125 0
Qt6:移除[signal] void QComboBox:: currentIndexChanged (const QString & text )信号
通过对比Qt 6.0.1和qt 5.12.9的文档发现,Qt 6.0.1中已经没有[signal] void QComboBox:: currentIndexChanged (const QString & text )信号了。
163 0
Qt6:移除[signal] void QComboBox:: currentIndexChanged (const QString & text )信号
|
Android开发
解决 error: style attribute '@android:attr/windowEnterAnimation' not found.
解决 error: style attribute '@android:attr/windowEnterAnimation' not found.
197 0