Hello everyone, good morning!
I would like to know if it is possible to add a method to an existing class. Ex.: Add the ChangeText method to the TBtnBmp class.
If so, would there be any practical example?
I need to add some information to an object and I would like not to touch the Fivewin classes.
Thank you in advance for everyone's attention.
Oliveiros Junior
Extend a Fivewin class
-
- Posts: 128
- Joined: Tue Mar 20, 2007 3:13 pm
- Has thanked: 1 time
- nageswaragunupudi
- Posts: 10703
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 6 times
- Contact:
Re: Extend a Fivewin class
1) Are you using xHarbour or Harbour? Depending on your answer, we will advise you how to add a new method.
2) Please reconsider. It is possible to changetext of BtnBmp using the Existing methods. No need to have any additional method for this. Can you explain what exactly are you looking for.
2) Please reconsider. It is possible to changetext of BtnBmp using the Existing methods. No need to have any additional method for this. Can you explain what exactly are you looking for.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 128
- Joined: Tue Mar 20, 2007 3:13 pm
- Has thanked: 1 time
Re: Extend a Fivewin class
Hello Mr Rao,
I'm using FWH, version 23.07;
My goal is to be able to write various information about the button, different positions.
Ex.:
+------------------------------------------------------------------------------------+
| xxxxxxx ...................................................................... |
| xxxxxxx .......................................XXXXX XXXXXX( image) |
| |
+------------------------------------------------------------------------------------+
I made a multi-button Loop for testing and tried a few things that didn't work using existing methods.
As:
For nX = 1 To Len( oDlg1:aItem )
@ nLinha, nColuna + 50 BTNBMP aBtns[ nX ];
PROMPT "" RIGHT;
FLAT NOBORDER FONT oFontTxt COLOR CLR_BLACK, CLR_WHITE ;
SIZE oDlg1:nLargura - 100, 100 OF oDlg1:oPanel
aBtns[ nX ]:nRound := 20
aBtns[ nX ]:lTransparent := .F.
//aBtns[ nX ]:bPainted := { || aBtns[ nX ]:SayText( 'Linha 1',{ 0, 0, 40, 140 }, 'R', oFontTxt, { CLR_GREEN, CLR_BLACK } ) }
//aBtns[ nX ]:SayText( 'Linha 1',{ 0, 0, 40, 140 }, 'R', oFontTxt, { CLR_GREEN, CLR_BLACK } )
nLinha += 110
Next
Another need I have is to have a wide button with an image aligned to the left and for the action to only be executed if the click occurs on the image.
Thank you in advance for your attention!
Oliveiros Junior
I'm using FWH, version 23.07;
My goal is to be able to write various information about the button, different positions.
Ex.:
+------------------------------------------------------------------------------------+
| xxxxxxx ...................................................................... |
| xxxxxxx .......................................XXXXX XXXXXX( image) |
| |
+------------------------------------------------------------------------------------+
I made a multi-button Loop for testing and tried a few things that didn't work using existing methods.
As:
For nX = 1 To Len( oDlg1:aItem )
@ nLinha, nColuna + 50 BTNBMP aBtns[ nX ];
PROMPT "" RIGHT;
FLAT NOBORDER FONT oFontTxt COLOR CLR_BLACK, CLR_WHITE ;
SIZE oDlg1:nLargura - 100, 100 OF oDlg1:oPanel
aBtns[ nX ]:nRound := 20
aBtns[ nX ]:lTransparent := .F.
//aBtns[ nX ]:bPainted := { || aBtns[ nX ]:SayText( 'Linha 1',{ 0, 0, 40, 140 }, 'R', oFontTxt, { CLR_GREEN, CLR_BLACK } ) }
//aBtns[ nX ]:SayText( 'Linha 1',{ 0, 0, 40, 140 }, 'R', oFontTxt, { CLR_GREEN, CLR_BLACK } )
nLinha += 110
Next
Another need I have is to have a wide button with an image aligned to the left and for the action to only be executed if the click occurs on the image.
Thank you in advance for your attention!
Oliveiros Junior
- nageswaragunupudi
- Posts: 10703
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 6 times
- Contact:
Re: Extend a Fivewin class
This is sample to show how to add our own method to an existing class with xHarbour or Harbour
Code: Select all | Expand
#include "fivewin.ch"
function Main()
local o
#ifdef __XHARBOUR__
EXTEND CLASS TestClass WITH MESSAGE Multiply METHOD Multiply
#else
__CLSADDMSG( TestClass():classH, "Multiply", HB_FUNCPTR( "MULTIPLY" ), HB_OO_MSG_METHOD )
#endif
o := TestClass():New()
? o:Value
? o:Multiply( 10 )
return nil
CLASS TestClass
VAR Value INIT 9
ENDCLASS
function Multiply( n )
local Self := HB_QSelf()
return ::Value * n
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 128
- Joined: Tue Mar 20, 2007 3:13 pm
- Has thanked: 1 time