When using Microsoft® Outlook®, we come across the mail notification window, which appears slowly and starts disappearing. It displays a summary of a mail, including the sender's name etc. This articles describes how to build that kind of a window using ATL.
I recently came across an article by Nick Wälti. But did not find any C++ code for achieving the same. So I tried to achieve something similar using ATL.
Using the code
There are three classes:
CATLNotifyDialog represents the main UI.
CNotifyWnd represents the notification window.
CBmpButton represents the bitmap button class, used as the 'Close' button.
typedef CWinTraits <WS_CLIPCHILDREN | WS_POPUP |WS_VISIBLE ,0 > CNotificationWinTraits;
class CNotifyWnd : public CWindowImpl<CNotifyWnd,CWindow,CNotificationWinTraits>
LRESULT ChangeOpacity(BYTE iFactor);
REFLECT_NOTIFICATIONS is declared to send messages to child windows. In this case, the button window is the child. In the
OnCreate function, modify the extended style of the window by adding
WS_EX_LAYERED. More information on Layered Windows can found in the MSDN.
if ( ModifyStyleEx(0,WS_EX_LAYERED ))
ChangeOpacity function of this class will bring a translucent effect to the window.
LRESULT CNotifyWnd::ChangeOpacity(BYTE iFactor)
typedef DWORD (WINAPI *pSetLayeredWindowAttributes)(HWND, DWORD, BYTE, DWORD);
HMODULE hDLL = LoadLibrary ("user32");
if (hDLL )
SetLayeredWindowAttributes = (pSetLayeredWindowAttributes)
iFactor, LWA_COLORKEY | LWA_ALPHA);
CBmpButton is a button class. It uses three bitmaps to represent its states, i.e., normal, mouse move, and pressed. I could not get better bitmaps for this application, but a more artistic person can really make it beautiful.
class CBmpButton :public CWindowImpl<CBmpButton>
DECLARE_WND_SUPERCLASS( _T("BitmapButton"), _T("Button") )
Here is an important function of the above class:
LRESULT CBmpButton::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
CBmpButton::OnMouseLeave will set
m_nCurrentBmp with the appropriate bitmap.
The code assumes that the taskbar is always at the bottom (does not consider other cases).
Points of Interest
It does not use MFC (that's lighter!).
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.