TTRAY

TTRAY

Postby Alexandre Oliveira » Mon Sep 29, 2008 6:09 pm

After the upgrade from version 2.7 to 8.08 to tray no longer appears in the Windows taskbar.
Alexandre Oliveira
FHW 8.11 + xHarbour
User avatar
Alexandre Oliveira
 
Posts: 10
Joined: Mon Sep 29, 2008 1:06 pm
Location: Brasil

Postby Antonio Linares » Mon Sep 29, 2008 9:27 pm

Alexandre,

Please try FWH\samples\TestTray.prg

Here it is working fine
regards, saludos

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

TestTray

Postby Alexandre Oliveira » Tue Sep 30, 2008 12:14 am

Antonio,

I did the test with the TestTray.prg and also the icon does not appear next to the clock, but the program is running.
Alexandre Oliveira
FHW 8.11 + xHarbour
User avatar
Alexandre Oliveira
 
Posts: 10
Joined: Mon Sep 29, 2008 1:06 pm
Location: Brasil

Postby concentra » Tue Sep 30, 2008 4:27 pm

Hi.
I found the same problem and I went back to TTray class in an old .PRG.
Couldn´t remember how do I got it...

Mauricio Faria

**************************************************
/*

TTrayIcon CLASS

Allows tray icon for any windows, including NT, 2000 and XP.

This class extracts a 32bit handle icon from a file( .EXE , .ICO, .DLL, etc... )

DATAS:
oTray : Object Tray
oWnd : Window that the tray icon is linked
cIcon : Specified path + file to get the icon
nIcon : Icon number from file(use 0 for default icon)
hIcon : 32bit handle of the icon
cCaption : ToolTip to show
bLClicked : Block to execute when Left Clicked
bRClicked : Block to execute when Right Clicked
bMMoved : Block to execute when Mouse Moved
bLDblClick : Block to execute when Left Double Click
bLButtonUp : Block to execute when Left Button Up
bRButtonUp : Block to execute when Right Button Up

METHODS:
METHOD New(oWnd,cICON,nICON,cTip,lON,uLClick,uRClick,uMMoved,uLDblClick,uLButtonUp,uRButtonUp) CONSTRUCTOR
lON : To show the icon at start.
METHOD End()
METHOD HIDE() INLINE Shell_NotifyIcon( NIM_DELETE , ::oTRAY:cBuffer )
METHOD SHOW() INLINE Shell_NotifyIcon( NIM_ADD , ::oTRAY:cBuffer )
METHOD Refresh( cIcon , nICON , cTip )
METHOD SetIcon( cICON , nICON ) INLINE ::Refresh( cIcon , nICON ) , ::SHOW()
METHOD SetText( cTITLE ) INLINE ::Refresh( , , cTitle ) , ::HIDE()
METHOD Command( nWPARAM , nLPARAM )

*/

#INCLUDE "Fivewin.ch"
#INCLUDE "Struct.ch"
#include "DLL.ch"

#define NIM_ADD 0
#define NIM_MODIFY 1
#define NIM_DELETE 2

#define NIF_MESSAGE 1
#define NIF_ICON 2
#define NIF_TIP 4

#define WM_LBUTTONDBLCLK 515 // 0x203


CLASS TTrayIcon FROM TCONTROL

DATA oTray
DATA oTimer
DATA oWnd
DATA cIcon
DATA nIcon
DATA aIcon
DATA hIcon
DATA cCaption
DATA nIndIco
DATA nIcoOriginal

DATA bLClicked
DATA bRClicked
DATA bMMoved
DATA bLDblClick
DATA bLButtonUp
DATA bRButtonUp

METHOD New(oWnd,cIcon,nIcon,cTip,lOn,uLClick,uRClick,uMMoved,uLDblClick,uLButtonUp,uRButtonUp,aIcon) CONSTRUCTOR
METHOD End()
METHOD Hide() INLINE Shell_NotifyIcon( NIM_DELETE, ::oTray:cBuffer ), ::oTray:nOn := 0
METHOD Show() INLINE Shell_NotifyIcon( NIM_ADD , ::oTray:cBuffer ), ::oTray:nOn := 1

METHOD Change() INLINE Shell_NotifyIcon( NIM_MODIFY, ::oTray:cBuffer )

METHOD Refresh( cIcon, nIcon, cTip )

METHOD SetIcon( cIcon, nIcon ) INLINE ::Refresh( cIcon, nIcon ),;
IF( ::oTray:nOn = 1, ::Change(), )

METHOD SetText( cTitle ) INLINE ::Refresh( ,, cTitle ),;
IF( ::oTray:nOn = 1, EVAL( { |Self| ::Hide(), ::Show() }, Self ), )

METHOD Command( nWParam, nLParam )

METHOD AnimateIcon()

METHOD Animate() INLINE ::oTimer:Activate()

METHOD DeAnimate() INLINE ::oTimer:DeActivate(),;
::SetIcon( ::cIcon, ::nIcoOriginal ),;
::SetIcon( ::cIcon, ::nIcoOriginal )



ENDCLASS





METHOD Command( nWParam, nLParam ) CLASS TTrayIcon

LOCAL A := GetCursorPos()
LOCAL PointAPI

STRUCT PointAPI
MEMBER X AS LONG
MEMBER Y AS LONG
ENDSTRUCT

PointAPI:X := A[1]
PointAPI:Y := A[2]
ScreenToClient( ::oWnd:hWnd, A )

DO CASE

CASE nLParam == WM_LBUTTONDOWN .AND. VALTYPE( ::bLClicked ) == "B"
RETURN EVAL(::bLClicked,a[1],a[2])

