FwMsgRun - Apresenta uma janela com uma mensagem durante o processamento.


Muitas vezes durante um processo que estamos executado, apenas vemos a barra de progresso do protheus indo de um lado para outro (ping-pong)  ou aquela barrinha que vai andando devagarinho, ou quando nada aparece. Temos sempre a impressão que o processo está travado, mas por trás está sendo processado. O uso da função FwMsgRun apresenta uma janela com uma mensagem durante o processamento. E está mensagem pode ir exibindo outras mensagens durante o processamento. Abaixo, segue um bom exemplo do seu uso.

//--------------------------------------------------------------
/*/{Protheus.doc} xFwMsgRun
Modelo que exemplifica o uso da função FwMsgRun.

@param   oObj     Variável de objeto exportável onde a função FwMsgRun irá executar.
@param   bBlock   Codeblock com a instrução a ser executada enquanto a mensagem fica a mensagem para o usuário.
@param   cTitle   Título da mensagem - não obrigatório.
@param   cMessage Mensagem enquanto processa a função passada no Codeblock - não obrigatória.

@author  Robson Luiz - Rleg
@since   05.09.2013
@version 1.0
/*/
//--------------------------------------------------------------
#Include "Protheus.ch"

User Function xFwMsgRun()
	Local oDlg
	Local oFld
	Local oPnl1, oPnl2, oPnl3, oPnl4
	Local oButton1, oButton2, oButton3, oButton4, oButton5, oButton6
	
	Local cTitulo := 'Processando'
	Local cMsg := 'Aguarde, processando a rotina'

	DEFINE MSDIALOG oDlg TITLE 'FwMsgRun' FROM 0, 0 TO 550, 800 PIXEL
		
		@ 1,1 MSPANEL oPnl1 PROMPT '' SIZE 100,100 OF oDlg RAISED
		oPnl1:Align := CONTROL_ALIGN_ALLCLIENT

		@ 4,80 FOLDER oFld SIZE 300,200 OF oPnl1 ITEMS 'Pasta1','Pasta2' PIXEL
		@ 1,1 MSPANEL oPnl2 PROMPT 'oPanel do folder 1' SIZE 300,42 OF oFld:aDialogs[1] RAISED
		oPnl2:Align := CONTROL_ALIGN_ALLCLIENT
		
		@ 220,80 MSPANEL oPnl3 PROMPT ''       SIZE 300,40 OF oPnl1 RAISED
		@   1, 1 MSPANEL oPnl4 PROMPT 'oPanel' SIZE 300,40 OF oPnl3 RAISED
		oPnl4:Align := CONTROL_ALIGN_ALLCLIENT
		
		@ 04,2 BUTTON oButton1 PROMPT 'Objeto Próprio 1' SIZE 60, 12 OF oPnl1 ACTION FWMsgRun(, {|oSay| Process( oSay ) }) PIXEL
		@ 20,2 BUTTON oButton2 PROMPT 'Objeto Próprio 2' SIZE 60, 12 OF oPnl1 ACTION FWMsgRun(, {|oSay| Process( oSay ) }, cTitulo, cMsg ) PIXEL
		@ 36,2 BUTTON oButton3 PROMPT 'Objeto Dialog'    SIZE 60, 12 OF oPnl1 ACTION FWMsgRun(oPnl1, {|oSay| Process( oSay ) } ) PIXEL
		@ 52,2 BUTTON oButton4 PROMPT 'Objeto Folder'    SIZE 60, 12 OF oPnl1 ACTION FWMsgRun(oPnl2, {|oSay| Process( oSay ) } ) PIXEL
		@ 68,2 BUTTON oButton5 PROMPT 'Objeto Panel'     SIZE 60, 12 OF oPnl1 ACTION FWMsgRun(oPnl4, {|oSay| Process( oSay ) } ) PIXEL
		@ 84,2 BUTTON oButton6 PROMPT 'Sair'             SIZE 60, 12 OF oPnl1 ACTION oDlg:End() PIXEL
	ACTIVATE MSDIALOG oDlg CENTER
Return

//------------------------------------
// Função que simula um processamento.
//------------------------------------
Static Function Process( oSay )
	Local nX := 0
	Sleep(2000)
	For nX := 1 to 5
		oSay:cCaption := ('Contador ' + StrZero(nX, 2))
		ProcessMessages()
		Sleep(1000)
	Next nX
Return
  Outras funções semelhantes: