Page 1 of 1

Meter in tray messages. Is it possible?

Posted: Sat Apr 02, 2016 4:40 pm
by ariston.ap
Hi.

How can I show a meter in a tray icon message? Something like MsgTrayMeter(nTotal, nPercent)? Is it possible?

Thanks.

Re: Meter in tray messages. Is it possible?

Posted: Sat Apr 02, 2016 4:43 pm
by cnavarro
Please, You can put any image you need?

Re: Meter in tray messages. Is it possible?

Posted: Sat Apr 02, 2016 5:55 pm
by ariston.ap
At present I um using the functions below to get what I need, but I would like to have a meter more real.

Code: Select all

FUNCTION TestMeterTray()
    LOCAL nTotal := 20
    FOR nPos := 1 TO nTotal
        MsgMeterTray(nPos, nTotal, "Enviando clientes...")
        SysWait(0.1)
    NEXT
    MsgMeterTray(nPos, nTotal, "Enviados com êxito")
RETURN NIL
//----------------------------------------------------------------------------\\
FUNCTION MsgMeterTray(_nPos, _nTot, _cTit)
    LOCAL nPorct, cMeter
   nPorct := INT((100/_nTot) * _nPos)
   cMeter := LEFT(REPLICATE("=", nPorct / 5)+REPLICATE("~", 20), 20)
   cMeter := LEFT(cMeter,10)+STRZERO(nPorct,3)+"%"+RIGHT(cMeter,10)
   ShowMsgTray("["+cMeter+"]", _cTit)
RETURN nil
*------------------------------------------------------------------------------*
FUNCTION ShowMsgTray(cMsg, cTit)
   SysRefresh()
   IF cMsg == NIL .OR. cTit == NIL
      c = GetNotifyIconData( oTray:oWnd:hWnd, 1, WM_TASKBAR, oTray:oIcon:hIcon, "", "")
      Shell_NotifyIcon( 1, c )
   ELSE
      c = GetNotifyIconData( oTray:oWnd:hWnd, 1, WM_TASKBAR, oTray:oIcon:hIcon, cMsg, cTit )
      Shell_NotifyIcon( 0, @c )
      Shell_NotifyIcon( 1, c )
   ENDIF
   oTray:Refresh()
RETURN NIL
 
Result obtained:

Image

Re: Meter in tray messages. Is it possible?

Posted: Sat Apr 02, 2016 8:50 pm
by Antonio Linares

Re: Meter in tray messages. Is it possible?

Posted: Sat Apr 02, 2016 9:45 pm
by ariston.ap
It is a very interesting example, but it is not exactly what I am looking for.
The icon of my aplication does not show on taskbar, but in the tray only (near the watch).
And I need to show the meter in the tray balloon message, with a title, not within the icon.
Is it possible? Is there a function that already does it?
Thanks in advance!

Re: Meter in tray messages. Is it possible?

Posted: Sun Apr 03, 2016 8:09 am
by Antonio Linares
I am trying to build your example but I can find how you build oTray

Please provide a complete example to test it here, thanks

Re: Meter in tray messages. Is it possible?

Posted: Sun Apr 03, 2016 2:32 pm
by Silvio.Falconi
Antonio,
I think this : (click on wnd after you show the window at ttray )

Code: Select all


#include "Fivewin.CH"

static oWnd, oTray, oIcon

function TESTIT()

  local oIcon1

  DEFINE ICON oIcon  FILE "c:\work\fwh\icons\fivewin.ICO"
  DEFINE ICON oIcon1 FILE "c:\work\fwh\icons\folder.ico"

  DEFINE WINDOW oWnd TITLE "Icon Tray Class for FiveWin! from Jim Gale" ICON oIcon

  ACTIVATE WINDOW oWnd ;
  ON CLICK TestMeterTray() ;
     ON INIT oTray := TTrayIcon():New( oWnd, oIcon, "Testing tray ...",;
             { || MsgInfo( "Left CLick" ) },;
             { | nRow, nCol | MenuTray( nRow, nCol, oTray ) } ) ;
     VALID oTray:End() ;
     ON RIGHT CLICK oTray:SetIcon( oIcon1, "Another" )

return NIL

