How to override a method in Fivewin
How to override a method in Fivewin
To all,
How could you override a method in FW?
I would like to disable VK_LEFT and VK_RIGHT and to use this keys to navigate between the different tabs of a folder.
Thanks in advance,
Otto
METHOD KeyDown( nKey, nFlags ) CLASS TWBrowse
do case
case nKey == VK_UP
::GoUp()
case nKey == VK_DOWN
::GoDown()
case nKey == VK_LEFT
::GoLeft()
case nKey == VK_RIGHT
::GoRight()
case nKey == VK_HOME
::GoTop()
case nKey == VK_END
::GoBottom()
case nKey == VK_PRIOR
if GetKeyState( VK_CONTROL )
::GoTop()
else
::PageUp()
endif
case nKey == VK_NEXT
if GetKeyState( VK_CONTROL )
::GoBottom()
else
::PageDown()
endif
otherwise
return Super:KeyDown( nKey, nFlags )
endcase
return 0
How could you override a method in FW?
I would like to disable VK_LEFT and VK_RIGHT and to use this keys to navigate between the different tabs of a folder.
Thanks in advance,
Otto
METHOD KeyDown( nKey, nFlags ) CLASS TWBrowse
do case
case nKey == VK_UP
::GoUp()
case nKey == VK_DOWN
::GoDown()
case nKey == VK_LEFT
::GoLeft()
case nKey == VK_RIGHT
::GoRight()
case nKey == VK_HOME
::GoTop()
case nKey == VK_END
::GoBottom()
case nKey == VK_PRIOR
if GetKeyState( VK_CONTROL )
::GoTop()
else
::PageUp()
endif
case nKey == VK_NEXT
if GetKeyState( VK_CONTROL )
::GoBottom()
else
::PageDown()
endif
otherwise
return Super:KeyDown( nKey, nFlags )
endcase
return 0
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Biel EA6DD
- Posts: 680
- Joined: Tue Feb 14, 2006 9:48 am
- Location: Mallorca
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- carlos vargas
- Posts: 1421
- Joined: Tue Oct 11, 2005 5:01 pm
- Location: Nicaragua
Kleyber
Saludos
podrias traducirme por favor.
Sobre el topico, puedo decir que efectivamente la mejor y mas adecuada manera es la que indica Antonio Linares, pero es necesario modificar la definiciones de Comandos, y para usuario noveles como yo es dificil.
Pero en _ donde el cambio es minimos es posible la redifinicion o agregar nuevos metodos, sin mayores traumas.
yo personalmente tego un prg con los metodos modificados o agregados y sin necesidad de recompilar los fuentes de fwh.
pero por experiencia el _ aislados podria presentar una dificultad.
hoy pondre un ejemplo de uso.
salu2
carlos vargas
Saludos
podrias traducirme por favor.
Sobre el topico, puedo decir que efectivamente la mejor y mas adecuada manera es la que indica Antonio Linares, pero es necesario modificar la definiciones de Comandos, y para usuario noveles como yo es dificil.
Pero en _ donde el cambio es minimos es posible la redifinicion o agregar nuevos metodos, sin mayores traumas.
yo personalmente tego un prg con los metodos modificados o agregados y sin necesidad de recompilar los fuentes de fwh.
pero por experiencia el _ aislados podria presentar una dificultad.
hoy pondre un ejemplo de uso.
salu2
carlos vargas
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Carlos Vargas
Desde Managua, Nicaragua (CA)
Hola Carlos,
Con gusto haré la trducción.
-- SET ENGLISH ON
About the subject, I can say that the best and adequate way to override a method is what Antonio said, but it's necessary to change all commands
definitions, and for a beginner like me it's difficult.
But in some cases, where the changes are minimal, it's possible to redefine or append new methods, without problems.
I personally have a prg with modified or appended methods and without need to recompile the fwh source codes.
But in my experience, in some isolated cases, this could present some difficulties.
Today I'll post an example about it.
Regards,
Carlos Vargas
Saludos,
Con gusto haré la trducción.
-- SET ENGLISH ON
About the subject, I can say that the best and adequate way to override a method is what Antonio said, but it's necessary to change all commands
definitions, and for a beginner like me it's difficult.
But in some cases, where the changes are minimal, it's possible to redefine or append new methods, without problems.
I personally have a prg with modified or appended methods and without need to recompile the fwh source codes.
But in my experience, in some isolated cases, this could present some difficulties.
Today I'll post an example about it.
Regards,
Carlos Vargas
Saludos,
Kleyber Derick
FWH / xHb / xDevStudio / SQLLIB
FWH / xHb / xDevStudio / SQLLIB
- carlos vargas
- Posts: 1421
- Joined: Tue Oct 11, 2005 5:01 pm
- Location: Nicaragua
In my Main PRG
in other .prg
Code: Select all
#include "fivewin.ch"
procedure main()
...
OverrideAndExtend()
...
define window ...
...
activate window ...
return
Code: Select all
/*-------------------------------------------------------------------------------------------------*/
PROCEDURE OverrideAndExtend()
EXTEND CLASS TFOLDER WITH METHOD RefreshPages
EXTEND CLASS TFOLDER WITH METHOD GoFirstControl
EXTEND CLASS TDIALOG WITH METHOD RefreshDialog
RETURN
/*-------------------------------------------------------------------------------------------------*/
STATIC FUNCTION RefreshDialog( nPos )
LOCAL SELF := HB_QSelf()
DEFAULT nPos := 0
AEval( ::aControls, { | oCtrl | oCtrl:Refresh() } )
IF nPos > 0 .AND. Len( ::aControls ) > 0
::aControls[ nPos ]:SetFocus()
ENDIF
RETURN NIL
/*-------------------------------------------------------------------------------------------------*/
STATIC FUNCTION RefreshPages()
LOCAL SELF := HB_QSelf()
LOCAL oPage
FOR EACH oPage IN ::aDialogs
AEval( oPage:aControls, { | oCtrl | oCtrl:Refresh() } )
NEXT
RETURN NIL
/*-------------------------------------------------------------------------------------------------*/
STATIC FUNCTION GoFirstControl()
LOCAL SELF := HB_QSelf()
::aDialogs[ 1 ]:aControls[ 1 ]:SetFocus()
RETURN NIL
/*-------------------------------------------------------------------------------------------------*/
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Carlos Vargas
Desde Managua, Nicaragua (CA)
- carlos vargas
- Posts: 1421
- Joined: Tue Oct 11, 2005 5:01 pm
- Location: Nicaragua
Aca un codigo inicial para hacer lo que pides, falta codificar un poco
lo referente al movimiento de las page del folder, en este ejemplo solamente pasa de la pagina 1 a la pagina 2.
otra cosa es que no he probado el codigo, pero en teoria deberia funcionar. , si no pues habria que hacerle pequeños ajustes, pero la idea esta plasmada
salu2
carlos vargas
lo referente al movimiento de las page del folder, en este ejemplo solamente pasa de la pagina 1 a la pagina 2.
otra cosa es que no he probado el codigo, pero en teoria deberia funcionar. , si no pues habria que hacerle pequeños ajustes, pero la idea esta plasmada
Code: Select all
#include "fivewin.ch"
PROCEDURE main()
...
OverrideAndExtend()
...
redefine folder oFolder ...
...
redefine listbox oBrw ...
oBrw:oFolder := oFolder
...
RETURN
Code: Select all
/*---------------------------------------------------------------------------*/
#include "vkey.ch"
PROCEDURE OverrideAndExtend()
/*new data and method*/
EXTEND CLASS TWBROWSE WITH DATA oFolder
EXTEND CLASS TWBROWSE WITH METHOD NextPageOnFolder
EXTEND CLASS TWBROWSE WITH METHOD PrevPageOnFolder
/*change method*/
OVERRIDE METHOD KeyDown CLASS TWBROWSE WITH METHOD MyKeyDown
RETURN
/*---------------------------------------------------------------------------*/
STATIC FUNCTION NextPageOnFolder()
LOCAL SELF := HB_QSelf()
LOCAL nCountPage := len( ::oFolder:aDialogs )
//TODO: Make code correct :-)
::oFolder:SetOption(1)
RETURN NIL
/*---------------------------------------------------------------------------*/
STATIC FUNCTION PrevPageOnFolder()
LOCAL SELF := HB_QSelf()
LOCAL nCountPage := len( ::oFolder:aDialogs )
//TODO: Make code correct :-)
::oFolder:SetOption(2)
RETURN NIL
/*---------------------------------------------------------------------------*/
STATIC FUNCTION MyKeyDown( nKey, nFlags )
LOCAL SELF := HB_QSelf()
DO CASE
CASE nKey == VK_UP
::GoUp()
CASE nKey == VK_DOWN
::GoDown()
CASE nKey == VK_LEFT //modify
IF ::oFolder=NIL
::GoLeft()
ELSE
::PrevPageOnFolder()
ENDIF
CASE nKey == VK_RIGHT //modify
IF ::oFolder=NIL
::GoRight()
ELSE
::NextPageOnFolder()
ENDIF
CASE nKey == VK_HOME
::GoTop()
CASE nKey == VK_END
::GoBottom()
CASE nKey == VK_PRIOR
IF GetKeyState( VK_CONTROL )
::GoTop()
ELSE
::PageUp()
ENDIF
CASE nKey == VK_NEXT
IF GetKeyState( VK_CONTROL )
::GoBottom()
ELSE
::PageDown()
ENDIF
OTHEWISE
RETURN Super:KeyDown( nKey, nFlags )
ENDCASE
RETURN 0
/*---------------------------------------------------------------------------*/
carlos vargas
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Carlos Vargas
Desde Managua, Nicaragua (CA)