Results 1 to 9 of 9

Thread: PropertyList- how to get Item-Ptr?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    PropertyList- how to get Item-Ptr?

    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?
    Last edited by ReneMiner; 30-08-2013 at 10:50.
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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/libr...(v=vs.85).aspx
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    Actually (as far as I can see) the only way to apply changes are:
    1. get back PropertyList root structure and loop into PropertyList items, analyze values, apply all the changes.
    2. 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

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    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
    I think there are missing some Forum-sections as beta-testing and support

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    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...
    Last edited by ReneMiner; 31-08-2013 at 17:20.
    I think there are missing some Forum-sections as beta-testing and support

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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
    
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    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...
    I think there are missing some Forum-sections as beta-testing and support

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Yes, much better.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #8
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    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 ...
    Last edited by ReneMiner; 02-09-2013 at 07:37.
    I think there are missing some Forum-sections as beta-testing and support

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I will add
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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