|
|
HTML List control
I work as a java programmer in the real life and I hardly do any C++ development there. On the other hand, I get to do a lot of DHTML and web stuff, so I immediately thought of the recent Microsoft apps that use DHTML as user interface. Like the Windows Explorer, SQL Server 7, MS Outlook Express and even the little Add/Remove Programs control-panel applet in Windows 2000.
I like the Add/Remove Programs applet.
Now there's two simple list controls that look neat -
and they are written in DHTML using MS IE as layout engine.
With a list control like that, you can tweak out any cool layout, mouse-over
effect, fade, slide-out effect, font effect etc. etc. You have more choices and
better control than any grid control I know of.
HTML ListAt first sight, the HTML List control behaves like an ordinary ListBox control. It has a similar API. The main difference is that it is really a web browser window presenting the list items. Clicks and mouse events are generated by Internet Explorer and some DHTML scripting. Events are then sent back to the C++ class and back to the application code asWM_NOTIFY
messages. The application can manipulate the list items, but must use
the MS IE HTML interfaces, such as the IHTMLElement interface,
or have DHTML scripts on the HTML page execute the changes.
This is not a lightweight control! Of course you will carry the burden of loading MS Internet Explorer into your application. It's a horrible waste of resources just to get a list control running... but the result looks nice. How to use itTo use it, place a Web Browser control (ActiveX) on your dialog. You do this in the resource editor of Visual C++ v6 by right-clicking on the form and choose "Insert ActiveX control...". Then find the Microsoft Web Browser item.Add a member variable to your dialog implementation file...
In the OnInitDialog() event handler, add the following line:
The IDR_HTML is the HTML resource identifier, which
contains the HTML code the control is build from (explained below).
Add items to the control using
Notice how the item text can contain HTML. It may even contain scripting code.
The list is build from pure HTML. You can add script code and
style sheets as you wish - but you must provide a basic framework
for the control to work with.
Make sure to add it under the HTML resource type in the resource list.
That is... right click on the root of the resource list and choose "Insert"
and then choose "HTML".
The control sends a few notifications back to the owner window. It
sends information about the HTML elements affected in the
The HLN_INITIALIZE notification is generated when the control is ready
to accept input. Do your data initialisation there.
The HTML can include script code that calls methods inside the C++ control. This
is done using my ATL Dynamic Dispatch classes. The script code
uses NotesThe original Add/Remove Programs applet can be
inspected in the system file appwiz.cpl. It is a
so called "HTML application" (HTA).
Source Code DependenciesInternet Explorer 4 or betterMicrosoft Visual C++ 6.0 Microsoft WTL 3.1 Library Microsoft ATL Library See AlsoMy ATL Dynamic Dispatch classesEventually I did create a real grid control Download Files
Written by Bjarke Viksoe. Article submitted 6/12/2001. To the top
|
|||