CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2003
    Posts
    72

    Tray Notification Box

    Hi. Does anyone know how to make tray notifications similar to AIM and Skype? It's not really a popup menu or balloon tip, but a little rectangle that pops up near the tray to say when someone has signed on/off/etc.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Tray Notification Box

    Are you maybe looking for something like this:

    http://www.codeguru.com/cpp/controls...icle.php/c5931

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Tray Notification Box

    CreateWindow() ?

  4. #4
    Join Date
    Dec 2003
    Posts
    72

    Re: Tray Notification Box

    Cool, thanks!

  5. #5
    Join Date
    Dec 2003
    Posts
    72

    Re: Tray Notification Box

    Hmmm. In the example, he can pop up as many windows as he wants. But, I can only pop up one before each other attempt causes a fault. I traced it to his line of

    Code:
    const char * p = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
    ret = CreateEx(dwExStyle,p,NULL,dwStyle,rect,NULL,NULL);
    Apparently, my application only lets that happen once, but every other time the register function fails. Only thing I can think of is his project properties put Use MFC in a Shared DLL, and mine just says Use Standard Windows Libraries.

    Is there anything I can change that code to so it will work on my settings?

  6. #6
    Join Date
    Dec 2003
    Posts
    72

    Re: Tray Notification Box

    Nope, even when I tell my application to use mfc, still fails at that register line after 1 try. I don't get how his test application lets you show as many windows as possible. Something else must be different.

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tray Notification Box

    Try to register the window class just once in your application, at the beginning for example and then simple keep using that class name in subsequent create calls.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  8. #8
    Join Date
    Dec 2003
    Posts
    72

    Re: Tray Notification Box

    Thanks, Marc, it worked. Another question. For this box, it draws some text in the OnPaint() function. But, I decided it might be cool to have clickable text too. I found a static text class that makes the text clickable. But, I'm not sure how I add a static text object to my window. All this example has is an OnPaint() function which uses the CPaintDC DrawText() function. Do you know how I can tell it to "draw" a static text object?

    My other idea was to just handle the left click event myself, but then I can't figure out how to detect which text was clicked on, so it would seem easier if I just reused this hyperlink static text class.

  9. #9
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tray Notification Box

    A static text control is also a window. Almost everything you see in Windows is actually a "window". So, to create this static text control, you call Create with classname "STATIC".

    Your second idea is also possible. You can create an array which contains the rectangles of all your clickable text. When the user clicks somewhere in your window, you iterate over this array and see if the clicked point lies in a rectangle of some text and then you know which text you clicked.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured