New FTDN July/Julio (FWH 23.07)

New FTDN July/Julio (FWH 23.07)

Postby Antonio Linares » Thu Jul 27, 2023 6:13 pm

May, June, July 2023
====================

* Enhancement: function SetClipboardData() supports CF_HDROP. Here there is a working example - 1:

#include "FiveWin.ch"

#define CF_HDROP 15

function Main()

local oWnd, hDrop

DEFINE WINDOW oWnd

MsgInfo( OpenClipboard( oWnd:hWnd ) )

MsgInfo( SetClipboardData( CF_HDROP, { "tutor1.prg", "tutor02.prg", "tutor03.prg" } ) )

hDrop = GetClpData( CF_HDROP )

XBROWSER DragQueryFiles( hDrop )

CloseClipboard()

oWnd:End()

return nil

b. Working example-2:
#include "FiveWin.ch"
function Main()
? FW_CopyToClipBoard( { "tutor1.prg", "tutor02.prg", "tutor03.prg" } )
XBROWSER FW_GetClipBoardData()
return nil

* New: Class TWebView Method Center(). You can center a webview object simply doing oWebView:Center()

* New: vs2022_make.zip added in FWH\makes to build using Visual Studio Community 2022

* New: hbmk2_bcc64.zip in FWH\makes to build using Borland bcc 64 bits

* New: FWH and FWH64 built using the new gcc 8.5 32 and 64 bits. Thanks to Santo!

* Enhancement: webview.dll and WebView2Loader.dll have been updated to the most recent version and
we have included the changes for set_user_agent() and commented out the call to PostQuitMessage()
that was closing the FWH app when closing webview objects. Explained here:

viewtopic.php?p=261258&#p261258

webview.dll and WebView2Loader.dll are placed in FWH\samples and the 64 bits versions are placed at:
FWH\dll\webview64\

* New: samples\webview1.prg shows how to use an existing window (or dialog, or control) to create a
webview on such window.

* New: samples\webview3.prg shows how to place a webview inside a dialog.

* New: samples\webvieweval.prg shows how to use oWebView:Eval( cJavaScript )

* New: samples\webviewbody.prg shows how to reach the document.body.outerHTML

* New: METHOD InjectJavascript( cScript ) CLASS TWebView by by Charles KWON ( charleskwonohjun@gmail.com )
This allows to place your javascript code in public websites and do incredible things!

* New: function IsWebViewAvailable() --> lAvailable, it allows to check if the PC is ready to use
webview.

* New: samples\webviewlogin.prg shows how to use the web as the FWH app GUI using webview.

* New: CLASS TWebView METHOD OpenDevToolsWindow(). Please review samples\webview.prg and webvieweval.prg

* Enhancement: TListView class is now made Unicode compatible
Try samples\testvie1.prg

* LinkList: Method Sort( [lAsc], [lRecurse], [nCol] ) enhanced with
three new parameters.
Param.1 lAsc: .T. or "A" for ascending sort and .F. OR "D"
for descending sort.
Or, this parameter can be a codeblock also.
Default: Ascending sort
Param.2 lRecurse: Default .f. for backward compatibility
If set to .T. all subtrees are also sorted
Param.3 nCol: Default 0: Sorts on nCol of Cargo Array

* TreeItem: oItem[ n ] returns oItem:Cargo[ n ] if oItem:Cargo
is an array and n is withing the size and if n is '0' returns
oItem:cPromt and else returns 'nil'
If n is within the range, oItem[ n ] := newValue works too.

* Enhanced XEval( uVar, p1, p2, ... )
Now uVar can also be function name ending with "()".
If the named function is linked, the function is executed
with params p1,p2,... etc.
XEval( {|c| Upper( c ) }, "abc" ) --> ABC
XEval( "Upper()", c ) --> ABC
If uVar is neither a codeblock or a valid function name, uVar
itself is returned

* fw_stricmp() treats nil as lower than other datatypes

* New: We know that it is a tedious task to write help for an app, so
we have implemented a real simple way to do it using FWH:

SetAutoHelp( lOnOff, lEditable ) // lEditable is .T. by default

just call that function at the beginning of your app, and press F1 on any
control of your FWH app, you will be prompted to write the help for it, using
richedit text and the next time you press F1 the help will be shown! FWH
automatically creates a help.dbf with index and updates it properly

* TDataRow class: Image fields are displayed as images, though they
can not be modified and saved yet.

* XBROWSE:
- RTE while browsing PostGre query due to a bug in
method SetPostGreCol() fixed.
- If recordset is closed when setting up is setup, it
is opened by xbrowse for browing.
- New DATA bmPrevious (previous bookmark)
bChange can now access the previous Bookmark with
oBrw:bmPrevious
- Fixes in SetRDD() in case of very rare usages.
- Fix:SetTree(). Auto-generation of Tree with Array data is
crashing since version 2104 now fixed.
viewtopic.php?f=3&t=43494

* New: function EnumWindows( bEnumWindow [,nLParam] ). Enumerates all top-level
windows on the screen by passing the handle to each window, in turn, to a codeblock
where the handle of each window is provided and an optional nLParam value.

* ScrollMsg: NOBORDER clause added

* TGET:
- Picture claise "@M c1,c2,..." implemented like
FoxPro.
viewtopic.php?f=3&t=43407&hilit=foxpro

- RTE when ES_UPPERCASE style is specified in RC file
for non character gets is avoided.
viewtopic.php?f=3&t=43453

- Compatible with accented characters like German Umlauts even when
FW_SetUnicode(.t.). The problem arises where certain accented chars
have different notations in ANSI and UTF8.
viewtopic.php?f=3&t=43352&p=262129#p262129

* Command ? (WQout() function) enhanced. Displaying together
strings containing characters with different notiation in ANSI
and UTF8 was displaying garbage. Fixed.

* new functions AnsiToUtf8( cStr ) and Utf8ToAnsi( cStr )
Useful in case of some WU language characters like German
Umlauts who are encoded differently in ANSI and Utf8.
regards, saludos

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

Re: New FTDN July/Julio (FWH 23.07)

Postby Antonio Linares » Sat Jul 29, 2023 9:16 pm

Mayo, Junio, Julio 2023
=======================

* Mejora: La función SetClipboardData() soporta el formato CF_HDROP.
Un ejemplo de uso:
---
#include "FiveWin.ch"
#define CF_HDROP 15

function Main()
local oWnd, hDrop

DEFINE WINDOW oWnd

MsgInfo( OpenClipboard( oWnd:hWnd ) )
MsgInfo( SetClipboardData( CF_HDROP, { "tutor1.prg", "tutor02.prg", "tutor03.prg" } ) )
hDrop = GetClpData( CF_HDROP )

XBROWSER DragQueryFiles( hDrop )

CloseClipboard()
oWnd:End()

return nil
---

Otro ejemplo:
---
#include "FiveWin.ch"

function Main()
? FW_CopyToClipBoard( { "tutor1.prg", "tutor02.prg", "tutor03.prg" } )
XBROWSER FW_GetClipBoardData()
return nil
---

* Nuevo: Nuevo método Center() en la clase TWebView. Puedes centrar un objeto webview simplemente con oWebView:Center().

* Nuevo: Se ha añadido el fichero vs2022_make.zip en FWH\makes con los ficheros necesarios para construir nuestros programas
usando Visual Studio Community 2022.

* Nuevo: Se ha añadido el fichero hbmk2_bcc64.zip en hbmk2_bcc64.zip con los ficheros necesarios para construir nuestros programas
usando Borland C Compiler de 64 bits.

* Nuevo: Nuevas librerías FWH y FWH64 construidas usando el nuevo GCC 8.5 de 32 y 64 bits. Gracias a Santo !!!

* Mejora: Se han actualizado las librerías de enlace dinámico webview.dll y WebView2Loader.dll a la versión más reciente y hemos
incluido los cambios en set_user_agent() y comentado la llamada a PostQuitMessage() que cerraba la aplicación FWH al cerrar los
objetos webview. Explicado aquí:

viewtopic.php?p=261258&#p261258

Las librerías webview.dll y WebView2Loader.dll están ubicadas en FWH\samples y las de 64 bits en FWH\dll\webview64

* Nuevo: Nuevo ejemplo samples\webview1.prg, muestra como usar la ventana existente (diálogo o control) para crear un objeto
webview en dicha ventana (dálogo o control).

* Nuevo: Nuevo ejemplo samples\webview3.prg, muestra como colocar un objeto webview dentro de un diálogo.

* Nuevo: Nuevo ejemplo samples\webvieweval.prg, muestra como usar oWebView:Eval( cJavaScript ).

* Nuevo: Nuevo ejemplo samples\webviewbody.prg, muestra como alcanzar document.body.outerHTML

* Nuevo: Nuevo método InjectJavascript( cScript ) en la clase TWebView creado por Charles Kwon ( charleskwonohjun@gmail.com ).
Este permite colocar tu código javascript en sitios web públicos y hacer cosas increibles.

* Nuevo: Nueva función IsWebViewAvailable() --> lAvailable, permite comprobar si nuestro equipo está preparado para usar webview.

* Nuevo: Nuevo ejemplo samples\webviewlogin.prg, muestra como usar la web dentro de una aplicación de escritorio usando FWH y webview.

* Nuevo: Nuevo método OpenDevToolsWindow() en la clase TWebView. Por favor revisa los ejemplos: samples\webview.prg y webvieweval.prg

* Mejora: La clase TListView es compatible con Unicode. Prueba el ejemplo: samples\testvie1.prg

* Clase LinkList: Se ha mejorado el método Sort( [lAsc], [lRecurse], [nCol] ) con tres nuevos parámetros:

1.- lAsc: .T. o "A" para ordenación ascendente y .F. o "D" para ordenación descendente. Este parámetro puede ser un bloque de código.
Por defecto, ordenación ascendente.
2.- lRecurse: Por defecto .F., para compatibilidad con versiones anteriores. Si se pone a .T. todo los subárboles también son ordenados.

3.- nCol: Por defecto 0, ordena sobre nCol de la matriz Cargo.

* Clase TreeItem: oItem[ n ] devuelve oItem:Cargo[ n ] si oItem:Cargo es una matriz y n está dentro del tamaño y si n es '0' devuelve
oItem:cPromt y en caso contrario devuelve 'nil'.
Si n está dentro del rango, oItem[ n ] := newValue también funciona.

* Función XEval( uVar, p1, p2, ... ) mejorada.
Ahora uVar también puede ser un nombre de función que termine con "()".
Si la función nombrada está enlazada, la función se ejecuta con los parámetros p1,p2,... etc.
XEval( {|c| Upper( c ) }, "abc" ) --> ABC
XEval( "Upper()", c ) --> ABC
Si uVar no es ni un bloque de código ni un nombre de función válido, se devuelve uVar.

* La función fw_stricmp() trata el tipo de dato nil como inferior a otros tipos de datos.

* Nuevo: Sabemos que escribir la ayuda para una aplicación es una tarea tediosa, por lo que hemos implementado
una forma realmente sencilla de hacerlo utilizando FWH:

SetAutoHelp( lOnOff, lEditable ) // lEditable es .T. por defecto

simplemente llama a esa función al principio de tu aplicación, y pulsa F1 en cualquier control de tu aplicación
FWH, se te pedirá que escribas la ayuda para él, usando texto enriquecido y la próxima vez que pulses F1 se mostrará la ayuda.
FWH crea automáticamente un archivo llamado help.dbf con índice y lo actualiza correctamente.

* Clase TDataRow:

* TDataRow class: Los campos de imagen se muestran como imágenes, aunque todavía no se pueden modificar ni guardar.

* XBROWSE:
- RTE durante la navegación de la consulta PostGre debido a un error en el método SetPostGreCol() corregido.

- Si el conjunto de registros está cerrado al configurarlo, xbrowse lo abrirá para la búsqueda.

- Nuevo DATA bmPrevious (marcador anterior) bChange ahora puede acceder al marcador anterior con oBrw:bmPrevious

- Correcciones en SetRDD() en caso de usos muy raros.

- Corrección: SetTree(). Auto-generación de Tree con datos de tipo matriz está fallando desde la versión 21.04, ahora solucionado.
viewtopic.php?f=3&t=43494

* Nuevo: Nueva función EnumWindows( bEnumWindow [,nLParam] ). Enumera todas las ventanas de nivel superior de la pantalla pasando
el manejador de cada ventana, a su vez a un bloque de código donde se proporciona el manejador de cada ventana y un valor opcional nLParam.

* ScrollMsg: Se ha añadido la claúsula NOBORDER.

* TGET:

- Claúsula Picture "@M c1,c2,..." implementada como FoxPro.
viewtopic.php?f=3&t=43407

- Se evita el RTE cuando se especifica el estilo ES_UPPERCASE en el fichero RC para los gets sin carácter.
viewtopic.php?f=3&t=43453

- Compatible con caracteres acentuados como las diéresis alemanas incluso cuando se usa FW_SetUnicode(.t.).
El problema surge cuando ciertos caracteres acentuados tienen diferentes notaciones en ANSI y UTF8.
viewtopic.php?f=3&t=43352&p=262129#p262129

* Comando ? (función WQout()) mejorado. La visualización conjunta de cadenas que contienen caracteres con notación diferente
en ANSI y UTF8 mostraba basura. Corregida.

* Nueva funciones AnsiToUtf8( cStr ) y Utf8ToAnsi( cStr ).
Útil en el caso de algunos caracteres de idiomas WU, como las diéresis alemanas, que se codifican de forma diferente en ANSI y UTF8.
regards, saludos

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

Re: New FTDN July/Julio (FWH 23.07)

Postby goosfancito » Tue Aug 15, 2023 8:23 am

Me interesa mucho la ordenacion del arbol. yo puedo acceder a esa version de FW o tengo que hacer un upgrade?
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: New FTDN July/Julio (FWH 23.07)

Postby Antonio Linares » Tue Aug 15, 2023 3:28 pm

Estimado Gustavo,

Aqui tienes la versión más reciente:

