📄 ch27.htm
字号:
<HTML>
<HEAD>
<TITLE>Chapter 27 -- ActiveX Controls</TITLE>
<META>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT COLOR=#FF0000>Chapter 27</FONT></H1>
<H1><B><FONT SIZE=5 COLOR=#FF0000>ActiveX Controls</FONT></B>
</H1>
<P>
<HR WIDTH="100%"></P>
<P>
<H3 ALIGN=CENTER><FONT COLOR="#000000"><FONT SIZE=+2>CONTENTS<A NAME="CONTENTS"></A>
</FONT></FONT></H3>
<UL>
<LI><A HREF="#ActiveXConceptsandBackground" >ActiveX Concepts and Background</A>
<UL>
<LI><A HREF="#OLEandCOM" >OLE and COM</A>
<LI><A HREF="#ContainersforAnything" >"Containers" for Anything</A>
<LI><A HREF="#ActiveXSonofOLE" >ActiveX, Son of OLE</A>
<LI><A HREF="#ComponentCategories" >Component Categories</A>
</UL>
<LI><A HREF="#WhyTheyMatter" >Why They Matter</A>
<UL>
<LI><A HREF="#Functionality" >Functionality</A>
<LI><A HREF="#Financials" >Financials</A>
</UL>
<LI><A HREF="#ActiveXControlsinAction" >ActiveX Controls in Action</A>
<UL>
<LI><A HREF="#ActiveMovie" >ActiveMovie</A>
<LI><A HREF="#HTMLLayoutControl" >HTML Layout Control</A>
<LI><A HREF="#OtherControls" >Other Controls</A>
</UL>
<LI><A HREF="#DevelopingActiveXControls" >Developing ActiveX Controls</A>
<UL>
<LI><A HREF="#UnderlyingProgrammingBasics" >Underlying Programming Basics</A>
<LI><A HREF="#ControlFramework" >Control Framework</A>
<LI><A HREF="#ToolsforCreation" >Tools for Creation</A>
</UL>
<LI><A HREF="#IntegratingControlswithYourWebSite" >Integrating Controls with Your Web Site</A>
<UL>
<LI><A HREF="#TheOBJECTtag" >The <OBJECT> tag</A>
<LI><A HREF="#InternetComponentDownload" >Internet Component Download</A>
</UL>
<LI><A HREF="#ActiveXViabilityandDirections" >ActiveX Viability and Directions</A>
<UL>
<LI><A HREF="#WhosGoingtoDevelop" >Who's Going to Develop?</A>
<LI><A HREF="#OpeningtheStandard" >Opening the Standard?</A>
<LI><A HREF="#GoingCrossPlatform" >Going Cross Platform</A>
<LI><A HREF="#CompetitiveStandards" >Competitive Standards</A>
<LI><A HREF="#NetscapeandActiveX" >Netscape and ActiveX</A>
<LI><A HREF="#Market" >Market</A>
</UL>
<LI><A HREF="#Resources" >Resources</A>
<UL>
<LI><A HREF="#ActiveXSDK" >ActiveX SDK</A>
<LI><A HREF="#OLEandOCXControlsBooks" >OLE and OCX Controls Books</A>
<LI><A HREF="#WebSites" >Web Sites</A>
<LI><A HREF="#ExistingDevelopersVisualBasicandC" >Existing Developers (Visual Basic and C++)</A>
</UL>
<LI><A HREF="#Summary" >Summary</A>
</UL>
<HR>
<P>
Wouldn't it be great if you could easily add new functionality
to your Web site or even your standard hard-drive-bound programs?
You see something new, you want it, poof... You add it into your
word processor, your desktop shell, or anything else you feel
like. Seamless, painless, and possible.
<P>
ActiveX controls are the heart of Microsoft's new Internet strategy,
proposing to give developers and users that kind of flexibility
and functionality with that kind of ease of use. They're designed
to be little add-on pieces that enhance things you already have
so you don't have to start from scratch to build in every possible
situation. These reusable objects even hang around on your system
so that the next time you need them, you'll already have them
and not waste time downloading them again.
<P>
To introduce you to the realm of ActiveX, I'll do some digging
into the following areas:
<UL>
<LI><FONT COLOR=#000000>ActiveX concepts and background</FONT>
<LI><FONT COLOR=#000000>Why ActiveX controls matter to developers
and users</FONT>
<LI><FONT COLOR=#000000>Getting down and dirty with design and
implementation</FONT>
<LI><FONT COLOR=#000000>Where ActiveX is heading</FONT>
<LI><FONT COLOR=#000000>Resources you can turn to</FONT>
</UL>
<P>
Although knowing about ActiveX controls and how they can help
you is one thing, knowing how to create them is a separate task
altogether. Most of this chapter focuses on the usability side
of the ActiveX controls rather than the creation side, but a good
deal of the inner workings and concepts are explored as well.
If you see enough to get interested in building your own, bear
in mind that building ActiveX controls is programming at a high
level, and you'll want to have some serious programming experience
before experimenting on your own with a new type of control. If
you've got the motivation, though, anything can happen.
<H2><A NAME="ActiveXConceptsandBackground"><FONT SIZE=5 COLOR=#FF0000>ActiveX
Concepts and Background</FONT></A></H2>
<P>
The old theory goes that you can't fit a square peg into a round
hole unless you really pound it in there. In the same vein, it's
always been hard to take good content and integrate it with a
Web site or intranet unless you really beat on it to get it into
the form that you need. Even then, it just can't be done sometimes-some
of the things that exist just can't be forced to fit in the place
you want to put them. Until now, anyway.
<H3><A NAME="OLEandCOM">OLE and COM</A></H3>
<P>
Back some years ago, people in the Windows world began to get
frustrated with the inability to take things created in one application
and make easy use of them in another. In response to this frustration,
object linking and embedding was born. Object linking and embedding,
or OLE, was the answer to a number of problems because it allowed
you to take a chunk of data from one program and easily attach
it to another application that supported OLE. What was happening
behind the scenes was that each OLE-capable application had some
"hooks" in it that allowed other things to be attached
to it later and talk to one another. Much like using building
blocks, if you give everything a universal method of connecting,
you can just keep adding new pieces as you need them.
<P>
This universal method of connecting is the component object model,
or COM. This is a standard that acts like the blueprints for plastic
building blocks-it specifies what kind of connectors exist and
what configurations are acceptable. Without it, two blocks designed
by the same company just won't work together. OLE was built on
top of COM for use in the Windows environment and proved very
useful for both developers and end users. Now, instead of an image
of a spreadsheet, the actual spreadsheet itself could be embedded
within a document and manipulated. The basic premise was to add
on to existing functionality in as seamless and efficient a manner
as possible.
<H3><A NAME="ContainersforAnything">"Containers" for
Anything</A></H3>
<P>
In a sense, OLE components and OLE-enabled applications are all
containers-they exist to hold special types of information that
the other application may or may not be able to deal with. An
application could essentially be nothing more than one big container
to hold little containers, so that if you needed a component to
take care of text, you brought it in. If you needed a component
to take care of video, you brought it in, and so forth. It's the
whole component object model theory at work; you start out with
the pieces you need and put them together into the thing you want
without too much work in between.
<H3><A NAME="ActiveXSonofOLE">ActiveX, Son of OLE</A></H3>
<P>
ActiveX is the next generation of OLE controls and containers.
More precisely, it's the next-generation name of OLE controls
and components. For all intents and purposes, ActiveX controls
are OLE controls, just with a cooler name, a new focus, and some
new tricks. Microsoft defines an ActiveX control in a variety
of different ways, but the most basic one that they give is, "An
ActiveX Control is essentially a simple OLE object that supports
the IUnknown interface." This doesn't preclude it from doing
anything else, but the universal connector in this case is the
IUnknown interface. Don't worry too much about the technical-sounding
term. The IUnknown interface is just a way for an application
to say, "I have no idea what to do with this; do you?"
to something else.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Those Changing Names</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
In every product's life cycle, names end up changing around. Microsoft went through their own growing pains with ActiveX, but they finally seem to have made up their minds. After all, if "Oak" can evolve into "Java," why can't
"OLE" move to "Sweeper" to "the Active Internet Platform" and come to a halt at "ActiveX"? There were talks about renaming the Internet Information Server just as they'd ended up renaming the Internet SDK (it's now
the ActiveX SDK, for those who are keeping score), and if FrontPage didn't already have a nice name, it might have been next. Who knows what will end up with an ActiveX prefix before Microsoft is done...</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<P>
The real changes of ActiveX are beneath the surface where it makes
up for what OLE and OCXs (the next-to-last name used for ActiveX
controls) lacked.
<H3><A NAME="ComponentCategories">Component Categories</A></H3>
<P>
When you use a control, you'd like to be able to identify whether
it is what you think it is and does what you think it does. In
the future, you might like the ability to look for something not
necessarily by name, but by what it does. To handle both the present
and future requests, Microsoft brought up a number of methods
for categorizing all the controls and containers in the Windows
registry.
<P>
At a base level, categories are the types of questions that the
control responds to. In the COM and ActiveX world, these are the
interface signatures-the types of communications interfaces supported
by the control. The interface signatures tell someone whether
control A accepts type X of communication but not really what
it can do with the information once it gets it. This information
is a necessity for real intertwining of controls and their functionality
because if control A supports a text-reading function, you might
assume that it means you can do certain things once it reads the
file. If it doesn't, and you jumped the gun, your program wouldn't
be able to do much except sit there and complain that what it
needed from the other control wasn't there. You really wanted
to know not only that the control supported reading, but that
it also did some other things as well.
<P>
To organize all these possibilities, each unique control gets
its own chain of things that it supports added on to it in the
registry. If a registry identifier indicated, "This outputs
RTF files," you could have that tagged on to the control.
If a tag indicated, "This supports database access,"
you could tack that one on there as well until you've daisy-chained
this huge and unwieldy string of unique identifiers onto the poor
control and made it real apparent to other programs that your
control supports certain things.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Tip</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
The definition and implementation for category keys is in a state of flux. The current method involves placing human-readable keys in the registry so that people can change classifications easily, but in the long run, that is a big mess with thousands of
possible programs on one machine all putting long strings of data with arbitrary names inside your registry. If your role for ActiveX is a user and not a developer, you very rarely have to worry about how in the world these things are organized. If you're
developing and need to worry about it, check the latest release of the ActiveX SDK for the most current details and methodology, just to make sure you don't do something that will become obsolete in the blink of an eye.</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<H2><A NAME="WhyTheyMatter"><FONT SIZE=5 COLOR=#FF0000>Why They
Matter</FONT></A></H2>
<P>
ActiveX controls, and the ActiveX technologies in general, matter
to developers and to end users for a variety of reasons. Although
it's impossible to cover every single reason, the major ones fall
into two basic categories-functionality and financials.
<H3><A NAME="Functionality">Functionality</A></H3>
<P>
Creating your site so that it does everything you need is a tough
job. It's even harder when you need to keep it innovative and
up to speed with the latest trends and technologies. There's always
something new you want to add or something you read about that
clients and other end users really want to see in action. ActiveX
controls allow you to get hold of the interactivity and "wow"
factor without all the work. If you want to show a spreadsheet,
you don't convert it to an HTML table; you just provide it in
its native form and make an ActiveX control available for people
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -