CMFCDesktopAlertWnd Class
The CMFCDesktopAlertWnd class implements the functionality of a modeless dialog box which appears on the screen to inform the user about an event.
class CMFCDesktopAlertWnd : public CWnd
Members
Public Methods
Name |
Description |
---|---|
Creates and initializes the desktop alert window. |
|
Returns the animation speed. |
|
Returns the animation type. |
|
Returns the auto-close time out. |
|
Returns the height of the caption. |
|
|
|
Returns the last valid position of the desktop alert window on the screen. |
|
Returns the transparency level. |
|
Determines whether the desktop alert window is displayed with the small caption. |
|
|
|
Called by the framework when the user clicks a link button located on the desktop alert menu. |
|
The framework calls this member function when the user selects an item from a menu, when a child control sends a notification message, or when an accelerator keystroke is translated. (Overrides CWnd::OnCommand.) |
|
|
|
|
|
Sets the new animation speed. |
|
Sets the animation type. |
|
Sets the auto-close time out. |
|
Switches between small and normal captions. |
|
Sets the transparency level. |
Remarks
A desktop alert window can be transparent, it can appear with animation effects, and it can disappear (after a specified delay or when the user dismisses it by clicking the close button).
A desktop alert window can also contain a default dialog that in turn contains an icon, message text (a label), and a link. Alternatively, a desktop alert window can contain a custom dialog from the application's resources.
You create a desktop alert window in two steps. First, call the constructor to construct the CMFCDesktopAlertWnd object. Second, call the CMFCDesktopAlertWnd::Create member function to create the window and attach it to the CMFCDesktopAlertWnd object.
The CMFCDesktopAlertWnd object creates a special child dialog box that fills the client area of the desktop alert window. The dialog owns all the controls that are positioned on it.
To display a custom dialog box on the popup window, follow these steps:
Derive a class from CMFCDesktopAlertDialog.
Create a child dialog box template in the resources.
Call CMFCDesktopAlertWnd::Create using the resource ID of the dialog box template and a pointer to the runtime class information of the derived class.
Program the custom dialog box to handle all notifications coming from the hosted controls, or program the hosted controls to handle these notifications directly.
Use the following functions to control the behavior of the desktop alert window:
Set the animation type by calling CMFCDesktopAlertWnd::SetAnimationType. Valid options include unfold, slide, and fade.
Set the animation frame speed by calling CMFCDesktopAlertWnd::SetAnimationSpeed.
Set the transparency level by calling CMFCDesktopAlertWnd::SetTransparency.
Change the size of the caption to small by calling CMFCDesktopAlertWnd::SetSmallCaption. The small caption is 7 pixels high.
Example
The following example illustrates how to use various methods in the CMFCDesktopAlertWnd class to configure a CMFCDesktopAlertWnd object. The example shows how to set an animation type, set the transparency of the pop-up window, specify that the alert window displays a small caption, and set the time that elapses before the alert window automatically closes. The example also demonstrates how to create and initialize the desktop alert window. This code snippet is part of the Desktop Alert Demo sample.
CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd;
// int m_nAnimation
pPopup->SetAnimationType ((CMFCPopupMenu::ANIMATION_TYPE) m_nAnimation);
// int m_nAnimationSpeed
pPopup->SetAnimationSpeed (m_nAnimationSpeed);
// int m_nTransparency
pPopup->SetTransparency ((BYTE)m_nTransparency);
// BOOL m_bSmallCaption
pPopup->SetSmallCaption (m_bSmallCaption);
// BOOL m_bAutoClose, int m_nAutoCloseTime
pPopup->SetAutoCloseTime (m_bAutoClose ? m_nAutoCloseTime * 1000 : 0);
// int m_nPopupSource
if (m_nPopupSource == 0)
{
// int m_nVisualMngr
// CPoint m_ptPopup
// The this pointer points to a CDesktopAlertDemoDlg class which extends the CDialogEx class.
if (m_nVisualMngr == 5) // MSN-style
{
pPopup->Create (this, IDD_DIALOG2, NULL,
m_ptPopup, RUNTIME_CLASS (CMSNDlg));
}
else
{
pPopup->Create (this, IDD_DIALOG1,
m_menuPopup.GetSubMenu (0)->GetSafeHmenu (),
m_ptPopup, RUNTIME_CLASS (CMyPopupDlg));
}
}
Inheritance Hierarchy
Requirements
Header: afxDesktopAlertWnd.h