Hosting VB.NET controls/forms in a vb6 app 
Author Message
 Hosting VB.NET controls/forms in a vb6 app

Has anyone ever managed to succesfully use VB.NET forms or VB.NET
UserControls in a VB6 app? The closest I have come to doing this envolves
exposing the hwnd of the .net usercontrol, and then adding it to the vb6
forms by referencing the .tlb and then using the SetParent api in the VB6
code, but this causes problem withing tabbing. When I press tab, the focus
never leaves the control with the focus on the .net control. It seems that
Microsoft removed the ablity to create .net components that could be used as
vb6 usercontrols after beta1 of .net. Any help solving this problem would be
greatly received!

Regards

Peter Dobson



Fri, 27 Aug 2004 02:09:54 GMT  
 Hosting VB.NET controls/forms in a vb6 app


Quote:
> Has anyone ever managed to succesfully use VB.NET forms or VB.NET
> UserControls in a VB6 app?

This might help:

http://www.codeproject.com/netcomponents/exposingdotnetcontrols.asp

--
Patrick Steele
Microsoft .NET MVP



Sun, 29 Aug 2004 01:45:05 GMT  
 Hosting VB.NET controls/forms in a vb6 app
Patrick,

Thanks very much for your suggestion! I have tried this and it seems to
work well! I just need to convert it to VB from C#. I am unable to see
the component in my vb6 toolbox. This is not the end of the world for me
as I can use the following code from vb6

Dim ctlobj As Object
Set ctlobj = Me.Controls.Add CreateObject "Prisoner.PrisonerControl"),
"ctlobj")ctlobj.Visible = True

Should I do this and wrap this up in my own vb ocx or is there a better
way?

I have noticed that when tabbing around controls on the Prisoner control
(and I have added a few more to test) when the focus reaches the last
control, the next tab press does not return the fucus to the 1st
control. Do you have any idea what may be wrong?

Thanks again

Anton

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 29 Aug 2004 03:08:51 GMT  
 Hosting VB.NET controls/forms in a vb6 app


Quote:
> I am unable to see
> the component in my vb6 toolbox. This is not the end of the world for me
> as I can use the following code from vb6

> Dim ctlobj As Object
> Set ctlobj = Me.Controls.Add CreateObject "Prisoner.PrisonerControl"),
> "ctlobj")ctlobj.Visible = True

> Should I do this and wrap this up in my own vb ocx or is there a better
> way?

Did you try adding it to the toolbox (right-click, "Components...")?

Quote:
> I have noticed that when tabbing around controls on the Prisoner control
> (and I have added a few more to test) when the focus reaches the last
> control, the next tab press does not return the fucus to the 1st
> control. Do you have any idea what may be wrong?

Hmm...  Have you tried doing a "debug.print me.ActiveControl.Name" to
see where the focus is?

--
Patrick Steele
Microsoft .NET MVP



Mon, 30 Aug 2004 02:10:53 GMT  
 Hosting VB.NET controls/forms in a vb6 app

Quote:
>>Did you try adding it to the toolbox (right-click, "Components...")?

Yes, it does not appear in the components list, and you can't browse the
NET.dll and select it. You can add a reference to the .tlb file but this
does not put it in the toolbox. After contacting the author of the
article
http://www.codeproject.com/netcomponents/exposingdotnetcontrols.asp#xx13
0683xx 'Morgan Skinner' who said:

"As for showing up in the toolbox in VB, you have to add a bunch of
other stuff into the registry, but I've never successfully got this to
work. You need at least a TypeLib entry, and a few others too. Best
thing to try is to create a VB control, hunt down all of the registry
stuff set by it, and attempt the same in your controls registration
code. Let me know if you get this to work successfully.
As for the tabbing stuff, I didn't spend too much time on it, so I can't
really help with that one."

I have found that from vb6, if you simply reference a .net .tlb file,
and then (in vb6 code) show a .net form then it is not possible to tab
around the .net form's controls at all! The .net buttons seem to get a
shadow when you click on them, but they never get a focus
(dotted)rectangle.

Quote:
>>>Hmm... Have you tried doing a "debug.print me.ActiveControl.Name" to

see where the focus is?

Yes, vb6 always thinks that the the active control is the .net
'Prisoner' control.

Regards

Anton

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Mon, 30 Aug 2004 17:28:04 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Script hosting in .NET apps...

2. Integrating Visio(or any other Win32 app form) in a Vb.net Form

3. ASP.NET App v. VB.NET App

4. Conversion of VB.Net App to ASP .Net App

5. Hosting Other, non-VB Apps

6. Hosting Other, non-VB Apps

7. Hosting Other, non-VB Apps

8. faking asp object context from vb.net app to vb6 dll

9. What's the equivalence of APP.PATH of VB6 in VB.NET

10. VB6: App.LogEvent VB.NET:?

11. Porting multi-component VB6 apps to VB.NET?

12. VB.NET Equivalent of APP.Path in VB6

 

 
Powered by phpBB® Forum Software