Peculiar Control Behaviour

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Mess

    #1

    Peculiar Control Behaviour

    Here's a simple example of my problem...
    Create a new Activex Control and just put a ComboBox on it.
    Add a project and site the new Control.

    Add this to the Form code. and run it.

    *************** *************** *************** *

    Option Explicit

    Private Sub UserControl_Ini tialize()
    MsgBox "Initialize "
    Combo1.AddItem "Hello"
    End Sub

    Private Sub UserControl_Ini tProperties()
    MsgBox "InitProperties "
    End Sub

    Private Sub UserControl_Rea dProperties(Pro pBag As PropertyBag)
    MsgBox "ReadProperties "
    End Sub

    Private Sub UserControl_Res ize()
    MsgBox "Resize"
    End Sub
    *************** *************** ******

    I find it very curious that it does the Initialize event, then the Resize
    event, then the ReadProperties event.

    It seems that adding something to the ComboBox with AddNew does this.
    When it's commented out it works like the docs say: Initialize event, then
    the ReadProperties event, then the Resize event.

    Am I not understanding something right, or is this not the right behaviour.
    I guess the workaround must be to put this in the ReadProperties event?

    I am using VB5, and have not made all that many controls.

    Thanks for any help.


  • Steve Gerrard

    #2
    Re: Peculiar Control Behaviour


    "The Mess" <email@none.com > wrote in message
    news:PLcod.1393 7$Le1.230463@ne ws20.bellglobal .com...
    | Here's a simple example of my problem...
    (snip)

    | I find it very curious that it does the Initialize event, then the
    Resize
    | event, then the ReadProperties event.
    |
    | It seems that adding something to the ComboBox with AddNew does this.
    | When it's commented out it works like the docs say: Initialize event,
    then
    | the ReadProperties event, then the Resize event.
    |
    | Am I not understanding something right, or is this not the right
    behaviour.
    | I guess the workaround must be to put this in the ReadProperties
    event?
    |

    This appears to be true for any type of control on the user control.
    Also, you don't have to actually change anything; merely inspecting a
    property of a contained control will do it. I tried "If Line1.X1 = 7
    Then", which also causes the Resize event to occur before the
    ReadProperties event.

    Evidently any reference to a contained control requires something to
    happen that triggers the resize event. I am in VB6, so I am pretty sure
    MS's response to this would be "This behavior is by design."

    So, I would say, do not count on ReadProperties occuring before Resize,
    unless you are willing to have Initialize not look at or touch anything.
    What you do instead depends on what you need to do. By the way, normally
    the size of the control is determined by the settings of the actual
    control placed on a form.




    Comment

    • The Mess

      #3
      Re: Peculiar Control Behaviour

      Thanks for the info, Steve. That helps.
      In fact I found a web site that tells me that constituant controls do not
      yet exist during the Initialize event, so that sound like it!

      "Steve Gerrard" <mynamehere@com cast.net> wrote in message
      news:TvWdnRpV3I Oh7jzcRVn-qQ@comcast.com. ..[color=blue]
      >
      > "The Mess" <email@none.com > wrote in message
      > news:PLcod.1393 7$Le1.230463@ne ws20.bellglobal .com...
      > | Here's a simple example of my problem...
      > (snip)
      >
      > | I find it very curious that it does the Initialize event, then the
      > Resize
      > | event, then the ReadProperties event.
      > |
      > | It seems that adding something to the ComboBox with AddNew does this.
      > | When it's commented out it works like the docs say: Initialize event,
      > then
      > | the ReadProperties event, then the Resize event.
      > |
      > | Am I not understanding something right, or is this not the right
      > behaviour.
      > | I guess the workaround must be to put this in the ReadProperties
      > event?
      > |
      >
      > This appears to be true for any type of control on the user control.
      > Also, you don't have to actually change anything; merely inspecting a
      > property of a contained control will do it. I tried "If Line1.X1 = 7
      > Then", which also causes the Resize event to occur before the
      > ReadProperties event.
      >
      > Evidently any reference to a contained control requires something to
      > happen that triggers the resize event. I am in VB6, so I am pretty sure
      > MS's response to this would be "This behavior is by design."
      >
      > So, I would say, do not count on ReadProperties occuring before Resize,
      > unless you are willing to have Initialize not look at or touch anything.
      > What you do instead depends on what you need to do. By the way, normally
      > the size of the control is determined by the settings of the actual
      > control placed on a form.
      >
      >
      >
      >[/color]


      Comment

      Working...