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 udt.name 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