FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Meter in tray messages. Is it possible?
Posts: 11
Joined: Mon Jun 29, 2015 08:16 PM
Meter in tray messages. Is it possible?
Posted: Sat Apr 02, 2016 04:40 PM

Hi.

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

Thanks.

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]

FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO

Please visit: arsoft-ap.com

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Meter in tray messages. Is it possible?
Posted: Sat Apr 02, 2016 04:43 PM

Please, You can put any image you need?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 11
Joined: Mon Jun 29, 2015 08:16 PM
Re: Meter in tray messages. Is it possible?
Posted: Sat Apr 02, 2016 05:55 PM
At present I um using the functions below to get what I need, but I would like to have a meter more real.

Code (fw): Select all Collapse
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:

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]

FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO

Please visit: arsoft-ap.com

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Meter in tray messages. Is it possible?
Posted: Sat Apr 02, 2016 08:50 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 11
Joined: Mon Jun 29, 2015 08:16 PM
Re: Meter in tray messages. Is it possible?
Posted: Sat Apr 02, 2016 09:45 PM

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: arsoft-ap.com

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Meter in tray messages. Is it possible?
Posted: Sun Apr 03, 2016 08:09 AM

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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Meter in tray messages. Is it possible?
Posted: Sun Apr 03, 2016 02:32 PM
Antonio,
I think this : (click on wnd after you show the window at ttray )
Code (fw): Select all Collapse
#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 11
Joined: Mon Jun 29, 2015 08:16 PM
Re: Meter in tray messages. Is it possible?
Posted: Sun Apr 03, 2016 03:56 PM

Yes, that is excactly how I built the oTray, using testtray.prg from samples.

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]

FWH1206 / XHB121 / BCC582 / RESOURCE WORKSHOP / XDEVSTUDIO

Please visit: arsoft-ap.com

[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Meter in tray messages. Is it possible?
Posted: Sun Apr 03, 2016 08:05 PM
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 (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Meter in tray messages. Is it possible?
Posted: Sun Apr 03, 2016 08:10 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Meter in tray messages. Is it possible?
Posted: Sun Apr 03, 2016 08:36 PM
It seems as we can not instantiate new windows of such class:

Code (fw): Select all Collapse
#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

Continue the discussion