Reusing Browser Technology - Colbtn - 15 Nov 2001

Description: The COLBTN example shows a control that accesses and changes the HTML document in which it is contained.

More Details
COLBTN is written using ATL2.0 and was originally built using VC++5. The control subclasses a button and causes the background color of the document to change to pink when pressed. Loading the button.htm file into Internet Explorer 4.0 or above, demonstrates the control. The control actually implements the equivalent of the following line of script to make use of the Dynamic HTML support of IE4: document.bgcolor = "pink"

When clicked, the button follows these steps to access its container and the document (shown in the button.h file).

Call getContainer on the client site, to obtain the container's IOleContainer interface
Call QueryInterface for IHTMLDocument2. This interface gives access to the document.
Call get_Body to obtain the IHTMLBodyElement interface call put_bgColor

Browser/Platform Compatibility
The Colbtn sample is supported in Internet Explorer 4 and Internet Explorer 5 on Win32 platforms

Complete Article

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish