Clipper On Line • Ver Tópico - Radio Horizontal - FWHX16.10
Mudar para estilo Clássico
Discussão sobre a biblioteca Fivewin - O Clipper para Windows.
Postar uma resposta

Radio Horizontal - FWHX16.10

12 Dez 2016 09:18

Para quem ainda usa @Say()

Código:
#include "FiveWin.ch"

function main()

   local oDlg, oRad, nValue := 1
   local oGet1
   local lSave := .f.
   local ctestget

   if !file("test1.dbf")
      createfilea()
   endif

   if (Select("test1") == 0)
      use test1 new
      index on field -> msg1 to temp
   else
      select Select("test1")
   endif

   Append Blank

   onerror("APPEND")

   Replace field -> msg1 With "This is Radio 1"
   Replace field -> msg2 With "This is Radio 2"
   Replace field -> msg3 With "This is Radio 3"

   if nValue = 1
      ctestget = field -> msg1
   elseif nValue = 2
      ctestget = field -> msg2
   else
      ctestget = field -> msg3
   endif

   DEFINE DIALOG oDlg FROM 0, 0 TO 26, 79 ;
          TITLE "Test radio horizontal - FWHX16.10"

   @ 0.2,  2 RADIO oRad VAR nValue ITEMS "Radio 1" OF oDlg SIZE 40, 10 ;
      ON CHANGE { || radiobtntest(oRad:nOption, oGet1, @ctestget) } UPDATE

   @ 0.2,  17 RADIOITEM "Radio 2" RADIOMENU oRad OF oDlg SIZE 40, 10;
      UPDATE

   @ 0.2, 32 RADIOITEM "Radio 3" RADIOMENU oRad OF oDlg SIZE 40, 10;
      UPDATE

   @ 6, 1 get oGet1 VAR ctestget size 100, 11

   @ 9.95, 18.7 BUTTON "&Accept" OF oDlg ACTION (lSave := .t.) ;
                                            SIZE 40, 12
   @ 9.95, 25.7 BUTTON "&Exit" OF oDlg ACTION (oDlg:End()) SIZE 40, 12

   ACTIVATE DIALOG oDlg CENTERED

   if lSave

      select test1
      onerror("RLOCK")

      if nValue = 1
         replace field -> msg1 with ctestget
      elseif nValue = 2
         replace field -> msg2 with ctestget
      else
         replace field -> msg3 with ctestget
      endif

   endif

   close databases

return nil

*******************************************
function radiobtntest(nValue, oGet1, ctestget)

      if nValue = 1
         ctestget = field -> msg1     
      elseif nValue = 2
         ctestget = field -> msg2     
      else
         ctestget = field -> msg3     
      endif

      oGet1:ReFresh()

return nil
********************************************
function createfilea()

   // "File : test1.dbf"
   local tmpdbf:= {}

   AAdd(tmpdbf, {"msg1", "c", 50, 0})
   AAdd(tmpdbf, {"msg2", "c", 50, 0})
   AAdd(tmpdbf, {"msg3", "c", 50, 0})

   dbcreate("test1.dbf", tmpdbf)

   close

return nil
*******************************************
function ONERROR

   parameters errortype
   errortype:= Upper(errortype)

   do case
   case errortype == "RLOCK"
      if (RLock())
         return .T.
      endif
      do while (!RLock())
      InKey(3)
      enddo
   case errortype == "APPEND"
      if (!neterr())
         onerror("RLOCK")
         return .T.
      endif
      do while (neterr())
         InKey(3)
         append blank
      enddo
      onerror("RLOCK")
   endcase

return .T.
********************************


Abraços.
Postar uma resposta