Página 1 de 1

Equivalente da função ALERT()

Enviado: 05 Set 2014 14:56
por Mario Mesquita
Boa tarde, pessoal!

Qual a função no HMG à velha função ALERT do Clipper?

Estou tentando abrir um box de mensagem com opções configuradas por mim, mas ao que vejo tudo é pré-definido como "Sim, Não", "Ok, Cancel", etc.

Não tem mesmo nada que faça o que o ALERT fazia??

Desde já, obrigado.

Sds,
Mario.

Equivalente da função ALERT()

Enviado: 05 Set 2014 16:32
por Toledo
Olá Mário, na MiniGui Extended veja os seguintes demos na pasta \SAMPLES:

\SAMPLES\BASIC\MsgEdit

\SAMPLES\BASIC\MsgMenu

Na primeira pasta (MsgEdit) procure por MsgOptions(), que é baseado no antigo Alert().

Na HMG Oficial, não encontrei nenhum exemplo na pasta \SAMPLES, mas acho que a função MsgOptions() deve funcionar em HMG.

Abraços,

Equivalente da função ALERT()

Enviado: 05 Set 2014 19:25
por Pablo César
Toledo escreveu:Na HMG Oficial, não encontrei nenhum exemplo na pasta \SAMPLES, mas acho que a função MsgOptions() deve funcionar em HMG
Não funciona sem ter que adaptar.

Só pra constar. Existem a seguintes opções de MSGxxx em HMG:

MsgYesNo( Message , Title , RevertDefault )
MsgRetryCancel( Message , Title )
MsgOkCancel( Message , Title )
MsgInfo( Message , Title )
MsgStop( Message , Title )
MsgExclamation ( Message , Title )
MsgBox( Message , Title )
MsgDebug(xVal)
MsgDebugTitle ( Title )
MsgDebugType ( nTypeIconButton )
MsgDebugTimeOut ( nMilliseconds )
MsgDebugUnicode(xVal)
MsgHMGError(Message)
MsgInfoUnicode (Message, Title)

No STRU (seção de Downloads) tem o fonte que contém a função MyAlert( cMessage, cTitle, nRow, cColor, aItems, lCentrar ).

Equivalente da função ALERT()

Enviado: 03 Out 2014 13:40
por Mario Mesquita
Boa tarde a todos!

Decidi fazer uma pequena função que reproduz o ALERT(). Ficou razoável e pra quem achar legal, aí está.

Código: Selecionar todos

// Função genérica que substitui o ALERT() do Clipper //

FUNCTION MSGALERT( xTit, ;  // Titulo da Janela
                   xMsg, ;  // Mensagem
                   vOpc  )  // Vetor com Opções

LOCAL xSaida := 0, ;
      xAltR  := 0, ;
      xAltF  := 0, ;
      xLarg  := 0

xTit := IIF(xTit == NIL, "Atenção!",          xTit)
xMsg := IIF(xMsg == NIL, "Escolha uma Opção", xMsg)

xAltR := ( 30 * LEN(vOpc) )
xAltF := 130 + ( 20 * LEN(vOpc) )

xLarg := LEN(xTit)
xLarg := IIF( LEN(xMsg) > xLarg, LEN(xMsg), xLarg )

FOR k = 1 TO LEN(vOpc)
    xLarg := IIF( LEN(vOpc[k]) > xLarg, LEN(vOpc[k]), xLarg )
NEXT

xLarg := (xLarg * 7)

DEFINE WINDOW Frm_Alerta  ;
 	   AT 0,0         ;
	   WIDTH  xLarg   ;
	   HEIGHT xAltF   ;
	   TITLE  xTit    ;
	   MODAL          ;
           NOSYSMENU      ;
	   FONT "Arial"   ;
           SIZE 10 

		 @ 10,00 LABEL Label_1            ; 
		              WIDTH xLarg - 10    ;
			      HEIGHT 20           ;
		              VALUE xMsg          ;
		              FONT "Arial"        ;
			      BOLD                ;
			      ITALIC              ;
			      FONTCOLOR {255,0,0} ;
			      SIZE 10             ;
			      CENTERALIGN

		 @ 40,10 RADIOGROUP Radio_1                                     ;
                              OPTIONS vOpc                                      ; 
			      VALUE 1                                           ;
			      WIDTH 510                                         ;
			      SPACING 20                                        ;
   		              ON CHANGE {||xSaida := frm_alerta.radio_1.value } ;  
   		              FONT "Arial"                                      ;
			      SIZE 10                                           ;
			      BOLD                                              ;
			      ITALIC

       @ (xAltR+20),(xLarg/2)-50 BUTTON Button_1 ;
		                 CAPTION "OK"    ;
				 WIDTH  100      ;
				 HEIGHT 25       ;
				 BOLD            ;
				 ACTION {|| IIF(xSaida > 0, Frm_Alerta.Release, MSGINFO("Selecione uma opção")) }
END WINDOW

Frm_Alerta.Radio_1.SetFocus
Frm_Alerta.Center
Frm_Alerta.Activate

RETURN xSaida
******
Pode ficar mais incrementada, mas pra mim já quebra o galho.

Sds,
Mario.

Equivalente da função ALERT()

Enviado: 03 Out 2014 13:42
por Mario Mesquita
O código ficou estranho em algumas partes, desculepm.

Deve ser algo do editor de programas.

Sds.