Change MsgBox() Font and its Size

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Paramvir
Posts: 44
Joined: Sun Mar 27, 2016 9:46 am
Location: India
Contact:

Change MsgBox() Font and its Size

Post by Paramvir »

Is it possible to change the font (and its size too) of messages when using MsgBox function in the HMG Console mode? It will be great if somebody solves the problem.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Change MsgBox() Font and its Size

Post by Rathinagiri »

Paramvir,

You can write your own messagebox if needed! It is just another modal window!

:)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Paramvir
Posts: 44
Joined: Sun Mar 27, 2016 9:46 am
Location: India
Contact:

Re: Change MsgBox() Font and its Size

Post by Paramvir »

Thank you Rathi Ji for your direction.

I'll try but this feature if inherently incorporated in generic MsgInfo() etc will be of great use and time saving.
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Change MsgBox() Font and its Size

Post by mustafa »

Hola Paramvir
Te dejo unos Samples MsgBox construidos con Windows MODAL
un saludo
*---------------- Google -------------------------*
Hello Paramvir
I leave some Samples MsgBox built with Windows MODAL
regards
Mustafa
Attachments
Sample_Personal_Box.zip
(4.23 KiB) Downloaded 326 times
Paramvir
Posts: 44
Joined: Sun Mar 27, 2016 9:46 am
Location: India
Contact:

Re: Change MsgBox() Font and its Size

Post by Paramvir »

Hello Mustafa

Great! Your source files have made things easier.

Thank you and regards
Paramvir
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Change MsgBox() Font and its Size

Post by SALINETAS24 »

Muchas gracias Mustafa, una gran rutina.
Así y todo sería interesante que para próximas versiones se pudiese añadir como indica Paravir, esta característica en la librería HMG, el poder cambiar la Fuente y el tamaño de las letras del mensaje.
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Change MsgBox() Font and its Size

Post by mustafa »

Hola amigos
Aquí dejo otro Sample
Regards
Mustafa :lol:
Attachments
Mustafa_Box.zip
(21.85 KiB) Downloaded 224 times
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Change MsgBox() Font and its Size

Post by SALINETAS24 »

Hola amigos, aqui os paso la función a falta de perfilar algún detalle que permite cambiar el tamaño, el color, el ico y que podeis enviar varias lineas.

La forma de llamarla es así

Code: Select all

xVar:="Este proceso borra todos los datos"    +CRLF+CRLF + ;
	"de la empresa.") +CRLF+CRLF + ;
          "Se eliminaran todos los datos " +CRLF+CRLF + ;
	"sin posibilidad alguna de recuperación."    + CRLF+CRLF+ ;
         "¿ Desea continuar ..?"
JM_BOXSINO("¡¡ATENCION!!", xVar, "Arial",10,RED,1,2)	
y devolvera .T. o .F.

Enviamos el titulo, la variable que contiene el mensaje, el tipo de letra, el tamaño, el tipo del dibujo que presentará la venta (1 la interrogación, 2 Alerta, 3...y así le puedes poner los que quieras) y por ultimo el tipo de botones que quieres.
Ah!, los iconos o dibujos ..,no se como ponerlos, pero cada uno puede usar los que quiera.

Code: Select all

//----------------------------------------------------
//--> CUADRO DE MENSAJE
//----------------------------------------------------
// Recibe el Titulo, Mensaje, Fuente y Tamaño, el color, el Tipo Ventana, y Botones
// nTipo=1 Ventana de Interrogación
// nTipo=2 Ventana de Cancelar-Prohibido

// nBton=1  -- Aceptar
// nBton=2  -- Aceptar y Cancelar


