Inherited handler problem.

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

    #1

    Inherited handler problem.

    Hi,

    I've problem with button click handler.

    In a short brief my program looks like this:

    there is form invoice with is base class for invoice_edit form.

    invoice form has public button "save" with modifers option set to
    public

    invoice_edit form has method which handles save.click and do some code

    Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles save.Click

    there is third form invoice_prod which inherits from invoice_edit and
    also handles "save" button with this method declaration:

    Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles save.Click

    So, when I launch my invoice_prod:

    invoice_prod.Sh owDialog() and click on "save" button involved with
    public sub save_click from form invoice_edit executing.

    Please help, how to execute method from invoice_prod form.

  • aaron.kempf@gmail.com

    #2
    Re: Inherited handler problem.

    personalyl I dont know who the hell came up with this syntax

    Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles save.Click


    that is TOO VERBOSE

    move back to VB6
    or change to PHP

    -Aaron


    kosecki wrote:
    Hi,
    >
    I've problem with button click handler.
    >
    In a short brief my program looks like this:
    >
    there is form invoice with is base class for invoice_edit form.
    >
    invoice form has public button "save" with modifers option set to
    public
    >
    invoice_edit form has method which handles save.click and do some code
    >
    Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles save.Click
    >
    there is third form invoice_prod which inherits from invoice_edit and
    also handles "save" button with this method declaration:
    >
    Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles save.Click
    >
    So, when I launch my invoice_prod:
    >
    invoice_prod.Sh owDialog() and click on "save" button involved with
    public sub save_click from form invoice_edit executing.
    >
    Please help, how to execute method from invoice_prod form.

    Comment

    • RobinS

      #3
      Re: Inherited handler problem.

      I'm sorry, I'm confused. Is this right:

      You have a base class form form called invoice_edit
      that has a Save method in it.

      You have a form that inherits from invoice_edit that
      is called invoice. This has a "save" button on it.

      You have a form that inherits from invoice_edit that
      is called invoide_prod. This has a "save" button on it.

      Is that right? So what's the problem exactly?

      Robin S.
      ------------------------------------

      "kosecki" <piotrkosinski@ gmail.comwrote in message
      news:1164228951 .634318.300320@ m73g2000cwd.goo glegroups.com.. .
      Hi,
      >
      I've problem with button click handler.
      >
      In a short brief my program looks like this:
      >
      there is form invoice with is base class for invoice_edit form.
      >
      invoice form has public button "save" with modifers option set to
      public
      >
      invoice_edit form has method which handles save.click and do some code
      >
      Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
      System.EventArg s) Handles save.Click
      >
      there is third form invoice_prod which inherits from invoice_edit and
      also handles "save" button with this method declaration:
      >
      Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
      System.EventArg s) Handles save.Click
      >
      So, when I launch my invoice_prod:
      >
      invoice_prod.Sh owDialog() and click on "save" button involved with
      public sub save_click from form invoice_edit executing.
      >
      Please help, how to execute method from invoice_prod form.
      >

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Inherited handler problem.

        Kosecki,

        Do you mean that you want to shadows the method of your last button?
        http://msdn.microsoft.com/library/de...keyShadows.asp

        Cor

        "kosecki" <piotrkosinski@ gmail.comschree f in bericht
        news:1164228951 .634318.300320@ m73g2000cwd.goo glegroups.com.. .
        Hi,
        >
        I've problem with button click handler.
        >
        In a short brief my program looks like this:
        >
        there is form invoice with is base class for invoice_edit form.
        >
        invoice form has public button "save" with modifers option set to
        public
        >
        invoice_edit form has method which handles save.click and do some code
        >
        Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
        System.EventArg s) Handles save.Click
        >
        there is third form invoice_prod which inherits from invoice_edit and
        also handles "save" button with this method declaration:
        >
        Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
        System.EventArg s) Handles save.Click
        >
        So, when I launch my invoice_prod:
        >
        invoice_prod.Sh owDialog() and click on "save" button involved with
        public sub save_click from form invoice_edit executing.
        >
        Please help, how to execute method from invoice_prod form.
        >

        Comment

        • Master Programmer

          #5
          Re: Inherited handler problem.


          aaron.kempf@gma il.com wrote:
          personalyl I dont know who the hell came up with this syntax
          >
          Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
          System.EventArg s) Handles save.Click
          >
          >
          that is TOO VERBOSE
          >
          move back to VB6
          or change to PHP
          >
          -Aaron
          >
          >
          kosecki wrote:
          Hi,

          I've problem with button click handler.

          In a short brief my program looks like this:

          there is form invoice with is base class for invoice_edit form.

          invoice form has public button "save" with modifers option set to
          public

          invoice_edit form has method which handles save.click and do some code

          Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
          System.EventArg s) Handles save.Click

          there is third form invoice_prod which inherits from invoice_edit and
          also handles "save" button with this method declaration:

          Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
          System.EventArg s) Handles save.Click

          So, when I launch my invoice_prod:

          invoice_prod.Sh owDialog() and click on "save" button involved with
          public sub save_click from form invoice_edit executing.

          Please help, how to execute method from invoice_prod form.

          Comment

          • Phill W.

            #6
            Re: Inherited handler problem.

            kosecki wrote:
            Hi,
            >
            I've problem with button click handler.
            >
            In a short brief my program looks like this:
            >
            there is form invoice with is base class for invoice_edit form.
            >
            invoice form has public button "save" with modifers option set to
            public
            >
            invoice_edit form has method which handles save.click and do some code
            >
            Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
            System.EventArg s) Handles save.Click
            >
            there is third form invoice_prod which inherits from invoice_edit and
            also handles "save" button with this method declaration:
            >
            Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
            System.EventArg s) Handles save.Click
            >
            So, when I launch my invoice_prod:
            >
            invoice_prod.Sh owDialog() and click on "save" button involved with
            public sub save_click from form invoice_edit executing.
            >
            Please help, how to execute method from invoice_prod form.
            When inheriting visual classes, it is *far* better to provide an
            Overridable method that performs each action, rather than attaching
            event handlers. I haven't found any way of finding out which, if any,
            event handlers exist for a given event and, if you can manipulate them
            in code, you can't guarantee the order in which the event handlers might
            run.

            Going down the "overriding " route, you'd have something like this:

            Class InvoiceForm
            Protected WithEvents save As Button

            Protected Overridable Sub OnSaveClick()
            ' Basic functionality goes here
            End Sub

            Private Sub save_Click( ... ) Handles save.Click
            Me.OnSaveClick( )
            End Sub

            End Class

            Class Invoice_Edit
            Inherits InvoiceForm

            Protected Overrides Sub OnSaveClick()
            ' *Alternative* functionality goes here

            ' ' To use the code in InvoiceForm.OnS aveClick, use
            ' MyBase.OnSaveCl ick()

            End Sub

            End Class

            Class Invoice_Prod
            Inherits Invoice_Edit

            Protected Overrides Sub OnSaveClick()
            ' Alternative functionality goes here

            ' ' To use the code in Invoice_Edit.On SaveClick, use
            ' MyBase.OnSaveCl ick()

            ' NB: You cannot access /InvoiceForm/.OnSaveClick directly
            End Sub

            End Class

            HTH,
            Phill W.

            Comment

            • Phill W.

              #7
              Re: Inherited handler problem.

              kosecki wrote:
              Hi,
              >
              I've problem with button click handler.
              >
              In a short brief my program looks like this:
              >
              there is form invoice with is base class for invoice_edit form.
              >
              invoice form has public button "save" with modifers option set to
              public
              >
              invoice_edit form has method which handles save.click and do some code
              >
              Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
              System.EventArg s) Handles save.Click
              >
              there is third form invoice_prod which inherits from invoice_edit and
              also handles "save" button with this method declaration:
              >
              Public Sub save_Click(ByVa l sender As System.Object, ByVal e As
              System.EventArg s) Handles save.Click
              >
              So, when I launch my invoice_prod:
              >
              invoice_prod.Sh owDialog() and click on "save" button involved with
              public sub save_click from form invoice_edit executing.
              >
              Please help, how to execute method from invoice_prod form.
              When inheriting visual classes, it is *far* better to provide an
              Overridable method that performs each action, rather than attaching
              event handlers. I haven't found any way of finding out which, if any,
              event handlers exist for a given event and, if you can manipulate them
              in code, you can't guarantee the order in which the event handlers might
              run.

              Going down the "overriding " route, you'd have something like this:

              Class InvoiceForm
              Protected WithEvents save As Button

              Protected Overridable Sub OnSaveClick()
              ' Basic functionality goes here
              End Sub

              Private Sub save_Click( ... ) Handles save.Click
              Me.OnSaveClick( )
              End Sub

              End Class

              Class Invoice_Edit
              Inherits InvoiceForm

              Protected Overrides Sub OnSaveClick()
              ' *Alternative* functionality goes here

              ' ' To use the code in InvoiceForm.OnS aveClick, use
              ' MyBase.OnSaveCl ick()

              End Sub

              End Class

              Class Invoice_Prod
              Inherits Invoice_Edit

              Protected Overrides Sub OnSaveClick()
              ' Alternative functionality goes here

              ' ' To use the code in Invoice_Edit.On SaveClick, use
              ' MyBase.OnSaveCl ick()

              ' NB: You cannot access /InvoiceForm/.OnSaveClick directly
              End Sub

              End Class

              HTH,
              Phill W.

              Comment

              Working...