
1.6.4 Framework
includes files
1.7 Adding
Controls to a Toolbar
1.7.1 Implementing
a “Go Home” Button
1.7.2 Implementing
a “Search Google” Combo-Box
1.7.3 Implementing
“Find & Highlight “ Buttons
2.1.5 class
CommandPointerSetC
2.1.8 class
CommandWithEventsC
2.1.10 class
ControlCollectionI
2.1.12 class
ControlPointerSetC
There are two key concepts
to understand when programming within the Diodia ToolbarCreator framework: Controls
and Commands.
Controls are what the user
sees in the toolbar, i.e. the buttons, the labels, the combo-boxes, etc..
Controls will not do or
display anything unless they are associated with a command. Once a control is
associated with a command the control can execute the command and display information
about the command.
Commands serve a dual
purpose: State and functionality.
State in the sense that when
a control displays a text string, or when a button is enabled or disabled, then
this is just the control reflecting the state of a command.
Functionality in the sense
that whenever a toolbar does something it is because a command has been
executed.
In other words, the
controls are the UI layer of a toolbar and the commands are the functionality/model
layer.
The two layers are
completely separated. Communication between the two layers goes through a few
well-defined interfaces.
Implementing a toolbar
means implementing the commands. The controls are implemented by the framework.
Controls and commands are
associated through an XML configuration file. The XML file simply lists the
controls in the toolbar in order, and associates each control with a named
command.
The IWebBrowser2 interface
and the interfaces associated with the DHTML document object model are very
important when programming within the Diodia ToolbarCreator framework since all
access to the Internet Explorer goes through these interfaces. More information
is available at http://msdn.microsoft.com.
The ToolbarCreator object
model is very simple. It consists of 6 classes: ControlC, ToolBandC, CommandC,
CommandSetC, ToolBandContextC and ToolBandHookC. Each class is described
briefly in the following.
Control objects represent
toolbar buttons etc.. The framework supports 7 different controls types: Menu,
button, label, edit, read-only, combo-box and separator.
Menu
A menu control implements
a pop-up menu. Multiple levels of sub-menus are supported.
Button
Three different button sub-types
exist:
1.
Push-button: A
regular button executing a command.
2.
Toggle-button:
An on/off button.
3.
Mixed-button:
A combination of a push-button and a menu.
Push-buttons and
toggle-buttons can be placed directly in a toolbar or in menus, where they act
as menu entries. Mixed buttons can only be placed directly in a toolbar.
Button controls placed
directly in a toolbar can display a bitmap, a text string or both. Button
controls placed in a menu can only display a text string.
Label
A label is a fixed text
string displayed in the toolbar.
Edit
An edit control is a text
field where text can be entered.
Read-only
A read-only control is a
text field displaying text that can’t be edited. Read-only controls are usually
displaying status information.
Combo-box
A combo-box is a
combination of an edit-control and a drop-down list. Two combo-box subtypes
exist: Regular and fixed-list. In a regular combo-box text can be typed into
the edit control. In a fixed-list combo-box the user must choose between a
fixed set of items.
Separator
A separator is a vertical
line displayed in the toolbar. Separators are used to give the visual appearance
that controls are grouped together.
ControlC objects are
implemented entirely by the framework.
A toolbar is created by
adding controls to a toolband object.
The toolband object is
responsible for drawing the toolbar on the screen.

ToolBandC objects are
implemented entirely by the framework.
Command objects implement
the actual functionality of a toolbar.
Command objects are
activated e.g. when the user clicks on a button in the toolbar, or when he
selects an item in a combo-box.

Examples of commands could
be a “Go Home” command or a “Search Google” command:

The class CommandC
implements basic command functionality such as the ability to be executed and a
command name attribute.
All commands created for a
specific toolbar are derived from class CommandC.
The command set object stores
a set of command objects.
CommandSetC objects are
implemented entirely by the framework.
The toolband context object
glues everything together.

