April 26, 2024, 10:48:25 PM

News:

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


Beginners questions

Started by Hobo, September 12, 2008, 06:14:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hobo

Hi,
I am new here and I am new to CB. I have some concept how to program, but obviously not near enough to figure out how to program by using the EB User Guide alone and the including samples. For example I could not find any sample(s) dealing with numbers.

I already got a lot of help. Technically they wrote the code for me. I am embarrassed to ask more. I really want to do the programming myself, but I got stuck. I tried so many ways to use the suggested commands, and yet I can’t get it right. The User Guide is very good and well organized and simple to use, but need to include more samples. Like how to deal with integers.

But again, perhaps it is so obvious, just I don’t see it.

Perhaps a forum for beginners? So the experts could look over the newbie at times and newbie would not bored to death the experts in other area.

Cheers,

Hobo

aurelCB

September 13, 2008, 07:45:37 AM #1 Last Edit: September 13, 2008, 07:49:23 AM by aurelCB
I realy dont understand what is too tuff for you ???
You say dealing with numbers,how to deal with integers?
Simple if you define with DEF a:INT then a is integer type of variable.
And if you then set varible a=3 and then add command Print a you will give 3 displayed.Clear?
Second type is FLOAT in some basics called SINGLE wich is floating type,example:
DEF f:float
f=3.14
PRINT f
will display 3.14
If you want integer result you must writte this:
PRINT int(f)
will dispaly 3
Another type is DOUBLE,for example 0.3456789 etc.
If you want use number from editcontrol you must transform this string to number with VAL command.
'------------------------------------
def text:string
def a,b,result:int
a=6

'in edit control you writte number 5
text=getcontroltext(w,1) :' 1 is ID of edit control
'transform text to int
b=val(text)

result = a + b
move w,10,10
print w,result

Or if you want show result in other edit control you must use setcontroltext
; SETCONTROLTEXT window | dialog, ID, text

SETCONTROLTEXT w,2,str$(result) :' 2 is ID of second edit control
SETCONTROLTEXT w,2,"" ; erase content of this control
Is this now much clear ?







techmail

Aurel and Hobo,
Please read again the subject of this topic.  Maybe you guys can move your discussion to another topic, or even to another forum.

aurelCB

Do you mean that i dont know wich is subject of this topic. >:(
So dont be too smart.
Man is lost and need help if you see.
I agree that this is no place for this disqusion.
So i suggest board for beginners ;)
regards
aurel

LarryMc

zlatko
He wasn't being smart.
He was simply saying that this topic is "Suggest more forum topics here." and not "Beginner's Tutorial".

Maybe the Moderator will create a new area as several have suggested and move this discussion there.

Larry ;D

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

aurelCB

Yes you right mr.Larry but i dont like this atitude .

LarryMc

Zlatko

It's remarkable that you speak more than one language.  I think maybe this time something got lost in the translation and you misunderstood his "attitude".

Again, I'm sure he meant nothing with an "attitude". ;)

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

GWS

Keep it friendly guys ..  :)

Beginner's questions and problems are always welcome - and consideration will be given to setting up a 'Beginners' section.

best wishes, :)

Graham
Tomorrow may be too late ..

Ionic Wind Support Team

I removed techmail's reply here, two wrongs don't make a right.  Keep it on topic and without flames guys or I will get my banning stick out. ::)

Paul.
Ionic Wind Support Team

Ionic Wind Support Team

Ionic Wind Support Team

aurelCB


Hobo

Thank you very much all of you, especially Larry and Aurel, who have helped me greatly to put my feet down in CB. Just a few weeks and look what I was able to put together. You are all great guys.  :)

The program below itself is useless, but teaches you to do a few things. I think that is good for beginners: creating a window, different controls, clicking on the check box the window stays front of all windows, and I now I try do do some simple mathematical calculation. More precisely add a few numbers together. 

As you see I tried to use the GETCONTROLTEXT and SETCONTORLTEXT, but worked only as text string. I am going to use Aurel suggestion and see how far I get.  :)

Hobo

'hobo example

