Page 1 of 1

Help Needed For Horizontal Radio Button

PostPosted: Sat Mar 31, 2012 2:58 am
by acwoo1
Hi

When I click on 'Message 2" below, how to make oGet to show the new message.

Code: Select all  Expand view
#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 msg1 to temp
else
select Select("test1")
endif
      Append Blank
      onerror("APPEND")
      Replace msg1 With "This is message 1"
      Replace msg2 With "This is message 2"
      Replace msg3 With "This is message 3"

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

        DEFINE DIALOG oDlg FROM 0, 0 TO 26, 79 ;
        TITLE "Test"

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

   @ 0.2,  17 RADIOITEM "Message 2" RADIOMENU oRad OF oDlg SIZE 40, 10;
      ON CHANGE { || radiobtntest(2, oGet1) } UPDATE

   @ 0.2, 32 RADIOITEM "Message 3" RADIOMENU oRad OF oDlg SIZE 40, 10;
      ON CHANGE { || radiobtntest(3, oGet1) } 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 msg1 with ctestget      
         elseif nValue = 2
            replace msg2 with ctestget      
         else
            replace msg3 with ctestget      
         endif
      endif

close databases
return nil
*******************************************
function radiobtntest(nValue, oGet1)

      if nValue = 1
         ctestget = msg1    
      elseif nValue = 2
         ctestget = msg2    
      else
         ctestget = msg3    
      endif
      oGet1:ReFresh()
return nil
********************************************
function createfilea()

// "File : test1.dbf"
tmpdbf:= {}
AAdd(tmpdbf, {"msg1", "c", 50, 0})
AAdd(tmpdbf, {"msg2", "c", 50, 0})
AAdd(tmpdbf, {"msg3", "c", 50, 0})
dbcreate("test1.dbf", tmpdbf)
close
*******************************************
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.
********************************


Thanks

Regards
ACWoo
Using FHW1201+Bcc582+Harbour

Re: Help Needed For Horizontal Radio Button

PostPosted: Sun Apr 08, 2012 3:18 am
by acwoo1
Hi,

Sample code or any hint to move in the right direction will be appreaciated.

Thanks

ACWoo
Using FWH1201+Bcc582+Harbour

Re: Help Needed For Horizontal Radio Button

PostPosted: Sun Apr 08, 2012 8:54 am
by Enrico Maria Giordano
Code: Select all  Expand view
#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 message 1"
      Replace field -> msg2 With "This is message 2"
      Replace field -> msg3 With "This is message 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"

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

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

   @ 0.2, 32 RADIOITEM "Message 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.
********************************


EMG

Re: Help Needed For Horizontal Radio Button

PostPosted: Sun Apr 08, 2012 9:32 am
by acwoo1
Thanks a lot Enrico. It works.

Regards
ACWoo
Using FWH1201+bcc582+Harbour