• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

How can I suppress a form's native subroutine (show method) and replace it with several overloads (do I use shadow?)

I want to replace my form's native "show" method with several overloaded subroutines that I've built.  I want to make sure that the native 'show' routine can not be seen.  Will shadow do this?
0
David L. Hansen
Asked:
David L. Hansen
  • 3
  • 2
1 Solution
 
x77Commented:
Yes you can

      Shadows Sub Show()
         MessageBox.Show("Ok")
         MyBase.Show()
      End Sub

      Shadows Function ShowDialog() As DialogResult
         MessageBox.Show("Ok")
         Return MyBase.ShowDialog
      End Function

But if it is the main Window and you has selected it as initial Form in the application panel, Form.Show is called.
0
 
x77Commented:
Also if your form is Form1 then
  Directcast(Form1,Form).Show  - bypass Shadow Function.
0
 
David L. HansenProgrammer AnalystAuthor Commented:
I'm curious about something: if I have one routine that overloades the native 'Show' sub I have to use the 'Overloads' keyword (the ide forces me to).  I guess that's because I'm not just overloading my own custom routine but a native .net routine.  Now, I would have assumed that in the case where I'm not only overloading the native routine but also shadowing it, that I'd have to use both keywords: 'Overloads' and 'Shadows' in the declaration (especially since I have several 'Show' subs that I'm inserting) .  I see however that the IDE doesn't force me to do that though; any idea why?
0
 
x77Commented:
When a sub or Function is declared as overridable, then is a Virtual Function (Called by Reference).
If you overrides the Function, the overrided method is called.
You can also in this case call MyBase.OveridedFunction. It calls it on No Virtual mode.

If you Shadows or overloads a function, yo can each Shadowed or not sadowed Functions
In this case you have Form.Show and also Form1.Show functions.

Dim f as Form = New Form1.
F.Show - Calls Form.Show not Form1.Show
0
 
David L. HansenProgrammer AnalystAuthor Commented:
Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now