Announcement

Collapse
No announcement yet.

Popup Notifications from Windows Tray

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scott Slater
    replied
    Thanks for the info guys. I will look at the MSDN info and the code provided here. The reason I am asking is because I am in the middle of putting together a new ap, and thought this would be a neat little feature.

    Thanks again!

    Leave a comment:


  • Pierre Bellisle
    replied
    Hey Scott,

    Here is what I got...

    Code:
    #COMPILE EXE '#Win 8.04#
    #DIM ALL
    #INCLUDE  "Win32Api.Inc" '#2005-01-27#
     
    %PopUpBaloon        = 201
    %PopUpDialogShow    = 202
    %PopUpDialogHide    = 203
    %PopUpEnd           = 204
    %WM_TRAYICON        = 501 + %WM_USER
     
    %NOTIFYICON_VERSION = 5
    '______________________________________________________________________________
     
    CALLBACK FUNCTION DlgProc
     LOCAL  pt           AS POINTAPI
     STATIC nfIconData   AS NOTIFYICONDATA5
     STATIC hInstance    AS DWORD
     STATIC hIcon        AS DWORD
     STATIC hPopup       AS DWORD
     STATIC zBaloon      AS ASCIIZ * 255
     STATIC zBaloonTitle AS ASCIIZ * 63
     
     SELECT CASE CBMSG
       CASE %WM_INITDIALOG
         nfIconData.cbSize           = SIZEOF(nfIconData)
         nfIconData.hwnd             = CBHNDL
         hInstance                   = GetModuleHandle(BYVAL 0)
         nfIconData.uID              = hInstance
         nfIconData.uFlags           = %NIF_ICON OR %NIF_MESSAGE OR %NIF_TIP OR %NIF_INFO
         nfIconData.uCallbackMessage = %WM_TRAYICON
         nfIconData.hIcon            = LoadIcon(%NULL, BYVAL MAKLNG(%IDI_INFORMATION, 0))
         nfIconData.szTip            = "Tray program"
         zBaloon                     = "Tray baloon"
         nfIconData.szInfo           = zBaloon
         nfIconData.uTimeout         = 10000 'Usually: min 10 secs. - max 30 secs.
         zBaloonTitle                = "Tray baloon title"
         nfIconData.szInfoTitle      = zBaloonTitle
         nfIconData.dwInfoFlags      = %NIIF_INFO OR %NIIF_NOSOUND
         Shell_NotifyIcon %NIM_ADD, BYVAL VARPTR(nfIconData)
     
         'uTimeout become uVersion when Shell_NotifyIcon send a NIM_SETVERSION message
         'Zero for Win95, %NOTIFYICON_VERSION for 2000/XP, %NOTIFYICON_VERSION_4 for Vista
         nfIconData.uTimeout = %NOTIFYICON_VERSION
         Shell_NotifyIcon %NIM_SETVERSION, BYVAL VARPTR(nfIconData)
         nfIconData.uTimeout = 10000 'Put back 10 secs. for future call
     
         MENU NEW POPUP TO hPopup
         MENU ADD STRING, hPopup, "&Baloon", %PopUpBaloon, %MF_ENABLED
         MENU ADD STRING, hPopup, "-", 0, %MF_ENABLED
         MENU ADD STRING, hPopup, "&Show dialog", %PopUpDialogShow, %MF_ENABLED
         MENU ADD STRING, hPopup, "&Hide dialog", %PopUpDialogHide, %MF_ENABLED OR %MF_CHECKED
         MENU ADD STRING, hPopup, "-", 0, %MF_ENABLED
         MENU ADD STRING, hPopup, "&Quit", %PopUpEnd, %MF_ENABLED
     
       CASE %WM_TRAYICON
         SELECT CASE LOWRD(CBLPARAM)
     
           CASE %WM_LBUTTONUP, %WM_RBUTTONUP
             GetCursorPos pt
             SetForegroundWindow CBHNDL
             TrackPopupMenu hPopup, %TPM_RightALIGN OR %TPM_BOTTOMALIGN OR %TPM_RIGHTBUTTON, _
                            pt.x, pt.y, 0, CBHNDL, BYVAL 0
     
           CASE %WM_LBUTTONDOWN
           CASE %WM_RBUTTONDOWN
           CASE %NIN_BALLOONSHOW
           CASE %NIN_BALLOONHIDE
           CASE %NIN_BALLOONTIMEOUT
     
           CASE %NIN_BALLOONUSERCLICK
             WinBeep 750, 50
             WinBeep 550, 50
     
         END SELECT
     
     
       CASE %WM_COMMAND
         SELECT CASE LOWRD(CBWPARAM)
     
           CASE %PopUpBaloon
             Shell_NotifyIcon %NIM_MODIFY, BYVAL VARPTR(nfIconData) 'Show baloon
     
           CASE %PopUpDialogHide
             CheckMenuItem hPopUp, %PopUpDialogHide, %MF_CHECKED
             CheckMenuItem hPopUp, %PopUpDialogShow, %MF_UnCHECKED
             ShowWindow CBHNDL, %SW_HIDE
             FUNCTION = 1
             EXIT FUNCTION
     
           CASE %PopUpDialogShow
             CheckMenuItem hPopUp, %PopUpDialogHide, %MF_UnCHECKED
             CheckMenuItem hPopUp, %PopUpDialogShow, %MF_CHECKED
             ShowWindow CBHNDL, %SW_RESTORE
             FUNCTION = 1
             EXIT FUNCTION
     
           CASE %PopUpEnd
             DIALOG END CBHNDL
     
         END SELECT
     
       CASE %WM_DESTROY
         Shell_NotifyIcon %NIM_DELETE, BYVAL VARPTR(nfIconData)
     
     END SELECT
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PBMAIN
     LOCAL hDlg AS DWORD
     
     DIALOG NEW %HWND_DESKTOP, "Baloon tray", , ,160, 80, %WS_SYSMENU OR %WS_MINIMIZEBOX TO hDlg
     DIALOG SHOW STATE hDlg, %SW_HIDE
     DIALOG SHOW MODAL hDlg CALL DlgProc
     
    END FUNCTION
    '______________________________________________________________________________

    Leave a comment:


  • Roger Garstang
    replied
    Only one balloon can appear down there too, so if any of those others are popped up they won't see yours. Might want to use the standard tooltips/balloons and position them where you want. My Tooltip function in my contest entry can be used like this. The Balloon Style 2 can make a static balloon that can be closed when clicked on or when the Close X is clicked. I'll see if I can toss together an example like I used in one of my previous applications using this.

    Leave a comment:


  • Kev Peel
    replied
    Paul, Scott was asking how to add these to an application, not remove them from the system.

    Scott,
    Yes, you can add these new style notifications to the system tray by setting the version and using the new NOTIFYICONDATA5 structure available on Windows 2000/IE 5 systems and later. I recommend modding the "Tray" example in PB's samples folder to use the new version so you can see how it works before adding it to your app.

    Note that if your application will need to run on an OS older than Windows 2000/IE 5, you will have to use the older NOTIFYICONDATA structure instead.

    MSDN link for the new structure: NOTIFYICONDATA Structure ()

    Leave a comment:


  • Paul Purvis
    replied
    using spybot and ccleaner you can remove some of the programs that startup, java update is one of these programs you can disable.
    i believe java just runs once on logins then after checking a web site, unloads if no updates are available or prompts you to download new updates.


    Other pops up are placed there by services, i am pretty sure.
    I would presume the service just calls another program that pops up, while the service continues on.

    Leave a comment:


  • Scott Slater
    started a topic Popup Notifications from Windows Tray

    Popup Notifications from Windows Tray

    In Windows XP aps like the Java Runtime will occasionally popup a notification telling you that there is a new version of the software available or something of that sort. Also Windows will use the same type of popup to alert you that your system firewall or virus scanner is not working properly. Is there an API to create these popups or are they just custom windows created by the aps?

    -Scott
Working...
X