REALbasic and ActiveX

REALbasic is wonderful at cross-platform programming. With a little elbow-grease it's possible to make very nice Windows and Mac OS X applications. That's the bread and butter of my business.

I have one client, however, that has had me working on a commercial VB6 application for five years. Since we know that someday VB6 will not be adequate for our needs we're looking for the 'next' development environment. .NET is the easy answer but since I have a lot invested in RB so I thought that if I can get them halfway to cross-platform that would be a win-win for everyone.
REALbasic is wonderful at cross-platform programming. With a little elbow-grease it's possible to make very nice Windows and Mac OS X applications. That's the bread and butter of my business.

I have one client, however, that has had me working on a commercial VB6 application for five years. Since we know that someday VB6 will not be adequate for our needs we're looking for the 'next' development environment. .NET is the easy answer but since I have a lot invested in RB so I thought that if I can get them halfway to cross-platform that would be a win-win for everyone.

By halfway, I mean convert their project to REALbasic running Windows only using all of the 3rd party components that they've acquired over the years. The majority of the 3rd party controls are from ComponentOne and we make heavy use of the TrueDB grid, list and dropdowns in addition to their calendar, mask and number fields. Anyone who's used them knows that they are extremely powerful and extremely feature rich. Heck, the TrueDB grid has a properties editor that has roughly 8 tabs and hundreds of properties that can all be set at design time.

So I fired up REALbasic 2007 r5 for Windows and started using the OLEObject. In my clients' project we use the XArray object which is a fancy array class but works well with the grids and dropdowns when they are in storage mode. It uses the ADO recordset.GetRows function to quickly load the XArray. That was my first problem since the GetRows object returns a multi-dimension array but the OLEObject.ValueArray only returns a single dimension array which is a bug.

This was reported to RS and is already fixed in RB 2008 r1 according to the feedback page. I give kudos to the RS engineering team for being accessible to track the bug down and quickly squashing it.

That problem could be worked around manually so I moved on to getting a grid to display on a window. Adding the ActiveX control is not a problem. RB will create a wrapper class around the ActiveX control. Once you've added it to the project you can view the wrapper. Thankfully you can fall back on this as RB doesn't help you much after this point. I found that the auto-complete was not very reliable in these situations and I'm not sure if it was the Windows IDE or the wrapper class. I often had to go back to the wrapper class to figure out what parameters were needed.

Adding the control to the window was no problem since it's just like adding native RB controls to a window. Drag and drop and you're there. Unfortunately, RB doesn't have a way to display the massive properties dialog like VB6. It simply attempts to use the regular RB properties list with somewhat disastrous results. With hundreds of properties RB simply had no way (or idea) on how to display them all.

I didn't expect RB to do well at this so I moved on thinking that I could set the properties manually like you do with a lot of 3rd party controls in RB (think the Einhugur grids). I managed to get the grid loaded with the data from an XArray that was obtained from an ADO recordset but never figured out how to get Font characteristics they way I wanted them. I did manage to figure out how to convert from RB's color object to the OLEColor value with a trip to the REALbasic forums.

The next item on the list was to get the multi-column dropdown control working with the grid. In VB6 this is easy. You open the big properties window in the VB6 IDE, select the column and use the dropdown property to select the dropdown control. Since RB can't do the properties window you have to do this via code. And that's where the whole thing blew up in my face. It appears that the grid and dropdown controls implement some interface that RB can't handle. It compiles and runs (more on that in a bit) but the dropdown never appears.

So that's where my quest ended. The following week the client told me that they (and me for that matter) would be using .NET in the near future. I'm disappointed that I don't get to use RB in a really big commercial project and I'm disappointed that RB isn't more friendly to ActiveX because I think it would be make the transition to RB easier for all those VB6 developers out there that don't want to use .NET. Give me six months and maybe I'll be a .NET fan. Hey, anything is possible.

My overall impressions with the Windows IDE is that it's not as robust as the Mac version. The IDE crashed on me a lot and I'm guessing most of that was because of my heavy use of OLEObjects. The odd thing about the ActiveX wrappers was that I encountered tons of OLEExceptions in debug run but not in a built executable. Whenever I had an OLEException I just kept hitting Run and after half a dozen of them the app would then run. Again I'm not sure if this is because of my ActiveX object not being initialized properly or RB itself.

I was also dismayed at the lack of documentation and examples for using ActiveX with RB. With the exception of the ADO example, I found nothing useful. In a forum chat I noted that it would be a great article for RB Developer or this blog. Alas, my lack of progress prevents me from doing a complete article and my experience is far from positive.

My quest continues. If you have some experience with ActiveX in REALbasic I'd like to hear about it. In particular, a lot of people ask about getting Crystal Reports working with RB so if you've made it work let us know.