FUNCTION JM_BOXSINO( Titulo, Mensaje, sFont,sSize,color_win,nTipo,nBton)

	LOCAL aJm_Msg:={}
	LOCAL nFor:=0
	LOCAL nPos:=0
	LOCAL nLen:=0
	LOCAL nAncho:=0
	LOCAL nAlto:=0
	LOCAL lOk:=.T.
	LOCAL nPosButton:=0
	// --> Cargo los tipos de letra y el color por defecto
	DEFAULT sFont:="Arial"
	DEFAULT sSize:=10
	DEFAULT Color_win:=COLOR_LemonChiffon1
	DEFAULT nTipo:=1
	DEFAULT nBton:=2
	
	// --> Busco si tiene lineas (CRLF+CRLF) para cargar un array
	nPos:=AT(CRLF+CRLF,Mensaje)
	DO WHILE nPos!=0
		AADD(aJm_Msg,SUBSTR(Mensaje,1,nPos-1))
		Mensaje:=substr(Mensaje,nPos+4)
		nPos:=AT(CRLF+CRLF,Mensaje)
	ENDDO
	AADD(aJM_Msg,Mensaje)
	
	// --> Vamos a calcular la dimensión de la Ventana
	FOR nFor=1 TO LEN(aJm_Msg)
		// --> Longitud Máxima de la línea
		nLen:=IF(LEN(aJm_Msg[nFor])> nLen,LEN(aJm_Msg[nFor]),nLen) 
	NEXT
	// ------------------------------------------------------------->
	// Cojemos la línea de Mayor longitud y multiplicamos por 7 
	// ¡¡ Ojo, si cambia el tamaño/tipo de LETRA  hay que ajustar.
	// Pero yo creo que tiene que haber algo que nos pueda indicar
	// el tamaño de las letras... Window lo sabe, Bill Gates tambien.., 
	// y nosotros no. Maldito sea el queso de bola..
	// ------------------------------------------------------------->
	nAncho:=(nLen*7)+ 40            //-> le añado 40 por MARGENES
	nAlto := ( LEN(aJm_Msg)*40)+60  //-> le añado 60 por los botones
	// --> Tamaño Minimo
	nAncho:=IF(nAncho<360,360,nAncho)
	nAlto :=IF(nAlto<160,160,nAlto)	
	IF LEN(aJm_Msg)=1  //--> Un chorrada de ajuste para cuando solo tiene una línea
		nAlto:=140
	ENDIF
	nPosButton:=INT(nAncho/4)

	
	
	DEFINE WINDOW JM_BOX	                 ;
        AT    0, 0 	                         ;
        WIDTH nAncho HEIGHT nAlto              ;
        TITLE Titulo                         ; 
        MODAL NOSIZE NOSYSMENU    			;
		BACKCOLOR   COLOR_Win	;
		FONT sFont SIZE sSize
  
		FOR nFor:=1 TO LEN(aJm_Msg)
		    cSay="SAY_"+StrZero(nFor,2)
			@ (30*nFor)-15 ,55 LABEL &cSAY VALUE aJm_Msg[nFor] TRANSPARENT AUTOSIZE FONT sFont SIZE sSize
		NEXT
		DO CASE
			CASE nTipo=1
				@ 25,10 IMAGE Img_JM_BOX PICTURE "ayuda_g" WIDTH 36 HEIGHT 36 TRANSPARENT 
			CASE nTipo=2
				@ 25,10 IMAGE Img_JM_BOX PICTURE "cancelar_g" WIDTH 36 HEIGHT 36 TRANSPARENT 	
			CASE nTipo=3
				@ 25,10 IMAGE Img_JM_BOX PICTURE "alerta_g" WIDTH 36 HEIGHT 36 TRANSPARENT 

		ENDCASE
		DO CASE
			CASE nBton=1
				@ nAlto-70,(nPosButton*2)-20 BUTTON Aceptar CAPTION "Aceptar" PICTURE "cancelar" ;
					LEFT WIDTH 120 HEIGHT 30 FONT sFont SIZE sSize BOLD;
					ACTION (lOk:=.F., JM_BOX.Release() ) 
			CASE nBton=2
				@ nAlto-70,nPosButton-25 BUTTON Aceptar CAPTION "Aceptar"  PICTURE "aceptar" ;
					LEFT WIDTH 120 HEIGHT 30 FONT sFont SIZE sSize BOLD ;
					ACTION (lOk:=.T., JM_BOX.Release() )  	
				@ nAlto-70,(nPosButton*2)+35 BUTTON Cancelar CAPTION "Cancelar" PICTURE "cancelar" ;
					LEFT WIDTH 120 HEIGHT 30 FONT sFont SIZE sSize BOLD;
					ACTION (lOk:=.F., JM_BOX.Release() )   
		ENDCASE
			
			
			
		
	END WINDOW
	CENTER WINDOW JM_BOX        
    JM_BOX.Activate   

RETURN lOk

Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Change MsgBox() Font and its Size

Post by SALINETAS24 »

Hola a todos, creo que ahora está mucho más decente.
Os adjuntos los fichero para compilar, ejecutar y modificar.
Se pueden poner colores, tamaño, etc., etc.
Se mantiene el mismo formato que tenemos en HMG y lo único es que para usar estar funciones tienes que poner delante "JM_"
Quedaria así JM_MSGBOX("MENSAJE","TITULO")

Pero ahora puede añadir, el tipo de letra, tamaño y color

JM_MsgYesNo("SELECCIONE UNA EMPRESA", "Yes - No","Courier",10,GREEN)

Venga.., una cerveza fresquita para todos.
Attachments
jm_box.rar
(1.23 MiB) Downloaded 172 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Change MsgBox() Font and its Size

Post by SALINETAS24 »

Os paso el enlace donde he puesto la ultima version...
Saludos.

http://www.hmgforum.com/viewtopic.php?f=24&t=5790
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Post Reply