Jump to content
Fivewin Brasil

CLEAR GETS


kapiaba

Recommended Posts

Pega essa ai, rascunhei agora, então se der algum erro avisa....

 

 

Function FwClearGets(oDlg)

Local nI

Local nJ

      For nI := 1 to Len(oDlg:aControls)
         If oDlg:aControls[nI]:ClassName()=="TGET"

            oDlg:aControls[nI]:Disable()

         ElseIf oDlg:aControls[nI]:ClassName()=="TFOLDER"

            For nJ := 1 to Len(oDlg:aControls[nI]:aDialogs)

               FwClearGets(oDlg:aControls[nI]:aDialogs[nJ])

            Next
         EndIf
      Next
 

Return

Link to comment
Share on other sites

veja se pelo menos entrou no FOR... mudei para considerar maiuscula e miniscula no nome da classe

 

Function FwClearGets(oDlg)


Local nI


Local nJ


      For nI := 1 to Len(oDlg:aControls)

         If AllTrim(Upper(oDlg:aControls[nI]:ClassName()))=="TGET"

            oDlg:aControls[nI]:Disable()

         ElseIf AllTrim(Upper(oDlg:aControls[nI]:ClassName()))=="TFOLDER"


            For nJ := 1 to Len(oDlg:aControls[nI]:aDialogs)


               FwClearGets(oDlg:aControls[nI]:aDialogs[nJ])


            Next

         EndIf

      Next

 

Return

Link to comment
Share on other sites

mas se não entra no FOR é pq a dialog (oDlg) que está passando não tem nenhum GET no aControls... rs...

 

tb se nao entra no FOR a funcao simplesmente nada faz, o problema do right deve ser outro...

 

tente fazer o exemplo em uma dialog simples e com apenas 3 gets normais...

Link to comment
Share on other sites

//-------------------------------------------------------------------

METHOD AEvalWhen(lDisableAll) CLASS TWindow

   local n
   local aControls := ::aControls
   
   default lDisableAll:=.F.

   if aControls != nil .and. ! Empty( aControls )
      for n = 1 to Len( aControls )
          if aControls[ n ] != nil .and. aControls[ n ]:bWhen != nil
             if lDisableAll
                ::aControls[ n ]:Disable()
             else
                if Eval( aControls[ n ]:bWhen )
                   ::aControls[ n ]:Enable()   // keep this as ::
                else
                   ::aControls[ n ]:Disable()  // keep this as ::
                endif
             endif   
         endif
      next
   endif

return nil

//-------------------------------------------------------------------

Olá, vc pode modificar a sua classe TWindow, método AevalWhen para fazer isso

 

basta chamar oDlg:AevalWhen(.T.) para desabilitar tudo

 

Abraço

Link to comment
Share on other sites

Ola Kapiaba, não sei como é seus objeto dos gets, mais é bem pratico trabalhar com array, pois dai fica fácil fazer isto e outros procedimentos que envolva todos gets da dialog...

local oGet[10]

redefine get oGet[1] ...

redefine get oGet[2] ...

usando assim basta dar um for next

Abraços

Luiz Fernando

Link to comment
Share on other sites

show de bola essa solução e nem precisa reinventar a roda... kkk

 

muito boa Yury

//-------------------------------------------------------------------

METHOD AEvalWhen(lDisableAll) CLASS TWindow

   local n
   local aControls := ::aControls
   
   default lDisableAll:=.F.

   if aControls != nil .and. ! Empty( aControls )
      for n = 1 to Len( aControls )
          if aControls[ n ] != nil .and. aControls[ n ]:bWhen != nil
             if lDisableAll
                ::aControls[ n ]:Disable()
             else
                if Eval( aControls[ n ]:bWhen )
                   ::aControls[ n ]:Enable()   // keep this as ::
                else
                   ::aControls[ n ]:Disable()  // keep this as ::
                endif
             endif   
         endif
      next
   endif

return nil

//-------------------------------------------------------------------

Olá, vc pode modificar a sua classe TWindow, método AevalWhen para fazer isso

 

basta chamar oDlg:AevalWhen(.T.) para desabilitar tudo

 

Abraço

Link to comment
Share on other sites

//-------------------------------------------------------------------

METHOD AEvalWhen(lDisableAll) CLASS TWindow

   local n
   local aControls := ::aControls
   
   default lDisableAll:=.F.

   if aControls != nil .and. ! Empty( aControls )
      for n = 1 to Len( aControls )
          if aControls[ n ] != nil .and. aControls[ n ]:bWhen != nil
             if lDisableAll
                ::aControls[ n ]:Disable()
             else
                if Eval( aControls[ n ]:bWhen )
                   ::aControls[ n ]:Enable()   // keep this as ::
                else
                   ::aControls[ n ]:Disable()  // keep this as ::
                endif
             endif   
         endif
      next
   endif

return nil

//-------------------------------------------------------------------

Olá, vc pode modificar a sua classe TWindow, método AevalWhen para fazer isso

 

basta chamar oDlg:AevalWhen(.T.) para desabilitar tudo

 

Abraço

