WinCtrl class

A few months ago I wrote a WinCtrl constructor function for Authorware 7 that makes using the winctrls.u32 from javascript more straightforward and I thought I’d share it here. Basically you create a WinCtrl object and all the properties and methods of the windows control are accessible through that object. I set it up so that any properties you’d get (or set) via the wcGetPropertyValue() of a particular control are added as property members of the object which means you can reference them like so: combobox1_wc.Visible = false; I made an effort to support all the members (properties and functions) of the winctrls and to make using the WinCtrl objects intuitive to those already familiar with working with winctrls in authorware script (aws).

Here’s some example js of setting up a listbox control:
// listbox
myLB_wc = new WinCtrl();
myLB_wc.wcDisplayControl(100, 100, 250, 200, "ListBox", "");
myLB_wc.Items = "Item 001\rItem 002\rItem 003\rItem 004";
myLB_wc._3D = false;
myLB_wc.Border = 1;
myLB_wc.Color = "#CCCCCC";
myLB_wc.FontColor = "Navy Blue";
myLB_wc.FontName = "MS Sans Serif";
myLB_wc.FontSize = 9;
myLB_wc.FontStyle = "Regular";
myLB_wc.Focus = false;

You can grab the WinCtrl.js file here. If you have any questions or comments feel free to post them here.

One thing to note, I’ve found creating a whole bunch of controls using this method is a little bit slower than other approaches. This is due to the way the properties for each WinCtrl object are being attached – the extra call to wcGetPropertiesByControl() means another trip to the u32 which seems to be the bottleneck.

Leave a Reply