Page 1 of 1

Change MsgBox() Font and its Size

Posted: Sun Jul 24, 2016 2:14 pm
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.

Re: Change MsgBox() Font and its Size

Posted: Sun Jul 24, 2016 4:45 pm
by Rathinagiri
Paramvir,

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

:)

Re: Change MsgBox() Font and its Size

Posted: Wed Jul 27, 2016 2:38 pm
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.

Re: Change MsgBox() Font and its Size

Posted: Wed Jul 27, 2016 8:25 pm
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

Re: Change MsgBox() Font and its Size

Posted: Thu Jul 28, 2016 1:34 pm
by Paramvir
Hello Mustafa

Great! Your source files have made things easier.

Thank you and regards
Paramvir

Re: Change MsgBox() Font and its Size

Posted: Sun May 27, 2018 6:30 pm
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.

Re: Change MsgBox() Font and its Size

Posted: Sun May 27, 2018 8:39 pm
by mustafa
Hola amigos
Aquí dejo otro Sample
Regards
Mustafa :lol:

Re: Change MsgBox() Font and its Size

Posted: Sun Aug 19, 2018 11:28 pm
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


Re: Change MsgBox() Font and its Size

Posted: Mon Aug 20, 2018 8:30 pm
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.

Re: Change MsgBox() Font and its Size

Posted: Sun Aug 26, 2018 8:58 pm
by SALINETAS24
Os paso el enlace donde he puesto la ultima version...
Saludos.

http://www.hmgforum.com/viewtopic.php?f=24&t=5790