Hi all! I have decided to go back to school possibly in winter or spring. I'm designing a calculator that contains all the knowledge of algebra to calculus.
now im having a few problems. im having a tough time getting the buttons in the right positions.
the 2nd problem is i cant get the function to show the calculation of what button the user hit.
the last problem is idk how to make the textbox readonly.
;calculator
Graphics3D 1024,768,0,2
Include "includes\blitzui.bb"
LoadColourScheme( "misc\slate.cs" )
Initialise( )
Global exitcase
width=GraphicsWidth()/4-4
height=GraphicsHeight()/2-4
xvalueChar = (GraphicsWidth()/2)-width*(0.57)
yvalueChar = (GraphicsHeight()/2)-height*(0.57)
win002 = Window( xvalueChar, yvalueChar, width, height, "Calculator", "0", 0, 0, 0, 0 )
Dim buttons(10)
;width And height relative To viewport
bwidth = width / 10
bheight = height / 15
;offset x,y relative To viewport
bts_left = width / 10
bts_top = height / 15
;Create 10 buttons
For i = 1 To 10
x = x + 1
If x = 3 Then
y = y + 1
x = 0
End If
;calculate screen position
xx = x * bwidth + bts_left
yy = y * bheight + bts_top
;make caption
s$ = i
If i = 10 Then s$ = "0"
buttons(i) = Button( xx,yy, bwidth, bheight, s$, "0", 1, 0, 0)
Next
Global butmultiply = Button( buttonmultiplyx,buttonmultiplyy, bwidth, bheight, "*", "0", 1, 0, 0 )
Global butdivide = Button( buttondividex,buttondividey, bwidth, bheight, "/", "0", 1, 0, 0 )
;TM_SETTEXT
returnans()
ans1 = TextBox((width-xvalueChar/2), 10, 92, 21, 0, 0, 18, 10, 0 )
SendMessage( ans, "WM_READONLY", 0, "" )
SendMessage( win002, "WM_SETLOCKED" )
;Windows must only be set as modal after
;the interface has been created.
SendMessage( win002, "WM_SETMODAL" )
exitcase = 0
While Not KeyHit(1)
Cls
;Draw the GUI and update the mouse
UpdateGUI( )
;Event Handling
Select app\Event
Case EVENT_WINDOW
Select app\WindowEvent
End Select
Case EVENT_MENU
Select app\MenuEvent
End Select
Case EVENT_GADGET
Select app\GadgetEvent
Case chk001
mysex = 1
Case chk002
mysex = 2
Case chk003
goodorbad = 1
Case chk004
goodorbad = 2
Case sendbut
ans1=SendMessage(ans1, "TM_GETTEXT")
;check to see if name has been entered
End Select
End Select
;Draw the mouse
DrawMouse( )
;Reset all GUI events
ResetEvents( )
UpdateWorld()
RenderWorld()
Flip
Wend
Function returnans()
If but0 <> 0 Then ans1 = 0
If but1 <> 0 Then ans1 = 1
If but2 <> 0 Then ans1 = 2
If but3 <> 0 Then ans1 = 3
If but4 <> 0 Then ans1 = 4
If but5 <> 0 Then ans1 = 5
If but6 <> 0 Then ans1 = 6
If but7 <> 0 Then ans1 = 7
If but8 <> 0 Then ans1 = 8
If but9 <> 0 Then ans1 = 9
ans1=SendMessage(ans1, "TM_GETTEXT")
Return ans1
End Function
Any help is GREATLY appreciated! :)
DS
|