ActiveX is dead! Long live ActiveX!
In a world governed by .NET you almost think that ActiveX is dead. In a certain way this is true. Everything must be save, everything must be marshaled, everything must be dot netted. But in a certain way, ActiveX is so easy. Especially when you use a free Visual Basic tool that has been written by Microsoft to promote ActiveX several years ago and what they have withdrawn from the internet. It is as simple as writing vba macros in Word or Excel.
I've always been interested in COM and ActiveX and how to use these controls in Alpha Five. As fellow Xbasic coders have experienced, each ActiveX control is different from each other and not every control is working well in Alpha Five. Some even let Alpha Five crash and burn.
I discovered that this is not always on the record of Alpha Five. I saw events not working in Alpha Five. In the past, I myself, said that this was a problem of Alpha Five. Now I know better when it comes to events. Other things such as passing variants and arrays, I have no experience so far and did not tested it yet. But this will come.
Creating a control
When you make an ActiveX there are always standard properties and events declared in the ActiveX control, at leat in the software I use. But to let them work properly to the outside the programmer who build the ActiveX must map these events in a proper way. I tested this with the Gauge.ocx ActiveX control which I have developed. I made the same mistake. I saw the event code in Alpha Five but it didn't work despite the fact that the events were declared. What did I wrong? Simply, I forgot the Raise Event command. Made other ActiveX builders the same mistake?
When you write an Event Click() in the declaration section of a vb control class and compile the control, Alpha Five will discover the events in the ocx and put them in the ActiveX Xbasic event section of the control. The sad thing is when the programmer forgot to put a raise event sub in his control it is of no use for Alpha Five or other applications.
There are other known cases the events did work in Word but not in Alpha Five. In that case I cannot recall my above discoveries and there must be other problems involved.
Gauge.ocx
To learn and test this I made a simple ActiveX control.
This control is a clock that you can place on a form and give the hands, dial and back a color of your choice. There are events that you can use as the next Xbasic code show.
Register the ActiveX
I made an example in Alpha Five version 8. To use this control just register it with the regsvr32.exe command: regsvr32 Gauge.ocx
You can put the control in the c:\windows\system32 folder and register it there or keep it in the same folder where you put the Alpha Five example. If the system can't find regsvr32.exe put the full path before the command. In my case it is C:\WINDOWS\system32\regsvr32.exe
Use the start, run command or a dos box to register the ocx.
You can inactivate the control by unregister the control with the /u switch: regsvr32 /u Gauge.ocx
Do not delete the Gauge.ocx before you have unregister it from the system or you'll have to delete the control manually from the registry.
When it is registered you can place the control on your form. Look for the id "gauge.ucclock" when you use the ActiveX control tool in Alpha Five Form design mode. Don't forget to refresh the ActiceX list.
Gauge.ucclock Properties
Use the next color numbers:
Number Color
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Yellow
7 White
8 Gray
9 Light Blue
10 Light Green
11 Light Cyan
12 Light Red
13 Light Magenta
14 Light Yellow
15 Bright White
This sets the color of the background of the control.
topparent:ACTIVEX1.activex.backcolor = 0
Sets the backstyle
transparent = 0
opaque = 1
topparent:ACTIVEX1.activex.backstyle = 1.0
Sets the borderstyle
none = 0
fixed single = 1
topparent:ACTIVEX1.activex.borderstyle = 1.0
Sets the color of the numbers, see color table.
topparent:ACTIVEX1.activex.colorcifra = 10
Sets the color of the dial.
topparent:ACTIVEX1.activex.colordial = 10
Sets the color of the hour hand
topparent:ACTIVEX1.activex.colorhandhr = 14
Sets the color of the minutes hand
topparent:ACTIVEX1.activex.colorhandmin = 14
Sets the color of the seconds hand
topparent:ACTIVEX1.activex.colorhandsec = 14
Sets the font size.
topparent:ACTIVEX1.activex.fontsize = 12
You'll see more properties in the ActiveX control properties window in Alpha Five. Only the above mentioned properties are mapped to the control.
This all is tested with with Alpha Five version 8 under Windows XP SP3. I'm curious how this controls behaves in Alpha Five 9 under vista?
Use this control at your own risk.
My discovery continues, more to come.
Marcel Kollenaar
In a world governed by .NET you almost think that ActiveX is dead. In a certain way this is true. Everything must be save, everything must be marshaled, everything must be dot netted. But in a certain way, ActiveX is so easy. Especially when you use a free Visual Basic tool that has been written by Microsoft to promote ActiveX several years ago and what they have withdrawn from the internet. It is as simple as writing vba macros in Word or Excel.
I've always been interested in COM and ActiveX and how to use these controls in Alpha Five. As fellow Xbasic coders have experienced, each ActiveX control is different from each other and not every control is working well in Alpha Five. Some even let Alpha Five crash and burn.
I discovered that this is not always on the record of Alpha Five. I saw events not working in Alpha Five. In the past, I myself, said that this was a problem of Alpha Five. Now I know better when it comes to events. Other things such as passing variants and arrays, I have no experience so far and did not tested it yet. But this will come.
Creating a control
When you make an ActiveX there are always standard properties and events declared in the ActiveX control, at leat in the software I use. But to let them work properly to the outside the programmer who build the ActiveX must map these events in a proper way. I tested this with the Gauge.ocx ActiveX control which I have developed. I made the same mistake. I saw the event code in Alpha Five but it didn't work despite the fact that the events were declared. What did I wrong? Simply, I forgot the Raise Event command. Made other ActiveX builders the same mistake?
When you write an Event Click() in the declaration section of a vb control class and compile the control, Alpha Five will discover the events in the ocx and put them in the ActiveX Xbasic event section of the control. The sad thing is when the programmer forgot to put a raise event sub in his control it is of no use for Alpha Five or other applications.
There are other known cases the events did work in Word but not in Alpha Five. In that case I cannot recall my above discoveries and there must be other problems involved.
Gauge.ocx
To learn and test this I made a simple ActiveX control.
This control is a clock that you can place on a form and give the hands, dial and back a color of your choice. There are events that you can use as the next Xbasic code show.
Code:
[FONT=Courier New][FONT=Courier New]function click as v ()[/FONT] [FONT=Courier New]ui_beep()[/FONT] [FONT=Courier New]msgbox("Title","Click_Event")[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function dblclick as v ()[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function keydown as v (KeyCode as N,Shift as N)[/FONT] [FONT=Courier New]msgbox("Title","Keydown_event")[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function keypress as v (KeyAscii as N)[/FONT] [FONT=Courier New]msgbox("Title","Keypress_Event")[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function keyup as v (KeyCode as N,Shift as N)[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function mousedown as v (Button as N,Shift as N,X as N,Y as N)[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function mousemove as v (Button as N,Shift as N,X as N,Y as N)[/FONT] [FONT=Courier New]'ui_beep()[/FONT] [FONT=Courier New]end function[/FONT] [FONT=Courier New]function mouseup as v (Button as N,Shift as N,X as N,Y as N)[/FONT] end function [/FONT]
I made an example in Alpha Five version 8. To use this control just register it with the regsvr32.exe command: regsvr32 Gauge.ocx
You can put the control in the c:\windows\system32 folder and register it there or keep it in the same folder where you put the Alpha Five example. If the system can't find regsvr32.exe put the full path before the command. In my case it is C:\WINDOWS\system32\regsvr32.exe
Use the start, run command or a dos box to register the ocx.
You can inactivate the control by unregister the control with the /u switch: regsvr32 /u Gauge.ocx
Do not delete the Gauge.ocx before you have unregister it from the system or you'll have to delete the control manually from the registry.
When it is registered you can place the control on your form. Look for the id "gauge.ucclock" when you use the ActiveX control tool in Alpha Five Form design mode. Don't forget to refresh the ActiceX list.
Gauge.ucclock Properties
Use the next color numbers:
Number Color
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Yellow
7 White
8 Gray
9 Light Blue
10 Light Green
11 Light Cyan
12 Light Red
13 Light Magenta
14 Light Yellow
15 Bright White
This sets the color of the background of the control.
topparent:ACTIVEX1.activex.backcolor = 0
Sets the backstyle
transparent = 0
opaque = 1
topparent:ACTIVEX1.activex.backstyle = 1.0
Sets the borderstyle
none = 0
fixed single = 1
topparent:ACTIVEX1.activex.borderstyle = 1.0
Sets the color of the numbers, see color table.
topparent:ACTIVEX1.activex.colorcifra = 10
Sets the color of the dial.
topparent:ACTIVEX1.activex.colordial = 10
Sets the color of the hour hand
topparent:ACTIVEX1.activex.colorhandhr = 14
Sets the color of the minutes hand
topparent:ACTIVEX1.activex.colorhandmin = 14
Sets the color of the seconds hand
topparent:ACTIVEX1.activex.colorhandsec = 14
Sets the font size.
topparent:ACTIVEX1.activex.fontsize = 12
You'll see more properties in the ActiveX control properties window in Alpha Five. Only the above mentioned properties are mapped to the control.
This all is tested with with Alpha Five version 8 under Windows XP SP3. I'm curious how this controls behaves in Alpha Five 9 under vista?
Use this control at your own risk.
My discovery continues, more to come.
Marcel Kollenaar
Comment