We Could Create ActiveX Controls Before, Couldn't We?

Sure, we could create ActiveX controls before this release of VB. If we knew ahead of time which fields we wanted to bind, we could create controls that bound to fields. But these fields had to be hard coded in the control. So it we wanted to bind the Title field from the Titles table in a control, we could do that - it was simple. However, to do this we had to know what database fields would be bound to which controls in advance.

This is not quite the generalized approach most of us require in our day-to-day programming activities. And it certainly won't permit us to create a bound control that can be used in just about any situation. For example, with the bound grid data control, we just draw a data control on our form and set its properties. The data control is responsible for creating the recordset. Then we can use a DBGrid, hook it up to the data control, and we are fixed up. The data control can retrieve any recordset and the DBGrid can visually display the recordset retrieved by the data control.

What if we wanted to create our own generalized ActiveX control that could be used with any data source, like the ADO data control can? The ADODC control does not know ahead of time what data source or fields you might want to retrieve, but by setting a few properties such as the ConnectString and RecordSource, you can easily retrieve any arbitrary recordset of data.

If you wanted to create a control like that in VB prior to version 6, it could be done - but it was far from easy. In fact, you had to know C++ and something called the Microsoft Interface Definition Language (MIDL). You also had to create your own 'ClassID' using a program called GUIDGEN.EXE. It was far from simple, and consequently most VB programmers passed on this option and lived with the controls that came with VB or could be purchased from the hundreds of third party suppliers.

© 1998 by Wrox Press. All rights reserved.