| By Bruce Armstrong | Article Rating: |
|
| August 26, 2007 03:00 PM EDT | Reads: |
9,903 |
Microsoft recently released the Interop Forms Toolkit 2.0 in order to allow "developers to incorporate VB.NET Forms and Controls into their VB6 applications" (www.microsoft.com/downloads/details.aspx? FamilyID=934de3c5-dc85-4065-9327-96801e57b81d&DisplayLang=en).
The interesting thing is that it operates by automatically generating a COM Callable Wrapper (CCW) for the VB.NET forms and controls. That means that the .NET visual user controls are not only available to VB6, but to any Win32 application that supports COM, including PowerBuilder.
To test it out, I wrote a simple gradient user object in VB.NET (see Listing 1) and deployed it as an interop user control. I then added it to a PowerBuilder 10.5 window as an ActiveX (see Figure 1).
Everything on the window, with the exception of the gradient control, is standard PowerBuilder stuff. After some simple calculations to determine the combined RGB value the user has selected through the sliders and display it, it is applied to the gradient control through the following (of_calcstart and of_calcend are the routines used to calculate the RGB values):
long ll_start, ll_end
ll_start = of_calcstart()
ll_end = of_calcend()
//This will actually cause two repaints, but I don't care
ole_1.object.StartColor = ll_start
ole_1.object.EndColor = ll_end
The reason there are two repaints is because I force a repaint of the control whenever either the start or end color for the gradient is changed. The repaint happens fast enough so the user doesn't notice there were two.
Note that this technique will work not only for controls that you create in VB.NET, but also for third-party controls that can be used in VB.NET. For example, Figure 2 shows Dundas Charts working within a PowerBuilder window after being exposed as an interop control. Similarily, Figure 3 shows Infragistics' WinChart control operating in a PowerBuilder window.
The Interop Toolkit also allows you to expose VB.NET Forms as ActiveX controls (and has since the original 1.0 version), but I can't see much use for that. The important change with the 2.0 version is support for deploying controls.
Note that if you reference a third-party control in your user control, you will need to provide your own methods that will in turn interact with the third-party control. Just because the third-party control is visually exposed through the control doesn't mean that its properties and methods have been exposed.
In an earlier PBDJ article on CCWs I mentioned how manifests can be used so that such controls can be deployed as side-by-side assemblies and invoked through registry-free COM. That simplifies deployment by not requiring changes to the registry or the GAC. One additional significant feature of the Interop Toolkit is that it automatically generates the manifest information you would need if you opted for that deployment method.
Finally, if you're a bit of a C# snob (as I am), you might be initially put off that Microsoft only released the toolkit with support for VB.NET. Fortunately, a couple of people decided to take matters in their own hands and made additional templates for the toolkit available on the CodeProject Website that make the functionality available in C# as well. In particular, Leon Langleyben made one available just after the release of the 1.0 version of the toolkit that implemented forms (www.codeproject.com/useritems/VB6InteropToolkit2.asp), and more recently James Ashley made one available for the 2.0 version of the toolkit and controls (www.codeproject.com/useritems/VB6_-_C__Interop_Form.asp).
To be honest, this isn't an ideal solution. What it does allow you to do is take advantage of Visual .NET controls in PowerBuilder now, until such time as PowerBuilder 12 is available and directly supports them.
Published August 26, 2007 Reads 9,903
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Bruce Armstrong
Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.
![]() |
wk_leo98 08/21/08 06:12:49 AM EDT | |||
I have tried to pulibc a UserControl via Interop Forms Toolkit 2.0. It work when i used it in VB6. However, only event can be seen when i used it PB9 |
||||
![]() |
Bruce Armstrong 03/26/08 11:27:31 PM EDT | |||
It would be best to post your questions on the Sybase newsgroups and I'll respond there. |
||||
![]() |
Prakash 02/06/08 03:05:22 AM EST | |||
Is it really true that Powerbuilder 10 supports Visual .Net Components ? I have been trying for last 2 weeks using the samples from code exchange. Sybase support team says that it is not possible in even in PB 11. |
||||
![]() |
dirk 08/28/07 12:38:06 PM EDT | |||
Is this only applicable to controls and not forms? I'm trying to load a C# from from PB 9. I tried this article in combination with your .net manifest article and still get a -3 return value back from ConnectToNewObject. |
||||
- Why SOA Needs Cloud Computing - Part 1
- The Cloud Transition: What Does It Mean For You?
- Cloud Expo and the End of Tech Recession
- Seeding The Cloud: The Future of Data Management
- Economy Drives Adoption of Virtual Lab Technology
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- The Cloud Has Cross-Border Ambitions
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- How PowerBuilder Got Its Groove Back
- Are Mobile Luddites Resisting Mobility?
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Five Reasons to Choose a Private Cloud
- The Cloud Transition: What Does It Mean For You?
- Cloud Expo and the End of Tech Recession
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Tips for Efficient PaaS Application Design
- Economy Drives Adoption of Virtual Lab Technology
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Sybase and Verizon Team up to Manage Mobility Solutions For Enterprises Worldwide
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects



































