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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch03.htm

?? 用vc開發(fā)activex
?? HTM
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
if(::SafeArrayGetElement(varOutputArray->parray, &lArrayCount, &bstrTemp)
== S_OK) <BR>
{ <BR>
// output the data <BR>
fprintf(m_fileLog, _T(&quot;%s(%10ld)-%s%ls\n&quot;), (LPCTSTR) oTimeStamp.Format(&quot;%H:%M:%S&quot;),
m_lHiResTime - m_lLastHiResTime, (LPCTSTR) cstrIndent, bstrTemp); <BR>
// store the last timer value <BR>
m_lLastHiResTime = m_lHiResTime; <BR>
// free the bstr <BR>
::SysFreeString(bstrTemp); <BR>
} <BR>
} <BR>
} <BR>
else <BR>
bResult = VARIANT_FALSE; <BR>
} <BR>
else <BR>
bResult = VARIANT_FALSE; <BR>
// unlock the array we don't need it anymore <BR>
::SafeArrayUnlock(varOutputArray-&gt;parray); <BR>
} <BR>
else <BR>
bResult = VARIANT_FALSE; <BR>
} <BR>
else <BR>
bResult = VARIANT_FALSE; <BR>
// return the result <BR>
return bResult; <BR>
<BR>
} </TT></FONT></P>
<P>It is worthwhile to review the documentation in the VC++ books online on ODL,
Automation, and <TT>VARIANT</TT> data types to see what kind of flexibility you have
when defining methods and parameters. See <A HREF="ch06.htm">Chapters 6</A> through
11 on developing ActiveX controls for descriptions of more options and features when
creating methods.</P>
<P>Now that you have added a method, you are ready to implement its counterpart,
the property.
<H2><A NAME="Heading18"></A>Adding Properties</H2>
<P>A <I>property</I> can be thought of as an exposed variable that is defined in
the Automation Server. Properties are useful for setting and retrieving information
about the state of the server.</P>
<P>Properties are implemented as a pair of methods: one to get the value, and the
other to set the value. The <TT>m_lIndent</TT> member variable that you added to
the class definition is a perfect candidate to be exposed as a property.</P>
<P>As with methods, properties are also added via the ClassWizard in MFC. From the
<U>V</U>iew menu, select the Class<U>W</U>izard menu item. In the MFC ClassWizard
dialog, select the Automation tab, and click the Add P<U>r</U>operty button. In the
Add Property dialog, enter the <U>E</U>xternal name of the property as Indent and
select the type as <TT>long</TT> (see fig. 3.6). Set the Implementation to Get/Set
<U>m</U>ethods, and click OK to add the property to the server. Click the <U>E</U>dit
Code button to close the MFC ClassWizard dialog and open the source file for editing.
<B><BR>
<BR>
</B><A HREF="Art/03/cfig6r.jpg"><B>FIG. 3.6</B></A> <I><BR>
Add the <TT>Indent</TT> property with the ClassWizard.</I></P>
<P>The actual implementation of the <TT>Indent</TT> property is very easy (see Listing
3.10). <TT>GetIndent</TT> returns the value currently stored in the member variable,
and <TT>SetIndent</TT> stores the new value, after a little bit of error checking,
in the member variable.
<H3><A NAME="Heading19"></A>Listing 3.10 TRACKER.CPP--Indent Property Implementation</H3>
<P><FONT COLOR="#0066FF"><TT>long CTracker::GetIndent() <BR>
{ <BR>
// return the member variable <BR>
return m_lIndent; <BR>
} <BR>
void CTracker::SetIndent(long nNewValue) <BR>
{ <BR>
// if the new value is a least 0 <BR>
if(nNewValue &gt;= 0) <BR>
// assign the value to our member variable <BR>
m_lIndent = nNewValue; <BR>
<BR>
} </TT></FONT></P>
<P>Properties, like methods, also have a wide variety of implementation options,
including parameterized and enumerated values. See <A HREF="ch06.htm">Chapters 6</A>
through 11 on developing ActiveX controls for descriptions of more options and features
when creating properties.</P>
<P>You've added methods and properties to the server but haven't really dealt with
the issue of error handling in their implementation. In some cases, simply returning
success or failure is not enough information for the developer to understand that
an error occurred and what caused it. You will communicate more error information
through the use of OLE exceptions.
<H2><A NAME="Heading20"></A>Generating OLE Exceptions</H2>
<P>While executing a method call or some other action, at times it is necessary to
terminate the process due to some critical error that has occurred or is about to
occur. For example, a method is called to write data to a file, but the method cannot
open the file because there is not enough room on the hard disk to do so. It is necessary
to halt further processing until the error can be resolved. An error of this kind
is known as an <I>exception. </I>Any type of error can be treated as an exception;
it depends on the requirements of your application and how you choose to deal with
the errors that may result.</P>
<P>You must become familiar with two forms of exceptions when creating ActiveX components.
The first is a C++ exception. A <I>C++ exception </I>is a language mechanism used
to create critical errors of the type described earlier and is confined to the application
in which they are defined. The second is an OLE exception. <I>OLE exceptions </I>are
used to communicate the same kinds of errors externally to applications that are
using a component. The difference between the two is that C++ exceptions are used
internal to an application's implementation, and OLE exceptions are used externally
to communicate errors to other applications.</P>
<P>The <TT>IDispatch</TT> interface contains specific parameters in its functions
for dealing with exceptions and passing them to the controller application. The MFC
implementation of the <TT>CCmdTarget</TT> class handles the details of generating
OLE exceptions by trapping any C++ exceptions that it receives and translates them
to the proper <TT>IDispatch</TT> error information. You need only create a C++ exception
of type <TT>COleDispatchException</TT> and throw it. MFC does all of the work for
you. When creating dual-interface servers, exceptions are handled in a different
way, which you will see later in this chapter.</P>
<P>The first step is to add an enumeration of the types of errors that the server
can generate to the ODL file (see Listing 3.11). Adding the enumeration to the ODL
has the effect of publishing the error constants to the applications developer that
is using the server. You add the constants in the form of an include file so that
you can use the same error constants file in the C++ source code implementation.
You also add a <TT>UUID</TT> to the <TT>typedef</TT> so that it can be identified
in the type library that is generated with the GUIDGEN.EXE program.
<H3><A NAME="Heading21"></A>Listing 3.11 MFCSERVER.ODL--Error Enumeration</H3>
<P><FONT COLOR="#0066FF"><TT>. . . <BR>
[ uuid(11C82947-4EDD-11D0-BED8-00400538977D) ] <BR>
coclass TRACKER <BR>
{ <BR>
[default] dispinterface ITracker; <BR>
}; <BR>
typedef [uuid(11C82948-4EDD-11D0-BED8-00400538977D), helpstring(&quot;Tracker Error
Constants&quot;)] <BR>
#include &quot;trackererror.h&quot; <BR>
//{{AFX_APPEND_ODL}} <BR>
<BR>
}; </TT></FONT></P>
<P>TrackerError.h contains a standard C/C++ enumeration of the errors that the application
supports (see Listing 3.12). The starting value of the errors falls into the range
of valid user-defined errors. Be careful when assigning error numbers since most
tools will first look up the system-defined error message before using the message
defined in the exception.
<H3><A NAME="Heading22"></A>Listing 3.12 TRACKERERROR.H--Tracker Error Constants</H3>
<P><FONT COLOR="#0066FF"><TT>// Error enumeration <BR>
enum tagTrackerError <BR>
{ <BR>
MFCSERVER_E_NO_UBOUND = 46080, <BR>
MFCSERVER_E_NO_LBOUND = 46081, <BR>
MFCSERVER_E_NO_ARRAYLOCK = 46082,<BR>
MFCSERVER_E_NO_FILE = 46083,<BR>
MFCSERVER_E_BAD_ARRAY_PARAMETER = 46084,<BR>
MFCSERVER_E_INVALID_VALUE = 46085<BR>
}TRACKERERROR;</TT></FONT></P>
<P>The next step is to add the code that will generate the exceptions to all of the
appropriate locations in the server code (see Listing 3.13). As you can see, instead
of returning <TT>VARIANT_FALSE</TT> or ignoring an error condition, you now generate
meaningful errors and messages instructing the developer as to the source of the
problem. The exception-generating code is fairly straightforward. First you create
a <TT>COleDispacthException</TT> and set the appropriate members with the data that
is necessary for the error that was generated (for information about other types
of exceptions, see the VC++ documentation). For your implementation, you set the
error code, the name of the file that generated the error, and the error message.
You could also supply a help filename and a help ID to further describe the error.
Note the use of the <TT>MAKE_SCODE</TT> macro to generate a valid <TT>SCODE</TT>
error number for the exception.
<H3><A NAME="Heading23"></A>Listing 3.13 TRACKER.CPP--Exception Handling Code Added
to the Source Files</H3>
<P><FONT COLOR="#0066FF"><TT>/////////////////////////////////////////////////////////////////////////////
<BR>
// CTracker message handlers <BR>
BOOL CTracker::OutputLines(VARIANT FAR* varOutputArray, const VARIANT FAR&amp; varIndent)
<BR>
{ <BR>
BOOL bResult = VARIANT_TRUE; <BR>
// if we have a file a if the variant contains a string array <BR>
if(m_fileLog &amp;&amp; varOutputArray-&gt;vt == (VT_ARRAY | VT_BSTR)) <BR>
{ <BR>
// lock the array so we can use it <BR>
if(::SafeArrayLock(varOutputArray-&gt;parray) == S_OK) <BR>
{ <BR>
LONG lLBound; <BR>
// get the lower bound of the array <BR>
if(::SafeArrayGetLBound(varOutputArray-&gt;parray, 1, &amp;lLBound) == S_OK) <BR>
{ <BR>
LONG lUBound; <BR>
// get the number of elements in the array <BR>
if(::SafeArrayGetUBound(varOutputArray-&gt;parray, 1, &amp;lUBound) == S_OK) <BR>
{ <BR>
CString cstrIndent; <BR>
CTime oTimeStamp; <BR>
BSTR bstrTemp; <BR>
// if we have an indent parameter <BR>
if(varIndent.vt != VT_I4) <BR>
{ <BR>
// get a variant that we can use for conversion purposes <BR>
VARIANT varConvertedValue; <BR>
// initialize the variant <BR>
::VariantInit(&amp;varConvertedValue); <BR>
// see if we can convert the data type to something useful - VariantChangeTypeEx()
could also be used <BR>
if(S_OK == ::VariantChangeType(&amp;varConvertedValue, (VARIANT *) &amp;varIndent,
0, VT_I4)) <BR>
// assign the value to our member variable <BR>
m_lIndent = varConvertedValue.lVal; <BR>
} <BR>
else <BR>
// assign the value to our member variable <BR>
m_lIndent = varIndent.lVal; <BR>
// if we have to indent the text <BR>
for(long lIndentCount = 0; lIndentCount &lt; m_lIndent; lIndentCount++) <BR>
// add a tab to the string <BR>
cstrIndent += _T(&quot;\t&quot;); <BR>
// for each of the elements in the array <BR>
for(long lArrayCount = lLBound; lArrayCount &lt; (lUBound + lLBound); lArrayCount++)
<BR>
{ <BR>
// update the time <BR>
oTimeStamp = CTime::GetCurrentTime(); <BR>
m_lHiResTime = timeGetTime(); <BR>
// get the data from the array <BR>
if(::SafeArrayGetElement(varOutputArray-&gt;parray, &amp;lArrayCount, &amp;bstrTemp)
== S_OK) <BR>
{ <BR>
// output the data <BR>
fprintf(m_fileLog, _T(&quot;%s(%10ld)-%s%ls\n&quot;), (LPCTSTR) oTimeStamp.Format(&quot;%H:%M:%S&quot;),
m_lHiResTime - m_lLastHiResTime, (LPCTSTR) cstrIndent, bstrTemp); <BR>
// store the last timer value <BR>
m_lLastHiResTime = m_lHiResTime; <BR>
// free the bstr <BR>
::SysFreeString(bstrTemp); <BR>
} <BR>
} <BR>
} <BR>
else <BR>
{ <BR>
bResult = VARIANT_FALSE; <BR>
// unable to get a record based on the sql statement - throw an exception <BR>
COleDispatchException * pOleDispExcep = new COleDispatchException(_T(&quot;&quot;),
NULL, 0); <BR>
// format the error code <BR>
pOleDispExcep-&gt;m_scError = MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, MFCSERVER_E_NO_UBOUND);
<BR>
// set the source file <BR>
pOleDispExcep-&gt;m_strSource = __FILE__; <BR>
// format the error description <BR>
pOleDispExcep-&gt;m_strDescription = _T(&quot;Unable to retrieve the upper bound
dimension of the array.&quot;); <BR>
// the function call failed cause an ole exception <BR>
throw(pOleDispExcep); <BR>
} <BR>
} <BR>
else <BR>
{ <BR>
bResult = VARIANT_FALSE; <BR>
// unable to get a record based on the sql statement - throw an exception <BR>
COleDispatchException * pOleDispExcep = new COleDispatchException(_T(&quot;&quot;),
NULL, 0); <BR>
// format the error code <BR>
pOleDispExcep-&gt;m_scError = MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, MFCSERVER_E_NO_LBOUND);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级久久久久久久大片| 国产精品影视在线| 精品嫩草影院久久| 日本高清不卡视频| 国产成人在线视频网站| 蜜臀久久久久久久| 亚洲一区二区三区三| 久久久久久99久久久精品网站| 麻豆高清免费国产一区| 一区二区视频免费在线观看| 久久精品人人做人人爽97| 6080国产精品一区二区| 91小视频免费观看| 亚洲一区二区视频| 欧美一级二级三级乱码| 欧美日韩亚洲国产综合| 97久久久精品综合88久久| 国产一区二区三区四| 日韩毛片在线免费观看| 欧美日韩精品一区二区三区四区 | 久久久精品一品道一区| 成人免费看片app下载| 亚洲欧美日韩成人高清在线一区| 久久久久久免费网| 精品裸体舞一区二区三区| 成人黄色在线网站| 亚洲福利视频一区二区| 久久久亚洲精品一区二区三区| 91一区一区三区| 成人久久视频在线观看| 亚洲第一成人在线| 久久美女艺术照精彩视频福利播放| 在线电影院国产精品| 欧美午夜精品久久久久久孕妇 | 成人激情电影免费在线观看| 国产一区二区三区电影在线观看 | 欧美色网一区二区| 国产呦精品一区二区三区网站| 国产精品电影一区二区| 国产日本欧美一区二区| 欧美无人高清视频在线观看| 在线观看亚洲专区| 成人免费高清在线观看| 日韩av不卡一区二区| 日韩精品成人一区二区三区| 中文字幕日本乱码精品影院| 欧美成人一区二区三区在线观看 | 91影视在线播放| 国产麻豆一精品一av一免费| 香港成人在线视频| 亚洲欧美在线视频| 亚洲激情图片一区| 爽好久久久欧美精品| 日本少妇一区二区| 香蕉成人啪国产精品视频综合网| 天天综合天天综合色| 亚洲欧美日韩成人高清在线一区| 一区二区三区不卡在线观看 | 91精品久久久久久蜜臀| 日韩女优毛片在线| 欧美日韩精品欧美日韩精品| 欧美一区日韩一区| 欧美日韩一级片网站| 日韩欧美在线一区二区三区| 欧美日韩国产综合视频在线观看| 538在线一区二区精品国产| 色综合久久99| 欧美精品自拍偷拍| 久久青草国产手机看片福利盒子| 欧美一区永久视频免费观看| 欧美日韩一级黄| 久久蜜桃一区二区| 一区二区三区四区不卡在线| 免费一级片91| www.亚洲精品| www.亚洲激情.com| 91麻豆精品国产自产在线观看一区 | 中文字幕在线观看不卡视频| 亚洲国产一区二区三区| 一区二区在线观看视频| 日本欧美在线看| www.成人在线| 欧美一二三在线| 亚洲私人影院在线观看| 日韩福利电影在线观看| 99久久伊人久久99| 色综合色综合色综合色综合色综合 | 欧美经典一区二区| 中文幕一区二区三区久久蜜桃| 一个色综合av| 国产福利不卡视频| 欧美男人的天堂一二区| 88在线观看91蜜桃国自产| 国产色综合久久| 手机精品视频在线观看| 免费观看久久久4p| 色婷婷亚洲综合| 国产日韩欧美综合一区| 天堂va蜜桃一区二区三区漫画版| 日本成人在线电影网| caoporn国产精品| 欧美三级电影在线看| 国产精品沙发午睡系列990531| 国产精品久久久久久福利一牛影视 | 亚洲视频狠狠干| 亚洲在线观看免费| 蜜臀久久99精品久久久画质超高清 | 一片黄亚洲嫩模| 成人免费高清在线观看| 久久久久久综合| 日本不卡一区二区三区高清视频| 91黄色免费版| 亚洲丝袜另类动漫二区| 大陆成人av片| 欧美日韩亚洲综合| 精品国产乱码久久久久久牛牛| 亚洲成av人片一区二区| 国产精品一二三| 欧美成人高清电影在线| 日日欢夜夜爽一区| 欧美日韩高清一区二区| 久久久久久久久久久久久夜| 亚洲乱码国产乱码精品精98午夜 | 蜜臀av性久久久久蜜臀aⅴ| 在线精品视频免费观看| 亚洲色图视频网站| 日本vs亚洲vs韩国一区三区二区| 91激情五月电影| 有码一区二区三区| 色哟哟日韩精品| 久久综合av免费| 国产主播一区二区| 精品日韩99亚洲| 久久99久久久欧美国产| 亚洲精品一区二区在线观看| 久草这里只有精品视频| 在线免费精品视频| 伊人夜夜躁av伊人久久| 国产精品一区二区久久不卡| 欧美成人激情免费网| 国产真实精品久久二三区| 久久影院视频免费| 午夜精品福利一区二区三区蜜桃| 国产精品一线二线三线精华| 国产日韩欧美综合在线| 国产成人av一区| 国产精品久久久久一区| 99久久99久久久精品齐齐| 一区二区三区中文在线| 欧美精品九九99久久| 中文字幕一区二区三区在线观看 | 日韩欧美国产系列| 国产在线播放一区三区四| 国产精品无遮挡| 99久久精品99国产精品| 久久免费午夜影院| 日本欧美在线观看| 精品国产乱码久久| 成人免费黄色在线| 一区av在线播放| 日韩午夜激情视频| 成人久久视频在线观看| 国产日韩精品一区| 国产做a爰片久久毛片| 欧美电影免费观看完整版| 亚洲国产美女搞黄色| 欧美tk丨vk视频| 日本欧美一区二区在线观看| 久久久www免费人成精品| 激情小说欧美图片| 国产精品久久久久一区二区三区| 国产成人精品网址| 久久综合久久综合久久| 99久久伊人精品| 日本最新不卡在线| 国产精品伦理在线| 欧美精品粉嫩高潮一区二区| 亚洲一区二区三区四区五区中文| 日韩女优av电影| 蜜臀久久99精品久久久画质超高清| 日本一区二区高清| 成人黄色在线视频| 中文字幕乱码亚洲精品一区| 欧美日韩国产大片| 成人综合婷婷国产精品久久蜜臀 | 91蝌蚪porny九色| 亚洲欧美一区二区久久| 日韩三级在线免费观看| 97精品国产露脸对白| 蜜桃视频一区二区| 久久久久久**毛片大全| 在线观看日韩国产| 三级影片在线观看欧美日韩一区二区| 久久久久久久久97黄色工厂| 欧美日韩免费高清一区色橹橹 | av色综合久久天堂av综合| 美女久久久精品| 亚洲国产成人va在线观看天堂| 欧美激情一区二区在线| 日韩欧美国产一区在线观看|