Fala Yuri, tava sumido meu rei?? Eu não quero desabilitar tudo, supunhetemos que eu TENHA 50 GETS, quero que 30 fiquem com WHEN( .F. ) e 20 fiquem com WHEN( .T. ) KAPISKA? 

 

Abs,

Link to comment
Share on other sites

Kapiada, nesse caso monte um array com os objetos GET que deseja desabilitar e use o método DISABLE neles

 

Fala Yuri, tava sumido meu rei?? Eu não quero desabilitar tudo, supunhetemos que eu TENHA 50 GETS, quero que 30 fiquem com WHEN( .F. ) e 20 fiquem com WHEN( .F. ) KAPISKA? 

 

Abs,

Link to comment
Share on other sites

Bem aqui no programa eu faço parecido com a primeira resposta , tambem me baseio na id do Get ou da classe tanto para usar o Hide como o Disabled ai vai as funçoes 
 

Function Desabilita_Controles(oDlg) // Passar Dialog no Parametro , caso for um Folder passar o oDlg:aDialogs[1] 
   local y,x:= len (oDlg:aControls)
   For y:=1 to  x
      oDlg:aControls[y]:Disable()
   next
 
 

Function Desabilita_Controles2(oDlg) //Essa voce so precisa mudar a classe 
   local y,x:= len (oDlg:aControls)
   For y:=1 to  x
      if oDlg:aControls[y]:classname<>"TBUTTONBMP"
         oDlg:aControls[y]:Disable()
      endif
   next
 

Function Desabilita_Controles3(oDlg,IdInicial) // Essa Funciona pelo Numero da Id
   local y,x:= len (oDlg:aControls)
   For y:=1 to  x
      if oDlg:aControls[y]:nId>=IdInicial
         oDlg:aControls[y]:Disable()
      endif
   next
 

 


 

Quaisquer duvidas ta ai os contatos : Matheus@inteligence.com.br / Matheushchaves@gmail.com / d.matheusfarias@hotmail.com / matheushchaves@hotmail.com / (83) 9854-0294

Link to comment
Share on other sites

o que eu utilizo e funciona com when determinado no get.

 

DEFINE DIALOG oDlg FROM 0,0 TO 460,900 PIXEL

....

....

Instruções de SAY e GET

@ 087,005 FOLDER oFld OF oDlg PROMPT "&Forma de Pagamento", "&Centro Administrativo", "&Observação" ;
    PIXEL SIZE 442,123

....

....

 

IF <parametro>

   TravaGet( oDlg, oFld )

ENDIF

 

ACTIVATE DIALOG oDlg CENTERED

 

FUNCTION TravaGet( oDlgAdj, oFldAdj )


LOCAL nCtrDlg, nCtrFld1, nCtrFld2

 

IF oDlgAdj # NIL

 FOR nCtrDlg:=1 TO LEN(oDlgAdj:aControls)

  cNomeClase:=oDlgAdj:aControls[nCtrDlg]:ClassName()

  IF cNomeClase=="TSAY"
  ELSEIF cNomeClase=="TRADIO"
   IF !oDlgAdj:aControls[nCtrDlg]:lChecked
    oDlgAdj:aControls[nCtrDlg]:DISABLE()
   ENDIF
  ELSEIF cNomeClase=="TCHECKBOX"
   oDlgAdj:aControls[nCtrDlg]:DISABLE()
  ELSEIF cNomeClase=="TFOLDER"
  ELSEIF cNomeClase == "TBTNBMP"
  ELSEIF cNomeClase=="TXBROWSE"
  ELSEIF cNomeClase=="TMULTIGET"
   oDlgAdj:aControls[nCtrDlg]:lReadOnly:=.T.
  ELSE
   oDlgAdj:aControls[nCtrDlg]:DISABLE()
  ENDIF

 NEXT

ENDIF

 

IF oFldAdj # NIL

 FOR nCtrFld1:=1 TO LEN(oFldAdj:aDialogs)

  FOR nCtrFld2:=1 TO LEN(oFldAdj:aDialogs[nCtrFld1]:aControls)

   cNomeClase:=oFldAdj:aDialogs[nCtrFld1]:aControls[nCtrFld2]:ClassName()

   IF cNomeClase == "TSAY"
   ELSEIF cNomeClase == "TRADIO"
    IF !oFldAdj:aDialogs[nCtrFld1]:aControls[nCtrFld2]:lChecked
     oFldAdj:aDialogs[nCtrFld1]:aControls[nCtrFld2]:DISABLE()
    ENDIF
   ELSEIF cNomeClase == "TCHECKBOX"
    oFldAdj:aDialogs[nCtrFld1]:aControls[nCtrFld2]:DISABLE()
   ELSEIF cNomeClase == "TFOLDER"
   ELSEIF cNomeClase == "TBTNBMP"
   ELSEIF cNomeClase == "TXBROWSE"
   ELSEIF cNomeClase == "TMULTIGET"
    oFldAdj:aDialogs[nCtrFld1]:aControls[nCtrFld2]:lReadOnly:=.T.
   ELSE
    oFldAdj:aDialogs[nCtrFld1]:aControls[nCtrFld2]:DISABLE()
   ENDIF

  NEXT

 NEXT

ENDIF

 

RETURN NIL

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...