FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Extend a Fivewin class
Posts: 148
Joined: Tue Mar 20, 2007 03:13 PM
Extend a Fivewin class
Posted: Sat Jan 25, 2025 11:06 AM

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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Extend a Fivewin class
Posted: Sat Jan 25, 2025 12:36 PM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 148
Joined: Tue Mar 20, 2007 03:13 PM
Re: Extend a Fivewin class
Posted: Sun Jan 26, 2025 02:23 PM

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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Extend a Fivewin class
Posted: Mon Jan 27, 2025 12:49 PM
This is sample to show how to add our own method to an existing class with xHarbour or Harbour
#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
Posts: 148
Joined: Tue Mar 20, 2007 03:13 PM
Re: Extend a Fivewin class
Posted: Mon Jan 27, 2025 01:43 PM

Hello Mr Rao,

Thanks,

Att.,

Oliveiros Junior

Continue the discussion