The class ToolBandContextC
implements basic toolband context functionality such as the ability to store
command objects and a reference to the Internet Explorer.
A specific toolbar always
derives a more specialized context class from class ToolBandContextC.
The derived context
creates command objects for the specific toolbar and defines the toolbar
layout.
The toolband hook object
is the link between the Internet Explorer and the toolbar.
The Internet Explorer
queries the toolbar for information through various interfaces on the hook,
e.g. the width and height of the toolbar. All the interfaces are implemented by
the framework, so usually you don’t have to worry about the hook.
However, if you want to do
something in response to Internet Explorer events, such as “new page opened”,
then you must add functionality to the hook.
The objects model also
defines a set of interfaces through which the objects communicate. They are:
CommandContainerI
CommandI
CommandObserverI
CommandSetI
ControlCollectionI
ControlI
ToolBandI
To create a new toolbar
first run Diodia ToolbarCreator. The following assumes that a new toolbar
called MyToolbar has been created.
Visual Studio Projects
Diodia ToolbarCreator
generates a Visual Studio 2005 project and a corresponding solution file:
The Visual Studio project
includes all the basic functionality required of an Internet Explorer toolbar.
The project contains four
build configurations: Debug, Release, Unicode Debug and Unicode Release.
The project can be built
immediately. The result is a simple toolbar that illustrates the available
controls.
Output from build
A toolbar is just a single
self-registering dll. Visual Studio registers the dll automatically when a
project is built.
The dll must be registered
with e.g. regsvr32.exe if the dll is installed on another PC:
Typically an installation
program will install and register the dll. A Visual Studio 2005 Setup Project
can be used.
A specific toolbar needs
to implement a toolband context, a toolband hook and a set of commands specific
to this exact toolbar.
The context and the hook
are pre-implemented by the classes ContextC and HookC, respectively.
The context contains the
command set to which new commands are added.
Internet Explorer events
are handled by adding functionality to the hook.
The initial Visual Studio
project implements six sample commands:
The commands can be used
as templates when the actual commands of the toolbar are implemented.
The framework comes with a
small set of built-in commands that make it easier to implement common
functionality, for example link buttons.
The built-in commands are
The sample project
illustrates how to use the built-in commands. A few lines must be uncommented
in the configuration file ToolbarLayout.xml to activate some of the examples.
The Visual Studio projects
contain the following files:
Header files:
Commands.h: Class definitions for the toolbar
commands.
ContextC.h: Class definition for the specialized
toolband context.
HookC.h: Class definition for the specialized
toolband hook.
Resource.h: Resource constants.
StdAfx.h: Standard includes.
Source files:
Commands.cpp: Implementation of the toolbar
commands.
Context.cpp: Implementation of the specialized
toolband context object.
Hook.cpp: Implementation of the specialized
toolband hook.
Framework.cpp: Framework initialization.
MyToolbar.def: Standard library definition
file.
MyToolbar.idl: COM interface definitions.
StdAfx.xpp: Makes precompiled headers.
Resource files:
*.bmp: Bitmaps for the toolbar buttons.
manifest.xml: Manifest enabling Windows XP
visual styles.
MyToolbar.rc: Resource script with strings,
dialogs, etc..
MyToolbar.rgs: Registry script for dll self-registration.
ToolbandLayout.xml: XML configuration file defining
the toolbar layout.
hello.js: A small JavaScript that can
be activated from the toolbar.
Framework include files are
located in the sub-directory include.
Framework library files
are located in the sub-directory lib8.
Both release and debug versions of the library files are included.
To add a “Go Home” button
to a toolbar you follow these steps:
1)
Implement the
“Go Home” command object.
2)
Add the “Go
Home” command to the command set in the context.
3)
Insert a
button control in the toolbar.
4)
Associate the
button control with the “Go Home” command.
All in all, fewer than 20
lines of C++ source code and 1 line of XML configuration.
The first step is to
implement the “Go Home” command object.
Command objects are
derived from the class CommandC, which implements basic command functionality.
The “Go Home” command
object is declared as:
class GoHomeCmdC : public
CommandC
{
public:
GoHomeCmdC();
virtual void Execute();
};
Each command must have a unique name, which is defined in the commands
constructor:
GoHomeCmdC::GoHomeCmdC()
{
// set unique command name
SetId("MyToolbar.GoHome");
// make the command
initially enabled
SetSensitive(true);
}
Once a button is associated with the command, and the button is clicked, the
framework calls the command’s Execute() method. The command object can use the
mWebBrowser member variable to navigate the Internet Explorer to its home page:
void GoHomeCmdC::Execute()
{
// mWebBrowser
is the Internet Explorer’s IWebBrowser2 interface
mWebBrowser->GoHome();
}
The next step is to make the command known to the framework. This is done by
adding the command to the context’s command set from the context’s Initialize()
method:
void ContextC::Initialize()
{
:
AddCommand(new
GoHomeCmdC);
}
Finally, a button control is
inserted in the toolbar and associated with the “Go Home” command by adding a
<button> tag to the toolbar’s XML configuration file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<toolband xmlns="http://www.diodia.com/toolband" name="MyToolbar">
:
<button command="MyToolbar.GoHome" caption="Home"/>
</toolband>
The first step is to
implement the “Search Google” command object:
class SearchGoogleCmdC : public
CommandC
{
public:
SearchGoogleCmdC();
virtual void Apply(CString Text);
};
The drop-down list with previous search phrases would normally be initialized
in the constructor, but in this example the command does not save the history,
i.e. the history is lost when the Internet Explorer exits.
SearchGoogleCmdC::SearchGoogleCmdC()
{
// set unique command name
SetId("MyToolbar.SearchGoogle");
// make the
command initially enabled
SetSensitive(true);
}
The Apply() method is
overridden instead of the Execute() method because the command is to be
associated with a combo-box. The framework calls Apply() when the user enters
text or selects an item in the combo-box:
void SearchGoogleCmdC::Apply(CString Text)
{
// create the
query URL
variant_t Url =
CString("http://www.google.com/search?q=") + Text;
// navigate to
Google's search page
mWebBrowser->Navigate2(&Url, NULL,
NULL, NULL, NULL);
// add the
query to the search history, if it’s not already there
const
ItemList *List = GetItemList();
for (unsigned Idx = 0; Idx < List->mList.size();
Idx++)
if
(List->mList[Idx] == Text)
return;
// the search
history is saved in the commands item list
AddItem(Text);
}
The “Search Google”
command is added to the context’s command set:
void ContextC::Initialize()
{
:
AddCommand(new
SearchGoogleCmdC);
}
And finally, a combo-box
control is inserted in the toolbar and associated with the “Search Google”
command by adding a <combo-box> tag to the toolbar’s XML configuration
file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<toolband xmlns="http://www.diodia.com/toolband" name="MyToolbar">
:
<combo-box command="MyToolbar.SearchGoogle" width="200"/>
</toolband>
The Google Toolbar adds a
new button to the toolbar for each word or phrase contained in a query when a
search is performed. Each button finds the next occurrence of a word or a
phrase on the current web page.
To implement similar “Find & Highlight” buttons for the “Search Google”
combo-box described in the previous example, first implement a “Find &
Highlight” command object:
class FindAndHighlightCmdC : public
CommandC
{
public:
FindAndHighlightCmdC(const char *Find);
virtual void Execute();
protected:
std::string mFind;
};
The word to find and highlight is saved in the command constructor. The word is
also incorporated in the command name to make the command name unique:
FindAndHighlightCmdC::FindAndHighlightCmdC(const char *Find)
{
mFind = Find;
SetId((std::string("MyToolbar.") +
Find).c_str());
SetSensitive(true);
}
The commands Execute()
method uses the mWebBrowser member, i.e. the IWebBrowser2 interface and the
Internet Explorers object model, to find and highlight a word. The details are
omitted here:
void FindAndHighlightCmdC::Execute()
{
// use
mWebBrowser member to find and highlight mFind
:
}
Find and highlight buttons
are added at the end of the toolbar when a search is performed. This example
just adds a single button finding and highlighting the entire query string. A
proper implementation would split the query into individual words and phrases,
and add a button for each.
A new member function
maintaining the find and highlight buttons is added to the “Search Google”
command object. Members keeping track of the current buttons are also added:
class
SearchGoogleCmdC : public CommandC
{
public:
SearchGoogleCmdC();
virtual void Apply(CString
Text);
protected:
void UpdateFindButtons(const char *Query);
CommandPointerSetC mCommands;
ControlPointerSetC mControls;
};
The control collection
interface on the toolband object is used to add the search button at the end of
the toolbar. If the toolbar contains a button from a previous search then this
button is deleted first:
void
SearchGoogleCmdC::UpdateFindButtons(const char *Query)
{
ToolBandI
*ToolBand = mContext->GetToolBand();
int Idx;
// first delete
the old search buttons (there can be at most one)
for (Idx
= 0; Idx < mControls.GetSize(); Idx++)
ToolBand->GetControlCollection()->DeleteControl(mControls[Idx]);
mControls.Clear();
for (Idx =
0; Idx < mCommands.GetSize(); Idx++)
mContext->DeleteCommand(mCommands[Idx]);
mCommands.Clear();
// create a new
search command and a new search button
CommandC *FindCmd = new FindAndHighlightCmdC(Query);
ControlI *FindButton =
CreateButtonControl(FindCmd, Query);
// save command
and button, so we can delete later
mCommands.AddCommand(FindCmd);
mControls.AddControl(FindButton);
// add the
command to the toolband context
mContext->AddCommand(FindCmd);
// add the new
button to the toolband (there is only one)
for (Idx
= 0; Idx < mControls.GetSize(); Idx++)
ToolBand->GetControlCollection()->AddControl(mControls[Idx]);
}
Finally, the
UpdateSearchButton() is called when a search is performed, i.e. from the
Apply() method of the “Search Google” command.
void
SearchGoogleCmdC::Apply(CString Text)
{
// create the
query URL
variant_t Url =
CString("http://www.google.com/search?q=") + Text;
// navigate to
Google's search page
mWebBrowser->Navigate2(&Url, NULL,
NULL, NULL, NULL);
const
ItemList *List = GetItemList();
for (unsigned Idx = 0; Idx < List->mList.size();
Idx++)
if
(List->mList[Idx] == Text)
return;
// add the query to drop-down list
AddItem(Text);
// add Find
& Highlight buttons
UpdateFindButtons(Text);
}
The Navigate command is used to open web pages.
In its simplest form it can be used to create a
button that opens a specific web site. This is done by adding a button tag to
the toolbar configuration file:
<button
command="Navigate"
url="http://www.cnn.com/"
caption="CNN"/>
By default the Navigate command opens the web page
in the same window, but a target frame can be specified. The button defined
below opens the same web page in a new window:
<button
command="Navigate"
url="http://www.cnn.com/"
target="_blank"
caption="CNN"/>
The navigate command can also be associated with an
edit control or a combo-box control. For example, a Navigate command associated
with a “search box” edit control can be used to open a web page with search
results.
The URL to the search results includes the search
phrase, which in this case is the text displayed in the edit control.
To specify where in the URL to insert the search
phrase a pattern is used. The pattern has the form ##ControlId##.
ControlId indicates which control to get the search
phrase from. So to make the search box work, an id must be assigned to the
“search box” edit control.
The “search box” therefore looks like this in the
toolbar configuration file:
<edit
command="Navigate"
id="SearchBox"
width="100"
url="http://www.google.com/search?q=##SearchBox##"/>
The same principle makes it possible to create
“search buttons” by using Navigate commands.
For example, suppose you want the edit control to
search on Google by default, but sometimes you want to search on Yahoo instead.
This can be achieved this by creating a button next
to the edit control that gets its search phrase from the edit control by using
the id of the edit control. For example:
<button
command="Navigate"
url="http://search.yahoo.com/search?p=##SearchBox##"
caption="Search Yahoo"/>
The JavaScript command can execute a piece of
JavaScript on the current web page.
The code to execute is specified in the script
attribute on the control activating the JavaScript command:
<button
command="JavaScript"
script="alert('Hello!');"
caption="Run Script..."/>
If the code to execute is more than a few
statements then it can be placed in a file. The file must have the extension
.js and it must be included in the toolbar dll as a HTML resource.
<button
command="JavaScript"
script="hello.js"
caption=" Run Script..."/>
The sample toolbar generated by toolbar creator
illustrates this.
The framework can either run the script once in the
innermost frame on the current web page, or once in each frame on the web page.
This is of course only relevant if the web page contains frames.
To run the script once, define a function called
diodia_run_once() in the script file. For example:
function
diodia_run_once()
{
alert("Hello!");
}
To run the script in all frame, define a function
called diodia_run_in_all_frames() in the script file. For example:
function diodia_run_in_all_frames()
{
alert("Hello!");
}
The VBScript command is similar to the JavaScript
command, except it executes VBScript instead of JavaScript.
<button
command="VBScript"
script='MsgBox "Hello!"'
caption="Run Script..."/>
VBScript files must have extension .vb or .vbs.
The framework calls either the sub routine diodia_run_once
or diodia_run_in_all_frames, so one of these must be defined in the script
file. For example:
Sub diodia_run_once()
MsgBox "Hello!"
End Sub
The Toolband.ToolbarLayout command opens the
customize dialog. The dialog lets the user disable toolbar controls:
<button
command="ToolBand.ToolbarLayout"
caption="Customize..."/>
The FindNext command finds the next occurrence of a
text string on the current web page.
The pattern attribute contains the text string to search for, or alternatively, the id of an edit or combo-box control to retrieve the text string from. The id must be enclosed in ##.
Example:
<edit
command="Navigate"
id="SearchBox"
width="100"
url="http://www.google.com/search?q=##SearchBox##"/>
<button command="FindNext"
pattern="##SearchBox##"
caption="Find Next"
tooltip="Find Next"
image="203"/>
The FindPrevious command finds the previous
occurrence of a text string on the current web page.
The pattern attribute contains the text string to
search for, or alternatively, the id of an edit or combo-box control to
retrieve the text string from. The id must be enclosed in ##.
Example:
<edit
command="Navigate"
id="SearchBox"
width="100"
url="http://www.google.com/search?q=##SearchBox##"/>
<button command="FindPrevious"
pattern="##SearchBox##"
caption="Find Previous"
tooltip="Find Previous"
image="204"/>
The Highlight command highlights all occurrence of
a text string on the current web page.
The pattern attribute contains the text string to
highlight, or alternatively, the id of an edit or combo-box control to retrieve
the text string from. The id must be enclosed in ##.
The color attribute contains the color to highlight
with.
Example:
<edit
command="Navigate"
id="SearchBox"
width="100"
url="http://www.google.com/search?q=##SearchBox##"/>
<button command="Highlight"
pattern="##SearchBox##"
caption="Highlight"
tooltip="Highlight"
image="205"
color="yellow"
toggle-button="yes"/>
The Execute command launches an application.
The parameter attribute contains the file name of
the application to launch.
Example:
<button
command="Execute"
parameter="Calc.exe"
caption="Calculator"
tooltip="Calculator"
image="206"/>
Note:
Using the Execute command requires elevation support, even on Windows XP. See 1.8.9 for details.
On Windows Vista the Internet Explorer is usually
in protected mode, which basically
means that browser add-ins can’t access the local file system directly. To
learn more about protected mode, see here: http://msdn.microsoft.com/en-us/library/bb250462.aspx
Accessing the local file system requires elevation through a broker process. The
ToolbarCreator framework offers some basic support for elevation through the broker
application, DiodiaBroker.exe, which is available for download from our web
site.
If DiodiaBroker.exe is installed in the same
directory as the toolbar dll, and has the proper elevation policy, then the
Execute command (see 1.8.8) and the ToolbarContextC method ElevateShellExecute(
) (see 2.1.13) can be used.
Follow these steps to enable elevation in the
framework:
1) Download DiodiaBroker.exe from http://www.diodia.com/DiodiaBroker.zip.
2) Include DiodiaBroker.exe in your toolbar setup
project.
3) Find the GUID of the broker for your toolbar in the file Framework.cpp, i.e.
the string value returned by the function GetHelperGuid( ).
4) Make your setup project create the proper
elevation policy for the broker by creating values in the registry key:
HKEY_LOCAL_MACHINE\
SOFTWARE\
Microsoft\
Internet
Explorer\
Low Rights\
ElevationPolicy\
<broker
GUID>
The values to create are:
AppName="DiodiaBroker.exe" (STRING)
AppPath="[TARGETDIR]" (STRING)
Policy=00000003 (DWORD)
The Html command holds HTML text to be displayed in
an HTML control.
The HTML text to display is specified by attributes
on the associated HTML control, either as a URL or as HTML text directly.
Examples:
<html
command="Html"
id="LayoutTest.Html.2"
width="100"
url="http://www.diodia.com/html_control_test.htm"/>
<html
command="Html"
id="LayoutTest.Html.1"
width="100">
<![CDATA[
<html>
<head>
<meta
http-equiv="Content-Type"
content="text/html;
charset=UTF-8"/>
</head>
<body
bgcolor="#eeebdc"
topmargin="4"
leftmargin="2">
<p align="top">
<b><font
face="Arial" size="1">HTML
Example</font></b>
</p>
</body>
<html>
]]>
</html>
CommandC is the base class
for all command objects.
Interfaces:
Methods:
Overridables
Attributes:
Interface providing access
to a toolband context from a toolband. Used while a toolbar is being
initialized.
Methods:
The interface is
implemented by command objects, and provides access to commands from toolbands
and controls.
Types:
Methods:
The interface is
implemented by control objects. Controls are notified about state changes in
commands through the command observer interface.
Used internally only.
Stores a set of pointers
to commands. A command pointer set can be used to keep track of commands
created dynamically, for example “Highlight and Word Find” commands.
Methods:
Stores a set of uniquely
named command objects. A toolband context aggregates a command set.
Interfaces:
Types:
Methods:
Overridables:
Attributes:
Interface providing access
to the commands in a command set.
Types:
Methods:
CommandWithEventsC is a
specialization of class CommandC. It supports all the features of CommandC, as
well as handing of web browser events.
Methods:
ControlC implements
control objects, i.e. menus, buttons, combo-boxes, etc..
The class is used internally only. Controls are manipulated through the
ControlI interface.
The interface is
implemented by toolband objects and menu controls. it makes it possible to
dynamically change the controls in a toolbar or a menu.
Methods:
The interface is
implemented by control objects, and provides access to controls from toolbands.
Types:
Methods:
Stores a set of pointers
to controls. A control pointer set can be used to keep track of controls
created dynamically, for example “Find&Highlight” buttons.
Methods:
ToolBandContextC is base
class for a specialized toolband context.
The toolband context glues
everything together.
Interfaces:
Methods:
Overridables:
Attributes:
ToolBandHookC is base
class for a specialized toolband hook.
The toolband hook is the
channel through which the Internet Explorer communicates with a toolbar.
Interfaces:
Methods:
Overridables:
Attributes:
The class implements the
toolband object, which is responsible for drawing the toolbar on the screen.
The class is used internally only.
The interface is
implemented by toolband objects, and provides access to toolbands from toolband
contexts.
Methods:
Creates a new button
control, which can be added to a toolbar or a menu through a control collection
interface.
- Parameters:
Command: The command object to
associate with the button.
Text: The caption to display on the
button.
- Note: To associate a bitmap with a button, use SetBitmapId() on the command
object associated with the button. To make the button display the bitmap, use
SetMode() from the ControlI interface after creating the button.
- Note: To create a toggle button, use SetFlags() from the ControlI interface
after creating the button.
Creates a new combo-box
control, which can be added to a toolbar through a control collection
interface.
- Parameters:
Command: The command object to
associate with the control.
List: Items to add to the drop-down list
separated by ##, for example "Red##Green##Blue".
- Note: To make the combo-box automatically adjust its size when the Internet
Explorer is resized, use SetFlags() from the ControlI interface after creating
the combo-box.
Note: To create a fixed width combo-box, use SetWidth() from the ControlI
interface after creating the combo-box.
- Note: To prevent users from entering text in the combo-box, i.e. to make the
combo-box display a fixed list of items, use SetFlags() from the ControlI
interface after creating the combo-box.
Creates a new edit control, which can be added to a toolbar through a control collection interface.
- Parameters:
Command: The command object to
associate with the control.
- Note: To make the edit control automatically adjust its size when the
Internet Explorer is resized, use SetFlags() from the ControlI interface after
creating the edit control.
Note: To create a fixed width edit control, use SetWidth() from the ControlI
interface after creating the edit control.
Creates a new label
control, which can be added to a toolbar through a control collection
interface.
- Parameters:
Command: The command object to
associate with the label. May be NULL if the label is a fixed text string that
never changes.
Text: The label to display.
Creates a new menu
control, which can be added to a toolbar or a menu through a control collection
interface.
- Parameters:
Command: The command object to
associate with the menu. If Command == NULL then an ordinary menu is created.
If Command != NULL then a mixed button (i.e. a combination of a button and a
menu) is created,.
Text: The caption to display on the
menu.
- Note: To associate a bitmap with a menu, use SetBitmapId() on the command
object associated with the menu. To make the menu also display the bitmap, use
SetMode() from the ControlI interface after creating the button. Bitmaps cannot
be associated with sub-menus.
Creates a new read-only
control, which can be added to a toolbar through a control collection
interface.
- Parameters:
Command: The command object to
associate with the control.
- Note: To make the read-only control automatically adjust its size when the
Internet Explorer is resized, use SetFlags() from the ControlI interface after
creating the read-only control.
Note: To create a fixed width read-only control, use SetWidth() from the
ControlI interface after creating the read-only control.
Creates a new HTML
control, which can be added to a toolbar through a control collection
interface.
- Parameters:
Command: The command object to
associate with the control. Use SetText( ) on the command object to specify
either a URL or some HTML text to display in the HTML control.
- Note: To make the HTML control automatically adjust its size when the
Internet Explorer is resized, use SetFlags() from the ControlI interface after
creating the read-only control.
Note: To create a fixed width HTML control, use SetWidth() from the ControlI
interface after creating the read-only control.
Creates a new separator
control, which can be added to a toolbar or a menu through a control collection
interface.
Returns the value of an
attribute from an XML DOM node.
- Parameters:
Node: The DOM node to get an
attribute value from.
Name: The name of the attribute.
- Usage: Typically used to
get a value from the toolbar configuration file from within a command.
- Example: The Navigate
command is used like this in the toolbar configuration file:
<button
command="Navigate"
url="http://www.cnn.com/"
caption="CNN"/>
The Navigate command can
get the value of the url attribute by calling XmlGetNodeAttribute():
void
NavigateCmdC::Execute(ControlI *Control)
{
CString Url;
variant_t
vtUrl;
Url =
XmlGetNodeAttribute(Control->GetNode(), "url");
vtUrl = bstr_t(Url);
mWebBrowser->Navigate2(&vtUrl,
&vtMissing,
&vtMissing,
&vtMissing, &vtMissing);
}
Returns the content of an
XML DOM node.
- Parameters:
Node: The DOM node to get the
content from.
- Usage: Typically used to
get a value from the toolbar configuration file from within a command.
- Example: The command ExampleCmd
is used like this in the toolbar configuration file:
<button
command="ExampleCmd" caption="Example">
Here is some text!
</button>
The command can get the content
of the button tag by calling XmlGetNodeValue():
void ExampleCmdC::Execute(ControlI
*Control)
{
CString Text;
Text = XmlGetNodeValue(Control->GetNode());
/* Text
is now “Here is some text!” */
:
}
The layout of a toolbar is
described by an XML file.
The XML file is basically
an ordered list of the controls in the toolbar. Each control is associated with
a named command, and perhaps a caption and a bitmap image.
The XML file below describes
a toolbar with three controls: A menu with three entries, a “Go Home” button and
a “Search Google” combo-box:
<?xml version="1.0" encoding="ISO-8859-1"?>
<toolband xmlns="http://www.diodia.com/toolband" name="MyToolbar">
<menu image="209">
<button command="MyToolbar.GoHome"
caption="My
Home Page"/>
<button command="MyToolbar.Help" caption="Help..."/>
<button command="MyToolbar.About"
caption="About..."/>
</menu>
<button command="MyToolbar.GoHome"
image="210"
caption="Home"
show-caption="yes"/>
<separator/>
<combo-box command="MyToolbar.SearchGoogle"
caption="Search Google"
width="220"
auto-size="yes"
fixed-list="no"/>
</toolband>
Description: Encapsulates
the complete toolbar definition.
Attributes:
Example:
<toolband xmlns="http://www.diodia.com/toolband" name="MyToolbar">
…
</toolband>
Description: Inserts a
menu control in a toolbar, or a sub-menu in a menu, and encapsulates the items
in the menu.
Attributes:
Notes:
Example:
<menu image="211"
caption="MyMenu"
show-caption="yes">
…
</menu>
Description: Inserts a button
control in a toolbar, or a menu item in a menu.
Attributes:
Notes:
Example:
<button command="MyToolbar.GoHome"
image="210"
caption="Home"
show-caption="yes"
toggle-button="no"/>
Description: Inserts a label
control in a toolbar.
Attributes:
Notes:
Example:
<label caption="Background
color:"/>
Description: Inserts an
edit control in a toolbar.
Attributes:
Examples:
<edit command="MyToolbar.Find"
caption="Find"
width="200"
auto-size="yes"/>
<edit command="Navigate"
id="MyToolbar.SearchBox"
parameter="www.google.com/search?q=##MyToolbar.SearchBox##"
caption="SearchBox"
width="200"