'-------------------------
'Stay on Top setup
declare "user32",SetWindowPos(Hwnd:int,HwndAfter:int,x:int,y:int,cx:int,cy:int,flags:int)
'setid "NOMOVE",2
'setid "NOSIZE",1
'setid "TOPMOST",-1
'setid "NOTOPMOST",-2
'--------------------------

DEF win:WINDOW
DEF add2numberopen,add3numberopen:int
DEF inputa$,inputb$:string


WINDOW win,0,0,200,300,@MINBOX,0," CURVE Wiz",Handler
SETWINDOWCOLOR win,RGB(255,255,0)
Centerwindow win

'Draw Buttons'
CONTROL win,"B,Add2Num,5,5,60,20,0,1"
SETFONT win, "MS Sans Serif", 9, 400,0,1
CONTROL win,"B,Add3Num,5,30,60,20,0,2"
SETFONT win, "MS Sans Serif", 9, 400,0,2
CONTROL win,"B,Submit,70,200,60,20,0,10"
SETFONT win, "MS Sans Serif", 9, 400,0,10
showwindow win, @swhide,10

'Add edit fields
CONTROL win,"E,inputX,120,40,70,20,0,3"
showwindow win, @swhide,3
CONTROL win,"E,inputY,120,65,70,20,0,4"
showwindow win, @swhide,4
CONTROL win,"E,inputZ,120,15,70,20,0,9"
showwindow win, @swhide,9
CONTROL win,"E,output,120,115,70,20,0,7"
showwindow win, @swhide,7
CONTROL win,"T,Sum =,75,115,30,20,0,8"
showwindow win, @swhide,8
SETFONT win, "MS Sans Serif", 9, 400,0,8
SETCONTROLCOLOR win,8,0,rgb(255,255,0)
LINE win,100,100,190,100,RGB(255,255,0)

'Add Checkbox
CONTROL win,"C,,25,150,20,20,0x50000003,11"
SETCONTROLCOLOR win,11,rgb(0,0,0),RGB(255,255,0)

run =  1
WAITUNTIL win=0
END

Handler:
SELECT @CLASS

   CASE @IDCLOSEWINDOW
      CLOSEWINDOW win
   
   CASE @IDCONTROL
IF (@controlid=1)&(add3numberopen=1)
showwindow win, @swhide,9
add3numberopen=0
ENDIF
IF (@controlid=1)&(add2numberopen=0)
add2number()
ENDIF
IF (@controlid=2)&(add3numberopen=0)
add3number()
    ENDIF
'Stay on top control
IF (@CONTROLID=11)
mark =  GETSTATE (win, 11)
IF mark =1
SetWindowPos(win,-1,0,0,0,0,2|1)
ELSE
SetWindowPos(win,-2,0,0,0,0,2|1)
ENDIF
ENDIF

IF (@CONTROLID=10)
inputa$ = GETCONTROLTEXT (win,3)
inputb$ = GETCONTROLTEXT (win,4)
SETCONTROLTEXT win,7,inputa$+inputb$
ENDIF

ENDSELECT
RETURN

SUB add2number
LINE win,100,100,190,100
showwindow win, @swrestore,3
showwindow win, @swrestore,4
showwindow win, @swhide,9
showwindow win, @swrestore,7
showwindow win, @swrestore,8
showwindow win, @swrestore,10
add2numberopen=1
RETURN

SUB add3number
LINE win,100,100,190,100
showwindow win, @swrestore,3
showwindow win, @swrestore,4
showwindow win, @swrestore,9
showwindow win, @swrestore,7
showwindow win, @swrestore,8
showwindow win, @swrestore,10
add3numberopen=1
RETURN

Hobo

I did it.
I am sure it is not the neatest code, but it works. The only thing I don’t know is how to make the answer 3 decimal places instead of 2. I think the default is 2.

'hobo example

'-------------------------
'Stay on Top setup
declare "user32",SetWindowPos(Hwnd:int,HwndAfter:int,x:int,y:int,cx:int,cy:int,flags:int)
'setid "NOMOVE",2
'setid "NOSIZE",1
'setid "TOPMOST",-1
'setid "NOTOPMOST",-2
'--------------------------

DEF win:WINDOW
DEF add2numberopen,add3numberopen:INT
DEF TEXT:STRING
DEF inputa,inputb,inputc,result:float

