Change text button Toolbar

Post Reply
Riccardo
Posts: 13
Joined: Wed Dec 07, 2005 5:54 pm

Change text button Toolbar

Post by Riccardo »

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

Thank you
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Have you tried: oBtn:setText("New Text")?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Riccardo,

You have to add this method to Class TToolBar:

Code: Select all

METHOD SetText( nButton, cText ) INLINE TBSetText( ::hWnd, nButton, cText )                            
And this code to your app:

Code: Select all

#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:

Code: Select all

 oToolbar:SetText( 1, "Hello" ) // set first button text
regards, saludos

Antonio Linares
www.fivetechsoft.com
Riccardo
Posts: 13
Joined: Wed Dec 07, 2005 5:54 pm

Post by Riccardo »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
Post Reply