Notifications

Notifications

Postby Natter » Mon Sep 26, 2022 9:33 am

Hi,

My application is placed in Systray at startup. Sometimes I activate system notifications from my application (via PS). Each notification contains a text and an icon. Everything works well. However, if you look into SysTray, there will be as many icons as there were messages. When you hover the mouse cursor over these icons, they disappear. What could it be ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Notifications

Postby karinha » Mon Sep 26, 2022 3:10 pm

Muestre un ejemplo simple, por favor.

Show a simple example, please.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Notifications

Postby Antonio Linares » Mon Sep 26, 2022 3:47 pm

Dear Yuri,

You may try a SysRefresh() call after each message
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Notifications

Postby Natter » Tue Sep 27, 2022 8:50 am

SysRefresh() does not help.

hdn.bat - to call the PS script

Code: Select all  Expand view
%comspec% /c powershell -executionpolicy RemoteSigned -file C:\ZVK\TMP\my.ps1


my.ps1 - PS script

Code: Select all  Expand view
Add-Type -AssemblyName  System.Windows.Forms
$global:balmsg = New-Object System.Windows.Forms.NotifyIcon
$balmsg.Icon = '\\192.168.4.11\zvk\zvk.ico'
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
$balmsg.BalloonTipText ='ABCDEF'
$balmsg.BalloonTipTitle = 'My text'
$balmsg.Visible = $true
$balmsg.ShowBalloonTip(500000)


For some reason, with such a call, the icon appears in the Systray window :(
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Notifications

Postby Antonio Linares » Tue Sep 27, 2022 9:11 am

Please move this line to the end:
$balmsg.Visible = $true

https://stackoverflow.com/questions/20615151/how-can-i-close-a-notifyicon-ballontooltip-from-code

He uses an extra this.Hide(); that I don't know which control applies. You may try this:
$balmsg.Hide()

or
$balmsg.Visible = $false
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Notifications

Postby Natter » Tue Sep 27, 2022 9:20 am

I already specified in the script - $balms.Visible = $true. :o
In addition, true without $ gives an error
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Notifications

Postby Natter » Tue Sep 27, 2022 9:39 am

Removed the line from the script:

Code: Select all  Expand view
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
 


Everything worked :D
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Notifications

Postby Antonio Linares » Tue Sep 27, 2022 9:41 am

cool! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Notifications

Postby Jimmy » Wed Sep 28, 2022 6:09 am

hi,

try this CODE from HMG Forum (will run under FiveWin)
Code: Select all  Expand view
#include "FIVEWIN.CH"
#define WIN_NIIF_USER                      0x00000004

/*------------------------------------------------------
MsgBalloon( cMessage, [ cTitle ], [ xIcon ], [ nFlags ] ) -> nil

Copyright 2007-2013 Grigory Filatov <gfil...@inbox.ru>

Parameters:
cMessage        -> info text
cTitle          -> info title
xIcon           -> resource id / resource name / filename
                   of the icon displayed to the left of the title
nFlags          -> bit masked icon flags (default = WIN_NIIF_INFO)
                   for the icon displayed to the left of the message
                  set from ShellNotifyIcon() dwInfoFlags values:
                  #define WIN_NIIF_NONE                      0x00000000
                  #define WIN_NIIF_INFO                      0x00000001
                  #define WIN_NIIF_WARNING                   0x00000002
                  #define WIN_NIIF_ERROR                     0x00000003
                  #define WIN_NIIF_USER                      0x00000004
                  #define WIN_NIIF_NOSOUND                   0x00000010
                  #define WIN_NIIF_LARGE_ICON                0x00000020
                  #define WIN_NIIF_RESPECT_QUIET_TIME        0x00000080
                  #define WIN_NIIF_ICON_MASK                 0x0000000F
                  if nFlags is used via symbolic names it's needed to include "hbwin.ch" in source

Samples:
MsgBallon( "Some text" )
MsgBallon( "Some text", "A title" )
MsgBallon( "Some text", "A title", 123 )  123 is the id of the icon set in resource file
MsgBallon( "Some text", "A title", "PRGICON" ) "PRGICON" is the icon name set in resource file
MsgBallon( "Some text", "A title", "c:\path\icon.ico" )
MsgBallon( "Some text", "A title", "c:\path\icon.ico", NIIF_ERROR ) same as previous, but with an error icon
MsgBallon( "Some text", "A title", "c:\path\icon.ico", NIIF_USER + NIIF_NOSOUND ) no sound, same icon as title icon

--------------------------------------------------------*/


Procedure Main
*  MsgBalloon( "Any text", "Any title", "A2MAIN", WIN_NIIF_USER )
*  MsgBalloon( "Some text", "A title", "A2MAIN" )
   MsgBalloon( "Some text", "A title", 10002 )
RETURN

function MsgBalloon( cMessage, cTitle, xIcon, nFlags )

   ShowNotifyInfo( 0, .F. , xIcon, NIL, NIL, NIL, NIL )
   ShowNotifyInfo( 0, .T. , xIcon, NIL, cMessage, cTitle, hb_defaultValue( nFlags, 1 ) )

Return Nil

#pragma BEGINDUMP

      #include <windows.h>
      #include "hbapi.h"

      static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle, int nFlags );

      HB_FUNC ( SHOWNOTIFYINFO )
      {

         HICON hIcon;
         if ( HB_ISNUM( 3 ) )
         {
            hIcon = LoadIcon( ( HINSTANCE ) GetModuleHandle( NULL ), MAKEINTRESOURCE( hb_parni( 3 ) ) );
         }
         else
         {
            hIcon = LoadIcon( ( HINSTANCE ) GetModuleHandle( NULL ), hb_parc( 3 ) );
            if ( hIcon == NULL )
               hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 3 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
         }

         ShowNotifyInfo( (HWND) hb_parnl(1), (BOOL) hb_parl(2), hIcon , (LPSTR) hb_parc(4), (LPSTR) hb_parc(5), (LPSTR) hb_parc(6), hb_parni( 7 ) );

      }

      static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle, INT nFlags )
      {
          NOTIFYICONDATA nid;

          ZeroMemory( &nid, sizeof(nid) );

          nid.cbSize        = sizeof(NOTIFYICONDATA);
          nid.hIcon         = hIcon;
          nid.hWnd          = hWnd;
          nid.uID           = 0;
          nid.uFlags        = NIF_INFO | NIF_ICON;
          nid.dwInfoFlags   = nFlags;

          lstrcpy( nid.szTip, TEXT(szText) );
          lstrcpy( nid.szInfo, TEXT(szInfo) );
          lstrcpy( nid.szInfoTitle, TEXT(szInfoTitle) );

          if(bAdd)
              Shell_NotifyIcon( NIM_ADD, &nid );
          else
              Shell_NotifyIcon( NIM_DELETE, &nid );

          if(hIcon)
              DestroyIcon( hIcon );
      }

#pragma ENDDUMP
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Notifications

Postby Antonio Linares » Wed Sep 28, 2022 6:48 am

Thank you Jimmy :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 57 guests