CASE nLParam == WM_RBUTTONDOWN .AND. VALTYPE( ::bRClicked ) == "B"
RETURN EVAL(::bRClicked,A[1],A[2])

CASE nLParam == WM_MOUSEMOVE .AND. VALTYPE( ::bMMoved ) == "B"
RETURN EVAL(::bMMoved,a[1],a[2])

CASE nLParam == WM_LBUTTONDBLCLK .AND. VALTYPE( ::bLDblClick ) == "B"
RETURN EVAL(::bLDblClick,a[1],a[2])

CASE nLParam == WM_LBUTTONUP .AND. VALTYPE( ::bLButtonUp ) == "B"
RETURN EVAL(::bLButtonUp,a[1],a[2])

CASE nLParam == WM_RBUTTONUP .AND. VALTYPE( ::bRButtonUp ) == "B"
RETURN EVAL(::bRButtonUp,a[1],a[2])

ENDCASE

RETURN( Super:HandleEvent( nWParam, nLParam ) )









METHOD New(oWnd,cICON,nICON,cTip,lON,uLClick,uRClick,uMMoved,uLDblClick,uLButtonUp,uRButtonUp,aIcon) CLASS TTrayIcon

LOCAL c

IF oWND = NIL
MSGSTOP("ERROR: You need to specify a main window for tray icon")
RETURN NIL
ENDIF

DEFAULT cIcon := "PIFMGR.DLL" ,;
nIcon := 10 ,;
cTip := oWnd:cCaption ,;
uLClick := oWnd:bLClicked ,;
uRClick := oWnd:bRClicked ,;
uLDblClick := oWnd:bLDblClick ,;
uMMoved := oWnd:bMMoved ,;
uLDblClick := oWnd:bLDblClick ,;
uRButtonUp := oWnd:bRButtonUp ,;
uLButtonUp := oWnd:bLButtonUp ,;
lOn := .T. ,;
aIcon := { nIcon }


::oWnd = oWnd
::bLClicked = uLClick
::bRClicked = uRClick
::bMMoved = uMMoved
::bLDblClick = uLDblClick
::bRButtonUp = uRButtonUp
::bLButtonUp = uLButtonUp
::cIcon = cIcon
::nIcon = nIcon
::nIcoOriginal = nIcon
::nIndIco = 0
::aIcon = aIcon
::oWnd:bTaskBar = { |nRow, nCol| ::Command( nRow, nCol ) }

::Refresh( cIcon, nIcon, cTip )

IF( lOn, ::Show(), )

::oTimer = TTimer():New( 500, { || ::AnimateIcon() }, )

RETURN( Self )







METHOD Refresh( cIcon, nIcon, cTip ) CLASS TTrayIcon

LOCAL oTray

DEFAULT nIcon := ::nIcon ,;
cIcon := ::cIcon ,;
cTip := ::cCaption

::hIcon := DLL32GetExtractIcon( ::oWnd:hWnd, ::cIcon, ::nIcon )

STRUCT oTray
MEMBER nSize AS LONG
MEMBER hWnd AS LONG
MEMBER nId AS LONG //STRING LEN 4
MEMBER nFlags AS LONG //STRING LEN 4
MEMBER nCallMsg AS LONG //STRING LEN 4
MEMBER hIcon AS LONG
MEMBER cToolTip AS STRING LEN 64 //Len(cTip)+1
MEMBER nOn AS LONG
ENDSTRUCT

oTray:nSize = oTray:SizeOf()
oTray:hWnd = ::oWnd:hWnd
oTray:nId = 1
oTray:nFlags = nOr( NIF_ICON, NIF_MESSAGE, NIF_TIP )
oTray:nCallMsg = WM_TASKBAR
oTray:hIcon = ::hIcon
oTray:cToolTip = cTip + CHR(0)

oTray:nOn := IF( EMPTY(::oTray), 0, ::oTray:nOn )

::oTray = oTray
::cCaption = cTip
::cIcon = cIcon
::nIcon = nIcon
SysRefresh()

RETURN NIL









METHOD End() CLASS TTrayIcon

LOCAL c

IF !EMPTY(::oTray)
::oTray:nFlags := 0
c := ::oTray:cBuffer
Shell_NotifyIcon(NIM_DELETE,@c)
::oTray:cBuffer := c
ENDIF

::oTimer:End()

RETURN( .T. )









// Windows API that extracts the icon handle of file
DLL32 Function DLL32GetExtractIcon(hWnd as LONG, szText as LPSTR, nIconIndex as LONG);
AS LONG PASCAL FROM "ExtractIconA" LIB "SHELL32.DLL"





METHOD AnimateIcon() CLASS TTrayIcon

::nIndIco := ::nIndIco + 1

IF ::nIndIco > LEN( ::aIcon )
::nIndIco := 1
ENDIF

::SetIcon( ::cIcon, ::aIcon[::nIndIco] )

RETURN NIL
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Postby Antonio Linares » Tue Sep 30, 2008 5:00 pm

Alexandre,

What Windows version are you using ?

Here it is working fine on Vista
regards, saludos

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

Postby Alexandre Oliveira » Wed Oct 01, 2008 12:19 am

Antonio,

I use Windows XP, I will test with Windows Vista.

Thank you.
Alexandre Oliveira
FHW 8.11 + xHarbour
User avatar
Alexandre Oliveira
 
Posts: 10
Joined: Mon Sep 29, 2008 1:06 pm
Location: Brasil

Postby Enrico Maria Giordano » Wed Oct 01, 2008 7:28 am

Works fine here using XP.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 100 guests