FontColor and button - is it possible to change?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

FontColor and button - is it possible to change?

Post by mol »

Is any possibility to change font color of button caption?
I need to distinguish one of button.

Regards, Marek
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: FontColor and button - is it possible to change?

Post by IMATECH »

Not tested !


_SetFontColor ( ControlName, ParentForm , Value )


Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: FontColor and button - is it possible to change?

Post by mol »

It doesn't work :(

It's Windows problem, I think.
When you run:

Code: Select all

  MsgBox(hb_valtoexp(_GetFontColor(cControlName, cParentFormName)))
you'll get NIL value
Marek
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: FontColor and button - is it possible to change?

Post by IMATECH »

Yes
If control have color value: it will return Array[3]

Code: Select all


#include "hmg.ch"

Function Main()

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH  640 ;
      HEIGHT 480 ;
      MAIN;
      TITLE '_SetFontColor / _GetFontColor: Test' ;
      ON INIT { || _SetFontColor( 'BUTTON_1', 'FORM_1', { 255, 128, 16 } ), _SetFontColor( 'BUTTON_2', 'FORM_1', { 16, 128, 255 } ), _SetFontColor( 'TXT01', 'FORM_1', { 255, 128, 16 } ), _SetFontColor( 'TXT02', 'FORM_1', { 16, 128, 255 } ) }

      @ 100,30 BUTTON Button_1 CAPTION 'ANYTHING 01' PICTURE "button.bmp" WIDTH 120 HEIGHT 80 ACTION MSGBOX( hb_valtoexp( _GetFontColor( 'BUTTON_1', 'FORM_1' ) ) )
      @ 200,30 BUTTON Button_2 CAPTION 'ANYTHING 02' PICTURE "button.bmp" WIDTH 120 HEIGHT 80 ACTION MSGBOX( hb_valtoexp( _GetFontColor( 'BUTTON_2', 'FORM_1' ) ) )

      @ 100,160 textbox TXT01 value REPL('!', 150 ) WIDTH 360 HEIGHT 80
      @ 200,160 textbox TXT02 value REPL('x', 150 ) WIDTH 360 HEIGHT 80

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return

M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
salamandra
Posts: 311
Joined: Thu Jul 31, 2008 8:33 pm
DBs Used: DBF, MySQL, SQL
Location: Brazil

Re: FontColor and button - is it possible to change?

Post by salamandra »

Hi Ronaldo ;) ,
Yes
If control have color value: it will return Array[3]
Yes, if a color has been assigned it´s returned Array [3], but the captions are still shown
in black color, even using the windows default theme (Win9x.). :cry:

IMHO, it´s easier to resolve the issue using a bitmap image ;)


[]´s Salamandra
There is one time in which is crucial awakening. That time is now. ( Buddha )
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

FontColor and button - is it possible to change?

Post by Pablo César »

No way ! It´s does not working !
salamandra wrote:IMHO, it´s easier to resolve the issue using a bitmap image
Yes, but it would it be better to be able to assign fontcolor in buttons.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: FontColor and button - is it possible to change?

Post by danielmaximiliano »

mol wrote:Is any possibility to change font color of button caption?
I need to distinguish one of button.

Regards, Marek
HI:
I think that to work would be needed to modify "INITBUTTON"
in D:\hmg.3.0.42\SOURCE\c_button.c to include the style
BS_OWNERDRAW, that way you send messages to the button to change the style of it.

Code: Select all

HB_FUNC( INITBUTTON )
{
	HWND hwnd;
	HWND hbutton;
	int Style ;

	hwnd = (HWND) hb_parnl (1);

	Style =  BS_NOTIFY | WS_CHILD | BS_PUSHBUTTON ;

	if ( hb_parl (10) )
	{
		Style = Style | BS_FLAT ;
	}

	if ( ! hb_parl (11) )
	{
		Style = Style | WS_TABSTOP ;
	}

	if ( ! hb_parl (12) )
	{
		Style = Style | WS_VISIBLE ;
	}

	if ( hb_parl (13) )
	{
		Style = Style | BS_MULTILINE ;
	}


	hbutton = CreateWindow( "button" ,
                           hb_parc(2) ,
                           Style ,
                           hb_parni(4) ,
                           hb_parni(5) ,
                           hb_parni(6) ,
                           hb_parni(7) ,
                           hwnd ,
                           (HMENU)hb_parni(3) ,
                           GetModuleHandle(NULL) ,
                           NULL ) ;
                           
                    

	hb_retnl ( (LONG) hbutton );
}
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

FontColor and button - is it possible to change?

Post by Pablo César »

Thank you very much Daniel for your contrib. I do not tested, I do not know if is working.

I always I am afraid to change original lib of hmg. So in this case, Mr. Rathinagiri and Mr. Roberto, is it possible to include this changing in button defnition ? This is very important and makes powerfull our HMG !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: FontColor and button - is it possible to change?

Post by danielmaximiliano »

Pablo César wrote:Thank you very much Daniel for your contrib. I do not tested, I do not know if is working.

I always I am afraid to change original lib of hmg. So in this case, Mr. Rathinagiri and Mr. Roberto, is it possible to include this changing in button defnition ? This is very important and makes powerfull our HMG !
Hola Pablo:
voy a intentar charlar con el amigo Jair Pinho si tiene tiempo para intentar modificar el Boton. el ah modificado colores en el Menu.

http://hmgforum.com/viewtopic.php?f=24& ... hilit=jair
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Post Reply