Click here to Skip to main content
11,645,489 members (68,344 online)
Click here to Skip to main content

Taskbar Notification dialog

, 11 Jul 2002 500.6K 15.5K 325
Rate this:
Please Sign up or sign in to vote.
A MSN IM-style popup notification dialog
<!-- Download Links -->

Introduction

A few weeks ago I saw a MSN messenger popup class on Codeproject written by Prateek Kaul. Since I needed a taskbar popup with skin support, I decided to write my own new class.

This is my first submission to Codeproject, since I think my code begins to be mature enough to be posted.

Compatibility

This class needs MFC to be either statically or dynamically linked in your project; it has been written, compiled and tested under Visual Studio .Net (but should work with VC6)

How to use the Class

The class is very easy to use: Just add TaskbarNotifier.h and TaskbarNotifier.cpp into your project, then include TaskbarNotifier.h into your application, add a CTaskbarNotifier member variable in the header file of your Dialog or Window class.

In the OnInitDialog or OnCreate member functions add the following lines:

m_wndTaskbarNotifier.Create(this);
m_wndTaskbarNotifier.SetSkin(IDB_MY_BITMAP_RESOURCE);
m_wndTaskbarNotifier.SetTextFont("Arial",90,TN_TEXT_NORMAL,TN_TEXT_UNDERLINE);
m_wndTaskbarNotifier.SetTextColor(RGB(0,0,0),RGB(0,0,200));
m_wndTaskbarNotifier.SetTextRect(CRect(10,40,m_wndTaskbarNotifier1.m_nSkinWidth-10,
                                 m_wndTaskbarNotifier1.m_nSkinHeight-25));

Then when you want to show the popup animation just call anywhere m_wndTaskNotifier.Show("Text to display"); this will show the animation of the window appearing and then disappearing. You can call again the Show() method whenever you want. If the popup was still here, the text is just replaced, if it was disappearing, it maximizes again.

Be sure not to allocate the CTaskbarNotifier each time you want to show a message, because the skinning function takes a little CPU time to generate the region used to make a non rectangular window.

Class Documentation

int Create(CWnd *pWndParent);

Creates the popup window which remains hidden until Show() is called

 

BOOL SetSkin(UINT nBitmapID,short red=-1,short green=-1,short blue=-1);
BOOL SetSkin(LPCTSTR szFileName,short red=-1,short green=-1,short blue=-1);

Those two functions assign a skin to the popup, they take as parameter either a Bitmap resource ID or the path of a bitmap file.
The optional parameters are the RGB values for the transparency color for the bitmap. Use these parameters only if you want a non rectangular window; if these parameters are left blank no Region is created.

 

void SetTextFont(LPCTSTR szFont,int nSize,int nNormalStyle,int nSelectedStyle);

This function permits to specify the Font used for displaying the text (two styles are possible, one for the normal state and one when the mouse is over the window)

nNormalStyle or nSelectedStyle can be one or a combination of these parameters

  • TN_TEXT_NORMAL
  • TN_TEXT_BOLD
  • TN_TEXT_ITALIC
  • TN_TEXT_UNDERLINE

 

void SetTextColor(COLORREF crNormalTextColor,COLORREF crSelectedTextColor);

This function sets the color of the text when in normal or selected state.

 

void SetTextRect(RECT rcText);

This function allows to define a rectangle within the bitmap which will be the clipping zone for displaying the text.

 

void Show(LPCTSTR szCaption,DWORD dwTimeToShow=800,DWORD dwTimeToStay=3000,
           DWORD dwTimeToHide=500,int nIncrement=1);

Dispays the popup window animation:

szCaption: Text to display
dwTimeToShow: Duration in milliseconds for the popup to be fully visible
dwTimeToStay: Duration in milliseconds for the popup to be stay visible
dwTimeToHide: Time in millisecond for the popup to completely disappear
nIncrement: Pixel increment for moving the window during the animation (the higher, the faster)

Show can be called even if the popup is already visible, being hiding or showing.

void Hide();

Manually Hides the popup.

Additional notes:

When the user clicks on the popup, a message is being sent to its parent window (WM_TASKBARNOTIFIERCLICKED defined in TaskbarNotifier.h), you can intercept it by adding in your Message Map macro:

