473,769 Members | 4,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB HELP: Sharing A Variable From Win Application To Dynamically Added Control

I have an application and use custom user controls as plugins. Is there any
way to communicate back and forth from control to app. NOTE: The control is
not refrenced in the app, it will act as a plugin and will be dynamically
loaded to the app.

Example:

1. My application as a public variable
2. The control must receieve the value of the public variable
3. The control will do some math and encryption of the variable
4. The control will return the value to the main application
5. The application will display the results

Any help on how to communicate back and forth with the dynamically created
control will be greatly appreciated!

Thanks,

Dan
Nov 21 '05 #1
3 1090
"Daniel Friend" <da*@donotspam. com> wrote in message
news:O6******** ******@TK2MSFTN GP12.phx.gbl...
I have an application and use custom user controls as plugins.
Is there any way to communicate back and forth from control
to app. NOTE: The control is not referenced in the app


I'd do it this way:

Every Plug-In implements this Interface:

Public Interface IPlugIn
WriteOnly Property ParentForm as IPlugInContaine r
' Any other properties/methods that the main application
' might ask /every/ plug-in to do.
End Interface

Have the main application implement this Interface:

Public Interface IPlugInContaine r
' Include any properties/methods that a Plug-In might need.
' /Don't/ rely on properties that /happen/ to be on the Form
End Interface

Both of these exist in an assembly common to both the application
and the plug-ins. They form a well-defined communication channel
between plug-in and application; a common currency that the two
can "converse" in.

As you load [each] plug-in into your application, assign the Form
to the [IPlugIn].ParentForm property (you *know* it's there
because the plug-in, whatever /else/ it does, implements the Interface),
as in

' Get Plug-In object
oLoadedPlugIn = Activator.Creat eInstance( ...

' Pass the parent application [form] reference to the plug-in
DirectCast( oLoadedPlugIn, IPlugIn ).ParentForm _
= DirectCast( Me, IPlugInContaine r )

Your plug-in can now access anything in the IPlugInContaine r
Interface (which, of course, calls methods in the main application).

HTH,
Phill W.
Nov 21 '05 #2
If the control is created by the application can you create it based off of
MustInherit class?

Public MustInherit Class DynControl

Public ReadOnly Property MyCalulations () as Object (or whatever)

Public Event ImDoneCalculati ng (ByVal sender As Object, e as
System.EventArg s)

.......

Private sub Calc
....
RaiseEvent ImDoneCalculati ng (me, System.EventArg s.Empty)
End Sub

End Class
Public Class MyApp
Private Sub CreateDynContro l

Dim MyControl as New DynControl
AddHandler MyControl.ImDon eCalculating , AddressOf Handle_ImDone

End Sub

Private Sub Handle_ImDone (ByVal sender As Object, e as
System.EventArg s)

Dim objValue as Object (or whatever)
objValue = sender.MyCalcul ations

End Sub

End Class
"Daniel Friend" <da*@donotspam. com> wrote in message
news:O6******** ******@TK2MSFTN GP12.phx.gbl...
I have an application and use custom user controls as plugins. Is there
any
way to communicate back and forth from control to app. NOTE: The control
is
not refrenced in the app, it will act as a plugin and will be dynamically
loaded to the app.

Example:

1. My application as a public variable
2. The control must receieve the value of the public variable
3. The control will do some math and encryption of the variable
4. The control will return the value to the main application
5. The application will display the results

Any help on how to communicate back and forth with the dynamically created
control will be greatly appreciated!

Thanks,

Dan

Nov 21 '05 #3
Actually, scratch my answer.

I was in the middle of doing what I told you to do, and just skimmed over
your question, so it seemed right at the time. But thinking about it for a
sec...

1. What exactly are you dynamically creating? How do you 'on the fly'
create a control to do math calcs?
2. My syntax is off on the CreateDynContro l, we can get back to that.
3. I skipped over #2 of your explination, so it has nothing to do w/ your
problem.

How are you creating this control? And what exactly do you mean by dynamic?
If your doing math and encryption it seems like your using a precreated
class / .dll and just calling it at run time?


"Eric Dreksler" <ericd AT accessoneinc DOT com> wrote in message
news:%2******** *******@TK2MSFT NGP14.phx.gbl.. .
If the control is created by the application can you create it based off
of MustInherit class?

Public MustInherit Class DynControl

Public ReadOnly Property MyCalulations () as Object (or whatever)

Public Event ImDoneCalculati ng (ByVal sender As Object, e as
System.EventArg s)

......

Private sub Calc
....
RaiseEvent ImDoneCalculati ng (me, System.EventArg s.Empty)
End Sub

End Class
Public Class MyApp
Private Sub CreateDynContro l

Dim MyControl as New DynControl
AddHandler MyControl.ImDon eCalculating , AddressOf Handle_ImDone

End Sub

Private Sub Handle_ImDone (ByVal sender As Object, e as
System.EventArg s)

Dim objValue as Object (or whatever)
objValue = sender.MyCalcul ations

End Sub

End Class
"Daniel Friend" <da*@donotspam. com> wrote in message
news:O6******** ******@TK2MSFTN GP12.phx.gbl...
I have an application and use custom user controls as plugins. Is there
any
way to communicate back and forth from control to app. NOTE: The control
is
not refrenced in the app, it will act as a plugin and will be dynamically
loaded to the app.

Example:

1. My application as a public variable
2. The control must receieve the value of the public variable
3. The control will do some math and encryption of the variable
4. The control will return the value to the main application
5. The application will display the results

Any help on how to communicate back and forth with the dynamically
created
control will be greatly appreciated!

Thanks,

Dan


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3735
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button. When the user clicks the "Add another email" it will call a client side JavaScript function, add_email, which will dynamically add a new set of controls to the webpage using the innerHTML method. It appears to work perfectly fine in the browser. The...
2
7164
by: intrepid_dw | last post by:
All I am writing a C# WinForms application which is giving me some problems. The application consists of a form containing an empty Tab control to which TabPages are added dynamically (at runtime). Each TabPage contains a single Panel control. My intent is to draw a graph on that Panel control dynamically, with the code capturing a point at each update interval, then calling the Graphics.DrawLine method of the panel
5
1930
by: =?Utf-8?B?U2FsYW1FbGlhcw==?= | last post by:
Hi, I have a user control which I like to use in several projects (winforms) in the same solution. Inside lets say Winapp1 , When adding a reference to this control, I can dynamically or statically create it and when running the application it is correctly drawn on the form. But when I take out the reference to this control in Winapp1, reference it in a utility project, then reference the utility project in Winapp1 or Winapp2, instantiate...
2
10045
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name is used to access and read the value stored in it C.A variable is allocated or deallocated in memory during runtime D.A variable can be initialized at the time of its creation or later 2. The.……types feature facilitates the definition of classes...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.