亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch20.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<P><A HREF="javascript:popUp('20uvc05.gif')"><B>FIG. 20.5</B></A><B> </B><I>Create
a new class to handle asynchronous properties.</I></P>
<P>The reason that the new class should inherit from CCachedDataProperty is that
it will load the property information into a file, which is an easier way to handle
the bitmap. If the control has a property that was downloaded because it changed
often (for example, current weather), CDataPathProperty would be a better choice.</P>
<P><B>Add the <I>Image</I> Property to <I>CDierollCtrl</I></B><I>&#160;&#160;</I>With
the new CDierollDataPathProperty class added to the Dieroll control, add the property
to the original CDierollCtrl class that you copied: In ClassWizard, on the Automation
tab, make sure that CDierollCtrl is selected in the far right drop-down box. Click
Add Property and fill out the dialog as shown in Figure 20.6. The external name you
choose is the one that will appear in the HTML: Image is simple and doesn't require
a lot of typing. The type should be BSTR--that choice won't be in the drop-down box
for type until you change the Implementation to Get/Set Methods.</P>
<P><A HREF="javascript:popUp('20uvc06.gif')"><B>FIG. 20.6</B></A><B> </B><I>The image
file is added as a BSTR property.</I></P>
<P>ClassWizard adds the Get and Set functions to your control class, but the TODO
comments (see Listing 20.6) are cryptic.</P>
<P>
<H4>Listing 20.6&#160;&#160;DierollCtl.cpp--Get and Set Functions</H4>
<PRE>BSTR CDierollCtrl::GetImage()
{
    CString strResult;
    // TODO: Add your property handler here
    return strResult.AllocSysString();
}
void CDierollCtrl::SetImage(LPCTSTR lpszNewValue)
{
    // TODO: Add your property handler here
    SetModifiedFlag();
</PRE>
<PRE>}
</PRE>
<P>As with other Get and Set properties, you'll have to add a member variable to
the control class and add code to these functions to get or set its value. It is
an instance of the new CDierollDataPathProperty class. Right-click CDierollCtrl in
ClassView and choose Add Member Variable. Figure 20.7 shows how to fill in the dialog
box to declare the member variable mdpp_image. (The dpp in the name is to remind
you that this is a data path property.)</P>
<P><A HREF="javascript:popUp('20uvc07.gif')"><B>FIG. 20.7</B></A><B> </B><I>The image
file member variable is an instance of the new class.</I></P>
<P>Now you can finish the Get and Set functions, as shown in Listing 20.7.</P>
<P>
<H4>Listing 20.7&#160;&#160;DierollCtl.cpp--Completed Get and Set Functions</H4>
<PRE>BSTR CDierollCtrl::GetImage()
{
    CString strResult;
    strResult = mdpp_image.GetPath();
    return strResult.AllocSysString();
}
void CDierollCtrl::SetImage(LPCTSTR lpszNewValue)
{
    Load(lpszNewValue, mdpp_image);
    SetModifiedFlag();
</PRE>
<PRE>}
</PRE>
<P>At the top of the header file for CDierollCtrl, add this include statement:</P>
<P>
<PRE>#include &quot;DierollDataPathProperty.h&quot;
</PRE>
<P>Now there are some bits and pieces to deal with because you are changing an existing
control rather than turning on asynchronous properties when you first built Dieroll.
First, in CDierollCtrl::DoPropExchange(), arrange persistence and initialization
for mdpp_image by adding this line:</P>
<P>
<PRE>PX_DataPath( pPX, _T(&quot;Image&quot;), mdpp_image);
</PRE>
<P>Second, add a line to the stub of CDierollCtrl::OnResetState() that ClassWizard
provided, to reset the data path property when the control is reset. Listing 20.8
shows the function.</P>
<P>
<H4>Listing 20.8&#160;&#160;DierollCtl.cpp--CDierollCtrl::OnResetState()</H4>
<PRE>/////////////////////////////////////////////////////////////////////////////
// CDierollCtrl::OnResetState - Reset control to default state
void CDierollCtrl::OnResetState()
{
    COleControl::OnResetState();  // Resets defaults found in DoPropExchange
    mdpp_image.ResetData();
</PRE>
<PRE>}
</PRE>
<P><B>Add the <I>ReadyStateChange</I> Event and the <I>ReadyState</I> Property&#160;&#160;</B>Use
ClassWizard to add the stock event ReadyStateChange. In ClassWizard, click the ActiveX
Events tab, then the Add Event button. Choose ReadyStateChange from the drop-down
box and click OK. Figure 20.8 shows the Add Event dialog box for this event. Events,
as discussed in Chapter 17, notify the control's container that something has happened
within the control. In this case, what has happened is that the rest of the control's
data has arrived and the control's state of readiness has changed.</P>
<P><A HREF="javascript:popUp('20uvc08.gif')"><B>FIG. 20.8</B></A><B> </B><I>Add a
stock event to notify the container of a change in the control's readiness.</I></P>
<P>Use ClassWizard to add a property to CDierollCtrl for the ready state. In ClassWizard,
click the Automation tab, then the Add Property button. Choose ReadyState from the
drop-down box, and because this is a stock property, the rest of the dialog box is
filled in for you, as shown in Figure 20.9. Click OK to finish adding the property
and then close ClassWizard. ClassWizard doesn't add a stub function for GetReadyState()
because CDierollCtrl will inherit this from COleControl.</P>
<P><A HREF="javascript:popUp('20uvc09.gif')"><B>FIG. 20.9</B></A><B> </B><I>Add a
stock property to track the control's readiness.</I></P>
<P>Add code to the constructor to connect the cached property to this control and
to initialize the member variable in COleControl that is used in COleControl::GetReadyState()
and set by COleControl::InternalSetReadyState(). Because the control can be used
right away, the readiness state should start at READYSTATE_INTERACTIVE. Listing 20.9
shows the new constructor.</P>
<P>
<H4>Listing 20.9&#160;&#160;DierollCtl.cpp--CDierollCtrl::CDierollCtrl()</H4>
<PRE>CDierollCtrl::CDierollCtrl()
{
    InitializeIIDs(&amp;IID_DDieroll, &amp;IID_DDierollEvents);
    mdpp_image.SetControl(this);
    m_lReadyState = READYSTATE_INTERACTIVE;
</PRE>
<PRE>}
</PRE>
<P><B>Implement <I>CDierollDataPathProperty&#160;&#160;</I></B>There is some work
to do in<B> </B>CDierollDataPathProperty before changing CDierollCtrl::OnDraw().
This class loads a bitmap, and this chapter isn't going to explain most of what's
involved in reading a BMP file into a CBitmap object. The most important function
is OnDataAvailable(), which is in Listing 20.10. Add this function to the class by
right-clicking CDierollCtrl in ClassView and choosing Add Virtual Function. Select
OnDataAvailable from the list on the left, and click Add and Edit; then type this
code.</P>
<P>
<H4>Listing 20.10&#160;&#160;DierollDataPathProperty.cpp--OnDataAvailable()</H4>
<PRE>void CDierollDataPathProperty::OnDataAvailable(DWORD dwSize, DWORD grfBSCF)
{
    CCachedDataPathProperty::OnDataAvailable(dwSize, grfBSCF);
    if(grfBSCF &amp; BSCF_LASTDATANOTIFICATION)
    {
        m_Cache.SeekToBegin();
        if (ReadBitmap(m_Cache))
        {
            BitmapDataLoaded = TRUE;
            // safe because this control has only one property:
            GetControl()-&gt;InternalSetReadyState(READYSTATE_COMPLETE);
            GetControl()-&gt;InvalidateControl();
        }
    }
</PRE>
<PRE>}
</PRE>
<P>Every time a block of data is received from the remote site, this function is
called. The first line of code uses the base class version of the function to deal
with that block and set the flag called grfBSCF. If, after dealing with the latest
block, the download is complete, the ReadBitmap() function is called to read the
cached data into a bitmap object that can be displayed as the control background.
(The code for ReadBitmap() isn't presented or discussed here, though it is on the
Web site for you to copy into your application.) After the bitmap has been read,
the control's ready state is complete and the call to InvalidateControl() arranges
for a redraw.</P>
<P><B>Revise <I>CDierollCtrl::OnDraw()&#160;&#160;</I></B>The structure of CDierollCtrl::OnDraw()<B>
</B>was laid out long ago. In this block of code, the background is filled in before
the code that checks whether to draw dots or a number:</P>
<P>
<PRE>    COLORREF back = TranslateColor(GetBackColor());
    CBrush backbrush;
    backbrush.CreateSolidBrush(back);
    pdc-&gt;FillRect(rcBounds, &amp;backbrush);
