FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Change text button Toolbar
Posts: 13
Joined: Wed Dec 07, 2005 05:54 PM
Change text button Toolbar
Posted: Thu Sep 07, 2006 03:14 PM

Hi,
how is possible to change the text of a button in a toolbar?

Thank you

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Change text button Toolbar
Posted: Thu Sep 07, 2006 07:55 PM

Have you tried: oBtn:setText("New Text")?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Change text button Toolbar
Posted: Fri Sep 08, 2006 06:06 AM
Riccardo,

You have to add this method to Class TToolBar:
METHOD SetText( nButton, cText ) INLINE TBSetText( ::hWnd, nButton, cText )

And this code to your app:
#pragma BEGINDUMP

#include <hbapi.h>
#include <Windows.h>
#include <CommCtrl.h>

HB_FUNC( TBSETTEXT )
{
   HWND hToolBar = ( HWND ) hb_parnl( 1 );
   TBBUTTONINFO tbi;

   memset( ( char * ) &tbi, 0, sizeof( tbi ) );

	tbi.dwMask  = TBIF_TEXT | TBIF_BYINDEX;
	tbi.cbSize  = sizeof( TBBUTTONINFO );
	tbi.pszText = hb_parc( 3 );
	tbi.cchText = hb_parclen( 3 );
	 
   SendMessage( hToolBar, TB_SETBUTTONINFO, hb_parni( 2 ) - 1, ( LPARAM ) &tbi );
}

Then use it this way:
 oToolbar:SetText( 1, "Hello" ) // set first button text
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 13
Joined: Wed Dec 07, 2005 05:54 PM
Change text button Toolbar
Posted: Fri Sep 08, 2006 08:23 AM

Antonio,
thank you, works fine.

I've modify the Method Commad of the TToolBar to have the nId of the buttom when pressed:
Eval( bAction, Self ) -> Eval( bAction, Self, nID )

Bye
Riccardo

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Change text button Toolbar
Posted: Fri Sep 08, 2006 08:29 AM

Riccardo,

> Eval( bAction, Self ) -> Eval( bAction, Self, nID )

Ok, we have also modified it here, though we may finally create a new Class TTBButton and the TBButton object will be supplied instead of nID.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion