sambomb Posted May 10, 2013 Report Share Posted May 10, 2013 Redefine Get oGt[4]; Var cStr[5] ; Update; ID 108; Picture "999,999.99" ; of oDlg Procedure TrocaMascara() cMascara := "999,999.999" oGt[4]:cPicture := cMascara oGt[4]:oGet:Picture := cMascara oGt[4]:Refresh() Return Com essa procedure a máscara é modificada, mas apenas se eu pressionar "." ( ponto ) antes do primeiro decimal ser adicionado Exemplo das teclas pressionadas 123.456 = OK => 123.456 12345.678 = OK => 12,345.678 123456.789 = OK => 123,456.789 123456789 = Falha => 123,456.780 1234567.89 = Falha => 123,456.790 12345678.9 = Falha => 123,456.790 Na classe TGet achei no método KeyChar esse trecho, que aparentemente é o responsável por esse funcionamento mas não consegui implementar if ::oGet:Type == "N" .and. ( Chr( nKey ) == "." .or. Chr( nKey ) == "," ) if ::oGet:Clear() #ifndef __XHARBOUR__ ::oGet:DelEnd() #endif endif ::oGet:ToDecPos() Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 10, 2013 Report Share Posted May 10, 2013 Vaje se é isso que você quer... // Testing a GET #Include "FiveWin.ch" //------------------------------------------------------------------------// Function Mascara() LOCAL oDlg LOCAL nNumero := 0 LOCAL cPicture := "9,999,999.99" // Mascara do get LOCAL aGet := Array(5) DEFINE DIALOG oDlg TITLE "Trocando a Mascara" oDlg:lHelpIcon := .F. @ 1.6, 2 SAY "Digite:" OF oDlg @ 2, 6 GET aGet[1] VAR nNumero OF oDlg SIZE 80, 10 PICTURE cPicture ; VALID CHECA_NUMERO( nNumero, aGet, cPicture ) CENTER @ 3, 10 BUTTON "&Cancelar" SIZE 50, 12 OF oDlg ACTION( oDlg:End() ) CANCEL ACTIVATE DIALOG oDlg CENTERED Return Nil STATIC FUNCTION CHECA_NUMERO( nNumero, aGet, cPicture ) cPicture := "@KE 9,999,999.99" aGet[1]:oGet:Picture := cPicture aGet[1]:VarPut( nNumero ) aGet[1]:Refresh() RETURN( .T. ) //-> FIM DO PROGRAMA Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 10, 2013 Author Report Share Posted May 10, 2013 Kapiaba, o que preciso é mudar de 2 decimais para 3 decimais, só que só funciona os 3 decimais se eu apertar ponto, ou seja mesmo com a máscara definida para "999,999.999" se eu pressionar 123456789 o último caracter continua inalterado, mas se eu pressionar até 6 caracteres, ponto e depois as casas decimais funciona. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 10, 2013 Report Share Posted May 10, 2013 Ai, eu acho que você tem fazer algo assim: FUNCTION Num2Str( nCampo, nSize, nDec ) LOCAL cPicture := "@E 999,999,999,999" DO CASE CASE nSize = 12 .AND. nDec = 0 cPicture := "@E 999,999,999,999" CASE nSize = 12 .AND. nDec = 2 cPicture := "@E 999,999,999.99" CASE nSize = 12 .AND. nDec = 3 cPicture := "@E 99,999,999.999" CASE nSize = 08 .AND. nDec = 0 cPicture := "@E 99,999,999" CASE nSize = 08 .AND. nDec = 2 cPicture := "@E 99,999.99" CASE nSize = 08 .AND. nDec = 3 cPicture := "@E 9,999.999" CASE nSize = 07 .AND. nDec = 0 cPicture := "@E 9,999,999" CASE nSize = 07 .AND. nDec = 2 cPicture := "@E 9,999.99" CASE nSize = 07 .AND. nDec = 3 cPicture := "@E 999.999" CASE nSize = 05 .AND. nDec = 0 cPicture := "@E 99,999" CASE nSize = 05 .AND. nDec = 2 cPicture := "@E 99.99" CASE nSize = 05 .AND. nDec = 3 cPicture := "@E 9.999" CASE nSize = 02 .AND. nDec = 0 cPicture := "99" ENDCASE RETURN Transform( nCampo, cPicture ) Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 10, 2013 Author Report Share Posted May 10, 2013 Isso eu já faço, olha aqui: Eu resumi meu código para ficar só cMascara := "999,999.999" Procedure TrocaMascara() cMascara := "999,999.999" oGt[4]:cPicture := cMascara oGt[4]:oGet:Picture := cMascara oGt[4]:Refresh() Return Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 17, 2013 Author Report Share Posted May 17, 2013 Kapiaba, olha ae: http://alanart.net/fivewin/index.php?/files/download/1083-picture-erro.zip Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 20, 2013 Report Share Posted May 20, 2013 Sorry, you don't have permission for that! [#10854]Você não tem permissão para fazer download deste arquivo Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 20, 2013 Author Report Share Posted May 20, 2013 Hmm... Vou dar um jeito Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 20, 2013 Report Share Posted May 20, 2013 Coloque no www.4shared.com, não sei porque não tenho permissão para fazer download de dicas... abs. Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 20, 2013 Author Report Share Posted May 20, 2013 http://www.youtube.com/watch?v=X7Ld24pJLRg Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 20, 2013 Report Share Posted May 20, 2013 Eu acho que somente o Liñares para te ajudar. Quote Link to comment Share on other sites More sharing options...
Theotokos Posted May 30, 2013 Report Share Posted May 30, 2013 Isso eu já faço, olha aqui: Eu resumi meu código para ficar só cMascara := "999,999.999" Procedure TrocaMascara() cMascara := "999,999.999" oGt[4]:cPicture := cMascara oGt[4]:oGet:Picture := cMascara oGt[4]:Refresh() Return eu utilizo algo parecido, só que no meu caso eu troco a picture quando de cliente fisico ou juridico para os campos CPF/CNPJ e RG/IE Tente Assim: Procedure TrocaMascara() cMascara := "999,999.999" oGt[4]:cPicture := cMascara oGt[4]:oGet:Picture := cMascara oGt[4]:VarPut( sua_variavel ) oGt[4]:Refresh() Return Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 31, 2013 Author Report Share Posted May 31, 2013 Só o VarPut não resolve....Testa nesse exemplo que postei ae com e sem o VarPut pra vc ver, Linares mandou atualizar o Fivewin pra ver se resolve...Até então resolvi com uma gambiarra... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.