I'm on a team converting a large VB6 enterprise solution
into a VB.Net solution. We've started small. In other
words, we're taking MS' advice and beginning with small
pieces. I've created a Windows Application (VB.NET) that
calls an ActiveX DLL (VB6) using a CreateObject followed
by a call to a visual class method in the object that
exposes UI functionality. If I load the VB6 dll in the
VB6 IDE and leave it running, then run the VB.Net
application, everything works fine. However, when I try
to run without preloading the VB6 dll, I get a 406 error
when executing frmForm.Show vbModeless. I found a
workaround on the web that indicated I should use
ShowWindow frmForm.hWnd, SW_SHOWNORMAL to show the form.
I implemented a wrapper function that shows the form this
way and call it everywhere I am showing a modeless form in
VB6. The form now displays properly, but now the form and
controls don't respond to keystrokes. I've put debugging
code in the ActiveX dll that shows that the Form
(KeyPreview = True) gets KeyDown, KeyPress and KeyUp
events. Also, the controls on the form all get the
KeyDown, Keypress and KeyUp events. I found a trouble
report on MS KB <http://support.microsoft.com/default.aspx?
scid=kb;en-us;187988> that indicated that the problem
arises because the ActiveX Control (or in this case DLL)
doesn't own the message pump for the VB6 form that is
loaded. I'd have to assume that the VB.Net form is the
parent who owns the message pump for the form. The events
are firing (as stated earlier), but the VB6 form isn't
getting them. Where are the events going? How can I
reroute them back to my VB6 form(s)? Any help would be
appreciated greatly.
Thanks!
Tony