June 25, 2024, 06:05:59 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Control update

Started by Andy, May 03, 2016, 12:35:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

May 03, 2016, 12:35:38 AM Last Edit: May 03, 2016, 12:37:24 AM by Andy
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.




Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

May 03, 2016, 03:28:40 AM #1 Last Edit: May 03, 2016, 03:48:30 AM by Andy
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.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

May 04, 2016, 12:07:27 AM #3 Last Edit: May 04, 2016, 12:21:10 AM by Andy
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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.