christianssen
19-03-2010, 10:07
... please delete this post, thanks. denis
christianssen
19-03-2010, 11:59
little progress ;)
I have now wished feedback for numbers, forgotten "Select Case CBCTL" and changed my first example. it's not perfect, I know, but it's a good step to right direction.
better numeric calcinput example:
' Empty GUI script created on 03-18-2010 20:42:49 by (ThinAIR)
Uses "console", "ui"
%idOk1 = 101
%btnTest = 102
%label1 = 103
%textbox1 = 104
%textbox2 = 105
%result = 106
%Number1 = 107
%number2 = 108
%ButtonClose = 109
%multiply = 110
'-----------------------------------------------tbmain ------------------
Function TBMain() As Long
Local hDlg As DWord
Dialog New 0, "Numeric CalcInput Test", -1, -1, 240, 180, %WS_CAPTION Or %WS_SYSMENU To hDlg
Control Add Label, hDlg, %label1, "-+,.1234567890 is allowed", 40, 15, 120, 20
Control Add Button, hDlg, %IDOK, "Test", 75, 60, 50, 15
Control Add Button, hDlg, %result, "result", 25, 60, 50, 15
Control Add Button, hDlg, %Number1, "<5>", 165, 60, 25, 25
Control Add Button, hDlg, %number2, "<25>", 195, 60, 25, 25
Control Add Button, hDlg, %multiply, "<Multiply*>", 160, 30, 55, 25
Control Add Textbox, hDlg, %textbox1, "", 45, 90, 100, 14
Control Add Textbox, hDlg, %textbox2, "", 75, 120, 120, 14
Control Add Button, hDlg, %ButtonClose, "close", 25, 140, 50, 15, Call cbDialog
Dialog Show Modal hDlg, Call DlgProc
End Function
'------------------callback -----------
CallBack Function DlgProc() As Long
Local sTest As String '
Local x As Long
Local tTest As String
Local p As String
Local s As String
Local zText As Asciiz*4
Local zText2 As Asciiz*4
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %IDOK
'If CBWPARAM = %IDOK Then
Control Get Text CBHNDL, %textbox1 To sTest
MsgBox 0, "sTest = "+stest, ,"Result"
'End If
Case %textbox1
'If CBWPARAM = %textbox1 Then
Control Get Text CBHNDL, %textbox1 To sTest
x = Verify (sTest , "-+,.1234567890")
If x > 0 Then
Beep 100
sTest = Remove$(sTest, Mid$(sTest, x, 1))
Control Set Text CBHNDL, %textbox1, sTest
Control Send CBHNDL, %textbox1, %EM_SETSEL, x-1, x-1
'Control Send hwnd, ctrlID, Msg, wParam, lParam [ To Result]
'End If
End If
Case %textbox2
'If CBWPARAM = %textbox2 Then
'If CBCTLMSG = %EN_UPDATE Then
Control Get Text CBHNDL, %textbox2 To tTest
x = Verify (tTest , "-+,.01234567890")
If x > 0 Then
Beep 100
tTest = Remove$(tTest, Mid$(tTest, x, 1))
Control Set Text CBHNDL, %textbox2, tTest
Control Send CBHNDL, %textbox2, %EM_SETSEL, x-1, x-1
' End If
End If
Case %result
'If CBWPARAM = %result Then
Control Get Text CBHNDL, %textbox2 To tTest
MsgBox 0,"5*25 = " + multy
'End If
Case %Number1
'If CBWPARAM = %Number1 Then
zText = "5"
Control Send CBHNDL, %textbox1, %EM_REPLACESEL, %TRUE, VarPtr(zText)
MsgBox 0, "ok: shows number 5"
' End If
Case %number2
'If CBWPARAM = %Number2 Then
zText2 = "25"
Control Send CBHNDL, %textbox2, %EM_REPLACESEL, %TRUE, VarPtr(zText2)
MsgBox 0, "ok: shows number 25"
'End If
End Select
End Select
End Function
'------------------/DlgProc -----------
Function multy() As Long
Dim valux,v As Long
v = 5*25
Function = v
'Function = valux*valux
End Function
'------------------/function multiply
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
I will try find solution :) my aim to make calculation (multiply) after number (5,25) clicking.
last edit: this afternoon.
qt: I am looking for a thinbasic example for input/output numbers (values) or calculation with modal feedback!
thanks, bye, denis
Petr Schreiber
19-03-2010, 17:19
Hi Denis,
thanks for sharing.
One side note - you tend to do similar thing Frank did in the past -> to guarantee the IDs of the controls are correct, please do not use random numbers, but use:
Begin ControlID
%idOk1
%btnTest
%label1
%textbox1
%textbox2
%result
%Number1
%number2
%ButtonClose
%multiply
End ControlID
Petr
Michael Clease
19-03-2010, 18:14
Have a look in the samplescripts
C:\thinBasic\SampleScripts\UI\Calculator
:D
christianssen
22-03-2010, 09:44
thanks for infos and link, petr, michael clease. I will try to understand calculator example. looks very interesting. who has built this example ? good strike ;)
bye, denis
(ps. with less time this week, I will have four hard examinations this week. yoh!)
Lionheart008
26-03-2010, 22:34
hi denis.
by chance I found in my archive this example for calculation and find results with textboxes.
Hope this one can help for progress.
good evening, frank
christianssen
29-03-2010, 11:26
hello lionheart, many thanks for this little and precious example :D
bye, denis
:)
hi denis.
by chance I found in my archive this example for calculation and find results with textboxes.
Hope this one can help for progress.
good evening, frank
:p Hi, I took Frank's example and did a calculator. It's not done yet, but it's comming along good.7356
ErosOlmi
27-07-2011, 08:07
Dear steinie,Thanks a Lot for experimenting with thinBasic.Hope you will have nice time using it.CiaoEros