ReneMiner
20-05-2020, 18:17
Eros you are the only one who can answer this:
We assign the name to a control or dialog while we create it. It is assigned without double-quotes, that means its kind of a variable?
Is that variable used in any way except to tell UI the name?
Can't we just assign the name like this:
(simplyfied code!)
' -- a basic object-udt for anything that is a
Type tWindowsObject
[RESERVED_FOR_UI As Bytes(128)
' it were a possibility if UI needs storage for 64-chars-wide-string or
' not to cover anything that wil be stored to the variable that we use as NAME for dialogs & controls]
hWnd As Dword ' the objects windows-handle
pParent As Dword ' pointer to the parenting tWindowsObject
pChildren As String ' pointer-list (&= MKDWD$(Varptr(childvar)) to append children here)
' -- i omit statics & functions that this udt would have to manage all the inheriting objects and to
' reply to any requests concerning relatives. This UDT would also handle the assignment and of
' storage of CONTROLID's. Instead to ask the ID we have (variable-)names and indexes in 3 dimensions as
' every thinbasic variable offers.
Function _Create(whatever assigned)
msgbox "ERROR this type is a template only. You can not create objects from it."
End function
End Type
' this now the udt containing a dialogs data and wrapping the properties to functions:
Type tDialog Extends tWindowsObject
Title$ As String ' store the caption of a window.
Function Caption(Optional Byval sTitle As String ="&%$(/%$§$&" ) As String
' function to assign and request window-caption
' "&%$(/%$§$&" is a random pattern to make sure that
' user wants to assign empty string and not not requests current caption only
if Not sTitle = "&%$(/%$§$&" then
Dialog Set Text me.hWin, sTitle
Me.Title$ = sTitle 'store title to the object
' request the stored value again from the object to have it fit (perhap was truncated)
Dialog Get Text, me.hWin to sTitle
Function = sTitle
End Function
'Function _Create(optional byref Parent As tWindowsObject,
' byval [File] sText As String,
' posX, posY, sizeW, sizeH, lStyle,lExStyle)
' This function sadly not doable this way.
' It can not assign its own name because we do not use quoted string for Name-assignement
' (also we can not achieve to pass keywords like File without quotes.
' Like Parse File "filename" would be nice to use that as switch too whether sText contains
' the caption or filename to obtain the data. )
'End function
End Type
' sadly not possible as easy as this:
' Global MainDialog As tDialog( NULL, FILE "ini or resource-filename")
'But to stick with currently possible methods use the regular way - now knowing which direction (see above)
If I do this:
Dim MainDialog As tDialog
Local hDlg As Dword At Varptr(MainDialog.hWin)
' no need to create hParent At the parenting udts .hWin if no parent...
Dialog New Pixels, Name MainDialog, 0, sTitle, x, y, w, h, style, xstyle to hDlg
I assign the same VariableName - that i dimension before as tDialog already !!!
Now my question :
Will it be enough to allocate a RESERVE of 128 Bytes before the name is passed or will it internal store anything at all to that name?
_______________________________________________________________________________________________
Thoughts about a direction only: (Stop reading it!)
Maybe you are storing hWin only?
Maybe UI stores handle of Parent too? - Then it were better to have the pointer of the parents assigned udt stored but
in fact the objects data in the udt contains all that information.
The first 4 Bytes of the udt mandatory would hold windows handle (hWnd).
Now it sounds complicated but is easy
think of any tWinObject and all that extends it (remove the RESERVED_FOR_UI in your mind)
VARPTR(anyObject) equals "AbsolutePosition:Byte1" of the objects data-structure
BYTES 1,2,3,4 hold "ME.windows-handle, "hWnd"
following
BYTES 5,6,7,8 hold Varptr( Me.ParentObject ) equals "AbsolutePosition:Byte1" of this current objects parent.
That means At the position
Varptr( Me.ParentObject ) is where the UDT starts that holds Me.Parent's data
AND at the same timeit is where to peek me.Parent's hWnd
If we could simply assign the Name of an existing Variable that meets that condition:
Size 8 Bytes
so use a LongLong or Quad if you dont want to create an udt
HI(<currentName>) equals hWnd
LO(<currentName>) pointer where to peek 4 bytes telling currents parent's hWnd.
If I create 5x5 images andplace them to the background of anything- will it be possible to create 5x5 variables
myImage(5,5) and pass on their creation the names myImage(x,y) so UI knows- "oh that guy has an index, or 2 or 3--- i dont care as long as he provides a space where i can put his handle!" But in fact UI gets presented a value that
the control does not know about itself but the programmer would like in the callback to know which of the 5x5 in Callback Function image_OnHit() was hit by the players ball. And ui could remember what index belongs to that handle...
so Programmer will luckily provide for 2d-array myImage(5,5) in the
callback Function myImage_OnHit(byval X as Long, byval Y as Long) as Long
' if named index1 and index2 does not matter, its up to the programmer
' but 2 dimensions mean 2 varaiables in the range of long
'---------------------------------------------------------------------------------
Function = TRUE ' kindly wave back so ui will keep sending messages to you
End Function
Using 8 Bytes would mean had to take care of the controlID's ourselves because we need another 4 bytes to store it.
And to make it complete: 12 bytes ? computers do not like odds. 16 were fine.
4 bytes a pointer to a list (@heap, an array or simply a string) where we can node all additional objects that to see as direct Child-objects.
The dialog might hold a viewport...but inside the viewport lives another dialog holding controls there....
The order of the childrens pointers can mean a lot - zOrder(drawing order), default tabbing-order (tab-key)... so these can be useful for UI how to proceed in doubt
We assign the name to a control or dialog while we create it. It is assigned without double-quotes, that means its kind of a variable?
Is that variable used in any way except to tell UI the name?
Can't we just assign the name like this:
(simplyfied code!)
' -- a basic object-udt for anything that is a
Type tWindowsObject
[RESERVED_FOR_UI As Bytes(128)
' it were a possibility if UI needs storage for 64-chars-wide-string or
' not to cover anything that wil be stored to the variable that we use as NAME for dialogs & controls]
hWnd As Dword ' the objects windows-handle
pParent As Dword ' pointer to the parenting tWindowsObject
pChildren As String ' pointer-list (&= MKDWD$(Varptr(childvar)) to append children here)
' -- i omit statics & functions that this udt would have to manage all the inheriting objects and to
' reply to any requests concerning relatives. This UDT would also handle the assignment and of
' storage of CONTROLID's. Instead to ask the ID we have (variable-)names and indexes in 3 dimensions as
' every thinbasic variable offers.
Function _Create(whatever assigned)
msgbox "ERROR this type is a template only. You can not create objects from it."
End function
End Type
' this now the udt containing a dialogs data and wrapping the properties to functions:
Type tDialog Extends tWindowsObject
Title$ As String ' store the caption of a window.
Function Caption(Optional Byval sTitle As String ="&%$(/%$§$&" ) As String
' function to assign and request window-caption
' "&%$(/%$§$&" is a random pattern to make sure that
' user wants to assign empty string and not not requests current caption only
if Not sTitle = "&%$(/%$§$&" then
Dialog Set Text me.hWin, sTitle
Me.Title$ = sTitle 'store title to the object
' request the stored value again from the object to have it fit (perhap was truncated)
Dialog Get Text, me.hWin to sTitle
Function = sTitle
End Function
'Function _Create(optional byref Parent As tWindowsObject,
' byval [File] sText As String,
' posX, posY, sizeW, sizeH, lStyle,lExStyle)
' This function sadly not doable this way.
' It can not assign its own name because we do not use quoted string for Name-assignement
' (also we can not achieve to pass keywords like File without quotes.
' Like Parse File "filename" would be nice to use that as switch too whether sText contains
' the caption or filename to obtain the data. )
'End function
End Type
' sadly not possible as easy as this:
' Global MainDialog As tDialog( NULL, FILE "ini or resource-filename")
'But to stick with currently possible methods use the regular way - now knowing which direction (see above)
If I do this:
Dim MainDialog As tDialog
Local hDlg As Dword At Varptr(MainDialog.hWin)
' no need to create hParent At the parenting udts .hWin if no parent...
Dialog New Pixels, Name MainDialog, 0, sTitle, x, y, w, h, style, xstyle to hDlg
I assign the same VariableName - that i dimension before as tDialog already !!!
Now my question :
Will it be enough to allocate a RESERVE of 128 Bytes before the name is passed or will it internal store anything at all to that name?
_______________________________________________________________________________________________
Thoughts about a direction only: (Stop reading it!)
Maybe you are storing hWin only?
Maybe UI stores handle of Parent too? - Then it were better to have the pointer of the parents assigned udt stored but
in fact the objects data in the udt contains all that information.
The first 4 Bytes of the udt mandatory would hold windows handle (hWnd).
Now it sounds complicated but is easy
think of any tWinObject and all that extends it (remove the RESERVED_FOR_UI in your mind)
VARPTR(anyObject) equals "AbsolutePosition:Byte1" of the objects data-structure
BYTES 1,2,3,4 hold "ME.windows-handle, "hWnd"
following
BYTES 5,6,7,8 hold Varptr( Me.ParentObject ) equals "AbsolutePosition:Byte1" of this current objects parent.
That means At the position
Varptr( Me.ParentObject ) is where the UDT starts that holds Me.Parent's data
AND at the same timeit is where to peek me.Parent's hWnd
If we could simply assign the Name of an existing Variable that meets that condition:
Size 8 Bytes
so use a LongLong or Quad if you dont want to create an udt
HI(<currentName>) equals hWnd
LO(<currentName>) pointer where to peek 4 bytes telling currents parent's hWnd.
If I create 5x5 images andplace them to the background of anything- will it be possible to create 5x5 variables
myImage(5,5) and pass on their creation the names myImage(x,y) so UI knows- "oh that guy has an index, or 2 or 3--- i dont care as long as he provides a space where i can put his handle!" But in fact UI gets presented a value that
the control does not know about itself but the programmer would like in the callback to know which of the 5x5 in Callback Function image_OnHit() was hit by the players ball. And ui could remember what index belongs to that handle...
so Programmer will luckily provide for 2d-array myImage(5,5) in the
callback Function myImage_OnHit(byval X as Long, byval Y as Long) as Long
' if named index1 and index2 does not matter, its up to the programmer
' but 2 dimensions mean 2 varaiables in the range of long
'---------------------------------------------------------------------------------
Function = TRUE ' kindly wave back so ui will keep sending messages to you
End Function
Using 8 Bytes would mean had to take care of the controlID's ourselves because we need another 4 bytes to store it.
And to make it complete: 12 bytes ? computers do not like odds. 16 were fine.
4 bytes a pointer to a list (@heap, an array or simply a string) where we can node all additional objects that to see as direct Child-objects.
The dialog might hold a viewport...but inside the viewport lives another dialog holding controls there....
The order of the childrens pointers can mean a lot - zOrder(drawing order), default tabbing-order (tab-key)... so these can be useful for UI how to proceed in doubt