WINDOW win,0,0,200,300,@MINBOX,0," CURVE Wiz",Handler
SETWINDOWCOLOR win,RGB(255,255,0)
Centerwindow win

'Draw Buttons'
CONTROL win,"B,Add2Num,5,5,60,20,0,1"
SETFONT win, "MS Sans Serif", 9, 400,0,1
CONTROL win,"B,Add3Num,5,30,60,20,0,2"
SETFONT win, "MS Sans Serif", 9, 400,0,2
CONTROL win,"B,Submit,70,200,60,20,0,10"
SETFONT win, "MS Sans Serif", 9, 400,0,10
showwindow win, @swhide,10

'Add edit fields
CONTROL win,"E,inputX,120,40,70,20,0,3"
showwindow win, @swhide,3
CONTROL win,"E,inputY,120,65,70,20,0,4"
showwindow win, @swhide,4
CONTROL win,"E,inputZ,120,15,70,20,0,9"
showwindow win, @swhide,9
CONTROL win,"E,output,120,115,70,20,0,7"
showwindow win, @swhide,7
CONTROL win,"T,Sum =,75,115,30,20,0,8"
showwindow win, @swhide,8
SETFONT win, "MS Sans Serif", 9, 400,0,8
SETCONTROLCOLOR win,8,0,rgb(255,255,0)
LINE win,100,100,190,100,RGB(255,255,0)

'Add Checkbox
CONTROL win,"C,,25,150,20,20,0x50000003,11"
SETCONTROLCOLOR win,11,rgb(0,0,0),RGB(255,255,0)

run =  1
WAITUNTIL win=0
END

Handler:
SELECT @CLASS

   CASE @IDCLOSEWINDOW
      CLOSEWINDOW win
   
   CASE @IDCONTROL
'clears edit boxes
IF (@controlid=1)
SETCONTROLTEXT win,9,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETCONTROLTEXT win,7,""
ENDIF
IF (@controlid=2)
SETCONTROLTEXT win,9,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETCONTROLTEXT win,7,""
ENDIF
'----------------------------------------
IF (@controlid=1)&(add3numberopen=1)
showwindow win, @swhide,9
add3numberopen=0
ENDIF
'----------------------------------------
'draw edit boxes by pressing control buttons
IF (@controlid=1)&(add2numberopen=0)
add2number()
ENDIF
IF (@controlid=2)&(add3numberopen=0)
add3number()
    ENDIF
'----------------------------------------
'Stay on top control
IF (@CONTROLID=11)
mark =  GETSTATE (win, 11)
IF mark =1
SetWindowPos(win,-1,0,0,0,0,2|1)
ELSE
SetWindowPos(win,-2,0,0,0,0,2|1)
ENDIF
ENDIF
'----------------------------------------
'do mathematical operations
IF (@CONTROLID=10)&(add2numberopen=1)
text = GETCONTROLTEXT (win,3)
inputa=VAL(text)
text = GETCONTROLTEXT (win,4)
inputb=VAL(Text)
result=inputa+inputb
SETCONTROLTEXT win,7,STR$(result)
'SETCONTROLTEXT win,9,""
ENDIF

IF (@CONTROLID=10)&(add3numberopen=1)
text = GETCONTROLTEXT (win,9)
inputc=VAL(text)
text = GETCONTROLTEXT (win,3)
inputa=VAL(Text)
text = GETCONTROLTEXT (win,4)
inputb=VAL(text)
result=inputc+inputa+inputb
SETCONTROLTEXT win,7,STR$(result)
ENDIF
'---------------------------------------
ENDSELECT
RETURN

SUB add2number
LINE win,100,100,190,100
showwindow win, @swrestore,3
showwindow win, @swrestore,4
showwindow win, @swhide,9
showwindow win, @swrestore,7
showwindow win, @swrestore,8
showwindow win, @swrestore,10
add2numberopen=1
RETURN

SUB add3number
LINE win,100,100,190,100
showwindow win, @swrestore,3
showwindow win, @swrestore,4
showwindow win, @swrestore,9
showwindow win, @swrestore,7
showwindow win, @swrestore,8
showwindow win, @swrestore,10
add3numberopen=1
RETURN

Hobo

One more thing. Is there any way to jump from one edit box to the next edit box by pressing the TAB key?