ttreevie.prg
Code: Select all  Expand view  RUN
// Win32 TreeView support

#include "FiveWin.ch"
#include "Constant.ch"

#define TV_FIRST                4352    //0x1100
#define TVM_GETEDITCONTROL      ( TV_FIRST + 15 )
#define TVM_EDITLABELA          ( TV_FIRST + 14 )
#define TVM_EDITLABELW          ( TV_FIRST + 65 )
#ifdef UNICODE
#define TVN_BEGINLABELEDITW     ( TVN_FIRST - 59 )
#define TVN_ENDLABELEDITW       ( TVN_FIRST - 60 )
#define TVM_EDITLABEL           TVM_EDITLABELW
#define TVN_BEGINLABELEDIT      TVN_BEGINLABELEDITW
#define TVN_ENDLABELEDIT        TVN_ENDLABELEDITW
#else
#define TVN_BEGINLABELEDITA     ( TVN_FIRST - 10 )
#define TVN_ENDLABELEDITA       ( TVN_FIRST - 11 )
#define TVM_EDITLABEL           TVM_EDITLABELA
#define TVN_BEGINLABELEDIT      TVN_BEGINLABELEDITA
#define TVN_ENDLABELEDIT        TVN_ENDLABELEDITA
#endif

#define TVN_FIRST               -400
#define TVN_ITEMEXPANDED        (TVN_FIRST-6)

#define COLOR_WINDOW            5
#define COLOR_WINDOWTEXT        8
#define COLOR_BTNFACE           15
#define COLOR_BTNSHADOW         16
#define COLOR_BTNHIGHLIGHT      20

#define FD_BORDER               8
#define FD_HEIGHT               22

#define DT_CENTER               1
#define DT_VCENTER              4

#define WINDING                 2
#define SC_KEYMENU              61696 //  0xF100

#define TVS_HASBUTTONS          1
#define TVS_HASLINES            2
#define TVS_LINESATROOT         4
#define TVS_SHOWSELALWAYS       32 //  0x0020
#define TVS_DISABLEDRAGDROP     16 //  0x0010
#define TVS_CHECKBOXES          256 //  0x0100
#define TVS_EDITLABELS          8

#define CTRL_NAME "SysTreeView32"

//----------------------------------------------------------------------------//

CLASS TTreeView FROM TControl

   DATA   aItems
   DATA   oImageList
   DATA   bChanged
   DATA   bExpanded
   DATA   hEdit

   CLASSDATA aProperties ;
      INIT { "aItems", "cTitle", "cVarName", "l3D", "nClrText",;
             "nClrPane", "nAlign", "nTop", "nLeft",;
             "nWidth", "nHeight", "oFont", "Cargo" }

   METHOD New( nTop, nLeft, oWnd, nClrFore,;
               nClrBack, lPixel, lDesign, nWidth, nHeight,;
               cMsg, lCheckBoxes, bChange, lEditable ) CONSTRUCTOR

   METHOD ReDefine( nId, oWnd, nClrFore, nClrBack, lDesign, cMsg ) CONSTRUCTOR

   METHOD Add( cPrompt, nImage, nValue )

   METHOD VScroll( nWParam, nLParam ) VIRTUAL   // standard behavior requested

   METHOD HScroll( nWParam, nLParam ) VIRTUAL

   METHOD CollapseAll( oItem ) INLINE ScanItems( ::aItems, .f. ),;
      oItem := ::GetSelected(), if( oItem <> nil, oItem:MakeVisible(), nil )

   METHOD CollapseBranch( oItem ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(),), ;
      If( oItem != nil, ( oItem:Collapse(), ScanItems( oItem:aItems, .f. ), oItem:MakeVisible() ),)

   METHOD EditLabel( oItem ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(),), ;
      If( oItem != nil, oItem:Edit(),)

   METHOD Expand() INLINE AEval( ::aItems, { | oItem | oItem:Expand() } )

   METHOD ExpandAll( oItem ) INLINE ScanItems( ::aItems, .t. ),;
      oItem := ::GetSelected(), if( oItem <> nil, oItem:MakeVisible(), nil )

   METHOD ExpandBranch( oItem ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(), nil ), ;
      If( oItem != nil, ( oItem:Expand(), ScanItems( oItem:aItems, .t. ), oItem:MakeVisible() ), nil )

   METHOD GetEditControl() INLINE TVGetEditControl( ::hWnd )

   METHOD GetSelected()

   METHOD GetItem( hItem )

   METHOD GetItemPos( oItem )

   METHOD InsertAfter( oItemParent, cPrompt, nImage, nValue )  

   METHOD Select( oItem ) INLINE TVSelect( ::hWnd, oItem:hItem )

   METHOD GetSelText() INLINE TVGetSelText( ::hWnd )

   METHOD GoNext()

   METHOD GoPrev()

   METHOD GoTop() INLINE If( Len( ::aItems ) > 0, ::Select( ::aItems[ 1 ] ),)

   METHOD GoBottom()

   METHOD SelChanged() INLINE If( ::bChanged != nil, Eval( ::bChanged, Self ), nil )

   METHOD SetImageList( oImageList )

   METHOD DeleteAll() INLINE ( TVDelAllItems( ::hWnd ), ::aItems := {} )

   METHOD HitTest( nRow, nCol )

   METHOD HandleEvent( nMsg, nWParam, nLParam )

   METHOD Initiate( hDlg ) INLINE ::Super:Initiate( hDlg ), ::SetColor( ::nClrText, ::nClrPane )

   METHOD cToChar() INLINE ::Super:cToChar( CTRL_NAME )

   METHOD SetColor( nClrText, nClrPane ) INLINE ;
      ::Super:SetColor( nClrText, nClrPane ), TVSetColor( ::hWnd, nClrText, nClrPane )

   METHOD SwapUp()

   METHOD SwapDown()  

   METHOD Toggle() INLINE AEval( ::aItems, { | oItem | oItem:Toggle() } )

   METHOD ToggleAll( oItem ) INLINE ScanItems( ::aItems, , .t. ), ;
      oItem := ::GetSelected(), If( oItem <> nil, oItem:MakeVisible(), nil )

   METHOD ToggleBranch( oItem ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(), nil ), ;
      If( oItem != nil, ( oItem:Toggle(), ScanItems( oItem:aItems, , .t. ), oItem:MakeVisible() ), nil )

   METHOD GetCheck( oItem ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(), nil ), ;
      TVGetCheck( ::hWnd, oItem:hItem )

   METHOD SetCheck( oItem, lOnOff ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(), nil ), ;
      TVSetCheck( ::hWnd, oItem:hItem, lOnOff )

   METHOD SetItems( aItems )

   METHOD GenMenu( lPopup )

   METHOD LoadFromMenu( oMenu )

   METHOD Notify( nIdCtrl, nPtrNMHDR )

   METHOD Scan( bAction )

   METHOD SetItemImage( oItem, nImage ) INLINE ;
      If( oItem == nil, oItem := ::GetSelected(), nil ), ;
      TVSetItemImage( ::hWnd, oItem:hItem, nImage )

   METHOD SetItemHeight( nHeight ) INLINE TvSetItemHeight( ::hWnd, nHeight )

   METHOD SetSelText( cText ) INLINE ::GetSelected():SetText( cText )

   METHOD Len() INLINE Len( ::aItems )

   METHOD Count()  

