IonicWind Software

Creative Basic => GUI Programs => Topic started by: Hobo on April 16, 2010, 04:40:28 PM

Title: Question for more improvement
Post by: Hobo on April 16, 2010, 04:40:28 PM
Greetings to all. You may remember me. Frustrated CB beginner, but all the help form Paul, Graham, Aurel, Mike, just to list a few, I slowly progressed.  Eventually I have written a pretty useful program that has aided my work since. I recently rewritten, reorganized and added new features to it. It is version 3 now.  :)
It is more likely useless to anybody, but me, but if you are a beginner, this program may able to guide you toward programmers’ world. It is all there to start. Basic GUI, controls, layers of windows, input, output, stay on top etc. It also very easy to change to your needs if you need a repeating math calculations.
Title: Re: Just an other program
Post by: GWS on April 17, 2010, 12:50:45 AM
Thanks Hobo ..  :)

Hmm .. 'repeating math calculations' .. sounds interesting ..  :P

You never know when a nice bit of code will also come in useful for some other application ..

all the best, :)

Graham
Title: Question for more improvement
Post by: Hobo on April 19, 2010, 10:39:36 AM
I would like improve one more way my program. When I toggle my cursor (setfocus) between more then one Edit Controls I would like to not only place my cursor there but highlight the text, if there any, to over write with the new entry. Because the way is now, I manually have to delete the text for the new entry. Is there an easy way to that? I would like to add that I know Tab would do that, but I would like to jump one Edit Box to another by pressing Return key.
Title: Re: Question for more improvement
Post by: mrainey on April 19, 2010, 01:56:29 PM
With Emergence, I do it like this:

    SetFocus WindowName,ControlName
    ControlCmd WindowName,ControlName,@EDSetSelection,0,-1


It's worth a try in Creative.
Title: Re: Question for more improvement
Post by: Hobo on April 19, 2010, 02:13:34 PM
Sure it works.  :)
Thanks a lot Mike. This way using the program as I do, speeds the process up greatly.
This is just too cool.

George
Title: Re: Question for more improvement
Post by: REDEBOLT on April 19, 2010, 02:19:15 PM
Hobo,

Thanks for a well designed and organized program.  I will use it as a model when developing my own programs.  I have one question though:

"What numbers do I enter in the text boxes, and what does the program do with them?"
Title: Re: Question for more improvement
Post by: Hobo on April 19, 2010, 03:18:33 PM
I work for a Pump Ind. I produce curves (flow, head, efficiency etc.) I use pretty basic equations or series of math over and over plugging different numbers in of course. So, this program is more like an aid to produce graphical curve in X,Y coordinate setup. Also it is very compact, because I want to keep it on top of all windows, so I want it as small as possible. CurveWiz as right now includes 7 math functions. For example the first one (AFF) is a Affinity Law. A given point on the X, Y coordinate will be scaled by RPM change. In other words by changing the RPM it gives me the X and Y scaling factors.

But look at the last function â€Ã...“Head SCLâ€Ã,. On the coordinate system I want to show 1â€Ã, equal 50 feet ratio. Type 50 into the â€Ã...“Feet at inchâ€Ã, (There is a typo there. It says GPM at inch instead of Feet at inch. Just ignore it). Press Enter. It says 50 feet equal 15.24 meter. That gives me an idea to draw a 20 meter scale ratio so enter 20 into the â€Ã...“Muliply byâ€Ã,. Now it shows â€Ã...“Meter Scaleâ€Ã, equal 1.312. That means I am able to draw a meter scale into the coordinate system with 20 meter increments that is 1.312 inch in length.  

Well, I don’t know how clear my explanation was, but I honestly tried. :)
Here is a more simple code for a simple calculator that adds 2 or 3 numbers together. This program was one of my learning products to learn CB. I hope that helped.  :)
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
DECLARE "user32",GetForegroundWindow(),INT

DEF win:WINDOW
DEF add2numberopen,add3numberopen,focus,sw1,sw2:INT
DEF inputa$,inputb$,inputc$,result$:STRING
DEF MyWin:INT

WINDOW win,0,0,200,300,@MINBOX,0," Add Numbers",Handler
SETWINDOWCOLOR win,RGB(255,255,0)

SETPRECISION 3
CENTERWINDOW win
ENABLETABS win,1
STARTTIMER win,10,1

'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

'Add edit fields
CONTROL win,"E,inputZ,120,15,70,20,@tabstop|@cteditright,9"
showwindow win, @swhide,9
CONTROL win,"E,inputX,120,40,70,20,@tabstop|@cteditright,3"
showwindow win, @swhide,3
CONTROL win,"E,inputY,120,65,70,20,@tabstop|@cteditright,4"
showwindow win, @swhide,4
CONTROL win,"E,output,120,115,70,20,@tabstop|@cteditright,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)
CONTROL win,"T,Click to Stay on Top,20,180,150,20,0,12"
SETCONTROLCOLOR win,12,0,rgb(255,255,0)

MyWin = win
run =  1
WAITUNTIL win = 0
END

Handler:
SELECT @CLASS

CASE @IDCLOSEWINDOW
CLOSEWINDOW win
  CASE @IDCONTROL
IF (@controlid=1)
SETCONTROLTEXT win,9,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETCONTROLTEXT win,7,""
SETFOCUS win,3
focus=3
sw1=1
ENDIF
IF (@CONTROLID=2)
SETCONTROLTEXT win,9,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETCONTROLTEXT win,7,""
SETFOCUS win,9
focus=9
sw1=0
ENDIF
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
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
CASE @IDTIMER & (MyWin = GetForegroundWindow())
  IF (Enter(13) <> 0)&(sw1=1)
do:until Enter(13) = 0
add2numberoperation()
ENDIF
  IF (Enter(13) <> 0)&(sw2=0)
do:until Enter(13) = 0
add3numberoperation()
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
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
add3numberopen=1

SUB add2numberoperation
select focus

case 3
inputa$ = GETCONTROLTEXT (win,3)
SETFOCUS win,4
focus=4
case 4
inputb$ = GETCONTROLTEXT (win,4)
result=VAL(inputa$)+VAL(inputb$)
SETCONTROLTEXT win,7,STR$(result)
SETFOCUS win,1
focus=5
case 5
SETCONTROLTEXT win,9,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETCONTROLTEXT win,7,""
SETFOCUS win,3
focus=3
sw1=1
endselect
RETURN

SUB add3numberoperation
select focus

case 9
inputa$ = GETCONTROLTEXT (win,9)
SETFOCUS win,3
focus=3
case 3
inputb$ = GETCONTROLTEXT (win,3)
SETFOCUS win,4
focus=4
case 4
inputc$ = GETCONTROLTEXT (win,4)
result=VAL(inputa$)+VAL(inputb$)+VAL(inputc$)
SETCONTROLTEXT win,7,STR$(result)
SETFOCUS win,2
focus=6
case 6
SETCONTROLTEXT win,9,""
SETCONTROLTEXT win,3,""
SETCONTROLTEXT win,4,""
SETCONTROLTEXT win,7,""
SETFOCUS win,9
focus=9
sw1=0
endselect
RETURN