aurelCB

Good ;)
Yes you did it but there is simplier way or more direct way.Look:
'hobo example 1

'-------------------------
'Stay on Top setup
declare "user32",SetWindowPos(Hwnd:int,HwndAfter:int,x:int,y:int,cx:int,cy:int,flags:int)
'setid "NOMOVE",2
'setid "NOSIZE",1
'setid "TOPMOST",-1
'setid "NOTOPMOST",-2
'--------------------------

DEF win:WINDOW
DEF add2numberopen,add3numberopen:int
DEF inputa$,inputb$:string
DEF result:INT

WINDOW win,0,0,200,300,@MINBOX,0," CURVE Wiz",Handler
SETWINDOWCOLOR win,RGB(255,255,0)
Centerwindow win

'Draw Buttons'
CONTROL win,"B,Add2Num,5,5,60,20,0,1"
SETFONT win, "MS Sans Serif", 9, 400,0,1
CONTROL win,"B,Add3Num,5,30,60,20,0,2"
SETFONT win, "MS Sans Serif", 9, 400,0,2
CONTROL win,"B,Submit,70,200,60,20,0,10"
SETFONT win, "MS Sans Serif", 9, 400,0,10
showwindow win, @swhide,10

'Add edit fields
CONTROL win,"E,inputX,120,40,70,20,0,3"
showwindow win, @swhide,3
CONTROL win,"E,inputY,120,65,70,20,0,4"
showwindow win, @swhide,4
CONTROL win,"E,inputZ,120,15,70,20,0,9"
showwindow win, @swhide,9
CONTROL win,"E,output,120,115,70,20,0,7"
showwindow win, @swhide,7
CONTROL win,"T,Sum =,75,115,30,20,0,8"
showwindow win, @swhide,8
SETFONT win, "MS Sans Serif", 9, 400,0,8
SETCONTROLCOLOR win,8,0,rgb(255,255,0)
LINE win,100,100,190,100,RGB(255,255,0)

'Add Checkbox
CONTROL win,"C,,25,150,20,20,0x50000003,11"
SETCONTROLCOLOR win,11,rgb(0,0,0),RGB(255,255,0)

run =  1
WAITUNTIL win=0
END

Handler:
SELECT @CLASS

   CASE @IDCLOSEWINDOW
      CLOSEWINDOW win
   
   CASE @IDCONTROL
IF (@controlid=1)&(add3numberopen=1)
showwindow win, @swhide,9
add3numberopen=0
ENDIF
IF (@controlid=1)&(add2numberopen=0)
add2number()
ENDIF
IF (@controlid=2)&(add3numberopen=0)
add3number()
    ENDIF
'Stay on top control
IF (@CONTROLID=11)
mark =  GETSTATE (win, 11)
IF mark =1
SetWindowPos(win,-1,0,0,0,0,2|1)
ELSE
SetWindowPos(win,-2,0,0,0,0,2|1)
ENDIF
ENDIF

IF (@CONTROLID=10)
inputa$ = GETCONTROLTEXT (win,3)
inputb$ = GETCONTROLTEXT (win,4)
'you can use directly-clear control
SETCONTROLTEXT win,7,""
' calculate
result=val(inputa$)+val(inputb$)
'display
SETCONTROLTEXT win,7,str$(result)
ENDIF

ENDSELECT
RETURN

SUB add2number
LINE win,100,100,190,100
showwindow win, @swrestore,3
showwindow win, @swrestore,4
showwindow win, @swhide,9
showwindow win, @swrestore,7
showwindow win, @swrestore,8
showwindow win, @swrestore,10
add2numberopen=1
RETURN

SUB add3number
LINE win,100,100,190,100
showwindow win, @swrestore,3
showwindow win, @swrestore,4
showwindow win, @swrestore,9
showwindow win, @swrestore,7
showwindow win, @swrestore,8
showwindow win, @swrestore,10
add3numberopen=1
RETURN


If you need more decimal places you must define variable result as FLOAT or DOUBLE.
And before you display result you can setprecision to 3 or more.
Yeah  there is a way to jump to other edit control with TAB key but this only work in DIALOG  type.
You must better read User Guide.
But maby this work also in WINDOW if you use API-s ,i realy dont know.
regards
aurel

