View Full Version : Experimenting with an EZGUI Module for ThinBasic
Chris Boss
11-03-2016, 00:07
I am currently experimenting with an EZGUI ThinBasic module. So far I am understanding how a module works and it just may be possible to make a module out of an EZGUI runtime.
I was thinking of making a free version with limited features and possibly a commercial version with more "bells and whistles" afterwards.
If anyone would be interested in testing the free version once I get it working, please feel free to email me at: support@cwsof.com
ErosOlmi
11-03-2016, 08:25
Hi Chris,
thanks a lot for your effort.
If you need some info on how to create modules, let me know.
There is some info in thinBasic Issue number 2 at http://www.thinbasic.com/community/showthread.php?9450-ThinBasic-Journal-Issue-2
A little introductory article in parsing source code from module.
There is some material in SDK.ZIP included into all thinBasic distributions under \thinBasic\SDK\
You can also check GitHub at https://github.com/ErosOlmi/ThinBASIC_On_GitHub
There are 2 modules (Excel and Registry with full source code)
I'm sorry, I'm not sure there will be commercial market for thinBasic modules but ... who knows: maybe I'm wrong and you will open a new way.
Ciao
Eros
Chris Boss
11-03-2016, 16:38
One of the reasons I am interested in building a module for ThinBasic is that I want to do some online courses teaching BASIC. I need to have a free basic for those I teach and thinBasic is high up on my list. By creating an EZGUI module to make user interface stuff easier, then thinbasic may be the perfect teaching tool.
Also I like thinbasic because its syntax is close to PowerBasic.
As far as a commercial module for thinbasic I can see your point.
ErosOlmi
11-03-2016, 16:49
Thank you Chris,
this is a great news for thinBasic.
Let me know if you need something or have something to suggest.
Ciao
Eros
Chris Boss
11-03-2016, 16:57
One question I have is how to handle callbacks in ThinBasic modules.
For example, if I have a function WaitInput which waits for user input, is it possible to generate a callback from the module to thinbasic doe when an event occurs ?
For example, how do you handle callbacks in your UI module ?
EZGUI is all about Events, rather than API (dialog) style callbacks, but the principle is the same.
ErosOlmi
11-03-2016, 17:24
It is not the easiest are of thinBasic SDK :)
I will post an example this evening or maximum during the week-end.
I will take the example of a button of current UI module.
ErosOlmi
12-03-2016, 10:51
Dear Chris,
here attached an example of a new User Interface control called HoverButton.
HoverButton creates a new UI class using standard Windows Api RegisterClass to register a new control with its class callback.
Than control can be used in thinBasic scripts and react to messages.
IMPORTANT: because thinBasic modules are DLLs, new Windows classes must have %CS_GLOBALCLASS in WNDCLASS.Style otherwise they are not visible by thinBasic Core engine.
HoverButton control was posted by Kev Peel in PB web site at http://forum.powerbasic.com/forum/user-to-user-discussions/source-code/24875-hoverbutton-custom-control
Attached you will find:
HoverButton.inc
Include file containing HoverButton Class declaration, initialize functions and callback
thinBasic_UIHoverButton.BAS
source code of thinBasic new UIHoverButton Module
thinBasic_UIHoverButton.dll
compiled UIHoverButton module. In order to test it, place it into the same directory of the script or, if you want it available to all scripts, place it into \thinBasic\Lib\ directory
thinBasic_UIHoverButton.LNX
I use Lynx to manage PB Projects. This is Lynx project file for the module
UIHoverButton_Test.tbasic
Test script in thinBasic
Below the script using new module, so others can see it.
Hope this can help
Ciao
Eros
'________________________________________________________________________________________'
' HoverButton test program
' ========================
'
' Simple program testing the HoverButton's module capabilities
' Uses standard button messages/notifications for compatibility.
'________________________________________________________________________________________
Uses "UI"
Uses "UIHoverButton"
Begin ControlID
%IDC_BUTTON1
%IDC_BUTTON2
%IDC_BUTTON3
%IDC_BUTTON4
%IDC_BUTTON5
%IDC_BUTTON6
End ControlID
'------------------------------------------------------------------------------
' Callback function for main dialog
'------------------------------------------------------------------------------
CallBack Function dlgMain() As Long
Select Case CBMSG
Case %WM_COMMAND
If (CBCTLMSG <> %BN_CLICKED) Then Exit Function
Select Case CBCTL
Case %IDC_BUTTON1
MsgBox CBHNDL, "You clicked the first button, this button is marked as default.", "HoverButton", %MB_ICONINFORMATION
Case %IDC_BUTTON2
'---This button is a "spin" button with multiple messages on mousedown...
Static siAmount As Long
Incr siAmount
Control Set Text CBHNDL, %IDC_BUTTON2, "Spin #" + Format$(siAmount)
Control Redraw CBHNDL, %IDC_BUTTON2
Case %IDC_BUTTON3
MsgBox CBHNDL, "You checked the third button", "HoverButton", %MB_ICONINFORMATION
Case %IDC_BUTTON4
'---Set some random colors for the button...
Local ct As DWord, cb As DWord, cf As DWord
Randomize Timer
ct = Rnd(0, %WHITE)
cb = Rnd(0, %WHITE)
cf = Rnd(0, %WHITE)
Control Send CBHNDL, %IDC_BUTTON4, %HBM_SETCOLORS, ct, cb
Control Send CBHNDL, %IDC_BUTTON4, %HBM_SETHOVERCOLORS, -1, cb
Control Send CBHNDL, %IDC_BUTTON4, %HBM_SETFOCUSCOLOR, cf, 0
Control Redraw CBHNDL, %IDC_BUTTON4
Case %IDC_BUTTON5
MsgBox CBHNDL, "You clicked the old style (HBS_ORIGINAL) button", "HoverButton", %MB_ICONINFORMATION
Case %IDC_BUTTON6
MsgBox CBHNDL, "This button is disabled so this message should not be 'fired'", "HoverButton", %MB_ICONINFORMATION
End Select
End Select
End Function
'------------------------------------------------------------------------------
' Program Start Point
'------------------------------------------------------------------------------
Function TBMain() As Long
Local hDlg As DWord
Dialog New 0, "HoverButton Test", -1, -1, 210, 100, %DS_MODALFRAME Or %WS_CAPTION Or %WS_POPUP Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
Dialog Set Color hDlg, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON1, "Click Me!", 10, 10, 80, 20, %HBS_NORMAL Or %HBS_DEFAULT
Control Send hDlg, %IDC_BUTTON1, %HBM_SETCOLORS, %GREEN, %BLACK
Control Send hDlg, %IDC_BUTTON1, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON2, "Hold Down Mouse", 10, 40, 80, 20, %HBS_NORMAL Or %HBS_SPIN
Control Send hDlg, %IDC_BUTTON2, %HBM_SETCOLORS, %BLUE, %BLACK
Control Send hDlg, %IDC_BUTTON2, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON3, "Check Button", 10, 70, 80, 20, %HBS_NORMAL Or %HBS_CHECKBOX
Control Send hDlg, %IDC_BUTTON3, %HBM_SETCOLORS, %RED, %BLACK
Control Send hDlg, %IDC_BUTTON3, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON4, "Change Color", 120, 10, 80, 20, %HBS_NORMAL
Control Send hDlg, %IDC_BUTTON4, %HBM_SETCOLORS, %GRAY, %BLACK
Control Send hDlg, %IDC_BUTTON4, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON5, "Old Style", 120, 40, 80, 20, %HBS_NORMAL Or %HBS_ORIGINAL
Control Add HoverButton, hDlg, %IDC_BUTTON6, "Disabled", 120, 70, 80, 20, %HBS_NORMAL Or %WS_DISABLED
Control Send hDlg, %IDC_BUTTON6, %HBM_SETCOLORS, %GRAY, %BLACK
Dialog Show Modal hDlg Call dlgMain
End Function
eros,
thinBasic_UIHoverButton.BAS source code of thinBasic new UIHoverButton Module
What BASIC language is this file for? thinBasic uses script tbasic files.
Bill
Petr Schreiber
12-03-2016, 16:36
The module is written in PowerBASIC, it is very efficient low level BASIC compiler we use for developing most parts of thinBASIC.
Petr
ErosOlmi
12-03-2016, 17:57
eros,
What BASIC language is this file for? thinBasic uses script tbasic files.
Bill
That BASIC is Power Basic
thinBasic modules, thinBasic Core, thinAir, thinDebug are all developed using Power Basic compiler for Windows: http://powerbasic.com/pbwin.php
To my opinion is one of the best 32bit compiler around, regardless of the language itself.
Its syntax is very very close to thinBasic (well ... the other way round) so if you like thinBasic you will love Power Basic.
It creates super efficient code both dll and exe. It has OOP but you can program the without.
Its strings are one of the best string system around: OLE32 strings or BSTR strings. thinBasic has the same string handling.
Chris Boss is an "old" (in terms of years spent using PowerBasic) PowerBasic user.
Michael Hartlef
16-03-2016, 14:46
Sorry to hijack this Topic, but is there any other SDK on the same Level as the PowerBasic one?
ErosOlmi
16-03-2016, 17:51
Not now.
I experimented with FreeBasic and was quite OK but problem is always related to String handling.
thinBasic uses OLE32 BSTR strings. Other language uses other kind of strings. Making conversions in/out is very inefficient.
I made also some experiment using FreePascal than has WideString that are identical to BSTR strings except for functions returning strings.
Here are some explanation of the problem: http://stackoverflow.com/questions/9349530/why-can-a-widestring-not-be-used-as-a-function-return-value-for-interop
Eros,
If you praise Power Basic so much and you even use it to write thinBasic, why do you do thinBasic? I know it's freeware and Power Basic is shareware (I think almost $100 USD.)
Eros, if I may, I have wanted to mention several times before. Petr is Czech, Rene is German, and you are Italian. You three must be highly educated. The English of you three is some of the best I have seen, and I am speaking of Americans and British. Speaking the language in one thing, but the thought process you three display in it is as though it is your native language, not a second (or for all I know, a third or more), plus, highly educated.
Bill
ErosOlmi
17-03-2016, 08:40
:D
Regarding Power Basic and thinBasic: the only fact that one is a compiler (Power Basic) and the other is an interpreter (thinBasic) put them into complete different categories.
You cannot compare a compiled language able to execute billions of instructions in few milliseconds with an interpreted language that is at least hundred of times slower (sometimes thousands). Who needs speed must always go to compiled languages.
thinBasic try to recover from this speed gain having many compiled native commands (thinBasic keywords/commands/modules) able to perform more operations with a single command. This reduce the number of instructions you need to write earning some of the time lost in interpretation of the source code.
The only thing that is really in common is syntax: we love BASIC like syntax.
Power Basic has a lot more capabilities that I still have to find a way to do in thinBasic: native COM component interface and a powerful OOP just to mention few.
But thinBasic was not only inspired by Power Basic: I get some inspiration from PHP and other languages like AutoIt and even from languages I hate like C, C++ and C#
Why thinBasic: well, difficult to say. All started without a precise project but as a tool for personal use ...
Then, day by day, it become what it is now: a mix of passion, challenge, needs at work, joy to have and idea and being able to solve using programming.
During this journey I had the lucky to meet great people, like the one you mentioned, and others with similar passions. What's best?
We all do other things and work in real life but this project and this community were (at least for me) something important.
Regarding personal education ... every people has its trip in life. Sometimes missing education can be recovered with great passion and dedication to a target you absolutely want to get.
Many of us love to study new things as a personal attitude: there is always something new and interesting things to feed the brain. This is enough for many situations.
Eros,
Thanks for the detailed explanation. Yes, speed and billions of instruction in a few milliseconds do count.
there is always something new and interesting things to feed the brain. I consider it a wasted day if I do not learn something new.
Thanks, again,
Bill
i don't use powerbasic, but i am watching its forum.
the return of the company members and forum members also the reviving of its forum and the notes from here and there, makes me optimistic that they work on a x64 version of the product, since it is the x64 is the very near future . and i wish to powerbasic a good future like the old time.
Petr Schreiber
17-03-2016, 23:25
Regarding education - I think it was the communication with Eros which motivated me to find better ways to express in English. And as for the programming, again, I learned more by working (although remotely) with Eros than on the University lessons (although there were some nice ones) :)
I think the Star Wars model of sith lord and its apprentice has some true to it. Mass education is important, but personal approach is always the king!
Petr
I preciate the replies. I think that when I get some thing paid off, I purchase Power Basic. To tell you the truth, I have not heard anything bad about it.
Bill
Michael Hartlef
18-03-2016, 19:34
Not now.
I experimented with FreeBasic and was quite OK but problem is always related to String handling.
thinBasic uses OLE32 BSTR strings. Other language uses other kind of strings. Making conversions in/out is very inefficient.
I made also some experiment using FreePascal than has WideString that are identical to BSTR strings except for functions returning strings.
Here are some explanation of the problem: http://stackoverflow.com/questions/9349530/why-can-a-widestring-not-be-used-as-a-function-return-value-for-interop
Which PowerBasic version is need at the minimum these days? Is 9 enough?
ErosOlmi
19-03-2016, 09:54
PB 10 as a huge number of new features compared to 9 but for what is concerning to develop thinBasic modules, PB 9 is OK.