ENDCLASS

//----------------------------------------------------------------------------//

METHOD LoadFromMenu( oMenu ) CLASS TTreeView

   local n

   ::DeleteAll()

   for n = 1 to Len( oMenu:aItems )
      ::Add( oMenu:aItems[ n ]:cPrompt )
      if ValType( oMenu:aItems[ n ]:bAction ) == "O"
         AddSubItems( ATail( ::aItems ), oMenu:aItems[ n ]:bAction )
      endif
   next

return nil

//----------------------------------------------------------------------------//

static function AddSubItems( oItem, oSubMenu )

   local n

   for n = 1 to Len( oSubMenu:aItems )
      oItem:Add( oSubMenu:aItems[ n ]:cPrompt )
      if ValType( oSubMenu:aItems[ n ]:bAction ) == "O"
         AddSubItems( ATail( oItem:aItems ), oSubMenu:aItems[ n ]:bAction )
      endif
   next

return nil

//----------------------------------------------------------------------------//

METHOD New( nTop, nLeft, oWnd, nClrFore,;
            nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg, lCheckBoxes, bChange, lEditable ) CLASS TTreeView

   DEFAULT nTop        := 0, nLeft := 0,;
           oWnd        := GetWndDefault(),;
           nClrFore    := oWnd:nClrText,;
           nClrBack    := GetSysColor( COLOR_WINDOW ),;
           lPixel      := .f.,;
           lDesign     := .f.,;
           nWidth      := 150,;
           nHeight     := 150,;
           lCheckBoxes := .F.,;
           lEditable   := .F.

    ::lUnicode  = FW_SetUnicode()
   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE, CS_VREDRAW, CS_HREDRAW,;
                      If( lDesign, WS_CLIPSIBLINGS, 0 ), WS_TABSTOP,;
                      TVS_HASBUTTONS, TVS_HASLINES, TVS_LINESATROOT, TVS_SHOWSELALWAYS, TVS_DISABLEDRAGDROP,;
                      If( lCheckBoxes, TVS_CHECKBOXES, 0 ),;
                      If( lEditable, TVS_EDITLABELS, 0 ) )

   ::nId       = ::GetNewId()
   ::oWnd      = oWnd
   ::cMsg      = cMsg
   ::nTop      = If( lPixel, nTop, nTop * SAY_CHARPIX_H )
   ::nLeft     = If( lPixel, nLeft, nLeft * SAY_CHARPIX_W )
   ::nBottom   = ::nTop + nHeight - 1
   ::nRight    = ::nLeft + nWidth - 1
   ::lDrag     = lDesign
   ::lCaptured = .f.
   ::nClrText  = nClrFore
   ::nClrPane  = nClrBack
   ::aItems    = {}
   ::bChanged  = bChange

   if ! Empty( oWnd:hWnd )
      ::Create( CTRL_NAME )
      oWnd:AddControl( Self )
      ::SetColor( nClrFore, nClrBack )
   else
      oWnd:DefControl( Self )
   endif

   ::Default()
   ::lDrag = lDesign

   if lDesign
      ::CheckDots()
   endif

return Self

//----------------------------------------------------------------------------//

METHOD ReDefine( nId, oWnd, nClrFore, nClrBack, lDesign, cMsg, bChange ) CLASS TTreeView

   DEFAULT oWnd     := GetWndDefault(),;
           nClrFore := oWnd:nClrText,;
           nClrBack := oWnd:nClrPane,; // GetSysColor( COLOR_WINDOW ),;
           lDesign  := .f.

    ::lUnicode  = FW_SetUnicode()
   ::nId      = nId
   ::oWnd     = oWnd
   ::aItems   = {}
   ::nClrText = nClrFore
   ::nClrPane = nClrBack
   ::bChanged = bChange

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW, TVS_HASBUTTONS, TVS_HASLINES, TVS_LINESATROOT ) )

   oWnd:DefControl( Self )

return Self

//----------------------------------------------------------------------------//

METHOD Add( cPrompt, nImage, nValue ) CLASS TTreeView

   local oItem

   oItem := TTVItem():New( TVInsertItem( ::hWnd, cPrompt,, nImage, nValue ), Self )

   oItem:cPrompt := cPrompt
   oItem:nImage  := nImage

   AAdd( ::aItems, oItem )

return oItem

//----------------------------------------------------------------------------//

METHOD Count() CLASS TTreeView

   local nItems := 0, bAction := { | oItem | nItems++, .F. }

   ::Scan( bAction )

return nItems

//----------------------------------------------------------------------------//

METHOD InsertAfter( oItem, cPrompt, nImage, nValue ) CLASS TTreeView

   local oNewItem, nAt, oLastItem

   oNewItem := TTVItem():New( TVInsertItem( ::hWnd, cPrompt, oItem:oParent:hItem, nImage, nValue, oItem:hItem ), Self )

   oNewItem:cPrompt := cPrompt
   oNewItem:nImage  := nImage
   oNewItem:oParent := oItem:oParent

   if ( nAt := AScan( oItem:oParent:aItems, { | oIt | oItem:hItem == oIt:hItem } ) ) != 0
      oLastItem = ATail( oItem:oParent:aItems )
      AIns( oItem:oParent:aItems, nAt + 1 )
      AAdd( oItem:oParent:aItems, oLastItem )
      oItem:oParent:aItems[ nAt + 1 ] = oNewItem
      // XBrowse( oItem:oParent:aItems )
   endif

return oNewItem

//----------------------------------------------------------------------------//

static function ScanItems( aItems, lExpand, lToggle )

   local oItem, i

   DEFAULT lExpand := .t., lToggle := .f.

   for i := 1 to Len( aItems )
       oItem = aItems[ i ]

       if lToggle
          oItem:Toggle()
       elseif lExpand
          oItem:Expand()
       else
          oItem:Collapse()
       endif

       if Len( oItem:aItems ) != 0
          ScanItems( oItem:aItems, lExpand, lToggle )
       endif
   next

return nil

//----------------------------------------------------------------------------//

static function ScanItemsBlock( aItems, bAction )

   local oItem, n := 1, oItemFound

   while n <= Len( aItems ) .and. oItemFound == nil
      oItem = aItems[ n ]
      if Eval( bAction, oItem, n )
         return oItem
      else
         if Len( oItem:aItems ) > 0
            oItemFound = ScanItemsBlock( oItem:aItems, bAction )
         endif
      endif
      n++
   end

return oItemFound

//----------------------------------------------------------------------------//

METHOD GenMenu( lPopup ) CLASS TTreeView

   local oMenu

   DEFAULT lPopup := .T.

   if Len( ::aItems ) > 0
      if lPopup
         MENU oMenu POPUP
      else
         MENU oMenu
      endif
      GenMenuItems( ::aItems )
      ENDMENU
   endif

return oMenu

//----------------------------------------------------------------------------//

static function GenMenuItems( aItems )

   local n

   for n = 1 to Len( aItems )
      MENUITEM aItems[ n ]:GetText()
      if Len( aItems[ n ]:aItems ) > 0
         MENU
            GenMenuItems( aItems[ n ]:aItems )
         ENDMENU
      endif
   next

return nil

//----------------------------------------------------------------------------//

METHOD GetSelected() CLASS TTreeView

return SearchItem( ::aItems, TVGetSelected( ::hWnd ) )

//----------------------------------------------------------------------------//

METHOD GetItem( hItem ) CLASS TTreeView

return SearchItem( ::aItems, hItem )

//----------------------------------------------------------------------------//

METHOD GetItemPos( oItem ) CLASS TTreeView

return AScan( ::aItems, { | o | o == oItem } )

//----------------------------------------------------------------------------//

METHOD GoBottom() CLASS TTreeView

   local oLastItem

   ::Scan( { | oItem | oLastItem := oItem, .F. } )
   ::Select( oLastItem )

return nil  

//----------------------------------------------------------------------------//

METHOD GoPrev() CLASS TTreeView

   local oSelItem, oPrevItem

   if ( oSelItem := ::GetSelected() ) != nil
      ::Scan( { | oItem | If( oItem:hItem != oSelItem:hItem, oPrevItem := oItem,),;
                              oItem:hItem == oSelItem:hItem } )
      if oPrevItem != nil
         ::Select( oPrevItem )
      else
         ::GoBottom()
      endif
   endif
   
return nil  

//----------------------------------------------------------------------------//

METHOD GoNext() CLASS TTreeView

   local oSelItem := ::GetSelected(), lStop := .F., oNextItem

   ::Scan( { | oItem | If( oItem:hItem == oSelItem:hItem, lStop := .T.,),;
                       If( lStop .and. oItem:hItem != oSelItem:hItem, ( oNextItem := oItem, .T. ), .F. ) } )

   if oNextItem != nil                          
      ::Select( oNextItem )
   else
      ::GoTop()
   endif      
   
return nil  

//----------------------------------------------------------------------------//

METHOD HitTest( nRow, nCol ) CLASS TTreeView

   local hItem

   hItem := TVHitTest( ::hWnd, nRow, nCol )

   If hItem > 0
      return ::GetItem( hItem )
   Endif

return nil

//----------------------------------------------------------------------------//

METHOD Notify( nIdCtrl, nPtrNMHDR ) CLASS TTreeView

   local nCode := GetNMHDRCode( nPtrNMHDR )

   do case
      case nCode == TVN_ITEMEXPANDED
           if ! Empty( ::bExpanded )
              if NMTREEVIEWAction( nPtrNMHDR ) == 2 // Expanded
                 Eval( ::bExpanded, NMTREEVIEWItemNew( nPtrNMHDR ) ) // hItem
              endif
           endif

      case nCode == TVN_BEGINLABELEDIT
           ::hEdit  := SendMessage( ::hWnd, TVM_GETEDITCONTROL, 0, 0 )
           return 0      

      case nCode == TVN_ENDLABELEDIT
           ::SetSelText( GetWindowText( ::hEdit ) )
           ::hEdit := nil

   endcase

return nil

//----------------------------------------------------------------------------//

METHOD Scan( bAction ) CLASS TTreeView

return ScanItemsBlock( ::aItems, bAction )

//----------------------------------------------------------------------------//

METHOD SetImageList( oImageList ) CLASS TTreeView

   ::oImageList = oImageList

   TVSetImageList( ::hWnd, oImageList:hImageList, 0 )

return nil

//----------------------------------------------------------------------------//

METHOD SwapDown() CLASS TTreeView

   local oSelItem := ::GetSelected(), cPrompt := oSelItem:cPrompt

   ::GoNext()
   oSelItem:End()
   ::Select( ::InsertAfter( ::GetSelected(), cPrompt ) )
   
return nil

//----------------------------------------------------------------------------//

METHOD SwapUp() CLASS TTreeView

   local oSelItem := ::GetSelected(), cPrompt := oSelItem:cPrompt

   ::GoPrev()
   ::GoPrev()
   oSelItem:End()
   ::Select( ::InsertAfter( ::GetSelected(), cPrompt ) )
   
return nil

//----------------------------------------------------------------------------//

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TTreeView

   local oItem

   do case
      case nMsg == WM_CHAR
           if nWParam == VK_RETURN
              return 1
           endif
   endcase

return ::Super:HandleEvent( nMsg, nWParam, nLParam )

//----------------------------------------------------------------------------//

METHOD SetItems( aItems ) CLASS TTreeView

   local n

   for n = 1 to Len( aItems )
      ::Add( aItems[ n ] )
   next

return nil

//----------------------------------------------------------------------------//

static function SearchItem( aItems, hItem )

   local n, oItem

   for n = 1 to Len( aItems )
      if Len( aItems[ n ]:aItems ) > 0
         if ( oItem := SearchItem( aItems[ n ]:aItems, hItem ) ) != nil
            return oItem
         endif
      endif
      if aItems[ n ]:hItem == hItem
         return aItems[ n ]
      endif
   next

return nil

//----------------------------------------------------------------------------//
 


tvvitem.prg
Code: Select all  Expand view  RUN
// Win95 Class TTreeView items support ( TTVItem --> TreeViewItem )

#include "FiveWin.ch"

#define TV_FIRST          4352   // 0x1100
#define TVM_EXPAND        TV_FIRST + 2

#define TVE_COLLAPSE      1
#define TVE_EXPAND        2
#define TVE_TOGGLE        3

#define TVM_ENSUREVISIBLE TV_FIRST + 20
#define TVM_GETITEMSTATE  TV_FIRST + 39

//item state
#define TVIS_SELECTED           0x0002
#define TVIS_CUT                0x0004
#define TVIS_DROPHILITED        0x0008
#define TVIS_BOLD               0x0010
#define TVIS_EXPANDED           0x0020
#define TVIS_EXPANDEDONCE       0x0040

//----------------------------------------------------------------------------//

