ralph
4/5/2012 4:50:00 PM
On Thu, 05 Apr 2012 12:31:03 -0400, Jim Mack <no-uce-ube@mdxi.com>
wrote:
>I have this working after a slight hiccup, but I'm curious if anyone
>can explain what's going on in this situation. I'm a pragmatist at
>heart -- if it works, move on -- but I do like to know what's under the
>hood.
>
>In a project with a form and a module, I do all the real work in a loop
>(state machine) in the module, but I need the form to host two WMP
>(media player) controls, in a control array.
>
>To avoid having to always reference the form when manipulating them, I
>Dim an array of the same type in the module and Set into the variables
>a reference to the controls on the form. In the module:
>
> Private LocalForm As frmHost
> Private WMP(0 To 1) As WindowsMediaPlayer
> ...
> ...
> Sub Main
> Set LocalForm = New frmHost
> Load LocalForm
> Set WMP(0) = LocalForm.Player(0)
>
>Now WMP(0) can access Player(0)'s properties and invoke its methods.
>Very standard stuff, works as expected.
>
>But not quite -- some of the properties aren't available to the local
>reference. For example, this is setting up a player:
>
> With WMP(0) ' This is the local reference
> .uiMode = "none"
> .stretchToFit = True
> .URL = m_ClipNames(m_CurrentClip)
> .settings.Volume = 50
> Duration(m_CurrentClip) = .Controls.currentMedia.duration
> End With
>
>' HOWEVER --
>
> With LocalForm.Player(0) ' This is the original
> .Left = 0
> .Top = 0
> .Width = m_Width
> .Height = m_Height
> End With
>
>The second set of properties is not available via WMP (the copy), only
>via the original control. It hasn't escaped my notice that these are
>all "UI" properties, likely added by some wrapper.
>
>I'm sure there's a simple explanation, but I don't know enough about
>what happens behind the scenes to figure it out. Any insight would be
>appreciated.
Because the object references are not the same. They are declared as
two separate 'interfaces', albeit they are supported by the same
object.
All VB Object References actually refer to, is declared as, an
"Interface". This