description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CMFCDesktopAlertWnd Class |
CMFCDesktopAlertWnd Class |
10/18/2018 |
|
|
73a2dd7b-ea84-4ae2-9830-7cf6e8dd2425 |
The CMFCDesktopAlertWnd
class implements the functionality of a modeless dialog box which appears on the screen to inform the user about an event.
For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.
class CMFCDesktopAlertWnd : public CWnd
Name | Description |
---|---|
CMFCDesktopAlertWnd::Create | Creates and initializes the desktop alert window. |
CMFCDesktopAlertWnd::GetAnimationSpeed | Returns the animation speed. |
CMFCDesktopAlertWnd::GetAnimationType | Returns the animation type. |
CMFCDesktopAlertWnd::GetAutoCloseTime | Returns the auto-close time out. |
CMFCDesktopAlertWnd::GetCaptionHeight | Returns the height of the caption. |
CMFCDesktopAlertWnd::GetDialogSize | |
CMFCDesktopAlertWnd::GetLastPos | Returns the last valid position of the desktop alert window on the screen. |
CMFCDesktopAlertWnd::GetTransparency | Returns the transparency level. |
CMFCDesktopAlertWnd::HasSmallCaption | Determines whether the desktop alert window is displayed with the small caption. |
CMFCDesktopAlertWnd::OnBeforeShow | |
CMFCDesktopAlertWnd::OnClickLinkButton | Called by the framework when the user clicks a link button located on the desktop alert menu. |
CMFCDesktopAlertWnd::OnCommand | 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.) |
CMFCDesktopAlertWnd::OnDraw | |
CMFCDesktopAlertWnd::ProcessCommand | |
CMFCDesktopAlertWnd::SetAnimationSpeed | Sets the new animation speed. |
CMFCDesktopAlertWnd::SetAnimationType | Sets the animation type. |
CMFCDesktopAlertWnd::SetAutoCloseTime | Sets the auto-close time out. |
CMFCDesktopAlertWnd::SetSmallCaption | Switches between small and normal captions. |
CMFCDesktopAlertWnd::SetTransparency | Sets the transparency level. |
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.
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.
[!code-cppNVC_MFC_DesktopAlertDemo#1]
Header: afxDesktopAlertWnd.h
Creates and initializes the desktop alert window.
virtual BOOL Create(
CWnd* pWndOwner,
UINT uiDlgResID,
HMENU hMenu = NULL,
CPoint ptPos = CPoint(-1,-1),
CRuntimeClass* pRTIDlgBar = RUNTIME_CLASS(CMFCDesktopAlertDialog));
virtual BOOL Create(
CWnd* pWndOwner,
CMFCDesktopAlertWndInfo& params,
HMENU hMenu = NULL,
CPoint ptPos = CPoint(-1,-1));
pWndOwner
[in, out] Specifies the owner of the alert window. That owner will then receive all notifications for the desktop alert window. This value cannot be NULL.
uiDlgResID
[in] Specifies the resource ID of the alert window.
hMenu
[in] Specifies the menu that displays when the user clicks the menu button. If NULL, the menu button is not displayed.
ptPos
[in] Specifies the initial position where the alert window is displayed, using screen coordinates. If this parameter is (-1, -1), the alert window is displayed in the lower-right corner of the screen.
pRTIDlgBar
[in] Runtime class information for a custom dialog box class that covers the alert window's client area.
params
[in] Specifies parameters that are used to create an alert window.
TRUE if the alert window was created successfully; otherwise, FALSE.
Call this method to create an alert window. The client area of the alert window contains a child dialog box that hosts all controls that are displayed to the user.
The first method overload creates an alert window that contains a child dialog box that is loaded from the application's resources. The first method overload can also specify runtime class information for a custom dialog box class.
The second method overload creates an alert window that contains default controls. You can specify which controls to display by modifying the CMFCDesktopAlertWndInfo Class.
Returns the animation speed.
UINT GetAnimationSpeed() const;
The animation speed of the alert window, in milliseconds.
The animation speed describes how fast the alert window opens and closes.
Returns the animation type.
CMFCPopupMenu::ANIMATION_TYPE GetAnimationType();
One of the following animation types:
-
NO_ANIMATION
-
UNFOLD
-
SLIDE
-
FADE
-
SYSTEM_DEFAULT_ANIMATION
Returns the auto-close time out.
int GetAutoCloseTime() const;
The time, in milliseconds, after which the alert window will automatically close.
Use this method to determine how much time should elapse before the alert window will automatically close.
Returns the height of the caption.
virtual int GetCaptionHeight();
The height, in pixels, of the caption.
This method can be overridden in a derived class. The default implementation either: returns the small caption height value (7 pixels) if the popup window should display the small caption, or the value obtained from the Windows API function GetSystemMetrics(SM_CYSMCAPTION)
.
Returns the last position of the desktop alert window on the screen.
CPoint GetLastPos() const;
A point, in screen coordinates.
This method returns the last valid position of the alert window on the screen.
Returns the transparency level.
BYTE GetTransparency() const;
A transparency level between 0 and 255, inclusive. The greater the value, the more opaque the window.
Use this method to retrieve the current transparency level of the alert window.
Determines whether the desktop alert window has a small caption or a regular-size caption.
BOOL HasSmallCaption() const;
TRUE if the popup window is displayed with a small caption; FALSE if the popup window is displayed with a regular-sized caption.
Use this method to determine whether the popup window has a small caption or a regular-size caption. By default, the small caption is 7 pixels high. You can obtain the height of the regular-size caption by calling the Windows API function GetSystemMetrics(SM_CYCAPTION)
.
virtual BOOL OnBeforeShow(CPoint&);
[in] CPoint&
Called by the framework when the user clicks a link button located on the desktop alert menu.
virtual BOOL OnClickLinkButton(UINT uiCmdID);
uiCmdID
[in] This parameter is not used.
Always FALSE.
Override this method in a derived class if you want to be notified when a user clicks the link on the alert window.
virtual BOOL OnCommand(
WPARAM wParam,
LPARAM lParam);
[in] wParam
[in] lParam
virtual void OnDraw(CDC* pDC);
[in] pDC
BOOL ProcessCommand(HWND hwnd);
[in] hwnd
Sets the new animation speed.
void SetAnimationSpeed(UINT nSpeed);
nSpeed
[in] Specifies the new animation speed, in milliseconds.
Call this method to set the animation speed for the alert window. The default animation speed is 30 milliseconds.
Sets the animation type.
void SetAnimationType(CMFCPopupMenu::ANIMATION_TYPE type);
type
[in] Specifies the animation type.
Call this method to set animation type. You can specify one of the following values:
-
NO_ANIMATION
-
UNFOLD
-
SLIDE
-
FADE
-
SYSTEM_DEFAULT_ANIMATION
Sets the auto-close time out.
void SetAutoCloseTime(int nTime);
nTime
[in] The time, in milliseconds, that elapses before the alert window automatically closes.
The alert window is automatically closed after the specified time if the user does not interact with the window.
Switches between small and regular-size captions.
void SetSmallCaption(BOOL bSmallCaption = TRUE);
bSmallCaption
[in] TRUE to specify that the alert window displays a small caption; otherwise, FALSE to specify that the alert window displays a regular-size caption.
Call this method to display the small or regular-size caption. By default, the small caption is 7 pixels high. You can obtain the size of the regular caption by calling the Windows API function GetSystemMetrics(SM_CYCAPTION)
.
Sets the transparency level of the popup window.
void SetTransparency(BYTE nTransparency);
nTransparency
[in] Specifies the transparency level. This value must be between 0 and 255, inclusive. The greater the value, the more opaque the window.
Call this function to set the transparency level of the popup window.
virtual CSize GetDialogSize();
Hierarchy Chart
Classes
CMFCDesktopAlertWndInfo Class
CMFCDesktopAlertDialog Class
CWnd Class