Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

WebPage as MDI Background In TangramLite

4.20/5 (2 votes)
21 Aug 2006CPOL1 min read 1  
WebPage as MDI Background and Interact with User

HTML Background:

Image 1

Click "Create New Document" Button:

Image 2

Navigate to some URL:

Image 3

New Document:

Image 4

Introduction

Generally, there is a bitmap of company Logo as the background of MDI window. Sometimes, you may need a dynamic picture or more interactive ability. Here I will tell you how do it using TangranLite framework.

Config Background for MDI

You may download TangramLite first. After you setup, you can see "OS:\Program Files\TangramLite\debug" directory on your disk. There are samples we prepare for you.

Open "TangramLiteD.exe.config" file. This the config file for "TangramLiteD.exe", actually, this is XML format. You may see two nodes:

XML
<BackgroundType>html</BackgroundType>
<BackgroundFile>background.htm</BackgroundFile>

The first node specifies what type of background, here we want HTML. The second node specifies the filename of the HTML. But where is it located? You can find it here:

"OS:\Program Files\TangramUniverseDocument\Tangram Team\TangramLite\Background"

Now you can change it with your HTML page.

Interact with HTML

How can we interact with HTML? When we create a CHTMLView and navigate to a special HTML file, the webbrowser gets IDispatch interface of a COM object. Then we can write a script to invoke methods of the object through IDispatch. COM object's method can call native code. Open "C:\Program Files\TangramUniverseDocument\Tangram Team\TangramLite\Background\Background.htm" in Notepad or other editor to see source. We can find the script:

VBScript
<!--
Sub Button1_onclick
 window.external.NewDocument
End Sub

Sub Button2_onclick
 window.external.opendoc
End Sub
-->

That means when you click Button1, it will invoke "NewDocument" method of theCOM object. We do an action in the method in fact. Open sample project "TangramLiteMainFrameD", there, you can find an interface "IApplication", it has a method "TangramLiteMainFrameD". We do NewDocument in the method implementation.

History

  • 21st August, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)