Functions in forms

G

Guest

Hello, I have a little problem with my compiler:

My Application consists of several forms. Some of these forms have
functions, e.g. function sayHello(). A module called modFlowControl has an
Object called form active, which is the currently visible form. Now I want to
call frmActive.sayHello(), because I don't know if this form has this
function, I called it in a Try Block. My Problem is, that the compiler
doesn't compile the programm, because sayHello is no Member of
Systems.Forms.Form. How can I solve this problem?

Greetings,
Cyberdot
 
R

Rüdiger Kardel

Cyberdot,

define the Interface :

public interface ICanSayHello
{
void sayHello();
}

and cast your instance of the form:

try
{
ICanSayHello hello;
hello = (ICanSayHello) theWindowInstanceYouWouldTest
hello.sayHello()
}

Ruediger
 
G

Guest

Hmm,

I don't know if it's my mistake, but I need all functions in the form if I
do it in this way. I have many possible functions, and all forms have a few.
Is there a way to call the function of the current form if it exists, and if
not do nothing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top