May 06, 2024, 01:32:46 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Enabletabs stops a Setcontrolnotify command

Started by Andy, August 22, 2013, 06:07:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

Sorry once more to post another question!

I have 3 edit's

CONTROL f5,@EDIT,"",200,35,30,25,0x50800000|@TABSTOP|ES_NUMBER,914 'Date1 D
CONTROL f5,@EDIT,"",232,35,30,25,0x50800000|@TABSTOP|ES_NUMBER,915 'Date1 M
CONTROL f5,@EDIT,"",264,35,54,25,0x50800000|@TABSTOP|ES_NUMBER,916 'Date1 Y

and I want to be able to tab between them:

so I use "ENABLETABS f5,1", so far so good.

But - I also want to detect when the user presses <Enter> on control 916 (the last one)

so I use "SETCONTROLNOTIFY(f5,916,0,1)"

They both work on their own, but if I include "ENABLETABS f5,1" then "SETCONTROLNOTIFY(f5,916,0,1)"
does not work.

If I remove "ENABLETABS f5,1" then "SETCONTROLNOTIFY(f5,916,0,1)" works?  ???

are they mutually exclusive OR more likely I'm doing something wrong?

Thanks,
Andy.

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

LarryMc

I'm assuming f5 is a window since you are using ENABLETABS.

The OS does not support tabbing in a window, just dialogs.

ENABLETABS sets an element of IWB's internal WINDOW structure.  With special internal coding IWB simulate, in a window, what happens normally in a dialog.

Evidently, there is a conflict between the coding associated with ENABLETABS and SETCONTROLNOTIFY that gives you what you are seeing.

The solution is simple as demonstrated by the following code:
window f5
openwindow f5,0,0,640,400,@caption|@SIZE|@sysmenu,0,"Andy21",&mainwindow
CONTROL f5,@EDIT,"",200,35,30,25,0x50800000|@TABSTOP|@CTEDITNUMBER,914 'Date1 D
CONTROL f5,@EDIT,"",232,35,30,25,0x50800000|@TABSTOP|@CTEDITNUMBER,915 'Date1 M
CONTROL f5,@EDIT,"",264,35,54,25,0x50800000|@TABSTOP|@CTEDITNUMBER,916 'Date1 Y
SETCONTROLNOTIFY(f5,914,1,0)
SETCONTROLNOTIFY(f5,915,1,0)
SETCONTROLNOTIFY(f5,916,1,1)

setfocus f5,914
waituntil iswindowclosed f5
end

sub mainwindow(),int
select @MESSAGE
case @IDCREATE
centerwindow f5
case @IDCONTROL
if @NOTIFYCODE = @ENTABKEY
select @CONTROLID
case 914:setfocus f5,915
case 915:setfocus f5,916
case 916:setfocus f5,914
endselect
endif
if @NOTIFYCODE =@ENENTERKEY
select @CONTROLID
case 916
messagebox f5,"ENTER key pressed","",0
endselect
endif
case @IDCLOSEWINDOW
closewindow f5
endselect
return 0
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

Thanks Larry,

Yes, your solution was quite simple and thanks.

I have put into action on one screen that has only 5 edit controls and works correctly, however the main screen has 30+ edits so I have to decide now do I keep the Enabletabs and do without the <Enter> facility or do I re-code the main screen.

Anyway, once again Larry - Thanks!

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

LarryMc

Quote from: andy1966 on August 22, 2013, 11:26:29 PM
Thanks Larry,

Yes, your solution was quite simple and thanks.

I have put into action on one screen that has only 5 edit controls and works correctly, however the main screen has 30+ edits so I have to decide now do I keep the Enabletabs and do without the <Enter> facility or do I re-code the main screen.

Anyway, once again Larry - Thanks!

Andy.
:)
You can add one little block of code (if all your edit controls are in order) to take care of tabbing.
   int x
   for x=914 to 944
      SETCONTROLNOTIFY(f5,x,1,0)
   next x

You could maybe expand the above to 3 loops(one of tab only, one for enter only, and one for both)
You'd need to make sure the numbers fell correctly.
or you could just add some if statements for the ones that needed something other than just tabbing.


   case @IDCONTROL
      if @NOTIFYCODE = @ENTABKEY
         x = @CONTROLID
         if x >= 914 and x<=944
            x++
            if x>944 then x=914
            setfocus f5,x
         endif
      endif
      if @NOTIFYCODE = @ENENTERKEY
         ...


LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Thanks Larry for that idea,

Good one, as it happens it only took me about 30 minutes to do it the long way around, but might save someone else a lot of time.

But much appreciated!!!

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