"Interface" for a form object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antony

    "Interface" for a form object

    I know this sounds stupid but I am going to carry on anyway.

    I want to create an interface that implements all methods of a form,
    plus another one or two. But I need to know if there is an interface
    that defines all a forms methods etc. In the example below
    "System.Windows .Forms.Form" isn't an interface, but it gets my point
    across. Is there an interface for a form that I can substitute here?
    Thank you again
    Tony


    Public Interface interfaceSuperF orm
    Inherits System.Windows. Forms.Form
    Sub sub1(byVal i As Integer)
    Sub sub2(byVal i As Integer)
    End Interface
  • Nak

    #2
    Re: "Interface " for a form object

    Hi there,
    [color=blue]
    > I want to create an interface that implements all methods of a form,
    > plus another one or two. But I need to know if there is an interface
    > that defines all a forms methods etc. In the example below
    > "System.Windows .Forms.Form" isn't an interface, but it gets my point
    > across. Is there an interface for a form that I can substitute here?
    > Thank you again
    > Tony[/color]

    There isn't an interface object for a form. Why do you want to declare an
    interface? are you sure it's what you want and not a derived class? Just
    make a class derived from System.Windows. Forms.Form and add your extra
    functionality. An interface isn't supposed to define how a class acts, it
    defines how a class should look.

    Nick.

    --
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    "No matter. Whatever the outcome, you are changed."

    Fergus - September 5th 2003
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    "Antony" <tonypeterson00 0001@hotmail.co m> wrote in message
    news:37ebdce4.0 309230801.6fab3 4c3@posting.goo gle.com...[color=blue]
    > I know this sounds stupid but I am going to carry on anyway.
    >[/color]
    [color=blue]
    >
    >
    > Public Interface interfaceSuperF orm
    > Inherits System.Windows. Forms.Form
    > Sub sub1(byVal i As Integer)
    > Sub sub2(byVal i As Integer)
    > End Interface[/color]


    Comment

    • Armin Zingler

      #3
      Re: &quot;Interface &quot; for a form object

      "Antony" <tonypeterson00 0001@hotmail.co m> schrieb[color=blue]
      > I know this sounds stupid but I am going to carry on anyway.
      >
      > I want to create an interface that implements all methods of a
      > form, plus another one or two. But I need to know if there is an
      > interface that defines all a forms methods etc. In the example
      > below "System.Windows .Forms.Form" isn't an interface, but it gets my
      > point across. Is there an interface for a form that I can substitute
      > here?[/color]

      No, I don't think so. What's your intention?
      [color=blue]
      > Thank you again
      > Tony
      >
      >
      > Public Interface interfaceSuperF orm
      > Inherits System.Windows. Forms.Form
      > Sub sub1(byVal i As Integer)
      > Sub sub2(byVal i As Integer)
      > End Interface[/color]


      --
      Armin

      Comment

      • Fergus Cooney

        #4
        Re: &quot;Interface &quot; for a form object

        Hi Tony,

        This is the inheritance heirarchy for Forms:

        System.Object
        System.MarshalB yRefObject
        System.Componen tModel.Componen t
        System.Windows. Forms.Control
        System.Windows. Forms.Scrollabl eControl
        System.Windows. Forms.Container Control
        System.Windows. Forms.Form

        Nary an Interface in sight. You've got lots of typing to do. :-(

        Regards,
        Fergus




        Comment

        • Tom Spink

          #5
          Re: &quot;Interface &quot; for a form object

          People have been saying that there isn't an interface, but there is...
          perhaps you want to check out the IWin32Window interface... Which is
          implemented somewhere down that fantastic hierarchy Fergus gave us.

          --
          HTH,
          -- Tom Spink, Über Geek

          Please respond to the newsgroup,
          so all can benefit

          "Chaos, Panic, Disorder, my work here is done"


          "Antony" <tonypeterson00 0001@hotmail.co m> wrote in message
          news:37ebdce4.0 309230801.6fab3 4c3@posting.goo gle.com...
          : I know this sounds stupid but I am going to carry on anyway.
          :
          : I want to create an interface that implements all methods of a form,
          : plus another one or two. But I need to know if there is an interface
          : that defines all a forms methods etc. In the example below
          : "System.Windows .Forms.Form" isn't an interface, but it gets my point
          : across. Is there an interface for a form that I can substitute here?
          : Thank you again
          : Tony
          :
          :
          : Public Interface interfaceSuperF orm
          : Inherits System.Windows. Forms.Form
          : Sub sub1(byVal i As Integer)
          : Sub sub2(byVal i As Integer)
          : End Interface


          Comment

          • Fergus Cooney

            #6
            Re: &quot;Interface &quot; for a form object

            Hi Tom,

            I was just writing a well-done-that-man response and went into MSDN to
            find out more about IWin32Window.

            System.Windows. Forms.Control
            Implements ISynchronizeInv oke, IWin32Window

            IWin32Window
            Members:
            Handle

            LOL. One member. Ah, well. :-)

            Regards,
            Fergus


            Comment

            • Jeremy Cowles

              #7
              Re: &quot;Interface &quot; for a form object


              "Nak" <a@a.com> wrote in message
              news:uTlt1DfgDH A.1404@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Hi there,
              >[color=green]
              > > I want to create an interface that implements all methods of a form,
              > > plus another one or two. But I need to know if there is an interface
              > > that defines all a forms methods etc. In the example below
              > > "System.Windows .Forms.Form" isn't an interface, but it gets my point
              > > across. Is there an interface for a form that I can substitute here?
              > > Thank you again
              > > Tony[/color]
              >
              > There isn't an interface object for a form. Why do you want to declare an
              > interface? are you sure it's what you want and not a derived class? Just
              > make a class derived from System.Windows. Forms.Form and add your extra
              > functionality. An interface isn't supposed to define how a class acts, it
              > defines how a class should look.[/color]

              Agreed. If you had an interface for a Form, there would be TONS of stuff to
              implement, why do you want that? And if you need to identify a type of
              class, you could just inherit from Forms.Form and check the unknown object
              against System.Windows. Forms.Form.

              Can you give some more information about what you want to accomplish?

              ~
              Jeremy

              Comment

              • Tom Spink

                #8
                Re: &quot;Interface &quot; for a form object

                Well.... You can't have a window without a Handle... ;-)

                Perhaps if Antony kindly explained why he wants an interface containing
                everything from all that is in your list, we could give him a better
                solution.

                --
                HTH,
                -- Tom Spink, Über Geek

                Please respond to the newsgroup,
                so all can benefit

                "Chaos, Panic, Disorder, my work here is done"


                "Fergus Cooney" <filter-1@tesco.net> wrote in message
                news:#CtCFZggDH A.2260@TK2MSFTN GP10.phx.gbl...
                : Hi Tom,
                :
                : I was just writing a well-done-that-man response and went into MSDN to
                : find out more about IWin32Window.
                :
                : System.Windows. Forms.Control
                : Implements ISynchronizeInv oke, IWin32Window
                :
                : IWin32Window
                : Members:
                : Handle
                :
                : LOL. One member. Ah, well. :-)
                :
                : Regards,
                : Fergus
                :
                :


                Comment

                • Jeremy Cowles

                  #9
                  Re: &quot;Interface &quot; for a form object

                  lol, IWin32Window is an Interface for HWND. Really though, what other
                  properties does *every* type of Win32 Window share? (style bits maybe?)

                  =)


                  "Tom Spink" <thomas.spink@n tlworld.com> wrote in message
                  news:e9rVUcggDH A.3128@tk2msftn gp13.phx.gbl...[color=blue]
                  > Well.... You can't have a window without a Handle... ;-)
                  >
                  > Perhaps if Antony kindly explained why he wants an interface containing
                  > everything from all that is in your list, we could give him a better
                  > solution.
                  >
                  > --
                  > HTH,
                  > -- Tom Spink, Über Geek
                  >
                  > Please respond to the newsgroup,
                  > so all can benefit
                  >
                  > "Chaos, Panic, Disorder, my work here is done"
                  >
                  >
                  > "Fergus Cooney" <filter-1@tesco.net> wrote in message
                  > news:#CtCFZggDH A.2260@TK2MSFTN GP10.phx.gbl...
                  > : Hi Tom,
                  > :
                  > : I was just writing a well-done-that-man response and went into MSDN[/color]
                  to[color=blue]
                  > : find out more about IWin32Window.
                  > :
                  > : System.Windows. Forms.Control
                  > : Implements ISynchronizeInv oke, IWin32Window
                  > :
                  > : IWin32Window
                  > : Members:
                  > : Handle
                  > :
                  > : LOL. One member. Ah, well. :-)
                  > :
                  > : Regards,
                  > : Fergus
                  > :
                  > :
                  >
                  >
                  >[/color]

                  Comment

                  • Antony

                    #10
                    Re: &quot;Interface &quot; for a form object

                    >[color=blue]
                    > Perhaps if Antony kindly explained why he wants an interface containing
                    > everything from all that is in your list, we could give him a better
                    > solution.
                    >[/color]

                    Tom, apologies, I post and read through Google Groups UK and there is
                    a considerable (normally about 6-9 hours) delay before the thread is
                    updated and I can see my and everyone elses posts. I have just
                    read all the postings now (9:45am BST, 24 Sept 2003). Armin also asked
                    me why I wanted to do this. Here's my attempt at explaining. Don't be
                    hard on me, I'm a novice programmer, late 60's, and still learning.

                    I think I needed an interface for the following reason. I want to
                    create an instance of a form that behaves like all other forms in
                    every respect except for I want to be able to **guarantee** that it has
                    additional methods. The following works:


                    Public Interface testInterface
                    Sub sub1(ByVal i As Integer)
                    Sub sub2(ByVal i As Integer)
                    End Interface

                    Public Class class1
                    Inherits Form
                    Implements testInterface

                    Public Sub sub1(ByVal i As Integer) Implements testInterface.s ub1
                    'do something
                    End Sub

                    Public Sub sub2(ByVal i As Integer) Implements testInterface.s ub2
                    'do something
                    End Sub
                    End Class


                    But what I really think I want, is where "class1" just implements an
                    interface (or an abstract mustinherit class) - that is no "Inherits"
                    statement in the class declaration. The following imaginary code is
                    what I am after. This way I always know that sub1 and sub2 exist,
                    along with all the other stuff for form, because they implement superForm.


                    Public Interface superForm
                    Inherits ...... 'Whatever the form interface or mustinherit class is
                    Sub sub1(ByVal i As Integer)
                    Sub sub2(ByVal i As Integer)
                    End Interface

                    Public Class class1
                    Implements superInterface
                    'code in here
                    'code in here
                    End Class


                    Thank you all.
                    Tony

                    "Tom Spink" <thomas.spink@n tlworld.com> wrote in message news:<e9rVUcggD HA.3128@tk2msft ngp13.phx.gbl>. ..[color=blue]
                    > Well.... You can't have a window without a Handle... ;-)
                    >
                    > Perhaps if Antony kindly explained why he wants an interface containing
                    > everything from all that is in your list, we could give him a better
                    > solution.
                    >
                    > --
                    > HTH,
                    > -- Tom Spink, Über Geek
                    >
                    > Please respond to the newsgroup,
                    > so all can benefit
                    >
                    > "Chaos, Panic, Disorder, my work here is done"
                    >
                    >
                    > "Fergus Cooney" <filter-1@tesco.net> wrote in message
                    > news:#CtCFZggDH A.2260@TK2MSFTN GP10.phx.gbl...
                    > : Hi Tom,
                    > :
                    > : I was just writing a well-done-that-man response and went into MSDN to
                    > : find out more about IWin32Window.
                    > :
                    > : System.Windows. Forms.Control
                    > : Implements ISynchronizeInv oke, IWin32Window
                    > :
                    > : IWin32Window
                    > : Members:
                    > : Handle
                    > :
                    > : LOL. One member. Ah, well. :-)
                    > :
                    > : Regards,
                    > : Fergus
                    > :
                    > :[/color]

                    Comment

                    • Fergus Cooney

                      #11
                      Re: &quot;Interface &quot; for a form object

                      Hi Antony,

                      Welcome to programming! :-)

                      || I want to create an instance of a form that behaves
                      || like all other forms in every respect except for I want
                      || to be able to **guarantee** that it has additional methods.

                      A reasonable request.

                      || Public Class MyForm
                      || Inherits Form
                      || Implements testInterface

                      This will do exactly that, you'll be glad to know. The compiler won't let
                      you get away without implementing testInterface. You might just write empty
                      methods - but they <have to exist>. Therefore, for a user of your new Form
                      class, they are guaranteed.

                      It's a good job too. If you had a Form that 'inherits' a Form interface it
                      would have to have implementations of <everything> in that interface. In other
                      words you would have to write fresh, <new> code for the entire class. By
                      inheriting from the Form class, you effectively get the Form interface <and>
                      all the code.

                      I hope that explains things a bit. :-)

                      Regards,
                      Fergus


                      Comment

                      • Fergus Cooney

                        #12
                        Re: &quot;Interface &quot; for a form object

                        Hi Antony,

                        Welcome to programing! :-)

                        || I want to create an instance of a form that behaves
                        || like all other forms in every respect except for I want
                        || to be able to **guarantee** that it has additional methods.

                        A reasonable request.

                        || Public Class MyForm
                        || Inherits Form
                        || Implements testInterface

                        This will do exactly that, you'll be glad to know. The compiler won't let
                        you get away without implementing testInterface. You might just write empty
                        methods - but they <have to exist>. Therefore, for a user of your new Form
                        class, they are guaranteed.

                        It's a good job too. If you had a Form that 'inherits' a Form interface it
                        would have to have implementations of <everything> in that interface. In other
                        words you would have to write fresh, <new> code for the entire class. By
                        inheriting from the Form class, you effectively get the Form interface <and>
                        all the code.

                        I hope that explains things a bit. :-)

                        Regards,
                        Fergus



                        Comment

                        Working...