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

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

?? ch08.htm

?? 用VC開發(fā)ACTIVEX書籍和隨書源碼
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
{ <BR>
// NULL terminate the string reference <BR>
m_lptstrCaption = new TCHAR[1]; <BR>
m_lptstrCaption[0] = `\0'; <BR>
// set the alignment to the default of left <BR>
m_lAlignment = EALIGN_LEFT; <BR>
} <BR>
DECLARE_REGISTRY_RESOURCEID(IDR_ATLCONTROLWIN) <BR>
. . . </TT></FONT></P>
<P>The <TT>CaptionMethod</TT> contains all of the code for setting the caption and
the alignment style, and like the MFC implementation, deals with the optional parameter
correctly (see Listing 8.5). See <A HREF="ch06.htm">Chapter 6</A> for more information
about optional parameters and their use.</P>
<P>Since the <TT>CaptionMethod</TT> is used for the <TT>IDispatch</TT> implementation
and the custom interface, the method is implemented in a slightly different way than
its MFC counterpart. First the function is declared as <TT>STDMETHODIMP</TT>, which
expands to an <TT>HRESULT</TT> return type. The return value is used by OLE to determine
whether the method call succeeded. The string parameter is passed in differently
also. All strings are passed as <TT>UNICODE</TT> in OLE. This is true even for MFC.
The only difference is that MFC hides the implementation details of how the strings
are managed; the developer simply uses the appropriate string data type based on
the target application and platform, that is, Win32 ANSI versus Win32 UNICODE. Note
the use of the USES_CONVERSION and W2A macros to convert the string from UNICODE
to ANSI. <BR>
<BR>
<IMG SRC="bar.gif" WIDTH="480" HEIGHT="6" ALIGN="BOTTOM" BORDER="0"></P>


<BLOCKQUOTE>
	<P><B>Useful Helper Functions and Conversion Macros</B><BR>
	The files ATLCONV.H and ATLCONV.CPP, which can be found in the directory ...\DevStudio\VC\ATL\include,
	contain a number of helper functions and macros for converting data such as UNICODE
	strings to ANSI. Since ATL does not require the use of MFC, you are wise to examine
	these files before writing functions to convert data.

</BLOCKQUOTE>

<P>
<HR>
<BR>
<BR>
Next, if the <TT>VARIANT</TT> is of a valid data type other than <TT>VT_I4</TT>,
the method tries to convert it to a <TT>VT_I4</TT> type. You try to convert the data
for the cases where a user passes valid data in the form of a different data type,
for example, a short or a string.</P>
<P>One very important thing to note is the use of the function <TT>VariantInit:</TT>.
All <TT>VARIANT</TT> variables must be initialized prior to their use. This practice
guarantees that the <TT>VARIANT</TT> does not contain invalid data type information
or invalid values. This practice follows the basic C++ tenet of initializing all
member variables to ensure that they do not contain invalid information.</P>
<P>If the requirements of your control demand that you deal with only specific data
types, you can also choose to add code (error messages, exceptions, and so on) to
deal with the fact that the method did not receive a valid data type. If the function
<TT>VariantChangeType</TT> is unable to convert the data, the method exits and returns
a value of <TT>FALSE</TT>. A return of <TT>FALSE</TT> indicates to the caller of
the method that the method didn't succeed. Again, you can also choose to add additional
error handling code to the method to give the user more information about the error
that occurred. See <A HREF="ch03.htm">Chapters 3</A> through <A HREF="ch05.htm">5</A>
on generating OLE exceptions for more information.</P>
<P>Before proceeding, the method ensures that the <TT>m_lAlignment</TT> member variable
contains valid data.</P>
<P>If the method received valid data or converted the data to a valid value, as indicated
by the variable <TT>lResult</TT> equaling <TT>TRUE</TT>, the method stores the caption
and the alignment values in the class member variables, invalidates the control so
it will redraw its User Interface (UI) based on the new information, and exits the
function.</P>
<P>Listing 8.5 contains another important difference from that of its MFC counterpart:
use of the function <TT>FireViewChange</TT> in place of the MFC <TT>InvalidateControl</TT>
function to force the control to repaint itself. Wherever appropriate, we will point
out the differences between MFC and ATL.
<H3><A NAME="Heading9"></A>Listing 8.5 ATLCONTROLWIN.CPP--CaptionMethod Implementation</H3>
<P><FONT COLOR="#0066FF"><TT><BR>
<BR>
STDMETHODIMP CATLControlWin::CaptionMethod(BSTR bstrCaption, VARIANT <BR>
varAlignment, long * lRetVal) <BR>
{ <BR>
// needed for the W2A macro <BR>
USES_CONVERSION; <BR>
HRESULT hResult = S_OK; <BR>
// return value initialized to failure result <BR>
*lRetVal = FALSE; <BR>
// convert the string to ANSI <BR>
LPTSTR lptstrTempCaption = W2A(bstrCaption); <BR>
// if the variant is a long just use the value <BR>
if(VT_I4 == varAlignment.vt) <BR>
{ <BR>
// assign the value to our member variable <BR>
m_lAlignment = varAlignment.lVal; <BR>
// set the return value <BR>
*lRetVal = TRUE; <BR>
} <BR>
// if the user didn't supply an alignment parameter we will assign the default <BR>
else if(VT_ERROR == varAlignment.vt || VT_EMPTY == varAlignment.vt) <BR>
{ <BR>
// assign the value to our member variable <BR>
m_lAlignment = EALIGN_LEFT; <BR>
// set the return value <BR>
*lRetVal = TRUE; <BR>
} <BR>
else <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 <BR>
// VariantChangeTypeEx() could also be used <BR>
if(S_OK == ::VariantChangeType(&amp;varConvertedValue, <BR>
(VARIANT *) &amp;varAlignment, 0, VT_I4)) <BR>
{ <BR>
// assign the value to our member variable <BR>
switch(varConvertedValue.lVal) <BR>
{ <BR>
case EALIGN_CENTER: <BR>
m_lAlignment = EALIGN_CENTER; <BR>
break; <BR>
case EALIGN_RIGHT: <BR>
m_lAlignment = EALIGN_RIGHT; <BR>
break; <BR>
default: <BR>
m_lAlignment = EALIGN_LEFT; <BR>
break; <BR>
} <BR>
// set the return value <BR>
*lRetVal = TRUE; <BR>
} <BR>
else <BR>
{ <BR>
// at this point we could either throw an error indicating <BR>
// there was a problem converting <BR>
// the data or change the return type of the method and <BR>
// return the HRESULT value from the <BR>
// the &quot;VariantChangeType&quot; call. <BR>
} <BR>
} <BR>
// if everything was OK <BR>
if(TRUE == *lRetVal) <BR>
{ <BR>
// if we have a string <BR>
if(lptstrTempCaption != NULL) <BR>
{ <BR>
// if we have a string <BR>
if(m_lptstrCaption) <BR>
{ <BR>
// delete the existing string <BR>
delete [] m_lptstrCaption; <BR>
// clear the reference just to be safe <BR>
m_lptstrCaption = NULL; <BR>
} <BR>
// allocate a new string <BR>
m_lptstrCaption = new TCHAR[lstrlen(lptstrTempCaption) + 1]; <BR>
// assign the string to our member variable <BR>
lstrcpy(m_lptstrCaption, lptstrTempCaption); <BR>
} <BR>
// did they pass us bad data? <BR>
if(m_lAlignment &lt; EALIGN_LEFT || m_lAlignment &gt; EALIGN_RIGHT) <BR>
// sure did, lets fix their little red wagon <BR>
m_lAlignment = EALIGN_LEFT; <BR>
// force the control to repaint itself <BR>
this-&gt;FireViewChange(); <BR>
// this-&gt;InvalidateControl(); &lt;== MFC Version <BR>
} <BR>
// return the result of the function call <BR>
return hResult; <BR>
} </TT></FONT></P>
<H2><A NAME="Heading10"></A>Properties</H2>
<P><I>Properties</I> can be categorized as user defined, stock, or ambient.</P>
<P><I>User defined properties</I> are properties that are implementation-specific
and have meaning only to the component that contains them. User defined properties
can be further broken into those properties that are defined only as their specific
data type (<I>normal</I> properties) and those with additional parameters (<I>parameterized</I>
properties).</P>
<P><I>Stock properties</I> are a set of properties that are already defined by OLE
in terms of the basic meaning. Stock properties are not implemented in the control
of the container by default. They still require implementation by the control developer.
They are predefined only to imply a certain level of uniformity between various control
implementations.</P>
<P><I>Ambient properties,</I> on the other hand, are properties that are supported
by the container to provide a default value to the control that uses them.</P>
<P>In the remainder of this section, you will create normal, parameterized, and stock
properties. You will also learn how to use ambient properties.
<H3><A NAME="Heading11"></A>Creating Normal User Defined Properties</H3>
<P>A <I>normal property</I> is a property that is declared as a single type, for
example, <TT>long</TT> or <TT>BSTR</TT>, and has no parameters. You will expose your
control's Alignment member variable through a property.</P>
<P>Properties are added in much the same way as methods. From the ClassView tab in
the Project Workspace window, select the <TT>IATLControlWin</TT> interface, click
the right mouse button, and select the Add <U>P</U>roperty menu item (see fig. 8.11).
<B><BR>
<BR>
</B><A HREF="Art/08/gfigs11.jpg"><B>FIG. 8.11</B></A> <I><BR>
Add a new property to the control with the ATL ClassWizard.</I></P>
<P>In the Add Property to Interface dialog, set the Property <U>T</U>ype to <TT>long</TT>,
the Property <U>N</U>ame to <TT>Alignment</TT>, and leave the remainder of the settings
at their default values (see fig. 8.12). Click OK to confirm the entry and close
the dialog. <B><BR>
<BR>
</B><A HREF="Art/08/gfigs12.jpg"><B>FIG. 8.12</B></A><B> </B><I><BR>
Define the <TT>Alignment</TT> property attributes.</I></P>
<P>After adding the property, you need to update the IDL file with a dispid constant
name that can be used from within the control implementation source files. Listing
8.6 shows the <TT>typedef</TT> that is added to the IDL file. The dispids are added
as an enumeration so that the MIDL compiler will generate an enumeration in the ATLControl.h
header file, which defines the interfaces and classes available in the control IDL
file. The reason for adding the dispids as a set of constants is the same reason
for having any constant. If the value of the dispid were to change, you wouldn't
have to search your source code trying to find where you used the value. Listing
8.6 also shows the change that is made to the <TT>Alignment</TT> property declaration
functions to reflect the dispid constant.
<H3><A NAME="Heading12"></A>Listing 8.6 ATLCONTROL.IDL--Dispid Enumeration Added
to the IDL File to Aid in the Support of Properties in the Control</H3>
<P><FONT COLOR="#0066FF"><TT>. . . <BR>
typedef enum propdispids <BR>
{ <BR>
dispidAlignment = 2, <BR>
}PROPDISPIDS; <BR>
. . . <BR>
interface IATLControlWin : IDispatch <BR>
{ <BR>
[id(1), helpstring(&quot;method CaptionMethod&quot;)] <BR>
HRESULT CaptionMethod([in] BSTR bstrCaption, <BR>
[in, optional] VARIANT varAlignment, [out, retval] long * lRetVal); <BR>
[propget, id(dispidAlignment), helpstring(&quot;property Alignment&quot;)] <BR>
HRESULT Alignment([out, retval] long *pVal); <BR>
[propput, id(dispidAlignment), helpstring(&quot;property Alignment&quot;)] <BR>
HRESULT Alignment([in] long newVal); <BR>
}; <BR>
. . . </TT></FONT></P>
<P>Open the file ATLControlWin.cpp so that you can modify the <TT>get_Alignment/put_Alignment</TT>
functions. You could also select the functions from the Class View tab of the Project
Workspace window.</P>
<P>As you can see, Listing 8.7 takes advantage of the member variable <TT>m_Alignment</TT>,
which you added earlier, and uses the member to get and set the property value.</P>
<P>The <TT>GetAlignment</TT> function is simple in that it returns only the value
stored in the <TT>m_lAlignment</TT> member variable.</P>
<P>The <TT>SetAlignment</TT> function does a little more. This function checks to
see if the value is within the valid ranges of values and, if so, stores the value

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
五月婷婷另类国产| 久久er99精品| 色综合欧美在线| 中文字幕精品三区| 国产成人午夜片在线观看高清观看| 欧美日韩国产高清一区| 亚洲美女视频在线| 色一情一伦一子一伦一区| 国产精品二三区| 97久久精品人人做人人爽50路| 国产精品入口麻豆九色| 粉嫩久久99精品久久久久久夜 | 欧美精品 国产精品| 亚洲一区二区在线播放相泽| 一本到一区二区三区| 亚洲色图欧美偷拍| 91麻豆蜜桃一区二区三区| 亚洲精品中文在线观看| 欧美自拍偷拍午夜视频| 丝袜亚洲另类丝袜在线| 91精品国产福利| 香蕉久久夜色精品国产使用方法 | 一区二区三区精密机械公司| 欧美综合久久久| 日日夜夜一区二区| 日韩欧美精品在线视频| 国产精品一区免费视频| 国产精品女同互慰在线看| 国产高清精品久久久久| 亚洲天堂网中文字| 97久久久精品综合88久久| 亚洲欧美成aⅴ人在线观看| 在线观看免费一区| 青椒成人免费视频| 国产精品久久久久久妇女6080| 久久久久久日产精品| 亚洲成av人影院| 在线精品视频免费播放| 国产精品理论在线观看| 国产在线一区二区综合免费视频| 欧美日韩高清一区二区不卡| 一区二区三区四区激情| 91视频com| 亚洲欧洲日韩av| 99久久婷婷国产综合精品电影 | 波多野结衣欧美| 国产欧美日韩三区| 成人爽a毛片一区二区免费| 国产农村妇女毛片精品久久麻豆| 激情综合五月天| 56国语精品自产拍在线观看| 亚洲愉拍自拍另类高清精品| 97久久久精品综合88久久| 国产精品久久一卡二卡| 成人激情免费视频| 亚洲欧美日韩成人高清在线一区| av在线不卡免费看| 中文字幕佐山爱一区二区免费| 99麻豆久久久国产精品免费| 日韩一区欧美一区| 欧洲精品在线观看| 免费人成精品欧美精品| 久久综合九色综合久久久精品综合 | 不卡高清视频专区| 亚洲欧美另类小说视频| 欧美三级午夜理伦三级中视频| 亚洲成人av免费| 日韩欧美国产一区在线观看| 韩国中文字幕2020精品| 中文av一区特黄| 在线视频国内一区二区| 日本在线不卡视频一二三区| 26uuu国产在线精品一区二区| 国产精品1区2区3区| 1000精品久久久久久久久| 在线观看亚洲成人| 日本不卡高清视频| 欧美国产精品v| 欧美日韩精品一区二区三区蜜桃| 精品伊人久久久久7777人| 国产精品网站在线观看| 在线观看av不卡| 免费成人在线影院| 国产精品拍天天在线| 欧美老年两性高潮| 成人黄动漫网站免费app| 伊人夜夜躁av伊人久久| 日韩美女视频在线| 91亚洲国产成人精品一区二区三| 日日夜夜精品视频免费| 久久久激情视频| 欧美日本一道本在线视频| 国产99久久久国产精品| 亚洲综合男人的天堂| 日韩精品专区在线影院观看 | 欧美一区二区三区日韩| 成人黄色av电影| 男人的天堂亚洲一区| 亚洲视频一区在线| 2021中文字幕一区亚洲| 欧美日韩在线不卡| av在线播放不卡| 久久成人免费网| 亚洲国产欧美在线| 国产精品福利在线播放| 日韩免费观看高清完整版| 一本一道久久a久久精品综合蜜臀| 奇米一区二区三区| 一区二区三区四区在线播放| 欧美—级在线免费片| 精品毛片乱码1区2区3区| 国产精品一区二区黑丝| 丝袜美腿亚洲色图| 亚洲精品写真福利| 欧美激情在线观看视频免费| 欧美一区二区在线视频| 欧美优质美女网站| 色94色欧美sute亚洲线路一久 | 一区二区三区四区高清精品免费观看 | 成人蜜臀av电影| 久久av资源站| 美女脱光内衣内裤视频久久影院| 亚洲综合一区二区| 亚洲少妇30p| 精品国产免费一区二区三区四区| 欧美乱妇15p| 日本二三区不卡| 在线一区二区三区四区五区| av爱爱亚洲一区| 成人av在线电影| 国产不卡视频在线播放| 国产成人精品亚洲日本在线桃色| 日韩av二区在线播放| 日本女人一区二区三区| 日韩精品色哟哟| 久久国产成人午夜av影院| 免费视频一区二区| 麻豆高清免费国产一区| 精油按摩中文字幕久久| 国产一区二区久久| 国产91丝袜在线播放九色| 国产成人免费视频一区| 成人高清av在线| 一本色道久久综合亚洲精品按摩 | 另类小说一区二区三区| 捆绑变态av一区二区三区| 精品一区二区三区在线观看| 激情av综合网| 国产99久久久精品| 色综合久久综合网| 欧美精品久久久久久久多人混战 | 国产成人福利片| 国产一区久久久| 成人免费视频视频在线观看免费| 成人av中文字幕| 成人午夜大片免费观看| 99精品国产热久久91蜜凸| 91国模大尺度私拍在线视频 | 国产成人在线视频播放| thepron国产精品| 日本电影欧美片| 制服.丝袜.亚洲.中文.综合| 欧美日韩另类国产亚洲欧美一级| 欧美色精品在线视频| 26uuu欧美日本| 一区二区三区在线观看国产| 人人爽香蕉精品| 99久久精品免费看| 欧美一区二区在线视频| 中文字幕乱码久久午夜不卡| 夜夜精品浪潮av一区二区三区| 蜜桃视频在线观看一区二区| 不卡影院免费观看| 欧美日韩一区在线观看| 亚洲日本免费电影| 国产精品一品二品| 欧美v亚洲v综合ⅴ国产v| 亚洲伊人色欲综合网| 成人国产精品免费观看动漫| 26uuu久久天堂性欧美| 毛片不卡一区二区| 欧美猛男男办公室激情| 亚洲欧美日韩国产手机在线| 成人网在线免费视频| 国产日本亚洲高清| 国产一区二区三区久久久| 欧美成人免费网站| 美女爽到高潮91| 欧美一级淫片007| 日本麻豆一区二区三区视频| 欧美男人的天堂一二区| 亚洲高清不卡在线观看| 欧美天堂亚洲电影院在线播放| 亚洲欧美日韩在线| 91农村精品一区二区在线| 国产精品狼人久久影院观看方式| 成人深夜在线观看| 欧美国产激情一区二区三区蜜月| 成人在线综合网站| 国产精品国产精品国产专区不蜜|