CLASS TTVItem

   DATA   oParent
   DATA   hItem
   DATA   oTree
   DATA   aItems
   DATA   cPrompt
   DATA   nImage
   DATA   Cargo
   DATA   lBold   INIT .F.

   METHOD New( hItem, oTree, Cargo ) CONSTRUCTOR

   METHOD Add( cPrompt, nImage, Cargo )

   METHOD Bold() INLINE TVSetItemBold( ::oTree:hWnd, ::hItem, .T. )  
     
   METHOD Normal() INLINE TVSetItemBold( ::oTree:hWnd, ::hItem, .F. )  

   METHOD DeleteBranches()

   METHOD DelItemPos( nPos )

   METHOD Edit() INLINE TVEditLabel( ::oTree:hWnd, ::hItem )  

   METHOD Expand() INLINE ;
      SendMessage( ::oTree:hWnd, TVM_EXPAND, TVE_EXPAND, ::hItem )

   METHOD Collapse() INLINE ;
      SendMessage( ::oTree:hWnd, TVM_EXPAND, TVE_COLLAPSE, ::hItem )

   METHOD GetItemPos( oItem )

   METHOD GetParent() INLINE ;
      ::oTree:GetItem( TVGetParent( ::oTree:hWnd, ::hItem ) )

   METHOD IsExpanded() INLINE nAnd( ::GetState(), TVIS_EXPANDED ) > 0

   METHOD IsSelected() INLINE nAnd( ::GetState(), TVIS_SELECTED ) > 0

   METHOD ItemLevel( nPrevLevel )

   METHOD SetText( cText ) INLINE ;
      TVSetItemText( ::oTree:hWnd, ::hItem, cText )

   METHOD Set( cText, nImage )

   METHOD Toggle() INLINE ;
      SendMessage( ::oTree:hWnd, TVM_EXPAND, TVE_TOGGLE, ::hItem )

   METHOD MakeVisible() INLINE ;
      SendMessage( ::oTree:hWnd, TVM_ENSUREVISIBLE, 0, ::hItem )

   METHOD SetCheck( lOnOff ) INLINE ::oTree:SetCheck( Self, lOnOff )

   METHOD GetCheck() INLINE ::oTree:GetCheck( Self )

   METHOD GetState() INLINE SendMessage( ::oTree:hWnd, TVM_GETITEMSTATE, ::hItem, 0 )

   METHOD GetText() INLINE TVGetText( ::oTree:hWnd, ::hItem )

   METHOD SetText( cText ) INLINE TVSetItemText( ::oTree:hWnd, ::hItem, cText )  

   ACCESS cPrompt INLINE TVGetText( ::oTree:hWnd, ::hItem )
   
   ASSIGN cPrompt( cText ) INLINE TVSetItemText( ::oTree:hWnd, ::hItem, cText )      

   METHOD End()

   METHOD Len() INLINE Len( ::aItems )
     
   METHOD Count()    

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( hItem, oTree, Cargo, cPrompt, nImage, oParent ) CLASS TTVItem

   ::aItems  = {}
   ::hItem   = hItem
   ::oTree   = oTree
   ::Cargo   = Cargo
   ::cPrompt = cPrompt
   ::nImage  = nImage

   ::oParent = oParent

return Self

//----------------------------------------------------------------------------//

METHOD Add( cPrompt, nImage, Cargo ) CLASS TTVItem

   local oItem := TTVItem():New( TVInsertItem( ::oTree:hWnd, cPrompt,;
                     ::hItem, nImage ), ::oTree, Cargo, cPrompt, nImage, Self )

   AAdd( ::aItems, oItem )

   oItem:oParent = Self

return oItem

//----------------------------------------------------------------------------//

METHOD Count() CLASS TTVItem

   local oItem, nItems := 1

   for each oItem in ::aItems
      nItems += 1 + If( ! Empty( oItem:aItems ), ( oItem:Count() - 1 ), 0 )
   next
   
return nItems  

//----------------------------------------------------------------------------//

METHOD DeleteBranches() CLASS TTVItem

   AEval( ::aItems, { | o | TVDeleteItem( ::oTree:hWnd, o:hItem ) } )

   ::aItems  = {}

return nil

//----------------------------------------------------------------------------//

METHOD DelItemPos( nPos ) CLASS TTVItem

   if nPos > 0 .and. nPos <= Len( ::aItems )
      TVDeleteItem( ::oTree:hWnd, ::aItems[ nPos ]:hItem )
      ADel( ::aItems, nPos )
      ASize( ::aItems, Len( ::aItems ) - 1 )
   endif

return nil

//----------------------------------------------------------------------------//

METHOD End() CLASS TTVItem

   local nAt := 0

   if ! Empty( ::oParent )
      nAt := AScan( ::oParent:aItems, { | o | o == Self } )
   endif

   if nAt != 0
      if ::oParent:IsKindOf( "TTREEVIEW" )
         ADel( ::oTree:aItems, nAt )
         ASize( ::oTree:aItems, Len( ::oTree:aItems ) - 1 )
      else
         ADel( ::oParent:aItems, nAt )
         ASize( ::oParent:aItems, Len( ::oParent:aItems ) - 1 )
      endif
   endif

   TVDeleteItem( ::oTree:hWnd, ::hItem )

return nil

//----------------------------------------------------------------------------//

METHOD GetItemPos( oItem ) CLASS TTVItem

return AScan( ::aItems, { | o | o == oItem } )

//----------------------------------------------------------------------------//

METHOD ItemLevel( nPrevLevel ) CLASS TTVItem

   DEFAULT nPrevLevel := 0

   if ::oParent != NIL
      ++nPrevLevel
      ::oParent:ItemLevel( @nPrevLevel )
   endif

RETURN nPrevLevel

//----------------------------------------------------------------------------//

METHOD Set( cPrompt, nImage ) CLASS TTVItem

   DEFAULT cPrompt := ::cPrompt, nImage := ::nImage

   TVSetTextImage( ::oTree:hWnd, ::hItem, cPrompt, nImage )

return nil

//----------------------------------------------------------------------------//
 


treeview.c
Code: Select all  Expand view  RUN
// Windows 95 TreeView control support C routines

#define UNICODE
#define _UNICODE

#define NONAMELESSUNION

#define _WIN32_IE 0x0500
#include <Windows.h>
#include <CommCtrl.h>
#include <hbapi.h>

#ifdef _MSC_VER
   #define TVM_GETITEMSTATE  (TV_FIRST + 39)
#endif

#ifdef __GNUC__
   #define TreeView_SetCheckState(hwndTV, hti, fCheck) TreeView_SetItemState(hwndTV, hti, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), TVIS_STATEIMAGEMASK)
   #define TreeView_GetCheckState(hwndTV, hti) ((((UINT)(SNDMSG((hwndTV), TVM_GETITEMSTATE, (WPARAM)(hti), TVIS_STATEIMAGEMASK))) >> 12) -1)
#endif

#ifndef _WIN64
#define fw_parH( i )   ( (HANDLE) hb_parnl( i ) )
#define fw_retnll( l )  hb_retnl( (LONG) l )
#else
#define fw_parH( i )   ( (HANDLE) hb_parnll( i ) )
#define fw_retnll( l )  hb_retnll( (LONGLONG) l )
#endif

LPWSTR fw_parWide( int iParam );
LPSTR UTF16toSTR8( LPWSTR utf16, int iLen );
size_t wcslen( const wchar_t* wcs );

//-------------------------------------------------------------------------//

