Cast form from VB 6 to C# at runtime

R

ramhog

I have a custom control created in C#. The control is being consumed
in a COM exe written in VB 6. At runtime when a user moves the mouse
over the control I want to get the parent form for the control and use
it as if it were a C# form. Is that possible? If so, how?
Redesigning the consumer of the control in C# is not an option.

Thanks.
Kalvin
 
N

Nicholas Paldino [.NET/C# MVP]

Kalvin,

No, it is not possible. You can get the window handle, and that's about
it (by finding the parent of the current control, and working up). From
there, you would have to use API calls to perform any modifications to the
window or its contents.

A better solution would be to expose an interface which the parent form
implements, and passing that to child controls. This interface would expose
the operations/properties you need access to, in a language-agnostic way.

Hope this helps.
 

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