473,381 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 software developers and data experts.

"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 interfaceSuperForm
Inherits System.Windows.Forms.Form
Sub sub1(byVal i As Integer)
Sub sub2(byVal i As Integer)
End Interface
Nov 20 '05 #1
11 2189
Nak
Hi there,
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
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" <to****************@hotmail.com> wrote in message
news:37**************************@posting.google.c om... I know this sounds stupid but I am going to carry on anyway.


Public Interface interfaceSuperForm
Inherits System.Windows.Forms.Form
Sub sub1(byVal i As Integer)
Sub sub2(byVal i As Integer)
End Interface

Nov 20 '05 #2
"Antony" <to****************@hotmail.com> schrieb
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?
No, I don't think so. What's your intention?
Thank you again
Tony
Public Interface interfaceSuperForm
Inherits System.Windows.Forms.Form
Sub sub1(byVal i As Integer)
Sub sub2(byVal i As Integer)
End Interface

--
Armin

Nov 20 '05 #3
Hi Tony,

This is the inheritance heirarchy for Forms:

System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.ContainerControl
System.Windows.Forms.Form

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

Regards,
Fergus


Nov 20 '05 #4
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" <to****************@hotmail.com> wrote in message
news:37**************************@posting.google.c om...
: 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 interfaceSuperForm
: Inherits System.Windows.Forms.Form
: Sub sub1(byVal i As Integer)
: Sub sub2(byVal i As Integer)
: End Interface
Nov 20 '05 #5
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 ISynchronizeInvoke, IWin32Window

IWin32Window
Members:
Handle

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

Regards,
Fergus
Nov 20 '05 #6

"Nak" <a@a.com> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...
Hi there,
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


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.


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

Nov 20 '05 #7
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" <fi******@tesco.net> wrote in message
news:#C**************@TK2MSFTNGP10.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 ISynchronizeInvoke, IWin32Window
:
: IWin32Window
: Members:
: Handle
:
: LOL. One member. Ah, well. :-)
:
: Regards,
: Fergus
:
:
Nov 20 '05 #8
lol, IWin32Window is an Interface for HWND. Really though, what other
properties does *every* type of Win32 Window share? (style bits maybe?)

=)
"Tom Spink" <th**********@ntlworld.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
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" <fi******@tesco.net> wrote in message
news:#C**************@TK2MSFTNGP10.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 ISynchronizeInvoke, IWin32Window
:
: IWin32Window
: Members:
: Handle
:
: LOL. One member. Ah, well. :-)
:
: Regards,
: Fergus
:
:


Nov 20 '05 #9
>
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.

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.sub1
'do something
End Sub

Public Sub sub2(ByVal i As Integer) Implements testInterface.sub2
'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" <th**********@ntlworld.com> wrote in message news:<e9**************@tk2msftngp13.phx.gbl>... 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" <fi******@tesco.net> wrote in message
news:#C**************@TK2MSFTNGP10.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 ISynchronizeInvoke, IWin32Window
:
: IWin32Window
: Members:
: Handle
:
: LOL. One member. Ah, well. :-)
:
: Regards,
: Fergus
:
:

Nov 20 '05 #10
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
Nov 20 '05 #11
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

Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: BoonHead, The Lost Philosopher | last post by:
Does anyone know how to implement internal interface documentation for functions and parameters? I found a similair thing for proerties. For properties I found something like:...
0
by: Rex | last post by:
Hello... I have a C# app, and am trying to save a web page as a .mht file using CreateMHTMLBody. It was working a while back, but now I am getting "interface not registered" errors when calling...
2
by: seesaw | last post by:
When define an interface of all pure virtual functions, will the destructor of it will automatically virtual, or it has to be declared as virtual? Should it be declared as "virtual" when defining...
3
by: Markus Dehmann | last post by:
I have a two different value types with which I want to do similar things: store them in the same vector, stack, etc. Also, I want an << operator for each of them. class Value{}; // this would...
1
by: n_o_s_p_a__m | last post by:
My web service has a webmethod whose return type is declared as an interface type, for example: public IBusinessProcess GetBusinessProcess() {} which generates the lovely error: Cannot...
2
by: VolkerS | last post by:
Hallo, I need helping adding an existing Interface to an object I dispatched from a COM-server via win32com in Python. The Code for this in VisualBasic looks like that: Private Obj_1 As...
4
by: ~~~ .NET Ed ~~~ | last post by:
I am facing a problem. My project is composed of several assemblies. In one of them -the backend- I have several internal classes that must implement an interface. These internal classes are only...
0
by: Peter | last post by:
Hi I'm stuck and would appreciate some help. I have created a Class library project that contains a number of interface definitions that must be used by a range of other VB.NET applications. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.