Meter in tray messages. Is it possible?

Post Reply
User avatar
ariston.ap
Posts: 9
Joined: Mon Jun 29, 2015 8:16 pm
Location: Macapá - AP - Brazil
Contact:

Meter in tray messages. Is it possible?

Post by ariston.ap »

Hi.

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

Thanks.
Last edited by ariston.ap on Sat Apr 02, 2016 5:37 pm, edited 1 time in total.
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO
Please visit: http://www.arsoft-ap.com.br
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Meter in tray messages. Is it possible?

Post by cnavarro »

Please, You can put any image you need?
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
ariston.ap
Posts: 9
Joined: Mon Jun 29, 2015 8:16 pm
Location: Macapá - AP - Brazil
Contact:

Re: Meter in tray messages. Is it possible?

Post 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
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO
Please visit: http://www.arsoft-ap.com.br
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Meter in tray messages. Is it possible?

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ariston.ap
Posts: 9
Joined: Mon Jun 29, 2015 8:16 pm
Location: Macapá - AP - Brazil
Contact:

Re: Meter in tray messages. Is it possible?

Post 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!
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO
Please visit: http://www.arsoft-ap.com.br
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Meter in tray messages. Is it possible?

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Meter in tray messages. Is it possible?

Post 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
 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ariston.ap
Posts: 9
Joined: Mon Jun 29, 2015 8:16 pm
Location: Macapá - AP - Brazil
Contact:

Re: Meter in tray messages. Is it possible?

Post by ariston.ap »

Yes, that is excactly how I built the oTray, using testtray.prg from samples.
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO
Please visit: http://www.arsoft-ap.com.br
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Meter in tray messages. Is it possible?

Post 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
 
regards, saludos

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

Re: Meter in tray messages. Is it possible?

Post 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
regards, saludos

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

Re: Meter in tray messages. Is it possible?

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply