Change text button Toolbar

Change text button Toolbar

Postby Riccardo » Thu Sep 07, 2006 3:14 pm

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

Thank you
Riccardo
 
Posts: 13
Joined: Wed Dec 07, 2005 5:54 pm

Postby James Bott » Thu Sep 07, 2006 7:55 pm

Have you tried: oBtn:setText("New Text")?
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Fri Sep 08, 2006 6:06 am

Riccardo,

You have to add this method to Class TToolBar:
Code: Select all  Expand view
METHOD SetText( nButton, cText ) INLINE TBSetText( ::hWnd, nButton, cText )                           

And this code to your app:
Code: Select all  Expand view
#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  Expand view
oToolbar:SetText( 1, "Hello" ) // set first button text
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41463
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Riccardo » Fri Sep 08, 2006 8: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
Riccardo
 
Posts: 13
Joined: Wed Dec 07, 2005 5:54 pm

Postby Antonio Linares » Fri Sep 08, 2006 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41463
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 155 guests