Marquee_W3C UDF + User Friendly, Code Creating, Example Program

5 posts in this topic

TechCoder 40

Below you will find both a new Marquee UDF (many W3C/HTML5 features and more) as well as a user-friendly program that both serves as an example script, as well as it will create the code for any particular marquee for you! Enjoy!

~~~~~~~~~~~~~~~~~ BACKGROUND on <marquee> ~~~~~~~~~~~~~~~~~

<marquee> has been classed as "non-standard" and "non-conforming" as an HTML element

(http://www.w3.org/wiki/HTML/Elements/marquee) There is no promise that it will continue to be supported in the future, though it is obvious that many people have a need for this feature and it has remained in the major browsers for years.....

<marquee> was originally built into Internet Explorer only, now supported in other browsers, though some original features do not work in IE either - it is clearly trying to be phased out, though a 'replacement' of sorts is coming around, using HTML5 components, so I think it will never totally go away.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For a project I'm working on, I need a way to create a LOT of different marquees. I thought it simpler to have a program create the code needed, and built the attached 'user interface' program using various references to the feature.

THE USER PROGRAM IS BACKWARD COMPATIBLE WITH THE EXISTING UDF FROM Melba23

I also needed some features that are not part of the UDF from Melba23 that are direct references to current (HTML5) recommendations from http://www.w3.org/TR/CSS2/, so I modified the current UDF to create the additional functions, which make the UDF more HTML5 compliant (some of the features I built in have no HTML5 component, existing functions were updated only where needed for the first release - perhaps someday the rest can be done, though no immediate plans)

Testing has proven this is true for IE (11), however, in testing AutoIt (with the Marquee UDF), which I thought uses IE (?), it appears that just the OPPOSITE of this is true. Another item for further testing/study.........

- 'Align' feature not working 100% on all fonts (not the program's fault!

the initial version of <marquee> (designed for IE and copied to other browsers later) contained an element called 'align', which has long been obsolete in favor of css 'vertical-align', however, it is not a direct replacement and does not work inside <marquee>.

Several alternatives were tried (including 'line-height' and even 'vspace', which may also soon be phased out) and nothing works 'perfectly' (search the web on font sizing and spacing - you will see this is extremely difficult).

This program works around these challenges in a 'best effort' way, using calculations and 'top-margin' (or vspace) spacing.

If you need the other fonts, a bit of testing would give some offset numbers that could result in better display. (this is NOT on my list to do, though maybe someone would want to take that on???)

- You can create 'unreadable', 'unusable' and even 'UGLY' marquees (not the program's fault, either!)

While a bit of effort was put into limiting things, there is no cross-checking to make sure your marquee will look 'nice'. All parameters within the marquee feature have been tested to their max/min limits (and pushed well past the documented limits for speed and delay - you can make a F A S T or S L O W marquee well outside the published specs!) and set accordingly.

Any/all color scheme, font size, etc. can be used (no matter how horrible the outcome...) so have fun and create what you like!

Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Testing has proven this is true for IE (11), however, in testing AutoIt (with the Marquee UDF), which I thought uses IE (?), it appears that just the OPPOSITE of this is true. Another item for further testing/study.........

That's why I put that statement in the top post - seems very odd behaviour and I wasn't sure how it would react.

I left in all the W3C settings in case someone has an answer - felt it better to have them available than to make a 'perfect' user interface with only working items (then, someone would ask "why did you leave these out?"!)

Would like other feedback on just how AutoIt works internally on the embedded IE - does it really use the IE from the user's computer (which I thought, but testing seems it doesn't) or a broken-down version (for speed, etc.) or what? Haven't researched it, but certainly the behaviour here is not consistent on the borders.

AutoIt SysInfo Clock is a small tool in widget style to show the clock, current CPU usage, CPU speed, memory usage and network activity (tcp, ip and udp). Additionally you can use it as an alarm clock. To stop alarm clock tone press the left LED (mail) or wait 60 seconds.

The current CPU usage code is beta and might be not working for some CPUs!

Main window:

Move mouse to area below seconds and press rmb to select different color scheme.

Alarm Clock window:

Tray menu:

Credits: see scroller (select About).

Special thanks to trancexx for helping me to read out current CPU speed using the WinAPI stuff, AndyG for troubleshooting performance counter issue, czardas for composing "Für Elise" and Ascend4nt for the support!

IE Embedded Control Versioning
Use IE 9+ and HTML5 features inside a GUI

This UDF allows the use of embedded IE controls which support IE versions greater than IE 7. By default, all embedded IE controls default to IE 7 compatibility mode (unless for some reason somebody has IE 6 installed!), so its not possible to use most of the HTML5 features available today. Fortunately, IE 9 and greater allow the use of HTML5, and the embedded IE control actually supports it. The problem is convincing Windows to let your program actually use those features!
There are Registry branches that modify how an IE control works in specific programs. Those branches are:
HKCU\Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
In at least one of these branches, the executable name needs to appear as a value name ("autoit.exe" for example), and the value data needs to indicate what IE version to 'emulate'. The value data is actually dependent on the version and whether quirks-mode is enabled.
See Web Browser Control - Specifying the IE Version for more information.
Note that a 64-bit O/S needs adjustments to the HKLM paths. Also, prefer the HKCU branch unless the program needs to enable access across all user accounts.

HTML5 Canvas Element Example
Anyway, all the complexity of setting the right value with the right name with the right 32/64-bit branch is handled for you in this UDF. Enabling support for IE9+, and new HTML5 features, is as simple as making one call to _IE_EmbeddedSetBrowserEmulation().

_IE_EmbeddedSetBrowserEmulation() takes an executable name (@AutoItExe if none is provided), and checks the Registry for an entry for it. If it doesn't find one, it will create one and enable support for later versions of IE. The full parameters to the function are as follows:

_IE_EmbeddedSetBrowserEmulation($nIEVersion, $bIgnoreDOCTYPE = True, $bHKLMBranch = False, $sExeName = @AutoItExe)
The parameter passed in $nIEVersion can be anything from 8 to 11 [or 12+ in the future], or just the current version of IE, which is available also through a call to _IE_EmbeddedGetVersion(). $bIgnoreDOCTYPE controls when IE will go into quirks mode based on any "<!DOCTYPE>" declarations on webpages. This mode can cause major problems, so by default it is set to ignore it (set this to False to enable it). $bHKLMBranch controls where in the registry the Browser Emulation Mode setting will be stored. If you wish to store the mode for ALL users, set this parameter to True. Note, however, that elevated privileges are required for modifying the HKLM branch!

If the call to _IE_EmbeddedSetBrowserEmulation() is successful, then you can enable a (more) HTML5 compliant IE browser control in a GUI.

The complete set of functions in the UDF:
_IE_EmbeddedGetVersion() ; Gets version of IE Embeddable Control (from ieframe.dll or Registry)
_IE_EmbeddedGetBrowserEmulation() ; Gets Browser Emulation Version for given Executable (or 0 if not found)
_IE_EmbeddedSetBrowserEmulation() ; Sets Browser Emulation Version. NOTE: HKLM branch REQUIRES ELEVATED PRIVILEGES!
_
IMPORTANT:
Setting the embedded browser object to a newer version of IE may alter the behavior of some things. See documenation for the HTMLDocumentEvents2 interface and HTMLAnchorEvents2 interface for example.
Also, there is at least one difference in behavior noted by mesale0077 in working with IE10 (and possibly other versions of IE) - clicks for elements inside an <a> anchor tag will register as the actual internal element rather than the surrounding anchor. For example, an <img> element wrapped by an <a> anchor will only send the click to the <img> element and not propagate it any further. A workaround for this is to check the parentNode to see if it is an <a> element. See the discussion in the >ObjEvent dont work thread. It could be that there's some other reason for this behavior, but nothing has come to light yet.
As an aside, also see trancexx's response in >ObjEvent usage for more techniques for capturing IE events.
History:

An example of HTML5 use, which has a little interactive Canvas, follows (requires IE9 or higher!):

Never say I don't give this community some little gems once in a while. I came up with the concept of creating a directory structure using nothing but valid HTML5 and CSS3. It uses an unknown "checkbox hack" concept which some HTML5/CSS3 purists consider to be beyond the semantics of the language. But I say if it's supported by all major browsers and it works, then why not!

Note: I used >KaFu's idea for the current level and next level, but the rest I came up with myself, albeit I have used this "checkbox hack" before in other projects I have created.