ON_MESSAGE(WM_TASKBARNOTIFIERCLICKED,OnTaskbarNotifierClicked)

The fact I'm not releasing the HRGN handle is because when you call SetWindowRgn() function, the GDI takes care of the object deletion.

Conclusion

Thanks to Prateek Kaul whose code inspired me to write this class and to Vander Nunes for his article about skinning a window.

I hope this class will be useful to you, if you find any memory or GDI leaks, please let me know. If you have suggestions to enhance this class functionalities, please post a comment.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

John O'Byrne
Web Developer
United States United States
I live in Santa Clara CA and work as a software engineer for SAP Business Objects.

My areas of expertise are user interface developments in Eclipse RCP / SWT / Draw 2D and C#

You may also be interested in...

Comments and Discussions

 
QuestionPlease send me the demo src Pin
ASUO147828-Nov-13 17:00
memberASUO147828-Nov-13 17:00 
Questioncan i add close button on notification bitmap??? Pin
pramod_17_1027-Nov-12 16:07
memberpramod_17_1027-Nov-12 16:07 
QuestionHow to scroll information in the pop up window? Pin
qingqingcao21-Dec-11 19:35
memberqingqingcao21-Dec-11 19:35 
QuestionHow can i add a button in the Notifier Dlg? Pin
sl11l11l11l20-Sep-11 17:23
membersl11l11l11l20-Sep-11 17:23 
QuestionWTL Task Bar Notifier Pin
Gene OK17-Aug-11 7:36
memberGene OK17-Aug-11 7:36 
QuestionDoes not work for Windows 7? Pin
rootdial8-Jul-09 0:02
memberrootdial8-Jul-09 0:02 
AnswerRe: Does not work for Windows 7? Pin
Mr. S12-Feb-11 6:49
memberMr. S12-Feb-11 6:49 
QuestionDoes Anyone has the xmesseger.zip file ? Pin
tipiak0728-Jun-09 8:50
membertipiak0728-Jun-09 8:50 
AnswerRe: Does Anyone has the xmesseger.zip file ? Pin
handaomeng24-Mar-10 7:12
memberhandaomeng24-Mar-10 7:12 
also send me tangwanghan@gmail.com
thanks!
66