GWS

Yes, as Aurel says, just put the statement:

Setprecision 3

somewhere early in your code, to get 3 decimal places.

Edit boxes are not very user friendly - Microsoft didn't provide them with any recognition of the Enter key - except in multi-line boxes, and that only inserts a carriage return to put you on the next line.

Of course, you can 'do-it-yourself' with a bit of code ..  :)


DEF win:WINDOW 

DECLARE "user32",Enter alias GetAsyncKeyState(vKey:int),int

def left,top,width,height,textW,textH,focus as int

WINDOW win,0,0,600,400,0,0,"Test of Enter Key",mainwin 
setwindowcolor win,rgb(0,20,50)

starttimer win,100,1                           

GETCLIENTSIZE win,left,top,width,height

' Edit Boxes ...
CONTROL win,"E,,120,50,80,25,@cteditcenter,1"
CONTROL win,"E,,400,50,80,25,@cteditcenter,4"
setcontrolcolor win,1,rgb(0,0,0),rgb(0,200,200) 
setcontrolcolor win,4,rgb(0,0,0),rgb(0,200,200) 

' Text Box ...
CONTROL win,"T,,(width-80)/2,150,80,25,@cteditcenter,2"
setcontrolcolor win,2,rgb(0,0,0),rgb(0,200,200) 
SETFONT win,"Times New Roman",12,700,0,2

CONTROL win,"B,Exit,(width-50)/2,300,50,25,0,3"

SETFOCUS win,1
focus = 1: ' keep track of which edit box has the focus ...

SETFONT win, "Arial",10,500,0
a$ = "Enter some Text and press Enter ..."
GETTEXTSIZE win, a$, textW, textH
move win,(width- textW)/2,20
frontpen win, RGB(20,230,150)
PRINT win,a$

run = 1 

WAITUNTIL run = 0
stoptimer win,1 
CLOSEWINDOW win

END

SUB mainwin 
     SELECT @CLASS 
           CASE @IDCLOSEWINDOW 
                 run = 0 
           CASE @IDCONTROL 
                 SELECT @CONTROLID 
                       CASE 1 
                             IF @NOTIFYCODE = @ensetfocus
                                   setcontroltext win,1,""       
                                   focus = 1: ' acknowledge the focus in box 1 ...
                             ENDIF
                       CASE 3
                             run = 0
                       case 4
                             IF @NOTIFYCODE = @ensetfocus
                                   setcontroltext win,4,""       
                                   focus = 4: ' acknowledge the focus in box 4 ...
                             ENDIF
                 endselect
           case @idtimer
                 if Enter(13) <> 0
                       select focus
                             case 1
                                   a$ = getcontroltext(win,1)
                                   if ltrim$(a$) <> ""
                                         setcontroltext win,1,""
                                         setcontroltext win,2,a$
                                         setfocus win,4
                                         focus = 4
                                   endif
                             case 4
                                   a$ = getcontroltext(win,4)
                                   if ltrim$(a$) <> ""
                                         setcontroltext win,4,""
                                         setcontroltext win,2,a$
                                         setfocus win,1
                                         focus = 1
                                   endif
                       endselect
                 endif
ENDSELECT

RETURN



or just use an 'Enter' button wiht each box - a bit clumsy I know ..  ::)

best wishes,

Graham
Tomorrow may be too late ..

Hobo

Thanks Aurel. this way is much more straightforward.

As far as the TAB key goes. The ENTER key is much better. Thank you the sample Graham.
It is very good code and many information and commands to learn.  :)

Regards

Hobo

Hobo

Graham,
I played around and modified your code to learn and understand. I hope you don’t mind?  :)
But I can’t figure out why did you use STARTTIMER â€Ã,¦@IDTIMER?  I know it is about sensing when the ENTER key pressed. Is there any other way to sense if any key pressed?

Hobo


DEF win:WINDOW 

DECLARE "user32",Enter alias GetAsyncKeyState(vKey:int),int

def focus:int

WINDOW win,0,0,600,400,0,0,"Test of Enter Key",mainwin 
setwindowcolor win,rgb(0,20,50)

starttimer win,10,1                           

