I am not going to make a habit of feeding my
own threads, but I've posted a "solution" of a problem,
and after a little thinking I came to the conclusion that
1) my solution was no good
2) there was a much simpler way to do it.
So here's hopefully the last mail on this subject.
After this, I imagine I'll be posting a lot less.

I have a bunch of controls that can be shown or hidden
by clicking a disclosure triangle. They are positioned
below each other like this
|> control1
|> control2
...

I've written a method that does a couple of things to
accomodate for this changing of sizes.

This method is triggered through a disclosure triangle's
action handler.

Here's the method.

// declare all the controls
  Dim DT1, DT2, DT3, DT4, DT5, DT6, DT7, DT8, DT9 As DisclosureTriangle
  DT1=DisclosureTriangleAD1
  DT2=DisclosureTriangleAD2
  DT3=DisclosureTriangleAD3
  DT4=DisclosureTriangleAD4
  DT5=DisclosureTriangleAD5
  DT6=DisclosureTriangleAD6
  DT7=DisclosureTriangleAD7
  DT8=DisclosureTriangleAD8
  DT9=DisclosureTriangleAD9

  Dim st2, st3, st4, st5, st6, st7, st8, st9 as StaticText
  st2=StaticTextAD2
  st3=StaticTextAD3
  st4=StaticTextAD4
  st5=StaticTextAD5
  st6=StaticTextAD6
  st7=StaticTextAD7
  st8=StaticTextAD8
  st9=StaticTextAD9

  dim cc1,cc2,cc3,cc4,cc5,cc6,cc7,cc8,cc9 As ContainerControl
  cc1=ContainerControlArtDetail1
  cc2=ContainerControlArtDetail2
  cc3=ContainerControlArtDetail3
  cc4=ContainerControlArtDetail4
  cc5=ContainerControlArtDetail5
  cc6=ContainerControlArtDetail6
  cc7=ContainerControlArtDetail7
  cc8=ContainerControlArtDetail8
  cc9=ContainerControlArtDetail9

  dim ca As Canvas
  ca=CanvasArt

  ca.Height=330

//set the initial position of the controls
//extremely important!
  DT2.top=DT1.top+30
  DT3.top=DT2.top+30
  DT4.top=DT3.top+30
  DT5.top=DT4.top+30
  DT6.top=DT5.top+30
  DT7.top=DT6.top+30
  DT8.top=DT7.top+30
  DT9.top=DT8.top+30

// check for every disclosure triangle if it's
//open or not and depending on its state:
//show the hidden controls, shift the under-
lying triangle and make the canvas bigger

  if DT1.Value=false then
    cc1.Visible=False
    DT2.top=DT1.top+30
  else
    cc1.Visible=True
    DT2.Top=DT1.Top+300
    ca.Height=ca.Height+300
  end if
  if DT2.Value=false then
    cc2.Visible=False
    DT3.top=DT2.top+30
  else
    cc2.Visible=True
    DT3.Top=DT2.Top+300
    ca.Height=ca.Height+300
  end if
  if DT3.Value=false then
    cc3.Visible=False
    DT4.top=DT3.top+30
  else
    cc3.Visible=True
    DT4.Top=DT3.Top+300
    ca.Height=ca.Height+300
  end if
  if DT4.Value=false then
    cc4.Visible=False
    DT5.top=DT4.top+30
  else
    cc4.Visible=True
    DT5.Top=DT4.Top+300
    ca.Height=ca.Height+300
  end if
  if DT5.Value=false then
    cc5.Visible=False
    DT6.top=DT5.top+30
  else
    cc5.Visible=True
    DT6.Top=DT5.Top+300
    ca.Height=ca.Height+300
  end if
  if DT6.Value=false then
    cc6.Visible=False
    DT7.top=DT6.top+30
  else
    cc6.Visible=True
    DT7.Top=DT6.Top+300
    ca.Height=ca.Height+300
  end if
  if DT7.Value=false then
    cc7.Visible=False
    DT8.top=DT7.top+30
  else
    cc7.Visible=True
    DT8.Top=DT7.Top+300
    ca.Height=ca.Height+300
  end if
  if DT8.Value=false then
    cc8.Visible=False
    DT9.top=DT8.top+30
  else
    cc8.Visible=True
    DT9.Top=DT8.Top+300
    ca.Height=ca.Height+300
  end if
  if DT9.Value=false then
    cc9.Visible=False
  else
    cc9.Visible=True
    ca.Height=ca.Height+300
  end if

//now that all the triangles are at the right
//position, make sure that other controls
//are as well, and btw,
//this would be more elegant using indexes
  st2.Top=DT2.top
  st3.Top=DT3.top
  st4.Top=DT4.top
  st5.Top=DT5.top
  st6.Top=DT6.top
  st7.Top=DT7.top
  st8.Top=DT8.top
  st9.Top=DT9.top

  cc2.Top=st2.Top+32
  cc3.Top=st3.Top+32
  cc4.Top=st4.Top+32
  cc5.Top=st5.Top+32
  cc6.Top=st6.Top+32
  cc7.Top=st7.Top+32
  cc8.Top=st8.Top+32
  cc9.Top=st9.Top+32

Well, there you have it. I hope will be useful to
somebody, because as trivial as it looks, it took
me a lot of boiled brain cells to get here.

Koen van Hees
Les Allées de St. Genis
299 Allée Diderot
01630 St Genis Pouilly
France
tel: +33 (0)4 50 42 08 78

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to