<HTML>
<HEAD>
<TITLE>DirectX Media SDK DirectAnimation Tutorial</TITLE>
<LINK REL=STYLESHEET HREF="../../../../../webcd/da/tutorial.css">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso8859-1">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="ROBOTS" CONTENT="noindex">
</HEAD>
<BODY BGCOLOR="WHITE" LINK=#0033CC TOPMARGIN=0 LEFTMARGIN=20>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->

<DIV CLASS="flush">
<TABLE WIDTH=100% BORDER=0 BGCOLOR=#000000>
<TR ALIGN=RIGHT><TD VALIGN=TOP><FONT CLASS=desc1 SIZE=2>
<IMG SRC="../../../../../media/image/d_prev.gif"
 WIDTH=71 HEIGHT=16 BORDER=0 ALT="Previous Topic">
<A HREF="../../../../../webcd/da/tutorial_main.htm" TARGET="_top">
<IMG SRC="../../../../../media/image/d_home.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Tutorial Home Page"></A>
<IMG SRC="../../../../../media/image/d_next.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Next Topic">
</FONT></TD><TD WIDTH=30></TD></TR></DIV></TABLE>
<FONT CLASS=title><CENTER>Constructing a Windowless Control</CENTER></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1><BR>
 This template demonstrates how to construct an animation that
 makes use of IE4 windowless controls. It illustrates the following:
 - Using the modelmaker applet
 - Using the dxactrl (DirectAnimation windowless control)
 - Constructing the model and passing it to the control
<BR></TD></TR></FONT></TABLE>
<FONT CLASS=code>import com.ms.dxmedia.*;<BR>
import module.*;          </FONT><FONT CLASS=desc2> This gets ReactiveCube</FONT><FONT CLASS=code><BR>
import java.net.*;<BR>
</FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> When designing windowless controls, the Java applet is used purely to construct
 the model. At runtime, hand the finished model over to the windowless
 control to be displayed.</TD></TR></FONT></TABLE>
<FONT CLASS=code>class WindowlessModel extends Model {<BR>
<DIV STYLE="margin-left: 0.125in">public void createModel(BvrsToRun blist) {<BR>
</DIV></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Create any type of animation you like here... it is completely up to you
 what goes into the model.</TD></TR></FONT></TABLE>
<FONT CLASS=code></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> The image is simply the rendered cube without any background.
 Since you want to overlay the windowless control with other HTML
 elements, specifically avoid a solidColor background.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.25in">setImage(cubeGeo.render(Cam));<BR>
setSound(cube.getSoundBvr());<BR>
</DIV><DIV STYLE="margin-left: 0.125in">}<BR>
</DIV>}<BR>
</FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Here is the important part, rather than extending DXMApplet as usual,
 extend ModelMakerApplet. Aside from the name, the construction
 is exactly the same as if you were doing a normal applet.</TD></TR></FONT></TABLE>
<FONT CLASS=code>public class WindowlessApplet extends ModelMakerApplet {<BR>
<BR>
<DIV STYLE="margin-left: 0.125in">public void init() {</FONT>
<BR>
</DIV><TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Always call the super classes init first to ensure codeBase is set.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.25in">super.init() ;</FONT>
<BR>
</DIV><TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Now set the model.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.25in">setModel (new WindowlessModel());<BR>
</DIV><DIV STYLE="margin-left: 0.125in">}<BR>
</DIV>}<BR>
<BR>
&lt!--</FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> In the HTML file we place the DirectAnimation windowless control. This is what
 will actually display our model.  Notice you can set it's style properties to
 get the proper layout and sizing.  See IE4 documentation on style sheets for
 more information about using them.</TD></TR></FONT></TABLE>
<FONT CLASS=code>--&gt<BR>
&ltOBJECT STYLE="POSITION:ABSOLUTE; TOP:45; LEFT:35%; WIDTH:375; HEIGHT:375; Z-INDEX:1"<BR>
<DIV STYLE="margin-left: 0.0625in">ID="dxactrl" CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D"&gt&lt/OBJECT&gt<BR>
</DIV><BR>
&lt!--</FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Also insert the applet which constructs your model.  Notice that it's width and
 height are zero since it is only used to construct the animation</TD></TR></FONT></TABLE>
<FONT CLASS=code>--&gt<BR>
&ltAPPLET CODEBASE="IE4_Windowless" CODE=WindowlessApplet.class WIDTH=0 HEIGHT=0 ID=javaApp&gt&lt/APPLET&gt<BR>
<BR>
<BR>
&lt!--</FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> A script is used to bridge the gap and pass the needed view, image and sound to
 the dxactrl for display.</TD></TR></FONT></TABLE>
<FONT CLASS=code>--&gt<BR>
&ltSCRIPT LANGUAGE="VBScript"&gt<BR>
&lt!--<BR>
<DIV STYLE="margin-left: 0.125in">AnimationOnTop = false<BR>
</DIV><BR>
<DIV STYLE="margin-left: 0.125in">sub window_onLoad<BR>
</DIV><DIV STYLE="margin-left: 0.375in">dxactrl.View = javaApp.grabViewComPtr<BR>
dxactrl.Image = javaApp.grabImageComPtr<BR>
dxactrl.Sound = javaApp.grabSoundComPtr<BR>
</DIV><BR>
<DIV STYLE="margin-left: 0.375in">' Start the control viewing<BR>
dxactrl.Start<BR>
</DIV><DIV STYLE="margin-left: 0.125in">end sub<BR>
<BR>
Sub ChangeZ_OnClick<BR>
</DIV><DIV STYLE="margin-left: 0.25in">If AnimationOnTop Then<BR>
</DIV><DIV STYLE="margin-left: 0.375in">AnimationOnTop = false<BR>
dxactrl.style.zindex = 1<BR>
</DIV><DIV STYLE="margin-left: 0.25in">Else<BR>
</DIV><DIV STYLE="margin-left: 0.375in">AnimationOnTop = true<BR>
dxactrl.style.zindex = -1<BR>
</DIV><DIV STYLE="margin-left: 0.25in">End If<BR>
</DIV><DIV STYLE="margin-left: 0.125in">End Sub<BR>
</DIV>--&gt<BR>
&lt/SCRIPT&gt<BR>
<BR>
</FONT><FONT CLASS=link><A ID=cpslug HREF="../../../../../help/da/dalegal.htm" TARGET="_top">&#169; 1997 Microsoft Corporation. All rights reserved. Terms of Use.</A></FONT>
<BR>
<BR>
<DIV CLASS="flush">
<TABLE WIDTH=100% BORDER=0 BGCOLOR=#000000>
<TR ALIGN=RIGHT><TD VALIGN=TOP><FONT CLASS=desc1 SIZE=2>
<IMG SRC="../../../../../media/image/d_prev.gif"
 WIDTH=71 HEIGHT=16 BORDER=0 ALT="Previous Topic">
<A HREF="../../../../../webcd/da/tutorial_main.htm" TARGET="_top">
<IMG SRC="../../../../../media/image/d_home.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Tutorial Home Page"></A>
<IMG SRC="../../../../../media/image/d_next.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Next Topic">
</FONT></TD><TR><TD WIDTH=30></TD></TR></DIV></TABLE>
</BODY>
</HTML>
