Results 1 to 3 of 3

Thread: Please Improve ThinBasic

  1. #1
    Join Date
    Aug 2015
    Keralam, India
    Rep Power

    Please Improve ThinBasic

    Hi Eros,
    I was working on a GUI toolkit. But some imperfections in Thinbasic got in my way. They are as follows.
    1. Private is not working. So now we can access any private variable from a type.
    2. We need properties in thinBasic. I hope you cn imitate FreeBasic's property.
    3. We need Function overloading in thinBasic. Especially constructor overloading is important.
    4. Please update CodePtr to take a function with 6 parameters. See this function signature.

    Function Subclassproc(
      hWnd As Dword,
      uMsg As Dword,
      wParam As Dword,
      lParam As Long,
      uIdSubclass As Long,
      dwRefData As Long )  As Long
    We need to pass the pointer of this function, in order to subclass a control. CodePtr now take functions with only 4 params. So please consider this.
    I hope you complete these when you have time.
    Last edited by kcvinu; 01-05-2021 at 21:00.

  2. #2
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Blog Entries
    Rep Power
    for your Private request:
    Do not use variables to store data. Use the Heap-memory that will allow you to grant access to any data by your rules.
    Use variables local then to place the udt upon the data-pointers.

    For the properties:
    If you want to apply additional properties to some Window or control create simple udts for that to store additional information
    - order a bit by control types, i mean the window will not have the same additional properties as a button has.
    Use like a basic type for information that all items have in common as
    type tUIObjectInfo
      pType as Dword ' point the position where you store the typeOf(a control or dialogs udt)
                              ' as .pType = Heap_AllocByStr( typeOf( the that you append to this control )
                              ' it will work as this already but save a lot of memory and create a function that will remember 
                             ' where the name is stored so you can use the same value in .pType - that will also let you compare
                            ' if objects are similar, i.e. same typename if same pointer to typename...
    pText  as Dword  ' most objects have a text or caption. you can store up to 2 GB in one string and only append the pointer here
                             ' makes all objects same-sized. You can as well append an array of pointers >> put them together to a string
                           ' sPtr$=MKDWD$(ptr1, ptr2, ptr3,...) and store it : .pText=Heap_AllocByStr(sPtr$)
                          'that were the way to store it seperated to lines for multiline textboxes or lists & dropdown.lists and 
                                ' any arrays of dynamic data
    flags As Long   ' you can use bitflags and binary operators "AND|OR" to store plenty of information about usage of certain                                  ' subelements likewise pText were to treat as simple text or its a joined array to parse by a delimiter or a table to                      ' parse or stored data is as above an array of pointers where each pointer points 1 line of text.
    X1 as Long   ' the first(left) position of this object
    Y1 as Long   ' the top position  
    X2 as Long   ' the last position of this object - it were the very right pixel on the client of this objects parent
                       ' you can obtain the width of it - or do it the other way and store the width instead
    Y2 as Long             ' same to height 
    End Type
    this maybe 7 subelements were what all visible items in a windows-environment have in common, perhaps you require things as Enabled, Visible, BlinkOnFocus, just add it if all shall have it.

    now you might need an additional udt for the main-window that shall contain a menu and some accelerator table

    type tMainWindow extends tUIObjectInfo
       hMenu as Dword ' also can be Long, but handles and pointers are usually unsigned, i.e. no negative values
      hAccell as Long
    End Type
    ' and you will create controls:
    type tBasicControl extends tUIObjectInfo
       CtrlID as Long ' all controls will have a ControlID...
    End Type
    the types based on another type have automatic all properties of the one that they "extends"

    and then you want a few buttons that will perform actions. you would create a basic button typethat extends tBasicControl to provide standards as simple PushButtons that will change a state or commandbuttons that will instantly fire a sub, others were to open a dedicated dropdown or checkboxes, option buttons etc. for each special button you would create an extends-basic button-udt. Many of the items properies are part of the controls in UI already but some you are missing or should be private?
    Remind yourself and make the text-property of a Passwoord-control private and create the private-text property in a way that it can only be retrieved in a function with byref tUIObject-parameter and decide if the referenced object varptr is one who gets granted the access. Or add the varptr to the dataptr and add your lucky number that nobody knows that you store to the pText-slot and nobody knows how to use this number - even you need the correct controls udt-storage location (i.e. varptr for your udt) and your lucky number to subtract it and then you know where you get the data.

    and then, thats what you must think previously - besides some planning - ,
    Declare Function SetProp    Lib "user32.dll" Alias "SetPropW" (ByVal hwnd As Long, ByVal lpString As Asciiz, ByVal hData As Long) As Long
    Declare Function GetProp    Lib "user32.dll" Alias "GetPropW" (ByVal hWnd As Dword, ByVal lpString As Asciiz) As Long
    Declare Function RemoveProp Lib "user32.dll" Alias "RemovePropW"(ByVal hwnd As Long, ByVal lpString As Asciiz) As Long
    3 functions that will allow you to attach the additional properties to anything that has a Windows-handle.
    As You see its all WideString and null-terminated, so you would probably store the pointer of "myButton_123" additional data like
    String PropertyName = UTF8ToWideChar$("ControlExtraData") & String$(4, $NUL) 
    ' the property name can be anything. For same properties often used it makes sense to store the name
    ' instead to repeatedly create it
    Dword PointerToAdditionalData = Heap_Allocate(SizeOf(mySpecialButtonType))
    Local x as mySpecialButtonType At PointerToAdditionalData
    Heap_Set(x.pText,"Hello i am the special Button")  ' one of many ways to store something at heap
    x.CtrlID = myButton_123.ID
    SetProp(myButton_123.handle,  PropertyName, PtrToAdditionalData )
    thus there is no AddProp - SetProp will do, means if you change the location by allocating it elsewhere that you must also change the pointer to the properties which is attached to the hWnd. You can as well use named properties and add them one by one.
    GetProp will return you the stored pointer, i.e. position where you find your data or 0 if property with the passed name is not available on the windows-object thats handle was passed. maybe also error < 0 if no such handle
    Last edited by ReneMiner; 06-05-2021 at 20:58.
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: downgraded again to Windows 10 Enterprise x64 10.0.18363 Build 18363 (1909)
    (alternate OS: modified WinRE - boot from a fake ramdisk - currently in "reconstruction mode")

  3. #3
    Join Date
    Aug 2015
    Keralam, India
    Rep Power
    @Rene Miner,

    Thanks for the reply. I am not sure I get your idea completely. I think SetProp and GetProp seems a good idea but how does it solve the problem I stated ?
    My problem was the access scope of a property. If I declare something as private, it should remain private. Correct me if I am wrong. And once again sorry for not understanding what you described.

Similar Threads

  1. Any, Some, All, Neither|Nor, None to fix & improve.
    By ReneMiner in forum Suggestions/Ideas discussions
    Replies: 0
    Last Post: 23-03-2021, 19:53
  2. Need confirmation: speed improve
    By ErosOlmi in forum thinBasic General
    Replies: 20
    Last Post: 16-07-2007, 20:35
  3. Help us to improve thinBasic help file
    By ErosOlmi in forum Samples for help file
    Replies: 2
    Last Post: 25-05-2007, 18:16

Posting Permissions

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