' Edit Boxes ...
CONTROL win,"E,,120,50,80,25,@cteditcenter,1"
CONTROL win,"E,,400,50,80,25,@cteditcenter,4"
setcontrolcolor win,1,rgb(0,0,0),rgb(0,200,200) 
setcontrolcolor win,4,rgb(0,0,0),rgb(0,200,200) 

' Text Box ...
CONTROL win,"T,,250,150,80,25,@cteditcenter,2"
setcontrolcolor win,2,rgb(0,0,0),rgb(0,200,200) 
SETFONT win,"Times New Roman",12,700,0,2

CONTROL win,"B,Exit,265,300,50,25,0,3"

SETFOCUS win,1
focus = 1: ' keep track of which edit box has the focus ...

SETFONT win, "Arial",10,500,0
move win,200,20
frontpen win, RGB(20,230,150)
PRINT win,"Enter some Text and press Enter..."

run = 1 

WAITUNTIL run = 0
stoptimer win,1 
CLOSEWINDOW win

END

SUB mainwin 
SELECT @CLASS 
           CASE @IDCLOSEWINDOW
run =0
           
           CASE @IDTIMER
                 if Enter(13) <> 0
                       select focus
                             case 1
                                   a$ = getcontroltext(win,1)
                                   if (a$) <> ""
                                         setcontroltext win,1,""
                                         setcontroltext win,2,a$
                                         setfocus win,4
                                         focus = 4
                                   endif
                             case 4
                                   a$ = getcontroltext(win,4)
                                   if (a$) <> ""
                                         setcontroltext win,4,""
                                         setcontroltext win,2,a$
                                         setfocus win,1
                                         focus = 1
                                   endif
                       endselect
endif
CASE @idcontrol
IF (@CONTROLID=3)
run = 0
ENDIF
ENDSELECT

RETURN

mrainey

I found a long thread about trapping the Enter key in the old Pyxia forum archive.  I don't know how to grab it as a text file, so here's a long, skinny screenshot.  Just zoom it up in your graphics viewer so you can read it.
Software For Metalworking
http://closetolerancesoftware.com

Hobo

Thanks. Every bit of info helps.  :)


aurelCB

September 17, 2008, 03:57:46 PM #20 Last Edit: September 18, 2008, 08:13:28 AM by aurelCB
Hi guys...
I think that we forget read user guide.
I find in this big image, source code for hobo question how use button tab in window.
Simple with command ENABLETABS window|dialog,flag.
See code:

'Enter button traped for edit box in window with menu
def win:window
def run:int
def CurrentID:int
def ebox1$,ebox2$,ebox3$:string
def OK_ctr,Cancel_ctr,Close_ctr:int
'const BN_CLICKED = 0
'const BS_NOTIFY = &H4000
'const BN_SETFOCUS = 6

WINDOW win,0,0,450,250,@minbox,0,"Enter button traping",handler
SetWindowColor win,rgb(221,222,231)
Menu win,"T,&File,0,0","I,&Exit,0,1","I,&Exit2,0,2"
'1 enable tabing ,0 disable tab
Enabletabs win,1

'first edit control work only with numbers
control win,"E,,10,10,80,24,@tabstop|@cteditnumber,10"
setfont win,"MS Sans Serif",8,400,0,10
control win,"E,,110,10,80,24,@tabstop,20"
setfont win,"MS Sans Serif",8,400,0,20
control win,"E,,210,10,80,24,@tabstop,30"
setfont win,"MS Sans Serif",8,400,0,30
'if you need tabed  buttons then must use constants------------------
'control win,"B,OK,23,55,70,20,@tabstop|0x50010000|BS_NOTIFY,40"
'control win,"B,Cancel,120,55,70,20,@tabstop|0x50010000|BS_NOTIFY,50"
'control win,"B,Close,70,90,70,20,@tabstop|0x50010000|BS_NOTIFY,60"

SETFOCUS win ,10

run=1
Waituntil run=0
closewindow win
end

SUB handler
Select @CLASS
case @idclosewindow
run=0
case @idcreate
centerwindow win
Endselect
return

Hobo

I could swear that I have seen somewhere in the User Guide that TAB works only in Dialog and not in Window.

But anyway. Aurel's sample sure works.  :)