HB_FUNC( TVINSERTITEM ) // ( hWnd, cItemText, hItem, nImage, nValue, hItem )
{
   TV_INSERTSTRUCT is;
   HTREEITEM hItem;

   memset( ( char * ) &is, 0, sizeof( TV_INSERTSTRUCT ) );

   #ifndef _WIN64
      is.hParent      = ( HTREEITEM ) hb_parnl( 3 );
   #else
      is.hParent      = ( HTREEITEM ) hb_parnll( 3 );
   #endif

//    #if (_WIN32_IE >= 0x0400)
#ifdef __BORLANDC__

   #if __BORLANDC__ <= 1410

      is.DUMMYUNIONNAME.item.pszText = fw_parWide( 2 ); //hb_parc( 2 );
      is.DUMMYUNIONNAME.item.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
      is.DUMMYUNIONNAME.item.iImage  = hb_parnl( 4 );
      is.DUMMYUNIONNAME.item.iSelectedImage = hb_parnl( 4 );
      is.DUMMYUNIONNAME.item.lParam = hb_parnl( 5 );
   #else
      is.item.pszText = fw_parWide( 2 ); //hb_parc( 2 );
      is.item.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
      is.item.iImage  = hb_parnl( 4 );
      is.item.iSelectedImage = hb_parnl( 4 );
      is.item.lParam  = hb_parnl( 5 );
   #endif
#else
      is.u.item.pszText = fw_parWide( 2 ); //hb_parc( 2 );
      is.u.item.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
      is.u.item.iImage  = hb_parnl( 4 );
      is.u.item.iSelectedImage = hb_parnl( 4 );
      is.u.item.lParam  = hb_parnl( 5 );
#endif

   if( ( hb_pcount() > 5 ) && ( hItem = ( HTREEITEM ) hb_parnll( 6 ) ) )
   {
      is.hInsertAfter = hItem;
   }

   #ifndef _WIN64
      hb_retnl( SendMessage( ( HWND ) hb_parnl( 1 ), TVM_INSERTITEM, 0,
           ( LPARAM )( LPTV_INSERTSTRUCT )( &is ) ) );
   #else
      hb_retnll( SendMessage( ( HWND ) hb_parnll( 1 ), TVM_INSERTITEM, 0,
           ( LPARAM )( LPTV_INSERTSTRUCT )( &is ) ) );
   #endif

#ifdef __BORLANDC__
   #if __BORLANDC__ <= 1410
      hb_xfree( ( void * ) is.DUMMYUNIONNAME.item.pszText );
   #else
      hb_xfree( ( void * ) is.item.pszText );
   #endif
#else
      hb_xfree( ( void * ) is.u.item.pszText );
#endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETIMAGELIST ) // ( hWnd, hImageList, nType )
{
    #ifndef _WIN64
      hb_retnl( ( LONG ) TreeView_SetImageList( ( HWND ) hb_parnl( 1 ),
            ( HIMAGELIST ) hb_parnl( 2 ), hb_parnl( 3 ) ) );
   #else
      hb_retnll( ( LONGLONG ) TreeView_SetImageList( ( HWND ) hb_parnll( 1 ),
            ( HIMAGELIST ) hb_parnll( 2 ), hb_parnl( 3 ) ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVGETSELTEXT ) // ( hWnd ) --> cText
{
   #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif
   HTREEITEM hItem = TreeView_GetSelection( hWnd );
   TV_ITEM tvi;
   BYTE buffer[ 200 ];
   LPSTR szRet;

   if( hItem )
   {
      tvi.mask       = TVIF_TEXT;
      tvi.hItem      = hItem;
      tvi.pszText    = (LPWSTR) buffer; //( char * ) buffer;
      tvi.cchTextMax = 100;
      TreeView_GetItem( hWnd, &tvi );


//      hb_retc( tvi.pszText );
      szRet = UTF16toSTR8( (LPWSTR) buffer, wcslen( (LPWSTR) buffer ) );
      hb_retc( szRet );
      hb_xfree( ( void * ) szRet );
   }
   else
      hb_retc( "" );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVGETTEXT ) // ( hWnd, hItem ) --> cText
{
    #ifndef _WIN64
      HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      HTREEITEM hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif
   TV_ITEM tvi;
   BYTE buffer[ 200 ];
   LPSTR szRet;

   tvi.mask       = TVIF_TEXT;
   tvi.hItem      = hItem;
   tvi.pszText    = (LPWSTR) buffer; //( char * ) buffer;
   tvi.cchTextMax = 100;
   #ifndef _WIN64
      TreeView_GetItem( ( HWND ) hb_parnl( 1 ), &tvi );
   #else
      TreeView_GetItem( ( HWND ) hb_parnll( 1 ), &tvi );
   #endif

//   hb_retc( tvi.pszText );

   szRet    = UTF16toSTR8( (LPWSTR) buffer, wcslen( (LPWSTR) buffer ) );
   hb_retc( szRet );
   hb_xfree( ( void * ) szRet );

}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETITEMTEXT ) // ( hWnd, hItem, cText )
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif
   TV_ITEM tvi;
   BOOL bResult;
   BYTE buffer[ 200 ];

   #ifndef _WIN64
      tvi.hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      tvi.hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif
   tvi.mask       = TVIF_TEXT;
   tvi.pszText    = (LPWSTR) buffer;  //( char * ) buffer;
   tvi.cchTextMax = 100; //sizeof( buffer );
   bResult = TreeView_GetItem( hWnd, &tvi );

   if( bResult )
   {
      tvi.mask       = TVIF_TEXT;
      #ifndef _WIN64
         tvi.hItem      = ( HTREEITEM ) hb_parnl( 2 );
      #else
         tvi.hItem      = ( HTREEITEM ) hb_parnll( 2 );
      #endif
      tvi.pszText    = fw_parWide( 3 ); //( LPSTR ) hb_parc( 3 );
      tvi.cchTextMax = wcslen( tvi.pszText ); //hb_parclen( 3 );
      TreeView_SetItem( hWnd, &tvi );

      hb_xfree( ( void * ) tvi.pszText );
   }
}

//-------------------------------------------------------------------------//

HB_FUNC( TVGETSELECTED ) // ( hWnd ) --> hItem
{
    #ifndef _WIN64
      hb_retnl( ( LONG ) TreeView_GetSelection( ( HWND ) hb_parnl( 1 ) ) );
   #else
      hb_retnll( ( LONGLONG ) TreeView_GetSelection( ( HWND ) hb_parnll( 1 ) ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVDELALLITEMS ) // ( hWnd ) --> lSuccess
{
    #ifndef _WIN64
      hb_retl( ( BOOL ) TreeView_DeleteAllItems( ( HWND ) hb_parnl( 1 ) ) );
   #else
      hb_retl( ( BOOL ) TreeView_DeleteAllItems( ( HWND ) hb_parnll( 1 ) ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVHITTEST ) // ( hWnd, nRow, nCol ) --> hItem
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif
   TV_HITTESTINFO lpht;
   HTREEITEM hItem;

   lpht.pt.x = hb_parnl( 3 );
   lpht.pt.y = hb_parnl( 2 );

   hItem = TreeView_HitTest( hWnd, &lpht );

   if( ( hItem != NULL ) && ( lpht.flags & TVHT_ONITEM ) )
    #ifndef _WIN64
       hb_retnl( ( LONG ) hItem );
    #else
       hb_retnll( ( LONGLONG ) hItem );
    #endif
   else
    hb_retnl( ( LONG ) 0 );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSELECT ) // ( hWnd, hItem ) --> lSuccess
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif

   hb_retl( ( BOOL ) TreeView_Select( hWnd, hItem, TVGN_CARET ) );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVDELETEITEM ) // ( hWnd, hItem ) --> lSuccess
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif

   hb_retl( TreeView_DeleteItem( hWnd, hItem ) );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVEDITLABEL ) // ( hWnd, hItem ) --> lSuccess
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif

   SetFocus( hWnd );
   TreeView_EditLabel( hWnd, hItem );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVGETPARENT ) // ( hWnd, hItem ) --> hParentItem
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif

   #ifndef _WIN64
      hb_retnl( ( unsigned long ) TreeView_GetParent( hWnd, hItem ) );
   #else
      hb_retnll( ( LONGLONG ) TreeView_GetParent( hWnd, hItem ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETTEXTIMAGE ) // ( hWnd, hItem, cText, nImage )
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
      HTREEITEM hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif
   TV_ITEM tvi;

   tvi.hItem   = hItem;
   tvi.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
   tvi.pszText = fw_parWide( 3 ); //( LPSTR ) hb_parc( 3 );
   tvi.iImage  = hb_parnl( 4 );
   tvi.iSelectedImage = hb_parnl( 4 );
   TreeView_SetItem( hWnd, &tvi );

   hb_xfree( ( void * ) tvi.pszText );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETCOLOR ) // hWnd, nClrFore, nClrBack
{
    #ifndef _WIN64
      COLORREF clr = TreeView_SetBkColor( ( HWND ) hb_parnl( 1 ), hb_parnl( 3 ) );
      COLORREF clr2 = TreeView_SetTextColor( ( HWND ) hb_parnl( 1 ), hb_parnl( 2 ) );
   #else
      COLORREF clr = TreeView_SetBkColor( ( HWND ) hb_parnll( 1 ), hb_parnl( 3 ) );
      COLORREF clr2 = TreeView_SetTextColor( ( HWND ) hb_parnll( 1 ), hb_parnl( 2 ) );
   #endif

   HB_SYMBOL_UNUSED( clr );
   HB_SYMBOL_UNUSED( clr2 );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETCHECK ) // hTreeView, hItem, lOnOff
{
    #ifndef _WIN64
      TreeView_SetCheckState( ( HWND ) hb_parnl( 1 ),
                              ( HTREEITEM ) hb_parnl( 2 ), hb_parl( 3 ) );
   #else
      TreeView_SetCheckState( ( HWND ) hb_parnll( 1 ),
                              ( HTREEITEM ) hb_parnll( 2 ), hb_parl( 3 ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVGETCHECK ) // hTreeView, hItem --> lOnOff
{
    #ifndef _WIN64
      hb_retl( TreeView_GetCheckState( ( HWND ) hb_parnl( 1 ),
                                     ( HTREEITEM ) hb_parnl( 2 ) ) );
   #else
      hb_retl( TreeView_GetCheckState( ( HWND ) hb_parnll( 1 ),
                                     ( HTREEITEM ) hb_parnll( 2 ) ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVGETEDITCONTROL ) // hTreeView --> hEdit
{
    #ifndef _WIN64
      hb_retnl( ( HB_ULONG ) TreeView_GetEditControl( ( HWND ) hb_parnl( 1 ) ) );
   #else
      hb_retnll( ( HB_LONGLONG ) TreeView_GetEditControl( ( HWND ) hb_parnll( 1 ) ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVIPARAM ) // hItem --> nLParam
{
    #ifndef _WIN64
      hb_retnl( ( ( TV_ITEM * ) hb_parnl( 1 ) )->lParam );
   #else
      hb_retnll( ( ( TV_ITEM * ) hb_parnll( 1 ) )->lParam );
   #endif
}


//-------------------------------------------------------------------------//

HB_FUNC( TVSETITEMIMAGE ) // ( hWnd, hItem, iImage ) --> lSuccess
{
    #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif
   UINT iImage = hb_parni( 3 ) + 1;
   TV_ITEM pitem;

   #ifndef _WIN64
      pitem.hItem = ( HTREEITEM ) hb_parnl( 2 );
   #else
      pitem.hItem = ( HTREEITEM ) hb_parnll( 2 );
   #endif
   pitem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
   pitem.iImage = iImage;
   pitem.iSelectedImage = iImage;

   hb_retl( TreeView_SetItem( hWnd, ( LPTV_ITEM )( &pitem ) ) );
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETITEMHEIGHT )// ( hWnd, cyItemn ) --> lSuccess
{
    #ifndef _WIN64
      hb_retl( TreeView_SetItemHeight( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ) );
   #else
      hb_retl( TreeView_SetItemHeight( ( HWND ) hb_parnll( 1 ), hb_parni( 2 ) ) );
   #endif
}

//-------------------------------------------------------------------------//

HB_FUNC( TVSETITEMBOLD ) // ( hWnd, hTreeItem, lBold ) --> lSuccess
{
   UINT uiMask1, uiMask2 = 0, bBold = hb_parl( 3 );

   #ifndef _WIN64
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), &uiMask1 ) );
   #else
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), &uiMask1 ) );
   #endif

   if( bBold )
      uiMask2 = TVIS_BOLD;
   else
      uiMask1 = uiMask1 ^ TVIS_BOLD;

   #ifndef _WIN64
      TreeView_SetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), uiMask1, uiMask2 );
   #else
      TreeView_SetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), uiMask1, uiMask2 );
   #endif

   hb_retl( uiMask1 & TVIS_BOLD );
}

