March 7, 2021
Hot Topics:

ActiveX Control Tutorial - Part 3

  • By Karl Moore
  • Send Email »
  • More Articles »

Thankfully whilst beta-testing Visual Basic 5/6, Billionaire Bill and his gang of merry programmers decided that making developers type line after line of such repetitive code was rather cruel. And also dead boring.

So one of the head nerds played around to produce a magical Microsoft wizard that can automatically produce run-of-the-mill code and rid of all your worries. Well, maybe not all your worries.

Anyway, interested? Let's load up the Wizard...

  • Click Add-Ins, Add-In Manager
  • Double-click on the 'VB 5/6 ActiveX Ctrl Interface Wizard' until it's Load Behaviour changes to 'Loaded'
  • Click Add-Ins, ActiveX Control Interface Wizard
  • If you're presented with a welcome screen, click Next

Click here for larger image

The current screen should ask you to select the 'interfaces' you want Visual Basic to automatically 'code' for you.

Interfaces? Yeah, that's just a posh word to describe what stuff your control shows (or 'exposes') to the developer. And 'stuff' is a technical term defined as properties, methods and events.

So - the list box to the left of your screen displays this list of suggested interface members, such as the Font property and the Click event.

Note: These suggested interfaces have been determined by the existing properties, methods and events of controls you currently have in your workspace. At the moment, we just have a Text Box so it's suggesting it should code all the 'stuff' related to a Text Box, such as the Font property.

  • Move a few of the interface members across to the second box:
  • -- BackColor, BorderStyle, Click, DblClick, Font, FontBold, FontItalic, FontUnderline, PasswordChar, Refresh, Text
  • Click Next

If you wanted to add any extra properties, methods or events the current screen would be the place to do it. But we don't, so...

  • Click Next

Now we're going to 'map' all the properties, methods and events we selected direct to our Text Box. This lets the wizard know that our custom Click event, for example, should be fired when the Click event of the Text Box is activated. And the custom BackColor property should pass its value direct to the BackColor property of the Text Box. And so on and so forth.

This is called 'mapping'.

  • Select all the interface members in the list box (hold your left mouse button down and drag along the list)
  • From the 'Maps to Control' list, select your Text Box
  • Click Next

If you added any properties, methods or events that don't directly 'map' to anything - this is where you give the wizard a little more information, allowing it to create a basic skeletal outline procedure for you. But we haven't, so we won't.

  • Click Next
  • Click Finish

Hold on, Max... err, what's happened to all our beautiful code?

Page 4 of 6

This article was originally published on November 21, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date