function MenuTray( nRow, nCol, oTray )

   local oMenu

   MENU oMenu POPUP
      MENUITEM "Show" ACTION oWnd:Show(), oWnd:SetFocus()
      MENUITEM "Hide" ACTION oWnd:Hide()
      SEPARATOR
      MENUITEM "Close Application" ACTION oWnd:end()
   ENDMENU

   ACTIVATE POPUP oMenu AT nRow, nCol OF oTray:oWnd

return NIL





FUNCTION TestMeterTray()
    LOCAL nTotal := 20
    FOR nPos := 1 TO nTotal
        MsgMeterTray(nPos, nTotal, "Enviando clientes...")
        SysWait(0.1)
    NEXT
    MsgMeterTray(nPos, nTotal, "Enviados com êxito")
RETURN NIL
//----------------------------------------------------------------------------\\
FUNCTION MsgMeterTray(_nPos, _nTot, _cTit)
    LOCAL nPorct, cMeter
   nPorct := INT((100/_nTot) * _nPos)
   cMeter := LEFT(REPLICATE("=", nPorct / 5)+REPLICATE("~", 20), 20)
   cMeter := LEFT(cMeter,10)+STRZERO(nPorct,3)+"%"+RIGHT(cMeter,10)
   ShowMsgTray("["+cMeter+"]", _cTit)
RETURN nil
*------------------------------------------------------------------------------*
FUNCTION ShowMsgTray(cMsg, cTit)
   SysRefresh()
   IF cMsg == NIL .OR. cTit == NIL
      c = GetNotifyIconData( oTray:oWnd:hWnd, 1, WM_TASKBAR, oTray:oIcon:hIcon, "", "")
      Shell_NotifyIcon( 1, c )
   ELSE
      c = GetNotifyIconData( oTray:oWnd:hWnd, 1, WM_TASKBAR, oTray:oIcon:hIcon, cMsg, cTit )
      Shell_NotifyIcon( 0, @c )
      Shell_NotifyIcon( 1, c )
   ENDIF
   oTray:Refresh()
RETURN NIL
 

Re: Meter in tray messages. Is it possible?

Posted: Sun Apr 03, 2016 3:56 pm
by ariston.ap
Yes, that is excactly how I built the oTray, using testtray.prg from samples.

Re: Meter in tray messages. Is it possible?

Posted: Sun Apr 03, 2016 8:05 pm
by Antonio Linares
Ariston,

I have been able to find the hWnd of the balloon tooltip. The idea is to paint a progress bar on it:

I am able to grab its handle but don't know why I can't paint on it.

(Also on Windows 10 it looks like a toast. I wonder if we can use its Windows class to create them.)

Code: Select all

FUNCTION ShowMsgTray(cMsg, cTit)
   local hWnd, hDC
   SysRefresh()
   IF cMsg == NIL .OR. cTit == NIL
      c = GetNotifyIconData( oTray:oWnd:hWnd, 1, WM_TASKBAR, oTray:oIcon:hIcon, "", "")
      Shell_NotifyIcon( 1, c )
   ELSE
      c = GetNotifyIconData( oTray:oWnd:hWnd, 1, WM_TASKBAR, oTray:oIcon:hIcon, cMsg, cTit )
      Shell_NotifyIcon( 0, @c )
      Shell_NotifyIcon( 1, c )
      hWnd = FindWindow( 0, "New notification" )
      MoveWindow( hWnd, 200, 200, 300, 300, .T. )  // We have the right window handle as we can move it!
      // InvertRect( hDC := GetDC( hWnd ), { 20, 10, 300, 200 } )  does not seem to work
      // ReleaseDC( hWnd, hDC )
   ENDIF
   oTray:Refresh()
RETURN NIL
 

Re: Meter in tray messages. Is it possible?

Posted: Sun Apr 03, 2016 8:10 pm
by Antonio Linares
The class name of those notifications is "Windows.UI.Core.CoreWindow"

If we can create a window of such class then we could have standard Windows notifications

Re: Meter in tray messages. Is it possible?

Posted: Sun Apr 03, 2016 8:36 pm
by Antonio Linares
It seems as we can not instantiate new windows of such class:

Code: Select all

#include "FiveWin.ch"

function Main()

   TNotification():New()

return nil

CLASS TNotification FROM TWindow

   METHOD New()

   METHOD ClassName() INLINE "Windows.UI.Core.CoreWindow"

ENDCLASS

METHOD New() CLASS TNotification

   ::Create()

return nil