View Full Version : PropertyList- how to get Item-Ptr?
ReneMiner
30-08-2013, 10:42
I have some Property-List-Control which I fill just passing a root of data-structure which gets setup in advance.
Now I'm within Callback Function cbPropList
select case cbmsg
case %WM_COMMAND
select case hiwrd(cbwparam)
case %LBN_SELCHANGE
' how can I find out which item has been changed now,
' so I can apply the correct value to the related variable?
case %LBN_SELCANCEL
' here I have to restore the "old" value to display again? Or does it do this automatic?
end select
end select
Or did I interpret %LBN_SelChange/%LBN_SelCancel wrong? Does it just tell that another item has been selected/none is selected?
ErosOlmi
30-08-2013, 12:30
Hi René,
a PropertyList is a personalized control I created based on a standard Windows ListBox.
%LBN_SelChange and %LBN_SelCancel are classic notification messages fired by the Operating System when there is an interaction with the ListBox on which the PropertyList is based:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775161(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775159(v=vs.85).aspx
Actually (as far as I can see) the only way to apply changes are:
get back PropertyList root structure and loop into PropertyList items, analyze values, apply all the changes.
react to %LBN_SelChange, get the PropertyList item just left, get its value, apply changes
There is no way to know if the value of a property list item has really change unless you compare all items before/after %LBN_SelChange getting the differences.
But I will have a look if there are any chance to get what you need in the internal CallBack I developed for this control.
Ciao
Eros
ReneMiner
30-08-2013, 12:50
I guess the single property-items are stored in some kind of array - so all in a row as they get passed?
Then I would be satisfied to know the current activated items index because I just need to know which item is currently active - would also be fine if it just returns the items .propName - since they are all supposed to be unique anyway. Maybe add to help these .PropNames must not contain spaces ;)
But I think a pointer to the current active PropertyItem(s data) would be the best solution
ReneMiner
31-08-2013, 15:28
Ok, I use Listbox-Functions on it and works
CallBack Function PropList_Callback()
Local lastItem As Long
Select Case CBMSG
Case %WM_COMMAND
Control Get User CBHNDL, CBCTL, %UserPropSelect To lastItem
If lastItem Then
Local pItem As PROPERTYITEM At PropertyList_ItemGetPtr(CBHNDL, CBCTL, lastItem)
' Control Set Text CBHNDL,%PropTxtInfo, pItem.propName + $CRLF + pItem.curValue
EndIf
LISTBOX Get Selected CBHNDL, CBCTL To lastItem
Control Set User CBHNDL, CBCTL, %UserPropSelect, lastItem
End Select
End Function
Couldn't there be another kind of PropertyRoot-Items-"Extended" that have some User-Values so one could store some Type & UDT_ElementOffset?
For example I have some UDT
Type t_Control
X as Long
Y as Long
Width as Long
Height as Long
'...
End Type
Dim myControl(123) as t_Control
Fill_PropertyList(Varptr(myControl(7))
Sub Fill_PropertyList(Byval pControl As Dword)
Local pItem As PROPERTYITEM_EX
Local pRoot as Dword
'...
pItem.propName = "Width"
pItem.nItemType = %PIT_EDNUM
pItem.subtype = %PITS_NULL
pItem.sOwner = ""
pItem.cmbItems = ""
pItem.User1 = UDT_ElementOffset(myControl(1).Width)
pItem.User2 = %TypeIs_LONG ' might just contain enumeration as used for Types in thinBasic_VariableGetInfoEx...
' just to know what to peek later...
' #####so here would be a few "Select Case"s needed later ######
pItem.curValue = Str$( Peek(pItem.User2, pControl + pItem.User1 ) )
PropertyRoot_ItemExAdd pRoot, VarPtr(pItem)
'...
Control Set User hPropWindow, %PropList, %UserPropVarPtr, pControl
End Sub
The '%TypeIs_...' usage here just replaces a few "Select Case" - For Strings/Fonts the nItemType would tell. But it won't help differ floats from integers.
The intention is to connect the items directly to some UDT - especially in the reverse function when changed data shall be set to be used - even on different types - so the whole construct is multiple useable.
Also would be great if pItem.cmbItems would accept equates - maybe pItem.subtype could help to classify if uses Strings (default) or Equates. I imagine that way:
pItem.cmbItems = "%TRUE|%FALSE|"
pItem.subtype = %PITS_CMBEQUATES
pItem.curValue = Str$( Peek(pItem.User2, somewhere) )
' some "TypeIs"-Equates to build aliases for simple vartypes on the fly would be cool...
and property-item in list shows either "%TRUE" or "%FALSE"...perhaps can omit "%"
-reverse operation can be done using thinBasic_VariableGetInfoEx...
ErosOlmi
31-08-2013, 18:54
Yes,
next PROPERTYITEM version will have 10 user elements.
Type PROPERTYITEM
propName As Asciz * 32
sOwner As Asciz * 32 ' name of property who owns the item
curValue As Asciiz * 1024
nItemType As Integer
subtype As Long
cmbItems As Asciiz * 1024
fptr As propertyitem Ptr
User1 As Long
User2 As Long
User3 As Long
User4 As Long
User5 As Long
User6 As Long
User7 As Long
User8 As Long
User9 As Long
User10 As Long
End Type
ReneMiner
31-08-2013, 19:36
10? Oh my god, that's a lot... but I won't complain about - just why not indexing them as an array User(10) so one could use equates alike
pItem.User(%UserVarPtr) = Varptr(myVar)
pItem.User(%UserOffset) = Udt_ElementOffset...
ErosOlmi
31-08-2013, 20:51
Yes, much better.
ReneMiner
02-09-2013, 07:17
One more suggest to PropertyItems: Currently just supports "Browse for File" (%PIT_FILE) - my suggest "Browse for Folder" (%PIT_FOLDER).
Currently works using %PIT_RO and checking clicked pItem.propName - but pItem has no button ...
ErosOlmi
02-09-2013, 07:38
I will add