Page 7 of 7 FirstFirst ... 567
Results 61 to 70 of 70

Thread: thinBasic 1.10.x

  1. #61
    Member Kuron's Avatar
    Join Date
    Sep 2017
    Location
    Nashville
    Posts
    54
    Blog Entries
    2
    Rep Power
    6
    That is nice to know. Redownloading TB as I managed to completely bork it last night.

  2. #62
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    I'm very close to release thinBasic Beta 1.10.5
    New version will be focused on improving message handling in User Interface module.

    Mainly I'm expanding the possibility to give a name to every controls (so far only available for Label, Textbox, Button and TreeView) and using that name plus the even name in callback functions it will be possible to trap specific events without the need to have big main window Select/End select cases for events.

    In below example there are no callback declared in DIALOG NEW ... or CONTROL ADD ... but both Dialog and Controls has been declared with ... Name "..." ... clause that gives a name to the object like: "MyWindow", "txtFind", "CloseMe", ...
    Creating a Callback function having function name equal to the Dialog or Control name followed by the event you want to handle is the only thing you need to add to do in order to trap a specific event ad act according to your needs.
    I'm trying to add the most common events. Done that I will add more uncommon events.

    More or less it will be like old VB6 events.

    An example can show you what I mean. Also attached a Bundled example.
    USES "UI"
    uses "console"
    
    
    '---Define a button ID
    begin ControlID
      %ButtonClose
      %ButtonNew
      %lblFind
      %txtFind
      %lblReplace
      %txtReplace
    end ControlID
    
    
    Dim hDlg As DWORD
    
    
    DIALOG New Pixels, Name "MyWindow", 0, "Dialog to show automatic events handling",-1,-1, 640, 480,
                                       %WS_DLGFRAME Or %DS_CENTER Or %WS_CAPTION Or %WS_SYSMENU Or %WS_OVERLAPPEDWINDOW,
                                       0 To hDlg
    
    
    CONTROL ADD Label   Name "lblFind"    , hDlg, %lblFind     , "Find"    ,  10, 15, 350, 20, %SS_NOTIFY
    CONTROL ADD Textbox Name "txtFind"    , hDlg, %txtFind     , ""        ,  10, 30, 350, 25, %ES_AUTOHSCROLL | %ES_LEFT | %WS_BORDER | %WS_TABSTOP
    
    
    CONTROL ADD Label   Name "lblReplace" , hDlg, %lblReplace  , "Replace" ,  10, 55, 350, 20, %SS_NOTIFY
    CONTROL ADD Textbox Name "txtReplace" , hDlg, %txtReplace  , ""        ,  10, 70, 350, 25, %ES_AUTOHSCROLL | %ES_LEFT | %WS_BORDER | %WS_TABSTOP
    
    
    CONTROL ADD BUTTON  Name "New"        , hDlg, %ButtonNew   , "New"     , 480, 10, 150, 25, %BS_NOTIFY | %BS_CENTER | %BS_VCENTER | %WS_TABSTOP
    CONTROL ADD BUTTON  Name "CloseMe"    , hDlg, %ButtonClose , "Close"   , 480, 40, 150, 25, %BS_NOTIFY | %BS_CENTER | %BS_VCENTER | %WS_TABSTOP
    
    
    
    
    
    
    DIALOG SHOW MODAL hDlg
    
    
    '------------------------------------------------
    ' Callback function used to handle dialog events 
    ' not handled by specific event functions
    '------------------------------------------------
    CallBack Function MyWindow_OnCallBack() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, CBMSG, "DIALOG message not handled by specific event function"
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnInit() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
      control set Resize CBHNDL, %ButtonNew   , 0, 1, 0, 0
      control set Resize CBHNDL, %ButtonClose , 0, 1, 0, 0
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnSize() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, CBWPARAM, HIWRD(CBLPARAM), LOWRD(CBLPARAM)
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnMove() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, CBWPARAM, HIWRD(CBLPARAM), LOWRD(CBLPARAM)
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnMoving() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnMouseMove() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnNCHITTEST() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnSETCURSOR() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnLBUTTONDOWN() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnLBUTTONUP() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnLBUTTONDBLCLK() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnNCMOUSEMOVE() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnNCMOUSELEAVE() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnCommand() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnClose() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnSHOWWINDOW() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnDestroy() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      PrintL "Window just destroyed. Press a key to end" in %CCOLOR_FLIGHTRED
      WaitKey
    
    
    End Function
    
    
    
    
    
    
    '------------------------------------------------------------------------------
    ' BUTTON EVENT
    '------------------------------------------------------------------------------
    
    
    '------------------------------------------------
    CallBack Function CloseMe_OnClick() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      DIALOG End CBHNDL
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function CloseMe_OnSetFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function CloseMe_OnKillFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function New_OnClick() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    'CallBack Function CloseMe_OnCallBack() As Long
    ''------------------------------------------------
    '
    '  printl Timer, Function_Name, CBMSG, "BUTTON message not handled by specific event function"
    '
    'End Function
    
    
    '------------------------------------------------------------------------------
    ' LABEL EVENT
    '------------------------------------------------------------------------------
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnClick() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnDblClk() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnDisable() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnEnable() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    
    
    '------------------------------------------------------------------------------
    ' TEXTBOX EVENT
    '------------------------------------------------------------------------------
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnCallback() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, CBCTLMSG
      Function = %TRUE
    
    
    End Function
    
    
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnChange() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, "text changed to", Control_GetText(CBHNDL, CBCTL)
      Function = %TRUE
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnUpdate() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      Function = %TRUE
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnSetFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnKillFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnChange() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, "text changed to", Control_GetText(CBHNDL, CBCTL)
      Function = %TRUE
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnUpdate() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      Function = %TRUE
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnSetFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnKillFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
    End Function
    
    Attached Files Attached Files
    Last edited by ErosOlmi; 31-10-2017 at 22:23.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #63
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,796
    Blog Entries
    3
    Rep Power
    693
    Do like,

    I never enjoyed those huge SELECT CASE monuments for filtering API messages


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  4. #64
    if you want you can make a thinbasic experimental version completely like VB6. you can host it in github site. in the days of vb6 it was nearly every day job to write something like this:
    Private Sub Command1_Click()
    For i = 1 To 1000
    total = total + i
    Next i
    Text1.Text = total
    End Sub


    Text1 is the first Text Box, while Sub Command1_Click() is the click event of the first Button. the ""Private Sub Command1_Click()"" is opened automatically when we DBL click on the button in the vb6 Form designer.

    this why is why in thinbasic i am using 2 codes : one for the GUI design (because its complexity and i don't want to see it any more) and the other for the everyday usage code such as my post here:
    http://www.thinbasic.com/community/s...with-ThinBasic
    the controls and Dialog codes is so complex so it is better to hide it under easy to remember clothes and names. but this suggested approach will not run the old code. this is why i suggest it as an experimental and another flavor of thinbasic to put it in github site

  5. #65
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    Thanks a lot primo.

    So far I'm working on handling "events" that is "Command1_Click()" firing.
    But your suggestion on control.property (Text1.Text) is inspiring me on other fields.
    As soon as I will finish on control events, I will think about control properties. Control Name is already there.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #66
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    Quite exciting about new features I'm adding to UI (User Interface) module for the next thinBasic version.

    Dialog and controls automatic event handling functions: just give a name to windows or controls and your will have a lot of function events ready to be personalized.
    Dialog and controls properties: just give a name to windows or controls and you will have a lot of easy to be used properties to get/set

    An example that will be available with next thinBasic 1.10.5 as soon and it will be ready and attached a working executable:
    USES "UI"
    
    '---Define a button ID
    begin ControlID
      %lblNum1
      %txtNum1
      %lblNum2
      %txtNum2
      %lblResult
      %txtResult
      %lblOp
      %cbOp
      %btnResult
      %btnClose
    end ControlID
    
    
    string sOperations(4) = "+", "-", "*", "/"
    
    
    dialog Font "Courier New", 12
    
    
    DIALOG New Pixels   , Name SimpleCalc, 0, "Basic calculator with events",-1,-1, 640, 380,
                                       %WS_DLGFRAME | %DS_CENTER | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW,
    
    
    CONTROL ADD Label   , Name lblNum1  , SimpleCalc.Handle, %lblNum1   , "Number 1"  ,  10,  15, 350,  20, %SS_NOTIFY
    CONTROL ADD Textbox , Name txtNum1  , SimpleCalc.Handle, %txtNum1   , ""          ,  10,  30, 350,  30, %ES_AUTOHSCROLL | %ES_RIGHT | %WS_TABSTOP | %ES_NUMBER
    
    
    CONTROL ADD Label   , Name lblOp    , SimpleCalc.Handle, %lblOp     , "Operation" ,  10,  60, 350,  20, %SS_NOTIFY
    CONTROL ADD COMBOBOX, Name cbOp     , SimpleCalc.Handle, %cbOp      , sOperations ,  10,  75, 350, 100, %CBS_DROPDOWNLIST | %WS_TABSTOP
    
    
    CONTROL ADD Label   , Name lblNum2  , SimpleCalc.Handle, %lblNum2   , "Number 2"  ,  10, 110, 350,  20, %SS_NOTIFY
    CONTROL ADD Textbox , Name txtNum2  , SimpleCalc.Handle, %txtNum2   , ""          ,  10, 125, 350,  30, %ES_AUTOHSCROLL | %ES_RIGHT | %WS_TABSTOP '| %ES_NUMBER
    
    
    CONTROL ADD Label   , Name lblResult, SimpleCalc.Handle, %lblResult , "Result"    ,  10, 255, 350,  20, %SS_NOTIFY
    CONTROL ADD Textbox , Name txtResult, SimpleCalc.Handle, %txtResult , "0"         ,  10, 270, 350,  30, %ES_AUTOHSCROLL | %ES_RIGHT | %WS_TABSTOP | %ES_READONLY
    
    
    
    
    CONTROL ADD BUTTON  , Name btnResult, SimpleCalc.Handle, %btnResult , "Result"    , 480,  10, 150,  25, %BS_NOTIFY | %BS_CENTER | %BS_VCENTER | %WS_TABSTOP
    CONTROL ADD BUTTON  , Name btnClose , SimpleCalc.Handle, %btnClose  , "Close"     , 480, 340, 150,  25, %BS_NOTIFY | %BS_CENTER | %BS_VCENTER | %WS_TABSTOP
    
    
    
    
    DIALOG SHOW MODAL SimpleCalc.Handle
    
    
    '------------------------------------------------
    ' Callback function used to handle dialog events 
    ' not handled by specific event functions
    '------------------------------------------------
    CallBack Function SimpleCalc_OnCallBack() As Long
    '------------------------------------------------
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function SimpleCalc_OnLoad() As Long
    '------------------------------------------------
      '---Limits window minimum size
      DIALOG SET MINSIZE SimpleCalc.Handle, 550, 320
      
      '---Force resize logic
      control set Resize CBHNDL, %btnResult , 0, 1, 0, 0
      control set Resize CBHNDL, %btnClose  , 0, 1, 0, 1
      
      '---Select first element in combo operations
      COMBOBOX SELECT SimpleCalc.Handle, %cbOp, 1
      
      '---Some initial values
      txtNum1.Text  = "10"
      txtNum2.Text  = "20"
    
    
      '---Change name to Close button
      btnClose.Text = "Close Me"
    
    
    End Function
    
    
    '------------------------------------------------
    ' Function fired when SimpleCalc window will be closed
    '------------------------------------------------
    CallBack Function SimpleCalc_OnDestroy() As Long
    '------------------------------------------------
    
    
      MsgBox "Thanks for testing thinBASIC"
      
    End Function
    
    
    '------------------------------------------------
    ' Function fired when button Close is clicked
    '------------------------------------------------
    CallBack Function btnClose_OnClick() As Long
    '------------------------------------------------
    
    
      DIALOG End CBHNDL
    
    
    End Function
    
    
    '------------------------------------------------
    ' Function fired when drop down combo box is closed after a selection
    '------------------------------------------------
    callback function cbOp_ONCLOSEUP() as Long
    '------------------------------------------------
    
    
      CalculateResult
      
    End Function
    
    
    '------------------------------------------------
    ' Function fired when change selected item in a drop down combo box 
    '------------------------------------------------
    callback function cbOp_ONSELCHANGE() as Long
    '------------------------------------------------
    
    
      CalculateResult
      
    End Function
    
    
    '------------------------------------------------
    ' Function fired when button Result is clicked
    '------------------------------------------------
    CallBack Function btnResult_OnClick() As Long
    '------------------------------------------------
    
    
      CalculateResult
    
    
    End Function
    
    
    '------------------------------------------------
    ' Function fired when text inside txtNum1 textbox is changed
    '------------------------------------------------
    CallBack Function txtNum1_OnChange() As Long
    '------------------------------------------------
    
    
      CalculateResult
    
    
    End Function
    
    
    '------------------------------------------------
    ' Function fired when text inside txtNum2 textbox is changed
    '------------------------------------------------
    CallBack Function txtNum2_OnChange() As Long
    '------------------------------------------------
    
    
      CalculateResult
    
    
    End Function
    
    
    '------------------------------------------------
    ' Calculate and fill txtResult textbox
    '------------------------------------------------
    Function CalculateResult() as ext
    '------------------------------------------------
    
    
      txtResult.BackColor = rgb(0, 255, 255)
      
      select case cbOp.Text
        case "+"
          txtResult.Text = tstr$(val(txtNum1.text) + val(txtNum2.text))
        case "-"
          txtResult.Text = tstr$(val(txtNum1.text) - val(txtNum2.text))
        case "*"
          txtResult.Text = tstr$(val(txtNum1.text) * val(txtNum2.text))
        case "/"
          if val(txtNum2.text) Then
            txtResult.Text = tstr$(val(txtNum1.text) / val(txtNum2.text))
          Else
            txtResult.BackColor = rgb(255, 0, 0)
            txtResult.Text = "Div/0"
          end If
      end Select
      
      function = txtResult.Text
    End Function
    
    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  7. #67
    Thanks Eros
    txtNum1.Text = "10"
    txtNum2.Text = "20"
    this is what is needed, like the good old VB6
    so i can hide the GUI complex code in an include file and in the working code i use the new syntax
    hope also the same for the RichEdit box
    but does the new version can't run the TB 1.10.4 examples or it will run the 1.10.4 examples and the newer 1.10.5 examples ??. or may be an option button in the Options settings gives the user the choice of new vb6 style or the TB 1.10.4 style
    Last edited by primo; 08-11-2017 at 17:27.

  8. #68
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    thinBasic is always (or quite always) compatible with the past.
    So new features will not change anything and will remain compatible with old code.
    It will be just a matter of programmer coding style
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #69
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,796
    Blog Entries
    3
    Rep Power
    693
    Eros,

    you are on fire. Thank you very much for another bucket of hard work .

    I have an heretic suggestion - what about making the ctrlId optional for named controls? Once somebody names the control, he will probably use this magic as much as possible and that ctrlId could be generated internally automagically. What do you think?



    Petr
    Last edited by Petr Schreiber; 09-11-2017 at 01:17.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  10. #70
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    Great idea, as usual.

    First I need to get most of all possible properties available.
    Than I will make it optional.

    So far I've added the following control properties, most of them bot SET/GET, some only GET (read only) to Buttons, Labels, Textbox, Combobox, Canvas, Dialogs:

    • Name
    • Text
    • Id
    • Parent
    • Handle
    • FORECOLOR
    • BACKCOLOR
    • X
    • Y
    • W
    • H


    Also added many control and dialogs events.
    I'm really excited. Once done code will really resemble VB6

    Bad news is that it will take months to write help documentation
    Last edited by ErosOlmi; 09-11-2017 at 01:27.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Page 7 of 7 FirstFirst ... 567

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •