IonicWind Software

IWBasic => General Questions => Topic started by: Andy on May 03, 2016, 12:35:38 AM

Title: Control update
Post by: Andy on May 03, 2016, 12:35:38 AM
I'm looking at (as a test) two edit controls, one contains a hex value, and one an ascii value

edit control 1 = 61
edit control 2 = a

I edit control 1 to say 62, I then convert hex 62 to an ascii character (b), then set the control text of control 2 to b.

But if I try it the other way round, my program gets stuck in a loop as they try to update each other constantly - how can I stop this?

Also, how do I stop the updating of controls whilst the window is created?

Thanks,
Andy.




Title: Re: Control update
Post by: Andy on May 03, 2016, 03:28:40 AM
I have got this far, just click between edit 1 and 2, edit 2 Shows a Count adding up, and edit 1 a Count counting down.



DEF w1 as WINDOW
int c,d
d = 100
OPENWINDOW w1,0,0,600,350,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
CONTROL w1,@EDIT,"",60,40,500,25,@CTEDITLEFT|@TABSTOP,1
CONTROL w1,@EDIT,"",60,80,500,25,@CTEDITLEFT|@TABSTOP,2
CONTROL w1,@button,"cancel",60,120,100,25,@CTEDITLEFT|@TABSTOP,4
WAITUNTIL w1 = 0
END

SUB main
SELECT @MESSAGE

CASE @IDCONTROL

      select @CONTROLID

         case 1
            select @notifycode
               case @enkillfocus
                 c ++
                 setcontroltext w1,2,str$(c)
            endselect


         case 2
            select @notifycode
               case @enkillfocus
                 d --
                 setcontroltext w1,1,str$(d)
            endselect


      endselect

CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
ENDSELECT
RETURN 0
ENDSUB


But I need to stop it updating the other edit Control when neither of the two controls have the Focus.



Title: Re: Control update
Post by: LarryMc on May 03, 2016, 02:48:31 PM
See if this does want you want you last example to do
$include "windowssdk.inc"
DEF w1 as WINDOW
int c,d
d = 100
OPENWINDOW w1,0,0,600,350,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
CONTROL w1,@EDIT,"",60,40,500,25,@CTEDITLEFT|@TABSTOP,1
CONTROL w1,@EDIT,"",60,80,500,25,@CTEDITLEFT|@TABSTOP,2
CONTROL w1,@button,"cancel",60,120,100,25,@CTEDITLEFT|@TABSTOP,4
WAITUNTIL w1 = 0
END

SUB main(),int
SELECT @MESSAGE
CASE @IDCONTROL
select @CONTROLID
case 1
select @notifycode
case @ENKILLFOCUS
c ++
checkit()
endselect
case 2
select @notifycode
case @ENKILLFOCUS
d --
checkit()
endselect
endselect
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
ENDSELECT
RETURN 0
ENDSUB

sub checkit()
if GetFocus()=GETCONTROLHANDLE(w1,2)
setcontroltext w1,2,str$(c)
elseif GetFocus()=GETCONTROLHANDLE(w1,1)
setcontroltext w1,1,str$(d)
endif
return
endsub
Title: Re: Control update
Post by: Andy on May 04, 2016, 12:07:27 AM
Larry,

Thanks again, that works for me, and I have now finished (or so I think) editing binary with either hex values on the left, or Ascii values on the right.

Enter a hex value, and it updates the correcsponding Ascii character and vice versa.

See attached.

Andy.
:)