Quote:
' Empty GUI script created on 04-05-2011 18:54:03 by lionheart008 (ThinAIR)
Uses "UI", "console"
Begin Const
%cCanvasSB = %WM_USER + 500
%cCanvasDB
%btnClose
%btnPause
%texty
%btnstop
%tAnimationTimer
End Const
' 1) -- main dialog ------------------------------------------
Function TBMain()
Local hDlg As DWord
Dim cx, cy As Long
Dialog New 0, "Canvas numeric loops + counter for fun :)",-1,-1, 300, 180, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX, 0 To hDlg
Dialog Pixels hDlg, 200, 200 To Units cx, cy
Control Add Canvas, hDlg, %cCanvasDB, "", cx-50, 25, cx,cy
Control Add Textbox, hDlg, %texty, " ", 225,25,cx-45,cy-55
Control_SetText(hdlg, %texty,"still empty")
'Control Add Label, hDlg, %texty, " ", 225,25,cx-45,cy-55
Control Add Button, hDlg, %btnstop, "stop proggy", cx-35, 30+cy, cx-50, 14
Control Add Button, hDlg, %btnClose, "Click to close", 60+cx, 30+cy, cx-50, 14, Call btnCloseProc
Control Add Button, hDlg, %btnPause, "pause", cx-125, 30+cy, cx-50, 14 ', Call btnCloseProc
Dialog Show Modal hDlg, Call dlgProc
End Function
' -- 2) Callback for dialog -------------------------------->
CallBack Function dlgProc()
Local pauseflag As Long
Static counterx, counterz As Single
Local hdlg As DWord
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %btnPause Then
PauseFlag = IIf(PauseFlag = %TRUE, %FALSE, %TRUE)
End If
If PauseFlag = %TRUE Then
Sleep 750
DoEvents
'Iterate While
End If
If CBWPARAM = %btnStop Then
MsgBox 0, "click ok-> stop now program and fine"
Stop
End If
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %tAnimationTimer, 20, %NULL
Case %WM_TIMER
Canvas_Attach(CBHNDL, %cCanvasDB, %TRUE)
DrawGraphics()
'---------------------------------> counter idea 2 ----------------->
If counterx >= 0 Then
End If
Do
Incr Counterx
Console_WriteLine("--> counting up to 21 ->" + Format$(Counterx-1, "#.00")) '+Str$(Counterx))
If Counterx <= 21 Then Exit Do'And Counterx >= 22 Then Exit Do
Stop
Loop
Control_SetText(CBHNDL, %texty,"counter slowly.."+Str$(counterx)) 'Str$(counterx))
'---------------------------------> counter idea 2 end ----------------->
Canvas_Redraw
Case %WM_CLOSE
End Select
End Function
' -- 3) Callback for close button -------------------------------------->
CallBack Function btnCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End If
End Function
' 4)--------> loops and calculations ----------------------------------------->
Sub DrawGraphics()
Local hdlg As DWord
Local lenx,leny,proport,zx,zy,i,j As Long
Local a,b,c,d,zero, cnt, found As Long
Local CmdLine,CmdLine1,CmdLine2,CmdLine3,CmdLine4,CmdLine0 As String
Local rnda, rndb,rndc,rndd,rndzero As String
cnt = 0
For a = 1 To 4 'Until found = %TRUE
If a > 1 Then rnda = rnda + "VT"
For b = 1 To 4
If b = 4 And a >= 1 Then rndb = rndb + "XA" ' 4 x 4 = 16 a x b
For c = 1 To 4 ' 4 x 16 = 64 a x b x c
If c = 4 And b = 1 Then rndc = ""
If c = 4 And d = 5 Then rndc = rndc + "YB"
For d = 1 To 4 ' 4 x 64 = 256
cnt = cnt +1
If d = 4 And c = 1 Then rndd = ""
If d = 4 Then rndd = rndd + "ZC"
For zero = 1 To 4
If zero = 4 And d = 4 And a>=4 Then rndzero = rndzero + "+"
'found = %TRUE
CmdLine = "4. Loop : " + Format$(a) + " " + rnda
CmdLine1 = "3. Loop : " & Format$(b) + " " + rndb
CmdLine2 = "2. Loop : " & Format$(c) + " " + rndc
CmdLine3 = "1. Loop : " & Format$(d) + " " + rndd
CmdLine0 = "FunLoop : " & Format$(zero) + " " + rndzero
CmdLine4 = "to 256 at: "+ Format$(cnt)
If cnt = 257 Then Exit For
Canvas_Color Rgb(128, 255, 0), Rgb(100, 0, 0)
Canvas_Clear(Rgb(0,0,0))
Canvas_SetPos(25,12)
Canvas_Printl ""
Canvas_SetPos(25,20)
Canvas_Printl " > " + CmdLine
Canvas_SetPos(25,28)
Canvas_Printl " > " + CmdLine1
Canvas_SetPos(25,36)
Canvas_Printl " > " + CmdLine2
Canvas_SetPos(25,44)
Canvas_Printl " > " + CmdLine3
Canvas_SetPos(25,52)
Canvas_Printl " > " + CmdLine0
Canvas_SetPos(25,60)
Canvas_Printl " "
Canvas_SetPos(25,72)
Canvas_Printl " > " + CmdLine4
Canvas_Box (zx+10, zy+10, zx+120, zy+100, 0, %BLUE)
Canvas_Redraw
Next
Next
Next
Next
Next
End Sub
' 5) ---------------------> counter idea one -------------->
Sub counters()
Static counterx As Single
Local hdlg As DWord
counterx = 0
Do
Incr Counterx
Console_WriteLine("--> counter :"+Str$(Counterx))
If Counterx > 200 Then Exit Do
'PrintL "exit loop"
SendMessage hdlg,%EM_GETSEL, %texty,VarPtr(counterx)
Control_SetText(hDlg, %texty,Str$(counterx))
Loop
End Sub
'---------------------> counter idea -------------->
I add all example in zip folder. thanks, nice day, best regards, franko :)