Page 1 of 1

FontColor and BackColor in TEXTBOX

Posted: Mon Jan 20, 2014 3:47 am
by hmgchang
Dear Masters,

1. I tried to use the FontColor and BackColor in TEXTBOX, but when compile... its ERROR !
Any suggestion on how to use it ?


Thks n Rgds
Chang :D

Re: FontColor and BackColor in TEXTBOX

Posted: Mon Jan 20, 2014 4:58 am
by Javier Tovar
Hola hmgchang,

Espero te sirva!

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
*/

#include "hmg.ch"
#define YELLOW  { 255,  255,  000 }
#define PINK    { 255,  128,  192 }
#define RED     { 255,  000,  000 }
#define FUCHSIA { 255,  000,  255 }
#define BROWN   { 128,  064,  064 }
#define ORANGE  { 255,  128,  064 }
#define GREEN   { 000,  255,  000 }
#define PURPLE  { 128,  000,  128 }
#define BLACK   { 000,  000,  000 }
#define WHITE   { 255,  255,  255 }
#define GRAY    { 128,  128,  128 }
#define BLUE    { 000,  000,  255 }
#define VERDE   { 000,  128,  000 }

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN 

		@ 10,10 TEXTBOX Text_1 ;
			VALUE 123 ;
			TOOLTIP 'Numeric TextBox' ;
			NUMERIC ;
			MAXLENGTH 5 ;
			FONTCOLOR BLUE;
			BACKCOLOR RED;
			RIGHTALIGN ;
			ON LOSTFOCUS if ( This.Value < 100 , This.SetFocus , Nil)


		@ 40,10 TEXTBOX Text_2 ;
			VALUE 'Hi All' ;
			TOOLTIP 'Character TextBox' ;
			DISABLEDBACKCOLOR { 0,255,0 } ;
			DISABLEDFONTCOLOR { 255,255,255 } 

		DEFINE BUTTON C
			ROW	250
			COL	100
			WIDTH	160
			CAPTION	'Set Text_2 ReadOnly .T.'
			ACTION	Form_1.Text_2.ReadOnly := .T.
		END BUTTON

		DEFINE BUTTON D
			ROW	250
			COL	290
			WIDTH	160
			CAPTION	'Set Text_2 ReadOnly .F.'
			ACTION	Form_1.Text_2.ReadOnly := .F.
		END BUTTON


	END WINDOW

	Form_1.Center

	Form_1.Activate

Return Nil


Saludos

Re: FontColor and BackColor in TEXTBOX

Posted: Tue Jan 21, 2014 2:54 am
by hmgchang
Thks Tovar
it works, but if I add INPUTMASK ... its syntax error

@ 10,10 TEXTBOX Text_1 ;
VALUE 123 ;
TOOLTIP 'Numeric TextBox' ;
NUMERIC INPUTMASK "9999" ;
MAXLENGTH 5 ;
FONTCOLOR BLUE;
BACKCOLOR RED;
RIGHTALIGN ;
ON LOSTFOCUS if ( This.Value < 100 , This.SetFocus , Nil)

Why ? Pls Advise


Thks n rgds
Chang

Re: FontColor and BackColor in TEXTBOX

Posted: Tue Jan 21, 2014 4:56 am
by Javier Tovar
Hola hmgchang,

Creo que debes de revisar primero los ejemplos de C:\HMG\Samples\... Ahi vienen ejemplos variados de todos los controles, pero por otra parte si hay algo de razon en lo que dices, hay ciertas propiedades de los controles que no se pueden combinar y de ahí el problema, pero no he encontrado nada escrito. Deberia haber reglas cuales si se pueden conbinar y cuales no.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Hello hmgchang,

I think you need to check first examples of C: \ HMG \ Samples \ ... There are many examples of all the controls, but then if there is any reason in what you say, there are certain properties of controls that can not be combined and hence the problem but have not found anything written. There should be rules which if they can be a way to combine and which not.

@ 10,10 TEXTBOX Text_1 ;
VALUE 123 ;
TOOLTIP 'Numeric TextBox' ;
FONTCOLOR BLUE;
BACKCOLOR RED;
NUMERIC INPUTMASK "9999"

Saludos

Re: FontColor and BackColor in TEXTBOX

Posted: Tue Jan 21, 2014 5:08 am
by Javier Tovar
El problema esta con la propiedad "MAXLENGTH" , al parecer es solo para texto. pero no encuentro donde lo diga!

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

The problem is with the "maxlength" property, apparently it's only for text. but can not find where I say!

@ 10,10 TEXTBOX Text_1 ;
VALUE 123 ;
TOOLTIP 'Numeric TextBox' ;
FONTCOLOR BLUE;
BACKCOLOR RED;
NUMERIC INPUTMASK "99999" ;
ON LOSTFOCUS if ( This.Value < 100 , This.SetFocus , Nil);
RIGHTALIGN

Saludos

Re: FontColor and BackColor in TEXTBOX

Posted: Tue Jan 21, 2014 10:25 am
by danielmaximiliano
Javier Tovar wrote: @ 10,10 TEXTBOX Text_1 ;
VALUE 123 ;
TOOLTIP 'Numeric TextBox' ;
FONTCOLOR BLUE;
BACKCOLOR RED;
NUMERIC INPUTMASK "99999" ;
ON LOSTFOCUS if ( This.Value < 100 , This.SetFocus , Nil);
RIGHTALIGN

Saludos
Hola Javier :
La propiedad MaxLength es propia para TextBox de caracteres, si necesitas esa misma propiedad utiliza InputMask especificando en la mascara el formato numerico que necesita ser validado.
revisa [url]file:///C:/hmg.3.2/doc/data/index.htm[/url] para más informacion. ( Controles o Propiedades )
como el Clipper tiene "Valid" puedes utilizar "OnLostFocus" para reemplazarlo.

Re: FontColor and BackColor in TEXTBOX

Posted: Tue Jan 21, 2014 5:02 pm
by Javier Tovar
Hola Danielmaximiliano,

Pues volvi a consultar la propiedad y dice:

Code: Select all

MaxLength Property
Specifies the maximun input length for a TextBox control
 
 
  
Syntax:
MaxLength <nValue>
 
"Especifica la longitud máxima de entrada para un control TextBox", pero no especifica que sea únicamente para un TextBox tipo caracter. Y es por eso que solo la practica y error es como sabemos cuando si y cuando no!, y es por eso que muchos de nosotros cuando empesamos no damos con el "ERROR", seria bueno ampliar la información!, creo. :D

Saludos.

Re: FontColor and BackColor in TEXTBOX

Posted: Tue Jan 21, 2014 5:08 pm
by Javier Tovar
Hello Danielmaximiliano,

Then I went back to check the property and says:



Code: Select all

MaxLength Property 
Specifies the input maximun length for a TextBox control 
 
 
  
Syntax: 
MaxLength <nValue> 
 



"Specifies the maximum length of input for a TextBox control" but does not specify that it is only for a TextBox type character. And that is why I only practice and error is how we know when and when not if!, And that is why many of us when we do not give empesamos with "ERROR", further information would be good!, I think. :D

Greetings.