//-------------------------------------------------------------------------//
 
regards, saludos

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

Re: New FTDN July/Julio (FWH 23.07)

Postby goosfancito » Tue Aug 15, 2023 7:27 pm

gracias

Esto no tiene inconvenietnes al ser WARNING?
Source\tree_fw\treeview.c:
Warning W8060 Source\tree_fw\treeview.c 74: Possibly incorrect assignment in function HB_FUN_TVINSERTITEM
Warning W8019 Source\tree_fw\treeview.c 305: Code has no effect in function HB_FUN_TVEDITLABEL
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: New FTDN July/Julio (FWH 23.07)

Postby goosfancito » Wed Aug 16, 2023 11:08 am

han implementado ya la ordenacion de las ramas de un tree?
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: New FTDN July/Julio (FWH 23.07)

Postby CARLOS ATUNCAR » Thu Aug 17, 2023 2:59 am

Por que en este version en las funciones que trabajan con los archivos se necesita poner la ruta completa del archivo en versiones anteriores se podia poner el nombre nada mas si estaba en la misma carpeta, esta caracteristica no permite seguir usando otras clases como por ejemplo la de FastReport ya que habría q modificar y poner la ruta completa

cServer := GetPvProfString("mysql","host" ," " ,Path+"connect.ini")

en este caso he tenido que agregar la ruta para q la pueda acceder, la función FILE() pasa lo mismo
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
CARLOS ATUNCAR
 
Posts: 176
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru

Re: New FTDN July/Julio (FWH 23.07)

Postby Antonio Linares » Thu Aug 17, 2023 6:28 am

Estimado Carlos,

La función File() es de Harbour, por lo que podria tratarse de un cambio en Harbour

File() no deberia cambiar su comportamiento por los cambios de FWH
regards, saludos

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


Return to WhatsNew / Novedades

Who is online

Users browsing this forum: No registered users and 5 guests

cron