Hobo

LarryMc

Quote from: Hobo on September 17, 2008, 05:48:58 PM
I could swear that I have seen somewhere in the User Guide that TAB works only in Dialog and not in Window.
I didn't look in the user's guide but that information is here: http://www.ionicwind.com/forums/index.php/topic,375.msg3191.html#msg3191
quoting:
Quote...And it is OK to have controls in a window, but you have to fight the nature of Windows to do it, such as doing your own tabbing between controls (which is why we have the EnableTabs method).

Using windows alone you can not tab between controls so Paul wrote a function (EnableTabs) to make it appear to tab the way dialog controls can.

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

aurelCB

Thanks mrainey for big picture ;D

Hobo

I studded Graham’s earlier given code using ENTER and I tried to apply the same idea to my demo program and I can’t get it right.

The problem is once the ENTER key pressed it runs through the entire IF conditions. It won’t let me press the ENTER key after each EDITBOXES. My question is. Is there any way to reset the keyboard entry after each IF condition or should I use other commands instead of SETTIMEâ€Ã,¦@IDTIME?

Thanks,

Hobo

DECLARE "user32",SetWindowPos(Hwnd:int,HwndAfter:int,x:int,y:int,cx:int,cy:int,flags:int)
DECLARE "user32",Enter alias GetAsyncKeyState(vKey:int),int

DEF win:WINDOW
DEF inputa$,inputb$,inputc$,result$:STRING
DEF focus:INT

WINDOW win,0,0,200,300,@MINBOX,0," CURVE Wiz",Handler
SETWINDOWCOLOR win,RGB(255,255,0)

SETPRECISION 3
CENTERWINDOW win
ENABLETABS win,1
STARTTIMER win,10,1
focus=2

'Draw Buttons'
CONTROL win,"B,Add2Num,5,5,60,20,0,1"
SETFONT win, "MS Sans Serif", 9, 400,0,1

'Add edit fields
CONTROL win,"E,inputX,120,40,70,20,@tabstop|@cteditright,2"
showwindow win, @swhide,2
CONTROL win,"E,inputY,120,65,70,20,@tabstop|@cteditright,3"
showwindow win, @swhide,3
CONTROL win,"E,output,120,115,70,20,@tabstop|@cteditright,4"
showwindow win, @swhide,4
CONTROL win,"T,Sum =,75,115,30,20,0,5"
showwindow win, @swhide,5
SETFONT win, "MS Sans Serif", 9, 400,0,5
SETCONTROLCOLOR win,5,0,rgb(255,255,0)
LINE win,100,100,190,100,RGB(255,255,0)

'Add Checkbox
CONTROL win,"C,,25,150,20,20,0x50000003,6"
SETCONTROLCOLOR win,6,rgb(0,0,0),RGB(255,255,0)

run =  1
WAITUNTIL win=0
END

Handler:
SELECT @CLASS

CASE @IDCLOSEWINDOW
      CLOSEWINDOW win
   
CASE @IDCONTROL
IF @CONTROLID=1
addnumber()
ENDIF
IF (@CONTROLID=6)
mark =  GETSTATE (win, 6)
IF mark =1
SetWindowPos(win,-1,0,0,0,0,2|1)
ELSE
SetWindowPos(win,-2,0,0,0,0,2|1)
ENDIF
ENDIF

'This is the problem I don't understand. After pressing ENTER
'it runs through all the IF conditions.
CASE @IDTIMER
  IF (Enter(13) <> 0) & (focus=2)
inputa$ = GETCONTROLTEXT (win,2)
SETFOCUS win,3
focus=3
sw1=0
ENDIF
  IF (Enter(13) <> 0) & (focus=3)
inputb$ = GETCONTROLTEXT (win,3)
focus=4
ENDIF
IF (Enter(13) <> 0) & (focus=4)
result=VAL(inputa$)+VAL(inputb$)
SETCONTROLTEXT win,4,STR$(result)
ENDIF
ENDSELECT
RETURN

SUB addnumber
LINE win,100,100,190,100
showwindow win, @swrestore,2
showwindow win, @swrestore,3
showwindow win, @swrestore,4
SETCONTROLTEXT win,2,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETFOCUS win,2
focus=2
RETURN