</PRE>
<P>Replace that block with the one in Listing 20.11.</P>
<P>
<H4>Listing 20.11&#160;&#160;DierollDataPathProperty.cpp--New Code for OnDraw()</H4>
<PRE>    CBrush backbrush;
    BOOL drawn = FALSE;
    if (GetReadyState() == READYSTATE_COMPLETE)
    {
        CBitmap* image = mdpp_image.GetBitmap(*pdc);
        if (image)
        {
            CDC memdc;
            memdc.CreateCompatibleDC(pdc);
            memdc.SelectObject(image);
            BITMAP bmp;                         // just for height and width
            image-&gt;GetBitmap(&amp;bmp);
            pdc-&gt;StretchBlt(0,                  // upper left
                            0,                  // upper right
                            rcBounds.Width(),   // target width
                            rcBounds.Height(),  // target height
                            &amp;memdc,             // the image
                            0,                  // offset into image -x
                            0,                  // offset into image -y
                            bmp.bmWidth,        // width
                            bmp.bmHeight,       // height
                            SRCCOPY);           // copy it over
            drawn = TRUE;
        }
    }
    if (!drawn)
    {
        COLORREF back = TranslateColor(GetBackColor());
        backbrush.CreateSolidBrush(back);
        pdc-&gt;FillRect(rcBounds, &amp;backbrush);
</PRE>
<PRE>    }
</PRE>
<P>The BOOL variable drawn ensures that if the control is complete, but something
goes wrong with the attempt to use the bitmap, the control will be drawn the old
way. If the control is complete, the image is loaded into a CBitmap* and then drawn
into the device context. Bitmaps can only be selected into a memory device context
and then copied over to an ordinary device context. Using StretchBlt() will stretch
the bitmap during the copy, though a sensible Web page designer will have specified
a bitmap that matches the HEIGHT and WIDTH attributes of the OBJECT tag. The old
drawing code is still here, used if drawn remains FALSE.</P>
<P>
<H3><A NAME="Heading10"></A>Testing and Debugging Dieroll</H3>
<P>Having made all those changes, build the control, which will register it. One
way to test it would be to bring up that HTML page in Explorer again, but you might
prefer to debug the control. It is possible to debug a control even though you can't
run it standalone. Normally, a developer would arrange to debug the control in the
test container, but you can use any application that can contain the control.</P>
<P>In Developer Studio, choose Project Settings. Click the Debug tab and make sure
that all the lines in the far left list box are selected. Select General in the top
drop-down box, and in the edit box labeled Executable for Debug Session, enter the
full path to Microsoft Internet Explorer on your computer. (If there's a shorcut
to Microsoft Internet Explorer on your desktop, right-click it and choose Properties
to get the path to the executable. Otherwise, use the Find utility on the Start menu
to find iexplore.exe. Figure 20.10 shows an example.) Now when you choose Build,
Start Debug, Go or click the Go toolbar button, Explorer will launch. Open a page
of HTML that loads the control, and the control will run in the debugger. You can
set breakpoints, step through code, and examine variables, just as with any other
application.</P>
<P><A HREF="javascript:popUp('20uvc10.gif')"><B>FIG. 20.10</B></A><B> </B><I>Arrange
to run Explorer when you debug the control.</I></P>
<P>Here's the syntax for an OBJECT tag that sets the Image property:</P>
<P>
<PRE>&lt;OBJECT
CLASSID=&quot;clsid:46646B43-EA16-11CF-870C-00201801DDD6&quot;
CODEBASE=&quot;http://www.gregcons.com/test/dieroll.ocx&quot;
ID=die1
WIDTH=200
HEIGHT=200
ALIGN=center
HSPACE=0
VSPACE=0
&gt;
&lt;PARAM NAME=&quot;Dots&quot; VALUE=&quot;1&quot;&gt;
&lt;PARAM NAME=&quot;Image&quot; VALUE=&quot;http://www.gregcons.com/test/beans.bmp&quot;&gt;
If you see this text, your browser does not support the OBJECT tag. &lt;/BR&gt;
&lt;/OBJECT&gt;
</PRE>


