AmbientProperties: how to get it in my ActiveX control?
Help me please! I am beginner in VB.NET and i have a problem.
When I wrote ActiveX control in VB6, container properties was accessible in InitProperties or ReadProperties events of UserControl as:
| |
PrivateSub UserControl_InitProperties()Set m_objMyObject = UserControl.Ambient.SomeObj ' or just ' Set m_objMyObject = Ambient.SomeObj End Sub
|
How i can get same container property in VB.NET? And where i can get it (in what evemt or method)?
Thanks!
[807 byte] By [
Wrangler] at [2007-12-16]
To make a sub a event triggered sub, there are 2 ways.
1,
| |
Public Class Form1 Private WithEvents Mything As Thing Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Mything = New Thing End Sub
Public Sub Blah() Handles Mything.SomeEvent
End Sub End ClassPublic Class Thing Public Event SomeEvent()End Class
|
Method 2, is to add / remove event handlers.
| |
Public Class Form1 Private WithEvents Mything As Thing Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Mything = New Thing AddHandler Mything.SomeEvent, AddressOf Blah RemoveHandler Mything.SomeEvent, AddressOf Blah End Sub Public Sub Blah() End Sub End ClassPublic Class Thing Public Event SomeEvent()End Class
|
Thanks! But i think it is not exactly i need.
I make ActiveX control. Some application loads it in runtime and interact with my control through some "connection object".
In practice it looks like:
| |
Public Class MyControl Inherits System.Windows.Forms.UserControl Private WithEvents m_objConnObject as ContainerApp.ConnObject Private Sub m_objConnObject_OnSomeEvent(...) Handles m_objConnObject.SomeEvent ' event processing End Sub ' other m_objConnObject's events handlers End Class
|
But I don't know
how i can get m_objConnObject from container application and
where (in which event/method of VB.NET project).
Container application does provide ConnObject as Ambient property.
Btw, do You have examples of using AmbientProperties in VB.NET ActiveX controls? It could be very helpful for me i hope.
Thanks!