hiding the taskbar?

Postby Silvio » Wed Apr 11, 2007 10:55 pm

where I can found TTrayIcon() class ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby StefanHaupt » Thu Apr 12, 2007 5:11 pm

here is the class

Code: Select all  Expand view  RUN
#INCLUDE "Fivewin.CH"
#INCLUDE "Struct.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_SYSCOMMAND     274    // 0x112
#define WM_LBUTTONDBLCLK  515    // 0x203

CLASS TTrayIcon FROM TCONTROL
   DATA oTray
   DATA oWnd
   DATA cIcon
   DATA nIcon
   DATA hIcon
   DATA cCaption
   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) CONSTRUCTOR
   METHOD End()
   METHOD HIDE() INLINE Shell_NotifyIconA( NIM_DELETE , ::oTRAY:cBuffer ) , ::oTRAY:nON := 0
   METHOD SHOW() INLINE Shell_NotifyIconA( NIM_ADD    , ::oTRAY:cBuffer ) , ::oTRAY:nON := 1
   METHOD Refresh( cIcon , nICON , cTip )
   METHOD SetIcon( cICON , nICON ) INLINE ( ::Refresh( cIcon , nICON ) , ;
                   ::Refresh( cIcon , nICON ) , ;
                   IF( ::oTRAY:nON = 1 , EVAL( { |X| X:HIDE() , X:SHOW() } , SELF ) ,  ) )
   METHOD SetText( cTITLE )        INLINE ( ::Refresh( , , cTitle ) , ;
                   IF( ::oTRAY:nON = 1 , EVAL( { |X| X:HIDE() , X:SHOW() } , SELF ) ,  ) )
   METHOD Command( nWPARAM , nLPARAM )
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 )
//   A[1] := POINTAPI:X
//   A[2] := POINTAPI:Y
   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) CLASS TTrayIcon
   LOCAL c
   IF oWND = NIL
      MSGSTOP("ERROR: You need to specify a main window for tray icon")
      RETURN NIL
   ENDIF
   DEFAULT cIcon      := "OASYS.DLL"      ,;
      nIcon      := 1                ,;
      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.
   ::oWND       = oWND
   ::bLClicked  = uLClick
   ::bRClicked  = uRClick
   ::bMMoved    = uMMoved
   ::bLDblClick = uLDblClick
   ::bRButtonUp = uRButtonUp
   ::bLButtonUp = uLButtonUp
   ::cICON      = cICON
   ::nICON      = nICON
   ::oWnd:bTaskBar = { | nRow , nCol |  ::Command( nRow , nCol )}
   ::Refresh( cIcon , nICON , cTip )
   IF( lON , ::SHOW() , )
RETURN Self

METHOD Refresh( cIcon , nICON , cTip ) CLASS TTrayIcon
  LOCAL c
  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
  c := oTray:cBuffer
  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)
  c := oTray:cBuffer
  oTray:cBuffer := c
  oTRAY:nON := IF( !EMPTY(::oTRAY) , ::oTRAY:nON , 0 )
  ::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_NotifyIconA(NIM_DELETE,@c)
      ::oTray:cBuffer := c
   ENDIF
RETURN .T.

FUNCTION ClientToScreen(hWnd , aPOS)
   LOCAL POINTAPI
   STRUCT POINTAPI
      MEMBER X AS LONG
      MEMBER Y AS LONG
   ENDSTRUCT
   POINTAPI:Y := aPOS[1]
   POINTAPI:X := aPOS[2]
   KClientToScreen( hWnd, POINTAPI:cBuffer )
   aPOS[1] := POINTAPI:Y
   aPOS[2] := POINTAPI:X
RETURN { POINTAPI:Y , POINTAPI:X }

FUNCTION ScreenToClient(hWnd , aPOS)
   LOCAL POINTAPI
   STRUCT POINTAPI
      MEMBER X AS LONG
      MEMBER Y AS LONG
   ENDSTRUCT
   POINTAPI:X := aPOS[1]
   POINTAPI:Y := aPOS[2]
   KScreenToClient( hWnd, POINTAPI:cBuffer )
   aPOS[1] := POINTAPI:X
   aPOS[2] := POINTAPI:Y
RETURN { POINTAPI:X , POINTAPI:Y }

// 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"

// Windows API that converts Screen pixels to Client pixels
DLL32 Function KScreenToClient(hWnd as LONG, szText as LPSTR ) ;
AS LONG FROM "ScreenToClient" LIB "user32.dll"

// Windows API that converts Client pixels to Screen pixels
DLL32 Function KClientToScreen(hWnd as LONG, szText as LPSTR ) ;
AS LONG FROM "ClientToScreen" LIB "user32.dll"



Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Silvio » Thu Apr 12, 2007 9:43 pm

Shell_NotifyIconA fun not found !!
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby areang » Sat Apr 14, 2007 8:45 am

Hi Silvio, sorry for Error

please there is many erors
it not found lBebas

can you write a sample for it ?





Please Copy and Paste again the code on this forum, It was edited

Thank's
Areang
areang
 
Posts: 128
Joined: Mon Jul 31, 2006 3:23 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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