<BLOCKQUOTE>
	<P>
<HR>
<STRONG>TIPP:</STRONG> Remember, don't just copy these HTML samples to your own machine
	if you are building Dieroll yourself. You need to use your own CLSID, an URL to the
	location of your copy of the OCX, and the image file you are using. 
<HR>


</BLOCKQUOTE>

<P>Figure 20.11 shows the control with a background image of jelly beans. It takes
30-60 seconds to load this 40KB image through the Web, and while it is loading, the
control is perfectly usable as a plain die with no background image. That's the whole
point of asynchronous properties, and that's what all the effort of the previous
sections achieves.</P>
<P><A HREF="javascript:popUp('20uvc11.gif')"><B>FIG. 20.11</B></A><B> </B><I>Now
the die displays on a field of jelly beans or on any other image you choose.</I></P>
<H1><I></I></H1>
<CENTER>
<P>
<HR>
<A HREF="../ch19/ch19.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch21/ch21.htm"><IMG
SRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR>
</P>

<P>&#169; <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. All
rights reserved.
</CENTER>


</BODY>

</HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲人精品午夜| 国产精品亲子乱子伦xxxx裸| 国内精品久久久久影院一蜜桃| 国产喷白浆一区二区三区| 久久精品国产澳门| 国产精品国产精品国产专区不片| 在线视频亚洲一区| 蜜桃传媒麻豆第一区在线观看| 久久久99免费| 欧美中文字幕一区二区三区亚洲| 午夜视频一区在线观看| 国产亚洲一区字幕| 欧美日韩在线播放三区四区| 蓝色福利精品导航| 中文字幕亚洲成人| 欧美日本高清视频在线观看| 国产一区二区久久| 亚洲午夜一区二区三区| 久久久777精品电影网影网| 91福利区一区二区三区| 国产做a爰片久久毛片 | 欧美色网一区二区| 国产真实乱子伦精品视频| 亚洲黄色录像片| 久久青草国产手机看片福利盒子| 欧美中文字幕一区二区三区亚洲| 国产精品1区2区3区在线观看| 一区二区三区免费网站| 国产欧美日韩卡一| 日韩欧美一区中文| 色呦呦国产精品| 老司机免费视频一区二区三区| 一区二区三区欧美亚洲| 国产欧美va欧美不卡在线| 这里只有精品99re| 91麻豆免费在线观看| 国产一区二区在线电影| 亚洲国产成人精品视频| 亚洲欧洲av色图| 精品国产欧美一区二区| 欧美电影在线免费观看| 日本乱人伦aⅴ精品| 成人av资源在线| 国产福利一区二区三区| 午夜激情综合网| 亚洲日本在线天堂| 国产精品国模大尺度视频| 精品国产乱码久久久久久影片| 欧美卡1卡2卡| 欧美男人的天堂一二区| 在线一区二区观看| 色综合视频在线观看| 91视视频在线观看入口直接观看www | 午夜国产精品影院在线观看| 国产嫩草影院久久久久| 欧美精品一区二区精品网| 精品日韩欧美在线| 久久色成人在线| 欧美精彩视频一区二区三区| 国产精品久久久久三级| 一区二区三区成人在线视频| 亚洲第一主播视频| 蜜臀av一区二区| 国产精品一区二区久久不卡| 波多野结衣欧美| 在线看不卡av| 日韩欧美国产一区二区在线播放 | 精品三级av在线| 国产日韩欧美亚洲| 综合久久久久久| 日韩高清不卡一区| 国产综合成人久久大片91| 成人午夜激情片| 欧美性猛交一区二区三区精品| 91精品黄色片免费大全| 久久精品视频免费| 亚洲精品成人精品456| 日韩高清国产一区在线| 国产成人亚洲综合a∨婷婷图片| 91丨九色丨国产丨porny| 欧美日韩免费在线视频| 久久精品欧美一区二区三区不卡| 亚洲欧美成人一区二区三区| 日韩高清在线不卡| 成人丝袜18视频在线观看| 欧美午夜精品一区二区三区| 欧美精品一区二区三区久久久 | 欧美日韩高清在线| 久久综合成人精品亚洲另类欧美 | 亚洲男人电影天堂| 久久99日本精品| 91网上在线视频| 欧美一区二区视频在线观看2020 | 日韩精品专区在线影院重磅| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 午夜精品久久久| 国产91在线看| 在线综合视频播放| 国产精品久久福利| 久久av资源网| 欧美天堂一区二区三区| 久久精品亚洲一区二区三区浴池| 亚洲国产精品麻豆| 不卡高清视频专区| 欧美mv和日韩mv国产网站| 洋洋成人永久网站入口| 国产精品一二三四区| 欧美日韩激情一区二区| 国产精品毛片久久久久久| 奇米精品一区二区三区在线观看| 色久综合一二码| 中文无字幕一区二区三区| 亚洲观看高清完整版在线观看| 丰满白嫩尤物一区二区| 日韩欧美亚洲一区二区| 一区二区三区鲁丝不卡| 高清不卡在线观看av| 精品日韩一区二区三区免费视频| 亚洲成人第一页| 色婷婷综合激情| 中文字幕一区二区5566日韩| 国产乱子伦视频一区二区三区| 91精品福利在线一区二区三区| 尤物视频一区二区| av在线综合网| 26uuu国产在线精品一区二区| 亚洲成av人片在www色猫咪| 91丨porny丨蝌蚪视频| 亚洲国产精品黑人久久久| 狠狠色狠狠色合久久伊人| 日韩一区国产二区欧美三区| 视频一区视频二区中文| av不卡免费在线观看| 中文字幕日韩精品一区| av动漫一区二区| 国产精品久久久久久一区二区三区| 国产精品18久久久久久久久久久久| 欧美一区二区三区免费观看视频 | 蜜臀av性久久久久av蜜臀妖精| 欧美日本不卡视频| 亚洲一二三四久久| 欧美色倩网站大全免费| 午夜久久久久久久久久一区二区| 在线免费不卡视频| 亚洲一二三四久久| 欧美日韩一级黄| 美女诱惑一区二区| 欧美tk—视频vk| 国内精品嫩模私拍在线| 久久美女艺术照精彩视频福利播放| 国产在线播放一区二区三区| 国产欧美日韩在线观看| 国产精品一区二区三区乱码| 欧美国产激情一区二区三区蜜月| 成人福利在线看| 亚洲色图丝袜美腿| 欧美影视一区在线| 日产国产高清一区二区三区| 精品国产91乱码一区二区三区| 国产精品羞羞答答xxdd| 国产精品电影一区二区| 色八戒一区二区三区| 亚洲电影欧美电影有声小说| 日韩三级在线观看| 国产在线国偷精品免费看| 国产精品第四页| 欧美日产国产精品| 久久se这里有精品| 国产精品夫妻自拍| 欧美日韩精品专区| 麻豆传媒一区二区三区| 欧美高清在线精品一区| 色久综合一二码| 久88久久88久久久| 亚洲视频一区在线| 在线播放中文字幕一区| 国产一区二区按摩在线观看| 中文字幕制服丝袜一区二区三区| 欧美日韩一区二区三区在线 | 欧美性猛交xxxxxxxx| 六月丁香婷婷色狠狠久久| 国产精品色婷婷| 欧美日韩精品电影| 高清日韩电视剧大全免费| 亚洲国产精品天堂| 国产亚洲短视频| 欧美日韩一本到| 成人免费观看av| 视频一区二区三区入口| 国产日韩欧美麻豆| 91精品久久久久久久久99蜜臂| www.久久久久久久久| 日韩综合一区二区| 国产精品福利电影一区二区三区四区| 欧美高清激情brazzers| www.欧美日韩国产在线| 激情综合色综合久久| 亚洲第一搞黄网站| 国产欧美1区2区3区| 日韩一二在线观看|