Page 1 of 2
How can I detect the Enter key in TTreview Class.
Posted: Mon Nov 29, 2010 12:52 pm
by Horizon
Hi,
as subject.
Thanks,
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oTree
DEFINE DIALOG oDlg
@ 0, 0 TREEVIEW oTree OF oDlg SIZE 200, 200
oTree:bLDblClick := { |nRow, nCol, nKeyFlags, oItem| MsgInfo(oItem:GetSelText())}
oTree:bKeyDown = { | nKey, nFlags | KeyDown(nKey, nFlags, oTree)}
ACTIVATE DIALOG oDlg CENTERED ON INIT DefineTree( oTree )
return nil
function DefineTree(oTree)
local oMenu := array(3), ;
oSubMenu := array(10)
oMenu[1]:= oTree:Add( "Principal" )
oSubMenu[1]:= oMenu[1]:Add( "Imprimir..." )
oMenu[2]:= oTree:Add( "Proyectos" )
oSubMenu[6]:= oMenu[2]:Add( "Definir Proyectos" )
oSubmenu[7]:= oMenu[2]:Add( "Actualización datos" )
oTree:expand()
return nil
function KeyDown(nKey, nFlags, oItem)
? nKey, "I am here"
IF nKey=VK_RETURN
MsgInfo(oItem:GetSelText())
ENDIF
RETURN
Re: How can I detect the Enter key in TTreview Class.
Posted: Mon Nov 29, 2010 6:24 pm
by Horizon
any comments?
Re: How can I detect the Enter key in TTreview Class.
Posted: Mon Nov 29, 2010 6:59 pm
by Daniel Garcia-Gil
Re: How can I detect the Enter key in TTreview Class.
Posted: Mon Nov 29, 2010 8:25 pm
by Horizon
Thank you Daniel,
It works now.
Re: How can I detect the Enter key in TTreview Class.
Posted: Mon Nov 29, 2010 8:42 pm
by Horizon
Daniel,
Is there any way to find out that the TTVitem is expanded or not?
Thanks,
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 12:18 am
by Daniel Garcia-Gil
Hakan
this modifies is required in CLASS TTVItem
Add
Code: Select all | Expand
#define TVM_GETITEMSTATE TV_FIRST + 39
#define TVIS_EXPANDED 0x0020
METHOD IsExpanded() INLINE nAnd( ::GetState(), TVIS_EXPANDED ) > 0
METHOD GetState() INLINE SendMessage( ::oTree:hWnd, TVM_GETITEMSTATE, ::hItem, 0 )
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oTree
DEFINE DIALOG oDlg
@ 0, 0 TREEVIEW oTree OF oDlg SIZE 200, 200
oTree:bKeyDown = { | nKey, nFlags | KeyDown(nKey, nFlags, oTree)}
oTree:nDlgCode = DLGC_WANTALLKEYS
ACTIVATE DIALOG oDlg CENTERED ON INIT DefineTree( oTree )
return nil
function DefineTree(oTree)
local oMenu := array(3), ;
oSubMenu := array(10)
oMenu[1] = oTree:Add( "Principal" )
oSubMenu[1] = oMenu[1]:Add( "Imprimir..." )
oSubMenu[1]:Add( "Test 1" )
oSubMenu[1]:Add( "Test 2" )
oSubMenu[1]:Add( "Test 3" )
oSubMenu[1]:Add( "Test 4" )
oMenu[2] = oTree:Add( "Proyectos" )
oSubMenu[6] = oMenu[2]:Add( "Definir Proyectos" )
oSubmenu[7] = oMenu[2]:Add( "Actualización datos" )
oTree:expand()
return nil
function KeyDown(nKey, nFlags, oTree)
local oItem := oTree:GetSelected()
IF nKey=VK_RETURN
MsgInfo(oItem:IsExpanded())
ENDIF
RETURN
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 12:31 am
by Daniel Garcia-Gil
Hakan
the changes suggested in last post is already include to next fivewin version (10.11)
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 8:17 am
by Horizon
Thank you Daniel,
I will try it soon.
I use cargo properties as a baction in TTVItem. But sometimes I need also one more cargo properties (You can say that you can use cargo with array. I used it. But the code is more complex than I suggest.). If you modify it is it possible to insert a baction block?
Also Can I find out the Level of oItem?
Thanks again.
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 10:55 am
by Daniel Garcia-Gil
Hakan
this modifies is required in CLASS TTVItem
1) ADD
2) CHANGE
Code: Select all | Expand
METHOD New( hItem, oTree, Cargo, cPrompt, nImage, oParent )
3) ADD inside METHOD New
4) ADD
Code: Select all | Expand
METHOD ItemLevel( nPrevLevel )
...
METHOD ItemLevel( nPrevLevel ) CLASS TTVItem
DEFAULT nPrevLevel := 0
if ::oParent != NIL
++nPrevLevel
::oParent:ItemLevel( @nPrevLevel )
endif
RETURN nPrevLevel
REMARKS: level 0 is root
download sample

Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oTree
DEFINE DIALOG oDlg SIZE 400, 400
@ 0, 0 TREEVIEW oTree OF oDlg SIZE 400, 400
oTree:bKeyDown = { | nKey, nFlags | KeyDown(nKey, nFlags, oTree)}
oTree:nDlgCode = DLGC_WANTALLKEYS
ACTIVATE DIALOG oDlg CENTERED ON INIT DefineTree( oTree )
return nil
function DefineTree(oTree)
local oMenu := array(3), ;
oSubMenu := array(10), otemp
oMenu[1] = oTree:Add( "Principal" )
oSubMenu[1] = oMenu[1]:Add( "Imprimir..." )
oTemp = oSubMenu[1]:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oSubMenu[1]:Add( "Test 2" )
oSubMenu[1]:Add( "Test 3" )
oSubMenu[1]:Add( "Test 4" )
oMenu[2] = oTree:Add( "Proyectos" )
oSubMenu[6] = oMenu[2]:Add( "Definir Proyectos" )
oSubmenu[7] = oMenu[2]:Add( "Actualización datos" )
oTree:expand()
return nil
function KeyDown(nKey, nFlags, oTree)
local oItem := oTree:GetSelected()
IF nKey=VK_RETURN
MsgInfo( "Level: " + Str( oItem:ItemLevel() ) )
ENDIF
RETURN
already include to next fivewin version
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 1:48 pm
by Horizon
Daniel,
Should I change something in TTreview Class. Your example does not show ItemLevel. It show allways 0.
Thanks,
ps. I have added your chhanges to TTVItem. I have added TTVItem class to my example's builder script.
Edit:syntax
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 8:09 pm
by Daniel Garcia-Gil
Horizon wrote:Daniel,
Should I change something in TTreview Class. Your example does not show ItemLevel. It show allways 0.
Thanks,
to me working fine.... i use with window 7 and win xp prof
maybe other user can test too and show us
Re: How can I detect the Enter key in TTreview Class.
Posted: Tue Nov 30, 2010 10:14 pm
by lailton.webmaster
Work fine for me.

Re: How can I detect the Enter key in TTreview Class.
Posted: Wed Dec 01, 2010 7:49 am
by Horizon
Hi Daniel,
I have downloaded your sample. Exe file works ok.
I have compiled test.prg with xharbour builder. I have added to xhb.obj (because that gives an error about activex.obj) and TTVItem class (that is changed as you described). There is no change.
Could you please send TTVItem class as an e-mail?
Thanks,
Re: How can I detect the Enter key in TTreview Class.
Posted: Wed Dec 01, 2010 1:01 pm
by Horizon
Daniel,
Compile and run sample.
Select Imprimir.
Right click on "Definir Proyectos"
In ShowPopup function, I want to say "Definir Proyectos". The parameter oItem is TTreeview class handle not TTVItem.
Thanks,
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oTree
DEFINE DIALOG oDlg SIZE 400, 400
@ 0, 0 TREEVIEW oTree OF oDlg SIZE 400, 400
oTree:bKeyDown = { | nKey, nFlags | KeyDown(nKey, nFlags, oTree)}
oTree:bRClicked := { | nRow, nCol, nKeyFlags, oItem | ShowPopup( nRow, nCol, nKeyFlags, oItem )}
oTree:nDlgCode = DLGC_WANTALLKEYS
oTree:Expand()
ACTIVATE DIALOG oDlg CENTERED ON INIT DefineTree( oTree )
return nil
function DefineTree(oTree)
local oMenu := array(3), ;
oSubMenu := array(10), otemp
oMenu[1] = oTree:Add( "Principal" )
oSubMenu[1] = oMenu[1]:Add( "Imprimir..." )
oTemp = oSubMenu[1]:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oSubMenu[1]:Add( "Test 2" )
oSubMenu[1]:Add( "Test 3" )
oSubMenu[1]:Add( "Test 4" )
oMenu[2] = oTree:Add( "Proyectos" )
oSubMenu[6] = oMenu[2]:Add( "Definir Proyectos" )
oSubmenu[7] = oMenu[2]:Add( "Actualización datos" )
oTree:expand()
return nil
function KeyDown(nKey, nFlags, oTree)
local oItem := oTree:GetSelected()
IF nKey=VK_RETURN
MsgInfo( "Level: " + Str( oItem:ItemLevel() ) )
ENDIF
RETURN
function ShowPopup( nRow, nCol, nKeyFlags, oItem )
? oItem:ClassName(), nKeyFlags
// oItem is a TTreeview not TTVItem.
// How Can I say Test4:cCaption ?
return
Re: How can I detect the Enter key in TTreview Class.
Posted: Wed Dec 01, 2010 1:31 pm
by Daniel Garcia-Gil
Hakan
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oTree
DEFINE DIALOG oDlg SIZE 400, 400
@ 0, 0 TREEVIEW oTree OF oDlg SIZE 400, 400
oTree:bKeyDown = { | nKey, nFlags | KeyDown(nKey, nFlags, oTree)}
oTree:bRClicked := { | nRow, nCol, nKeyFlags, oTree | ShowPopup( nRow, nCol, nKeyFlags, oTree )}
oTree:nDlgCode = DLGC_WANTALLKEYS
oTree:Expand()
ACTIVATE DIALOG oDlg CENTERED ON INIT DefineTree( oTree )
return nil
function DefineTree( oTree )
local oMenu := array(3), ;
oSubMenu := array(10), otemp
oMenu[1] = oTree:Add( "Principal" )
oSubMenu[1] = oMenu[1]:Add( "Imprimir..." )
oTemp = oSubMenu[1]:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp = oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oTemp:Add( "Test 1" )
oSubMenu[1]:Add( "Test 2" )
oSubMenu[1]:Add( "Test 3" )
oSubMenu[1]:Add( "Test 4" )
oMenu[2] = oTree:Add( "Proyectos" )
oSubMenu[6] = oMenu[2]:Add( "Definir Proyectos" )
oSubmenu[7] = oMenu[2]:Add( "Actualización datos" )
oTree:expand()
return nil
function KeyDown(nKey, nFlags, oTree)
local oItem := oTree:GetSelected()
IF nKey=VK_RETURN
MsgInfo( "Level: " + Str( oItem:ItemLevel() ) )
ENDIF
RETURN
function ShowPopup( nRow, nCol, nKeyFlags, oTree )
local oItem
oItem = oTree:HitTest( nRow, nCol )
if ! oItem:IsSelected()
oTree:Select( oItem )
? oItem:cPrompt
endif
return