ErosOlmi
08-09-2013, 12:22
thinBasic Beta 1.9.8.0
Download from: http://www.thinbasic.biz/projects/thinbasic/thinBasic_1.9.8.0.zip
This is a real Beta in the sense there is a lot of new features all (more or less) to be finished and fully documented.
So, please use this version only for testing and not for real production scripts.
Have a look and please report any impression/problem/likes always remembering it is a beta!!!!!
Fixed some bugs
Added latest TBGL module from Petr Schreiber
...
List of changes can be found in Help file distributed with the product.
In this version I introduced a new way to handle Window Events.
Programmer can Name a Window using new Name "DialogName" option. Window name is used to create specific events callback functions automatically executed by thinBasic UI engine when such an event occurs. Window names is indicated in DIALOG NEW ... statement (see help)
Here an example:
uses "UI"
Uses "console"
Begin ControlID
%IDC_TIMER
%IDC_LABEL
%IDC_Start
%IDC_Stop
End ControlID
%TIMER_DELAY = 10 ' Timer delay (in milliseconds, not very accurate below about 100)
Global TimerValue As Double '---Will be used to calculate timer values
'------------------------------------------------------------------------------
' Main function
'------------------------------------------------------------------------------
FUNCTION TBMain() as long
LOCAL hDlg AS DWORD
Dialog New Name "TimerDialog", 0 , "Timer Example using CallBacks functions", -1, -1, 240, 40, %WS_OVERLAPPEDWINDOW To hDlg
CONTROL ADD BUTTON, hDlg, %IDC_Start, "Start" , 10, 10, 50, 20
CONTROL ADD LABEL , hDlg, %IDC_LABEL, "" , 90, 10, 55, 20, %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_CENTERIMAGE OR %SS_CENTER
CONTROL ADD BUTTON, hDlg, %IDC_Stop , "Stop" , 180, 10, 50, 20
Dialog Show Modal hDlg 'Call MainDialog_OnCallBack
END FUNCTION
'------------------------------------------------------------------------------
' OnCallBack
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnCallBack() As Long
PrintL Timer, Function_Name, CBMSG
End Function
'------------------------------------------------------------------------------
' OnCommand
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnCommand() As Long
Select Case CBCTL
'---Check which control as fired the event
Case %IDC_Start
'---If start, than enable/disable relevant buttons and activate the timer
Control Disable CBHNDL, %IDC_Start
Control Enable CBHNDL, %IDC_Stop
TimerValue = 0 '---Set the time counter to zero
Dialog Set Timer CBHNDL, %IDC_TIMER, %TIMER_DELAY
Case %IDC_Stop
'---If sstop, than enable/disable relevant buttons and destroy the timer
Control Disable CBHNDL, %IDC_Stop
Control Enable CBHNDL, %IDC_Start
Dialog Kill Timer CBHNDL, %IDC_TIMER
End Select
End Function
'------------------------------------------------------------------------------
' OnInit
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnLoad() As Long
Control Disable CBHNDL, %IDC_Stop
End Function
'------------------------------------------------------------------------------
' OnTimer
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnTimer() As Long
'---This event is fired by any timer created on the dialog. We have to check which one
'---CBWPARAM contains the ID of the timer that fired %WM_TIMER event
'---More than one timer can be active sumultaneously
Select Case CBWPARAM
Case %IDC_TIMER
'---Increment and set the test value...
TimerValue += 0.01
Control Set Text CBHNDL, %IDC_LABEL, Format$(TimerValue, "#0.00")
End Select
End Function
'------------------------------------------------------------------------------
' OnSize
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnSize() As Long
PrintL Timer, "Sizing", CBWPARAM, CBLPARAM
End Function
'------------------------------------------------------------------------------
' OnMove
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnMove() As Long
PrintL Timer, "Moving", CBWPARAM, CBLPARAM
End Function
Looking at the above example ....
Dialog New Name "TimerDialog", 0 , "Timer Example using CallBacks functions", -1, -1, 240, 40, %WS_OVERLAPPEDWINDOW To hDlg
Indicates that the dialog is names "TimerDialog", so automatic events callbacks are named TimerDialog followed by the handled event: TimerDialog_OnLoad(), TimerDialog_OnLoad(), ...
All callbacks, like all Window callbacks, will automatically receive the standard automatic pseudo variables like: CBHNDL, CBMSG, CBWPARAM, CBLPARAM, ...
So far I've developed the following automatic event functions:
Dialog Automatic Event Callback Function added: <DialogName>
Dialog Automatic Event Callback Function added: <DialogName>_OnCallBack
The above two functions are the standard callback function for the window and (if one is present) they are used to substitute the callback functions indicated in DIALOG SHOW ...
Dialog Automatic Event Callback Function added: <DialogName>_OnNotify
Dialog Automatic Event Callback Function added: <DialogName>_OnShow
Dialog Automatic Event Callback Function added: <DialogName>_OnSizing
Dialog Automatic Event Callback Function added: <DialogName>_OnMoving
Dialog Automatic Event Callback Function added: <DialogName>_OnActivate
Dialog Automatic Event Callback Function added: <DialogName>_OnDestroy
Dialog Automatic Event Callback Function added: <DialogName>_OnSysCommand
Dialog Automatic Event Callback Function added: <DialogName>_OnCallBack
Dialog Automatic Event Callback Function added: <DialogName>_OnClose
Dialog Automatic Event Callback Function added: <DialogName>_OnCommand
Dialog Automatic Event Callback Function added: <DialogName>_OnTimer
Dialog Automatic Event Callback Function added: <DialogName>_OnLoad
Dialog Automatic Event Callback Function added: <DialogName>_OnInit
Dialog Automatic Event Callback Function added: <DialogName>_OnMove
Dialog Automatic Event Callback Function added: <DialogName>_OnSize
The above methods can live face to face with the current one so programmer is free to choose if to create a big callback function full of SELECT CASE ... END SELECT messages or add a name to the dialolog and use automatic events handling.
If this new way will function as expected I will add more Windows events and start to add this new technique to controls too.
I've also started to change thinBasic tutorial example ( \thinBasic\Tutorial\ ) to adhere to the new way of events handling. So have a look at it too.
Known bugs:
among others (I hope not so many) I know there is a bug in this version when creating bundled exe. Some process can sometimes fail due to incorrect TOC inside Exe. I'm working on solving this problem asap.
Ciao.
Eros
Download from: http://www.thinbasic.biz/projects/thinbasic/thinBasic_1.9.8.0.zip
This is a real Beta in the sense there is a lot of new features all (more or less) to be finished and fully documented.
So, please use this version only for testing and not for real production scripts.
Have a look and please report any impression/problem/likes always remembering it is a beta!!!!!
Fixed some bugs
Added latest TBGL module from Petr Schreiber
...
List of changes can be found in Help file distributed with the product.
In this version I introduced a new way to handle Window Events.
Programmer can Name a Window using new Name "DialogName" option. Window name is used to create specific events callback functions automatically executed by thinBasic UI engine when such an event occurs. Window names is indicated in DIALOG NEW ... statement (see help)
Here an example:
uses "UI"
Uses "console"
Begin ControlID
%IDC_TIMER
%IDC_LABEL
%IDC_Start
%IDC_Stop
End ControlID
%TIMER_DELAY = 10 ' Timer delay (in milliseconds, not very accurate below about 100)
Global TimerValue As Double '---Will be used to calculate timer values
'------------------------------------------------------------------------------
' Main function
'------------------------------------------------------------------------------
FUNCTION TBMain() as long
LOCAL hDlg AS DWORD
Dialog New Name "TimerDialog", 0 , "Timer Example using CallBacks functions", -1, -1, 240, 40, %WS_OVERLAPPEDWINDOW To hDlg
CONTROL ADD BUTTON, hDlg, %IDC_Start, "Start" , 10, 10, 50, 20
CONTROL ADD LABEL , hDlg, %IDC_LABEL, "" , 90, 10, 55, 20, %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_CENTERIMAGE OR %SS_CENTER
CONTROL ADD BUTTON, hDlg, %IDC_Stop , "Stop" , 180, 10, 50, 20
Dialog Show Modal hDlg 'Call MainDialog_OnCallBack
END FUNCTION
'------------------------------------------------------------------------------
' OnCallBack
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnCallBack() As Long
PrintL Timer, Function_Name, CBMSG
End Function
'------------------------------------------------------------------------------
' OnCommand
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnCommand() As Long
Select Case CBCTL
'---Check which control as fired the event
Case %IDC_Start
'---If start, than enable/disable relevant buttons and activate the timer
Control Disable CBHNDL, %IDC_Start
Control Enable CBHNDL, %IDC_Stop
TimerValue = 0 '---Set the time counter to zero
Dialog Set Timer CBHNDL, %IDC_TIMER, %TIMER_DELAY
Case %IDC_Stop
'---If sstop, than enable/disable relevant buttons and destroy the timer
Control Disable CBHNDL, %IDC_Stop
Control Enable CBHNDL, %IDC_Start
Dialog Kill Timer CBHNDL, %IDC_TIMER
End Select
End Function
'------------------------------------------------------------------------------
' OnInit
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnLoad() As Long
Control Disable CBHNDL, %IDC_Stop
End Function
'------------------------------------------------------------------------------
' OnTimer
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnTimer() As Long
'---This event is fired by any timer created on the dialog. We have to check which one
'---CBWPARAM contains the ID of the timer that fired %WM_TIMER event
'---More than one timer can be active sumultaneously
Select Case CBWPARAM
Case %IDC_TIMER
'---Increment and set the test value...
TimerValue += 0.01
Control Set Text CBHNDL, %IDC_LABEL, Format$(TimerValue, "#0.00")
End Select
End Function
'------------------------------------------------------------------------------
' OnSize
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnSize() As Long
PrintL Timer, "Sizing", CBWPARAM, CBLPARAM
End Function
'------------------------------------------------------------------------------
' OnMove
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnMove() As Long
PrintL Timer, "Moving", CBWPARAM, CBLPARAM
End Function
Looking at the above example ....
Dialog New Name "TimerDialog", 0 , "Timer Example using CallBacks functions", -1, -1, 240, 40, %WS_OVERLAPPEDWINDOW To hDlg
Indicates that the dialog is names "TimerDialog", so automatic events callbacks are named TimerDialog followed by the handled event: TimerDialog_OnLoad(), TimerDialog_OnLoad(), ...
All callbacks, like all Window callbacks, will automatically receive the standard automatic pseudo variables like: CBHNDL, CBMSG, CBWPARAM, CBLPARAM, ...
So far I've developed the following automatic event functions:
Dialog Automatic Event Callback Function added: <DialogName>
Dialog Automatic Event Callback Function added: <DialogName>_OnCallBack
The above two functions are the standard callback function for the window and (if one is present) they are used to substitute the callback functions indicated in DIALOG SHOW ...
Dialog Automatic Event Callback Function added: <DialogName>_OnNotify
Dialog Automatic Event Callback Function added: <DialogName>_OnShow
Dialog Automatic Event Callback Function added: <DialogName>_OnSizing
Dialog Automatic Event Callback Function added: <DialogName>_OnMoving
Dialog Automatic Event Callback Function added: <DialogName>_OnActivate
Dialog Automatic Event Callback Function added: <DialogName>_OnDestroy
Dialog Automatic Event Callback Function added: <DialogName>_OnSysCommand
Dialog Automatic Event Callback Function added: <DialogName>_OnCallBack
Dialog Automatic Event Callback Function added: <DialogName>_OnClose
Dialog Automatic Event Callback Function added: <DialogName>_OnCommand
Dialog Automatic Event Callback Function added: <DialogName>_OnTimer
Dialog Automatic Event Callback Function added: <DialogName>_OnLoad
Dialog Automatic Event Callback Function added: <DialogName>_OnInit
Dialog Automatic Event Callback Function added: <DialogName>_OnMove
Dialog Automatic Event Callback Function added: <DialogName>_OnSize
The above methods can live face to face with the current one so programmer is free to choose if to create a big callback function full of SELECT CASE ... END SELECT messages or add a name to the dialolog and use automatic events handling.
If this new way will function as expected I will add more Windows events and start to add this new technique to controls too.
I've also started to change thinBasic tutorial example ( \thinBasic\Tutorial\ ) to adhere to the new way of events handling. So have a look at it too.
Known bugs:
among others (I hope not so many) I know there is a bug in this version when creating bundled exe. Some process can sometimes fail due to incorrect TOC inside Exe. I'm working on solving this problem asap.
Ciao.
Eros