Hi Guimauve,
thanks again for your update. I've included the new code into my project. All is working fine for my needs now! 
 
I like the new place (top-left corner) of the open-close button.... it's the logical place I think and other options shouldn't be needed...  
Please be aware to add following code at top of the code (without you will get a compiler error):
Code: Select all
Declare GetPropertyGridSectionCount(PropertyGridID)
Even if I don't need it myself for now, I've tested the new lock/unlock functions: They seem to work good, except the following (step by step for testing):
- one or more sections are already opened/expanded
- then the lock function is executed
- now the open-close button can still be clicked
- the section will not be collapsed correctly (the gadgets inside are still visible)
I think, that collapsing of the section(s) shouldn't happen (they should stay as they are, when the lock is done). But the click on the open-close button(s) shouldn't be processed then...
Furthermore I've changed the GetPropertyGridSectionCount() another time to fit my own needs, probably the following code is also interesting for other people and/or for including into the official package:
Code: Select all
Procedure GetPropertyGridSectionOpenCloseState(PropertyGridID, SectionNo)
  ; Function for checking one section (the given 'SectionNo') or all (-1 as 'SectionNo' parameter) property
  ; sections, if they are opened or not.
  ;- Testing for all sections by giving 'SectionNo = -1' added by Andre on 1st Jan. 2013
  ;  changed and improved on 4th Jan. 2013.
  
  Protected CurrentSection, NumberOfSections, SectionState
  Protected ClosedSections, EmptySections, OpenSections
  
  Protected *PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
  
  If *PropertyGridDataA <> #Null
    
    If SectionNo = -1
      
      NumberOfSections = GetPropertyGridSectionCount(PropertyGridID) - 1
      For CurrentSection = 0 To NumberOfSections
        SectionState = GetPropertyGridSectionOpenCloseState(PropertyGridID, CurrentSection)
        ;  SectionState can be: 1 = opened, 0 = closed, -1 = empty section
        ; Debug "'Section' " + Str(CurrentSection) + " has the state: " + Str(SectionState)
        Select SectionState
          Case -1 : EmptySections + 1
          Case 0  : ClosedSections + 1
          Case 1  : OpenSections + 1
        EndSelect
      Next
      ; Debug "Empty / Closed / Open sections: " + Str(EmptySections) + " / " + Str(ClosedSections) + " / " + Str(OpenSections) 
      
      If OpenSections > 0 And ClosedSections > 0
        ; => the CollapseAll button should be activated, and the ExpandAll should be too (because of still closed sections)
        SectionState = 4
      ElseIf OpenSections > 0 And ClosedSections = 0
        ; => the CollapseAll button should be activated, but the ExpandAll not (because there are no closed sections anymore)
        SectionState = 3
      ElseIf OpenSections = 0 And ClosedSections > 0
        ; => the CollapseAll button should be deactivated (because there aren't any opened sections), but the ExpandAll should be activated (because there are closed sections)
        SectionState = 2
      ElseIf OpenSections = 0 And ClosedSections = 0
        ; => the CollapseAll and ExpandAll buttons should be both deactivated (because there aren't any opened/closed sections, maybe only empty sections)
        SectionState = 1
      Else
        ; this option shouldn't occure, just in case...
        SectionState = 0
      EndIf
      ProcedureReturn SectionState
      
      
    ElseIf SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
      
      If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
        ProcedureReturn GetPropertyGridItemOpened(GetPropertyGridDataItems(*PropertyGridDataA))
      EndIf
      
    EndIf    
    
  EndIf
  
EndProcedure