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

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

?? ch03.htm

?? 用VC開(kāi)發(fā)ACTIVEX書(shū)籍和隨書(shū)源碼
?? 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一区二区三区免费野_久草精品视频
麻豆精品精品国产自在97香蕉| 精品视频全国免费看| 91网页版在线| 欧美日韩一区二区三区高清| 91精品一区二区三区久久久久久| 精品国产免费视频| 日本一区二区三区久久久久久久久不| 国产精品夫妻自拍| 亚洲一区二区成人在线观看| 久久激五月天综合精品| 福利一区二区在线观看| 欧美人牲a欧美精品| 久久精品一区蜜桃臀影院| 一区二区三区日本| 国产精品综合久久| 欧美影片第一页| 国产日韩欧美麻豆| 日精品一区二区三区| 国产精品1区2区| 欧美性xxxxxx少妇| 久久精品一区二区三区不卡牛牛| 综合欧美一区二区三区| 紧缚捆绑精品一区二区| 日本久久一区二区| 久久婷婷成人综合色| 亚洲午夜av在线| 成人动漫一区二区| 欧美一区二区三区四区高清| 国产精品国产三级国产aⅴ入口 | 成人国产免费视频| 欧美中文字幕久久 | 不卡视频在线观看| 欧美一二三区精品| 亚洲综合色成人| 高清国产一区二区三区| 欧美不卡一区二区| 亚洲成人tv网| 在线亚洲欧美专区二区| 国产精品区一区二区三区 | 久久九九久久九九| 婷婷激情综合网| 色狠狠一区二区三区香蕉| 久久九九久久九九| 蜜桃视频在线一区| 欧美视频中文字幕| 亚洲色图制服丝袜| 高清日韩电视剧大全免费| 日韩一区二区免费视频| 夜夜爽夜夜爽精品视频| 成人av电影免费在线播放| 精品电影一区二区| 日韩av电影天堂| 欧美日韩免费高清一区色橹橹| 国产精品国产三级国产aⅴ无密码| 精品一区在线看| 欧美乱妇一区二区三区不卡视频| 夜夜嗨av一区二区三区中文字幕| 成人免费视频播放| 亚洲国产精品国自产拍av| 国产一区二区三区观看| 日韩免费观看高清完整版| 亚洲高清在线视频| 在线视频国内一区二区| 亚洲三级免费电影| av不卡免费在线观看| 国产精品色在线观看| 国产精品一二三四| 欧美精品一区二区三区高清aⅴ| 日本不卡一区二区| 欧美精品在线一区二区| 丝袜美腿亚洲综合| 欧美福利电影网| 日本成人超碰在线观看| 日韩精品一区二区三区视频| 男女性色大片免费观看一区二区| 91精品国产品国语在线不卡| 午夜亚洲国产au精品一区二区| 欧美日韩不卡视频| 三级影片在线观看欧美日韩一区二区| 欧美日韩精品欧美日韩精品一| 亚洲大片在线观看| 91精品婷婷国产综合久久性色| 婷婷国产在线综合| 日韩视频在线你懂得| 久久黄色级2电影| 26uuu另类欧美| 国产成人在线视频播放| 国产精品天干天干在观线| 99在线精品观看| 亚洲精品ww久久久久久p站| 欧洲色大大久久| 五月天精品一区二区三区| 91精品国产欧美一区二区18 | 久久久久久97三级| 国产大陆精品国产| 亚洲天堂免费在线观看视频| 欧美网站大全在线观看| 日本不卡视频在线| 久久久综合九色合综国产精品| 国产成人精品免费一区二区| 综合婷婷亚洲小说| 欧美人妇做爰xxxⅹ性高电影| 奇米一区二区三区| 国产日本亚洲高清| 91久久国产综合久久| 日韩av成人高清| 欧美激情在线看| 欧美性高清videossexo| 免费在线成人网| 国产精品色哟哟| 欧日韩精品视频| 另类小说一区二区三区| 国产精品久久免费看| 在线观看日韩电影| 韩国v欧美v亚洲v日本v| 中文字幕中文字幕在线一区 | 亚洲资源在线观看| 日韩一区二区不卡| 成人永久aaa| 香蕉成人伊视频在线观看| 欧美精品一区二区三区在线播放| 成人精品国产福利| 日韩精品91亚洲二区在线观看| 亚洲第一福利视频在线| 久久综合久久鬼色| 欧洲一区在线电影| 国产精品伊人色| 性做久久久久久久久| 国产日韩欧美综合在线| 在线91免费看| av在线这里只有精品| 青草av.久久免费一区| 综合自拍亚洲综合图不卡区| 日韩欧美在线综合网| 91老司机福利 在线| 国产麻豆91精品| 日韩国产成人精品| 亚洲美女一区二区三区| 久久久久国产成人精品亚洲午夜| 欧美三级电影网站| 成+人+亚洲+综合天堂| 麻豆91小视频| 国产一区二区三区久久久| 天涯成人国产亚洲精品一区av| 亚洲欧洲成人自拍| 精品国产乱码久久久久久图片| 欧美性极品少妇| 91在线高清观看| 成人午夜在线免费| 国产一区二区伦理| 日本vs亚洲vs韩国一区三区| 夜夜嗨av一区二区三区网页| 国产精品成人免费在线| 国产日韩欧美高清| 精品国产91久久久久久久妲己 | 免费观看一级特黄欧美大片| 一区二区三区**美女毛片| 国产精品久久久久久久久晋中| 精品国产伦理网| 日韩欧美在线影院| 欧美日韩日日摸| 91亚洲精品乱码久久久久久蜜桃| 国产成人在线看| 精品一区二区久久久| 日韩精品色哟哟| 午夜久久久久久久久久一区二区| 一区二区在线观看视频| 18成人在线视频| 国产精品久久三| 国产精品国模大尺度视频| 欧美极品xxx| 国产欧美日韩激情| 欧美—级在线免费片| 日本一区二区三区四区| 国产日韩在线不卡| 中文字幕国产精品一区二区| 国产调教视频一区| 欧美激情在线看| 国产精品嫩草久久久久| 国产亚洲精品bt天堂精选| 久久欧美中文字幕| 国产日产欧美精品一区二区三区| 国产亚洲一区字幕| 国产欧美一区二区精品性色超碰 | caoporn国产精品| 成人美女在线视频| 成人国产电影网| 91在线免费视频观看| 色狠狠色噜噜噜综合网| 欧美在线视频日韩| 欧美日韩亚洲综合| 欧美一区二区视频在线观看 | 国产成人免费网站| 成人福利视频网站| 色香蕉成人二区免费| 欧美日韩视频在线一区二区 | 国产在线精品一区二区夜色| 国产麻豆精品在线观看| 风间由美一区二区三区在线观看| 岛国精品在线观看|