Home All Groups Group Topic Archive Search About

Best way to handle interface and Forms

Author
6 Dec 2006 6:50 PM
Michael
Hi Everyone,
I've created a project that uses a plugin interface. These plugings will
hold data entry forms that will be printed in Word. I have a main mdi form
that contains a combo that contains the clients. I need a way to send the
pluging form a message when a client changes in the main form.
My first though was to return an instance of the form when it is loaded, but
I need to set a property (clientId) on the plugin form and since ClientId is
not part of the form definition it will fail to compile. My next thought was
to create an interface and inherit Form and include my CleintId property, but
can't do that because Form is not an interface. Is there an Interface for the
form? Or would it be better to create a new Class inheriting from Form and
then add my new properties and then use that as a Base class for all Plugin
forms? Thanks for any suggestions.
Michael

Author
6 Dec 2006 7:30 PM
jeff
I would recommend Inheritance.




Show quoteHide quote
"Michael" <Mich***@discussions.microsoft.com> wrote in message
news:F5C0A9A4-72FD-4701-B107-F571CF59FACF@microsoft.com...
> Hi Everyone,
> I've created a project that uses a plugin interface. These plugings will
> hold data entry forms that will be printed in Word. I have a main mdi form
> that contains a combo that contains the clients. I need a way to send the
> pluging form a message when a client changes in the main form.
> My first though was to return an instance of the form when it is loaded,
> but
> I need to set a property (clientId) on the plugin form and since ClientId
> is
> not part of the form definition it will fail to compile. My next thought
> was
> to create an interface and inherit Form and include my CleintId property,
> but
> can't do that because Form is not an interface. Is there an Interface for
> the
> form? Or would it be better to create a new Class inheriting from Form and
> then add my new properties and then use that as a Base class for all
> Plugin
> forms? Thanks for any suggestions.
> Michael
>
Author
7 Dec 2006 5:18 AM
Cor Ligthert [MVP]
Michael,

I am not sure what you want to do, but did you ever thought on throwing and
catching Events?

Cor

Show quoteHide quote
"Michael" <Mich***@discussions.microsoft.com> schreef in bericht
news:F5C0A9A4-72FD-4701-B107-F571CF59FACF@microsoft.com...
> Hi Everyone,
> I've created a project that uses a plugin interface. These plugings will
> hold data entry forms that will be printed in Word. I have a main mdi form
> that contains a combo that contains the clients. I need a way to send the
> pluging form a message when a client changes in the main form.
> My first though was to return an instance of the form when it is loaded,
> but
> I need to set a property (clientId) on the plugin form and since ClientId
> is
> not part of the form definition it will fail to compile. My next thought
> was
> to create an interface and inherit Form and include my CleintId property,
> but
> can't do that because Form is not an interface. Is there an Interface for
> the
> form? Or would it be better to create a new Class inheriting from Form and
> then add my new properties and then use that as a Base class for all
> Plugin
> forms? Thanks for any suggestions.
> Michael
>
Author
7 Dec 2006 11:46 AM
Phill W.
Michael wrote:

> My first though was to return an instance of the form when it is loaded, but
> I need to set a property (clientId) on the plugin form and since ClientId is
> not part of the form definition it will fail to compile. My next thought was
> to create an interface and inherit Form and include my CleintId property, but
> can't do that because Form is not an interface. Is there an Interface for the
> form? Or would it be better to create a new Class inheriting from Form and
> then add my new properties and then use that as a Base class for all Plugin
> forms?

I think you may be confusing Interfaces and Inheritance.

If you want to add a property to a Form, you /could/ use an Interface:

Public Interface IPlugIn
    WriteOnly Property ClientId() As ..whatever..

The question is what do you then /do/ with that ID.  If you have some
common functionality that /all/ your Plug-in forms should have (even
just storing this value might be enough), then you need to look at
inheriting from Form and adding the property to this subclass.  In this
way, you can provide the /basic/ implementation for dealing with the
ClientID property (but, perhaps, giving each subclass a means to extend
it):

Public Class PlugInForm
    Inherits Form

    Public WriteOnly Property ClientId() as ..whatever..

' or, alternatively,

    Public Sub New() ' required by the Forms Designer (VB'2003)
    End Sub

    Public Sub New( ByVal clientId As ..whatever.. )
       Me.New()
       ' Store clientId
    End Sub

End Class

Actually, since plugins are normally loaded dynamically, you might be
better off doing /both/ - putting base functionality into your custom
Form, but /also/ implementing an Interface through which you /limit/
what you can do with the object, i.e. those common methods and
properties that /every/ plug-in has to have, without all the other stuff
that comes with any old Form.

HTH,
    Phill  W.
Author
7 Dec 2006 2:06 PM
Michael
Hi Everyone,
Thanks for the replys. I thought I would try and clear a few things up. I
work in a medical clinic and they have many forms (physicals, Treatments
plans, ect..) that need to be created each day. For each of these
reports/Forms I wanted to create a plugin that would allow them to enter the
data, view past reports and print the form in Word. I have designed the app
with a mdi interface with the main form (MDI Parent) has a combo with the
client names. I wanted to be able to open a report, then select a client and
create the document needed. Then I wanted to be able to select another client
and create another report without closing the form. So I needed to alert the
plugin when the client changes so that it can load up past reports.
For example, Yesterday I did some testing and didn't get the results I
wanted. For example, I played with the idea of creating a Template form that
contained the new property (ClientId). But once I inherit the form, the new
form can't be edited, can't edit the events on the new form that relate to
any control on the base form. I may not of had all the flags (MustInherit,
MustOverRide, ect..) correct.
I'll take a look at what you posted Phil and see if this helps me out. Thank
you all for the suggestions.
Michael