|
-
Dec 12th, 2003, 02:29 AM
#1
Thread Starter
Lively Member
Plug-in Interface
http://www.divil.co.uk/net/articles/plugins/plugins.asp
I have found this article on the topic. It is a very good article, but all it describes is how to access plug-in methods. I would like to know how to import a panel (or other control) created by a plug-in. All of the panel events can stay in the plug-in. Is there an easy way to do this without changing everything this guy has created? Or can you suggest a better article explaining implementation of plug-ins in a VB.NET application?
http://www.divil.co.uk/net/articles/plugins/plugins.asp
-
Dec 12th, 2003, 09:43 AM
#2
Well the way I do it is to send a reference of my form, or whatever container to use to put new controls on, to the plugin via some kind of loading method of the plugin.
Sub Load(ByRef myForm as System.Windows.Forms.Form)
Then the plugin takes that reference and adds whatever it needs to to the pased form.
I used a TabControl for a test I did once where the plugin added a new tab to the main apps form
looked like this
VB Code:
Public Class Chat
Implements Interfaces.IPlugin
Dim tb As TextBox
Public Sub Panel_Init(ByRef tab As TabControl) Implements Interfaces.IPlugin.Panel_Init
Dim page As TabPage
Dim x As Long
Dim tb2 As TextBox
Dim g As New GroupBox()
' Create a new tab
page = New TabPage()
page.Text = "Chat"
page.Name = "Chat"
g.Name = "beauh"
g.Tag = CStr(page.TabIndex)
g.Text = "blah"
g.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
' Create textbox that will appear in Home tab
tb = New TextBox()
tb.Name = "tbChat"
tb.Multiline = True
tb.Top = g.Top + 15
tb.Left = g.Left + 8
tb.Height = g.Height - 400
tb.Width = g.Width - 16
tb.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
' Add textbox to tab page and tab page to tab container.
tb2 = New TextBox()
tb2.Name = "tbSend"
tb2.Multiline = True
tb2.Top = g.Height - 75
tb2.Height = 50
tb2.Left = g.Left + 8
tb2.Width = g.Width - 16
tb2.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
' Add textbox to tab page and tab page to tab container.
g.Controls.Add(tb)
g.Controls.Add(tb2)
page.Controls.Add(g)
tab.TabPages.Add(page)
'tb = Nothing
SharedDLLTest.Test.Name = "Hello"
'MessageBox.Show(System.Environment.UserName)
End Sub
Private Sub go() Implements Interfaces.IPlugin.go
tb.Text = SharedDLLTest.Test.PluginCollection.Count
End Sub
End Class
-
Dec 12th, 2003, 02:26 PM
#3
Thread Starter
Lively Member
That's awesome, thanks a bunch. That really helped, I'm gonna try it when I get home. I see that you are the main authority on plug-ins.
-
Dec 12th, 2003, 08:44 PM
#4
yay gay
i've tried seting to my form a reference to the panel and that wont work, at least the way i did
anyways i overcame the problem adding the panel to the form control's collection
\m/  \m/
-
Dec 13th, 2003, 04:31 AM
#5
Thread Starter
Lively Member
How do I handle events on the plugin, Say I created a new tab page like Cander posted, How do I handle events on that tab page?
-
Dec 13th, 2003, 10:36 PM
#6
Thread Starter
Lively Member
-
Dec 13th, 2003, 10:39 PM
#7
yay gay
when you create the plugin just do its events as they will get attached to it when you load the panel with your main form
\m/  \m/
-
Dec 13th, 2003, 10:40 PM
#8
Thread Starter
Lively Member
Thanks for the speady reply, I think I have kinda figured it out. I'm just working on how to get info to the main form calling the plugin now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|