GeneralMultiple Text regions Pin
jamalhaider7-May-08 3:34
memberjamalhaider7-May-08 3:34 
GeneralShockwave ActiveX problem!! Pin
park00887-Jan-08 0:07
memberpark00887-Jan-08 0:07 
GeneralGREAT work!!! Pin
Assafk31-Oct-07 2:08
memberAssafk31-Oct-07 2:08 
GeneralBad look on Vista Pin
_alav_15-Oct-07 1:30
member_alav_15-Oct-07 1:30 
GeneralRe: Bad look on Vista Pin
Sachin_Developer30-Apr-08 19:53
memberSachin_Developer30-Apr-08 19:53 
QuestionAnimated Gif is possible ? Pin
lbispo11-Jul-07 9:44
memberlbispo11-Jul-07 9:44 
GeneralLong textes arent smart handled Pin
KarstenK8-Jul-07 23:24
memberKarstenK8-Jul-07 23:24 
GeneralHave you sample code... Pin
Antonio292912-Jun-07 23:44
memberAntonio292912-Jun-07 23:44 
Generala problem about hide main window, then popup window hide. Pin
jacky_zz31-May-07 19:06
memberjacky_zz31-May-07 19:06 
GeneralRe: a problem about hide main window, then popup window hide. Pin
stevenxyj29-Sep-07 16:16
memberstevenxyj29-Sep-07 16:16 
GeneralRe: a problem about hide main window, then popup window hide. Pin
Member 448122428-Jan-08 20:05
memberMember 448122428-Jan-08 20:05 
GeneralRe: a problem about hide main window, then popup window hide. Pin
Ralph Mullenders2-Apr-08 2:05
memberRalph Mullenders2-Apr-08 2:05 
QuestionCan i add button or option in notifier window Pin
gugalia1-May-07 19:58
membergugalia1-May-07 19:58 
Questioncan i popup this notifier using win service..? Pin
raam_kimi5-Feb-07 23:21
memberraam_kimi5-Feb-07 23:21 
Questionif my Module is console program, how can i use this style? Pin
charlie790827-Oct-06 4:20
membercharlie790827-Oct-06 4:20 
General'CWnd' : base class undefined [modified] Pin
JavaBeginner0125-Aug-06 12:47
memberJavaBeginner0125-Aug-06 12:47 
GeneralRe: 'CWnd' : base class undefined Pin
Luke DeStevens9-Oct-07 10:18
memberLuke DeStevens9-Oct-07 10:18 
GeneralAn error Pin
duplace10-Aug-06 22:18
memberduplace10-Aug-06 22:18 
QuestionHow to add flickering function.. [modified] Pin
wegaia10-Aug-06 4:57
memberwegaia10-Aug-06 4:57 
GeneralNice but a little problem... Pin
howenActions13-Jun-06 23:39
memberhowenActions13-Jun-06 23:39 
GeneralError Pin
TheChode6-Nov-05 9:17
memberTheChode6-Nov-05 9:17 
Questionhow to use this class in a managed c++ .net application Pin
olegarior7-Oct-05 11:40
memberolegarior7-Oct-05 11:40 
AnswerRe: how to use this class in a managed c++ .net application Pin
scorpion_anshul14-Jan-06 18:38
memberscorpion_anshul14-Jan-06 18:38 
GeneralFix small problem when TaskBar Notifier occupy focus of MainFrame Pin
KienDN16-Sep-05 18:41
memberKienDN16-Sep-05 18:41 
GeneralRe: Fix small problem when TaskBar Notifier occupy focus of MainFrame Pin
Aji Varghese Tera14-Sep-06 4:12
memberAji Varghese Tera14-Sep-06 4:12 
GeneralRe: Fix small problem when TaskBar Notifier occupy focus of MainFrame Pin
alfonsopilato20-Nov-06 18:48
memberalfonsopilato20-Nov-06 18:48 
GeneralRe: Fix small problem when TaskBar Notifier occupy focus of MainFrame Pin
jaxclin8811-Jun-07 21:41
memberjaxclin8811-Jun-07 21:41 
QuestionFor ATL use? Pin
kimi_roy14-Jul-05 23:57
susskimi_roy14-Jul-05 23:57 
GeneralIf Taskbar is in autohide Mode Pin
KarstenK29-Jun-05 23:58
memberKarstenK29-Jun-05 23:58 
GeneralUse &quot;SelectFolder&quot; should beware of Drive Volumn Name Pin
Evan Lin5-Jun-05 22:55
memberEvan Lin5-Jun-05 22:55 
Questionfade-in/out instead of sliding? Pin
flashyjigga16-May-05 4:49
memberflashyjigga16-May-05 4:49 
AnswerRe: fade-in/out instead of sliding? Pin
Dean Hallman28-Jun-05 11:24
memberDean Hallman28-Jun-05 11:24 
QuestionWTL Version? Pin
Dean Hallman9-May-05 5:45
memberDean Hallman9-May-05 5:45 
AnswerRe: WTL Version? Pin
WTL Student6-Jun-05 13:44
memberWTL Student6-Jun-05 13:44 
GeneralRe: WTL Version? Pin
Dean Hallman6-Jun-05 17:34
memberDean Hallman6-Jun-05 17:34 
GeneralHelp Pin
Ahmad Hussain19-Mar-05 18:49
memberAhmad Hussain19-Mar-05 18:49 
QuestionCan you convert this to a component? Pin
odegnan18-Mar-05 5:51
memberodegnan18-Mar-05 5:51 
AnswerRe: Can you convert this to a component? Pin
John O'Byrne18-Mar-05 7:33
memberJohn O'Byrne18-Mar-05 7:33 
GeneralRe: Can you convert this to a component? Pin
odegnan19-Mar-05 7:27
memberodegnan19-Mar-05 7:27 
GeneralPopup parent (fixed) Pin
Max Santos31-Dec-04 5:06
memberMax Santos31-Dec-04 5:06 
GeneralRe: Popup parent (fixed) Pin
cnss22-Feb-05 9:21
membercnss22-Feb-05 9:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150731.1 | Last Updated 12 Jul 2002
Article Copyright 2002 by John O'Byrne
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid