January 27, 2021
Hot Topics:

Beginning ActiveX - Part 1

  • By John Percival
  • Send Email »
  • More Articles »

Events are what you use to notify the developer who is using your control that something important has happened that they might want to react to. Examples of events for the ever-popular TextBox control are Change and KeyPress. Events must be declared in the declarations section of your control, then they can be raised at whatever moment you feel fit. It is these events, and not the InitProperties, ReadProperties, WriteProperties, etc. that the developer will see. Our blink event would require this declaration:

Public Event Blink()

Within the parenthesis, you can place any parameters that you want to pass with the event. For a click event, this might be the x and y co-ordinates of the click position. However, since we are only blinking, we don't need any extra parameters.

Surprisingly enough, to raise the event, you use the RaiseEvent method. For our blink event, we will have it connected to a timer, so that it will regularly blink:

Private Sub Blinker_Timer()
RaiseEvent Blink
End Sub

And that's all there it is to it! There are no secrets, no subtle twists and no hidden cheats. All our budding developer must do now is to write some code for blinking in the blink event:

Private Sub BodyControl1_Blink()
Debug.Print "Wow! I have just blinked!"
End Sub

A final word..

Well, that's about it for the first instalment of ActiveX controls. Next time we will be looking at loads more cool features that we can add to the control, including the picture and font properties, an aboutbox, and read-only at runtime properties to mention just a few. You know where to come if you're just craving for some more great ActiveX action. Tune in same time, same place for yet more OCX excitement.

Page 7 of 7

This article was originally published on November 20, 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