⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch27.htm

📁 CGI programming is the hottest stuff to look out for in this book
💻 HTM
📖 第 1 页 / 共 5 页
字号:
to use.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Note</B></TD></TR>
<TR><TD><BLOCKQUOTE>
Not everyone meets this type of content delivery with anticipation and enthusiasm. The reason for this is cross-platform compatibility. If you decide to use a proprietary content format as a major portion of your site, you're counting on your primary 
target audience to have the control they'll need to view it. If the manufacturer only has an ActiveX control for Windows 95 and doesn't have any plans to move to UNIX or Mac, your Internet content is no longer platform-independent. See the section 
&quot;ActiveX Viability and Directions&quot; later in this chapter for more details.</BLOCKQUOTE>

</TD></TR>
</TABLE></CENTER>
<P>
<P>
Just because ActiveX controls are designed to be small for Internet
use, it doesn't mean you have to use them that way. Just as the
more traditional OLE controls functioned on the desktop machine
level or over the network, ActiveX controls carry on the tradition.
You can plug in an ActiveMovie control to an existing Visual Basic
or C++ application with little or no difficulty because they've
been ready for that kind of communication for quite some time
now.
<H3><A NAME="Financials">Financials</A></H3>
<P>
How many developers out there have ever written OLE containers
or controls? Visual Basic Extensions? OCXs, in the more recent
past? If you add up the numbers of any estimate out there, you
end up with a staggering total. By casual estimates, over a million
developers out there have done these kinds of things as either
individual efforts or corporate software initiatives. That's a
heck of a user base to build on.
<P>
Now think about the interchangability of it all. People who make
one control sell it to a bunch of other people, and they might
end up buying an extension that someone else made. It could be
a compression algorithm, image display function, video or audio
handling, or text display and modification; look through any software
development magazine or newsgroup, and you'll see a small part
of the potential development audience.
<H4>The Migration Instinct</H4>
<P>
People don't usually like to waste time or money. If you've spent
a great deal of both in creating a piece of software, you're probably
more inclined to make a few small changes than you are to start
over from scratch. That's one of the things Microsoft is hoping
for.
<P>
With the huge base of existing customers who have created VBXs,
OLE controls, OLE container applications, and OCXs, the possibilities
opened by the ActiveX strategy are huge, and steps are in place
to help people move from the old way to the new way, in somewhat
of a software-upgrade path. The largest evidence of this is the
large portion of the ActiveX Development Kit dedicated to Visual
Basic migration to ActiveX components and controls. In fact, 14
lengthy chapters in the &quot;Control Migration Pack&quot; go
into more details than you can easily shake a mouse cursor at.
<H4>The Bandwagon Brigade</H4>
<P>
Who has more money to spend on advertising: Microsoft or independent
developers? Not a tough call. When Microsoft announces a new technology
and puts lots of hype behind it, it drags plenty of attention
in its wake even if the hype dies down after a while. This is
great for people who are developing ActiveX controls and components
because they just put the magic words &quot;ActiveX enabled&quot;
in their advertisements and the mouths of their sales people,
and they've grabbed onto some real big coattails at no real expense.
<P>
Because ActiveX has such a large public presence, unlike some
other object standards such as CORBA (which rings familiar to
a select segment of developers and companies, but not the general
population), it doesn't take much work to convince people it's
a good thing. The more people that hop on the bandwagon, the more
sheer momentum the wagon gets. Sure, it could eventually try to
round a technological corner and go careening off a cliff into
the depths of obscurity, but there's a pretty good stretch of
open road in front of it right now.
<H2><A NAME="ActiveXControlsinAction"><FONT SIZE=5 COLOR=#FF0000>ActiveX
Controls in Action</FONT></A></H2>
<P>
Knowing a little bit more about ActiveX, you might want to take
a look at some of the stuff it can do before diving into the realm
of just how it works. This is the opportunity to examine it from
an end-user perspective and see more than just hype and promises.
Microsoft started churning out controls like there was no tomorrow
right after Internet Explorer (IE) 3.0's beta release, and other
developers and software companies started to do the same. To start
with, take a look at what's going on with two of the more popular
Microsoft ActiveX Controls-ActiveMovie and the HTML Layout control.
<H3><A NAME="ActiveMovie">ActiveMovie</A></H3>
<P>
There are lots of video formats out there, such as MPEG, AVI,
and QuickTime. Some you need special hardware for; some you don't.
Some are well synchronized during playback; some aren't. Some
can be played back over the Internet... Hey, why not just solve
all the problems at once? ActiveMovie gives users the ability
to view any format they'd like, all with better playback rates
and synchronization and all without special hardware.
<P>
This means that you can play back highly compressed MPEG video
on a machine with no MPEG decoder board and get good results.
It means the same control can play back QuickTime and AVI videos,
as well as different forms of compressed audio. If that wasn't
enough, you can create filters to modify the video and audio as
it comes through. All of this is accomplished through Microsoft's
DirectX method of providing direct access to audio and video hardware,
so if there is anything on board that should make things faster,
it will.
<P>
All of this is accomplished through media streaming, where multimedia
data streams get run through a series of filters. Some do the
decoding, others do the drawing, and others do any modifications
necessary in between. Developers can use the ActiveMovie SDK to
create their own special filters for formats or effects, whereas
end users take the compilation of filters (called a filter graph)
and the ActiveX control and play back video or audio to their
heart's content.
<H3><A NAME="HTMLLayoutControl">HTML Layout Control</A></H3>
<P>
Have you ever tried to position things in a nice organized manner
using HTML? Let's see; you want the button to be in the top right
of the screen, just under the logo, all the form elements should
line up nicely, and that animated GIF needs to be positioned just
so over a specific spot in the background graphic. If your answer
to all the above issues is tables, good luck. It's frustrating
to come up with what you think is a great design, only to be limited
by not being able to position elements to your liking.
<P>
The playing field is changing. One of the proposed extensions
to HTML 2.0 is the ability to position HTML design elements on
a 2-D XY-coordinate grid. If you want the graphic in the upper-left
corner to be positioned precisely at 10,10, you can do it-assuming
your browser has support for it, of course.
<P>
The HTML Layout control gives you that ability now before worrying
about what happens with the standards. This is good and bad. If
you spend a long time designing something to be a specific way
using Microsoft's idea of what the final 2-D layout specs will
be, you might end up making changes later. If you want the functionality
now, some changes later are usually more acceptable than just
sitting around and waiting.
<H3><A NAME="OtherControls">Other Controls</A></H3>
<P>
What else is in the works? Pretty much anything you'd like to
imagine, such as animation, audio, and business applications.
If people are using it over the Internet (or want to), chances
are it's going to get an ActiveX control before too long. If you
want to see just what range of controls are out there, skim one
of the Web sites mentioned in the section &quot;Resources&quot;
later in this chapter, and you'll see everything from A to Z.
<H2><A NAME="DevelopingActiveXControls"><FONT SIZE=5 COLOR=#FF0000>Developing
ActiveX Controls</FONT></A></H2>
<P>
You've heard about them, seen them in action, and now you might
be wondering how in the heck they work. Before I dive into that,
I want to reiterate one of the things I mentioned in the beginning-creating
ActiveX components is advanced programming. It's not something
you approach casually and expect to do something fantastic in
an afternoon, having started from scratch. If it is and you're
successful at it, a lot of companies would like to have a long
talk with you about coming to work for them. If you're like the
rest of us, though, you need to have a strong background in programming
before you can really consider making a control of your own.
<P>
This section isn't going to take you through the creation of an
ActiveX control step-by-step. Microsoft has an ActiveX SDK for
that, and it's huge. What I'm going to do is outline some of the
more important starting points, and you can take the ball and
run with it from there.
<H3><A NAME="UnderlyingProgrammingBasics">Underlying Programming
Basics</A></H3>
<P>
If you're not familiar with COM or OLE, you have a lot of work
ahead before you create your first original ActiveX control. If
you've ever written VBXs, you're in much better shape. If you're
familiar with COM and OLE and have written OLE controls, you probably
won't even break a sweat. How difficult it will be is truly dependent
on your experience because there are several layers of development
concerns.
<H3><A NAME="ControlFramework">Control Framework</A></H3>
<P>
The basic framework for ActiveX controls is supplied by Microsoft
in an aptly named package called <TT><FONT FACE="Courier">BASECTL</FONT></TT>,
for &quot;Base Controls.&quot; This is part of the ActiveX SDK,
so you'll need a copy from Microsoft before you can do much with
it. In that package are two basic but useful Internet-aware ActiveX
controls and the C++ framework (named <TT><FONT FACE="Courier">FRAMEWRK</FONT></TT>),
which makes everything go.
<P>
The fact that there are 15 C and C++ files in the initial <TT><FONT FACE="Courier">FRAMEWRK</FONT></TT>
component goes to show that building an ActiveX control isn't
a walk in the park. Before you get too nervous, though, take a
look through the code. It's well-commented (sometimes with a sense
of humor...), and you can start to see just how it all fits together
without too much pain and suffering.
<H3><A NAME="ToolsforCreation">Tools for Creation</A></H3>
<P>
Although you can use any language to create ActiveX components,
the primary language for creating controls is C++. More specifically,
the initial tool is Visual C++ 4.0 on a 32-bit Windows platform,
such as NT 3.51 or 4.0. The reason for this is that the calls
and elements supplied in the first version of the framework are
all specific to Visual C++, as would be expected in a Microsoft
release. It takes time for these elements to be brought into other
development environments on Windows, such as compilers from Borland
and other vendors, and even longer for such pieces to reach other
platforms such as the Macintosh and various flavors of UNIX.
<P>
If things go as planned, Visual Basic 5.0 users will be able to
turn their development environment into control-creating powerhouses
as well. Currently existing VBX controls can be ported over already
through judicious use of Visual C++, and as time goes on, other
Rapid Application Development (RAD) tools such as Borland's Delphi
will undoubtedly add the functionality as well, just to satisfy
the growing developer audience. When and how are the key questions.
<H2><A NAME="IntegratingControlswithYourWebSite"><FONT SIZE=5 COLOR=#FF0000>Integrating
Controls with Your Web Site</FONT></A></H2>
<P>
Having created or otherwise obtained an ActiveX control, the next
real step is setting up your documents to use the controls. Compared
to understanding the mechanics behind it all, this is by far the
easiest part of the whole operation.
<H3><A NAME="TheOBJECTtag">The <TT><FONT SIZE=4 FACE="Courier">&lt;OBJECT&gt;</FONT></TT>
<FONT SIZE=4>tag</FONT></A></H3>
<P>
Until recently, the <TT><FONT FACE="Courier">OBJECT</FONT></TT>
tag was the <TT><FONT FACE="Courier">INSERT</FONT></TT> tag. Although
the name has evolved just as ActiveX's did, the purpose remains
the same. It's a straightforward method of including a compiled
object in the document, leaving it up to the browser on the other
end to determine if it's going to do anything with it. The two
primary components of the <TT><FONT FACE="Courier">OBJECT</FONT></TT>
tag are the <TT><FONT FACE="Courier">ClassID</FONT></TT> and the
optional parameters.
<H4><TT><FONT FACE="Courier">ClassID</FONT></TT></H4>
<P>
The <TT><FONT FACE="Courier">ClassID</FONT></TT> is a long Globally
Unique Identifier (GUID) that allows the system to know for certain
which piece of code you're talking about. No two components will
(or at least should) have the same GUID in the registry, and when
software developers create the ID for their function, they must
follow basic guidelines for ensuring that this doesn't happen.
<H4>Optional Parameters</H4>
<P>
As with any application, you can attach a lot of possible elements
to your <TT><FONT FACE="Courier">OBJECT</FONT></TT> tag. You can
indicate width, height, alignment, a nametag, and even the equivalent
of command-line parameters by tagging them on the end with the
expected <TT><FONT FACE="Courier">PARAMETER</FONT></TT> tags.
<P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -