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

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

?? ch09.htm

?? 用VC開(kāi)發(fā)ACTIVEX書(shū)籍和隨書(shū)源碼
?? HTM
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
Implementation Member Variables and Functions</H3>
<P><FONT COLOR="#0066FF"><TT>BEGIN_MSG_MAP(CATLControlWin) <BR>
MESSAGE_HANDLER(WM_PAINT, OnPaint) <BR>
MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) <BR>
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) <BR>
MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) <BR>
MESSAGE_HANDLER(WM_DESTROY, OnDestroy) <BR>
END_MSG_MAP() <BR>
. . . <BR>
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &amp; bHandled);
<BR>
. . . </TT></FONT></P>
<P>The next step is to add the <TT>OnDestroy</TT> implementation, which will clean
up the resources if they are still allocated (see Listing 9.17).
<H3><A NAME="Heading23"></A>Listing 9.17<SPACER TYPE="HORIZONTAL" SIZE="10"> ATLCONTROLWIN.CPP--OnDestroy
Implementation of Drawing Resource Cleanup</H3>
<P><FONT COLOR="#0066FF"><TT>LRESULT CATLControlWin::OnDestroy(UINT uMsg, WPARAM
wParam, LPARAM lParam, BOOL<BR>
&amp; bHandled) <BR>
{ <BR>
// if there is an old brush <BR>
if(hOldBrush) <BR>
{ <BR>
// get the DC <BR>
HDC hDC = this-&gt;GetDC(); <BR>
// select the old brush back <BR>
::SelectObject(hDC, hOldBrush); <BR>
// release the DC <BR>
this-&gt;ReleaseDC(hDC); <BR>
} <BR>
// if we created a brush <BR>
if(hBrush) <BR>
// destroy the brush we created <BR>
::DeleteObject(hBrush); <BR>
return TRUE; <BR>
} </TT></FONT></P>
<P>The last step is to update the <TT>OnDraw</TT> implementation to take advantage
of optimized drawing, if the container supports optimized drawing that is (see Listing
9.18). The only line that you need to add to the code is one that checks the <TT>bOptimize</TT>
member of the <TT>ATL_DRAWINFO</TT> structure to see if it is set to 0 (or <TT>FALSE</TT>),
which indicates that the container does not support optimized drawing. If that is
the case, you then clean up all of your allocated resources and restore any original
values. If the container does support optimized drawing, you ignore the cleanup and
reuse the allocated resources the next time around.
<H3><A NAME="Heading24"></A>Listing 9.18 <SPACER TYPE="HORIZONTAL" SIZE="10">ATLCONTROLWIN.CPP--OnDraw
Function Updated to Support Optimized Drawing</H3>
<P><FONT COLOR="#0066FF"><TT>HRESULT CATLControlWin::OnDraw(ATL_DRAWINFO &amp; di)
<BR>
{ <BR>
. . . <BR>
// The container does not support optimized drawing. <BR>
if(!di.bOptimize) <BR>
{ <BR>
// select the old brush back <BR>
::SelectObject(di.hdcDraw, hOldBrush); <BR>
// destroy the brush we created <BR>
::DeleteObject(hBrush); <BR>
// clear the brush handles <BR>
hBrush = hOldBrush = NULL; <BR>
} <BR>
return S_OK; <BR>
} </TT></FONT></P>
<H2><A NAME="Heading25"></A>Adding Clipboard and Drag and Drop Support</H2>
<P>The basic OLE Clipboard and Drag and Drop interfaces are only partially implemented
within your control implementation. As for the <TT>IPerPropertyBrowsing</TT> interface,
you must implement the remaining required interfaces yourself. As is pointed out
in <A HREF="ch07.htm">Chapter 7</A>, Clipboard and Drag and Drop support can add
much to your control implementation while requiring very little work.
<H3><A NAME="Heading26"></A>Clipboard Support</H3>
<P><I>Clipboard support</I> is based on the <TT>IDataObject</TT> and <TT>IEnumFORMATETC</TT>
interfaces. <TT>IDataObject</TT> is the interface through which the data is retrieved
from your control when it has been placed on the Clipboard, and <TT>IEnumFORMATETC</TT>
is the interface that is used by an application to determine what types of data your
<TT>IDataObject</TT> interface supports. In a basic ATL control project, only the
<TT>IDataObject</TT> Interface is supported. The <TT>IEnumFORMATETC</TT> interface
must be added.</P>
<P>Before adding the specific interfaces required by ActiveX to enable Clipboard
transfers, you must first decide which keystroke combinations will be used to initiate
the cut, copy, or paste operations. Fortunately, the Windows operating system (OS)
already has a number of standards in this area. You use Ctrl+X and Shift+Delete for
Cut, Ctrl+C and Ctrl+Insert for Copy, and Ctrl+V and Shift+Insert for Paste.</P>
<P>To trap the keystroke combinations, you need to implement a message handler for
the <TT>WM_KEYDOWN</TT> message in the form of a method called <TT>OnKeyDown</TT>
(see Listing 9.19).
<H3><A NAME="Heading27"></A>Listing 9.19<SPACER TYPE="HORIZONTAL" SIZE="10"> ATLCONTROLWIN.H--WM_KEYDOWN
and OnKeyDown Message Handler Added to the Class Declaration of the Control</H3>
<P><FONT COLOR="#0066FF"><TT>. . . <BR>
BEGIN_MSG_MAP(CATLControlWin) <BR>
MESSAGE_HANDLER(WM_PAINT, OnPaint) <BR>
MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) <BR>
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) <BR>
MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) <BR>
MESSAGE_HANDLER(WM_DESTROY, OnDestroy) <BR>
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) <BR>
END_MSG_MAP() <BR>
. . . <BR>
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &amp; bHandled);
<BR>
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &amp; bHandled);
<BR>
. . . </TT></FONT></P>
<P>The <TT>OnKeyDown</TT> implementation looks for the particular keystroke combinations
listed in the preceding paragraph and upon finding them invokes the proper set of
functions to complete the requested Clipboard operation (see Listing 9.20). Note
that in addition to copying the data to the Clipboard, the Cut operation clears the
control's data.
<H3><A NAME="Heading28"></A>Listing 9.20<SPACER TYPE="HORIZONTAL" SIZE="10"> ATLCONTROLWIN.CPP--OnKeyDown
Implementation</H3>
<P><FONT COLOR="#0066FF"><TT>LRESULT CATLControlWin::OnKeyDown(UINT uMsg, WPARAM
wParam, LPARAM lParam, <BR>
BOOL &amp; bHandled) <BR>
{ <BR>
UINT nChar = wParam; <BR>
UINT nRepCnt = LOWORD(lParam); <BR>
UINT nFlags = HIWORD(lParam); <BR>
// find out if the shift key is being held down <BR>
short sShift = ::GetKeyState(VK_SHIFT); <BR>
// find out if the control key is being held down <BR>
short sControl = ::GetKeyState(VK_CONTROL); <BR>
switch(nChar) <BR>
{ <BR>
// COPY <BR>
case 0x43: // `C' <BR>
case 0x63: // `c' <BR>
case VK_INSERT: <BR>
// if the control key is being held down <BR>
if(sControl &amp; 0x8000) <BR>
{ <BR>
// copy the data to the clipboard <BR>
this-&gt;CopyDataToClipboard(); <BR>
// we don't need to pass this key to the base implementation <BR>
bHandled = TRUE; <BR>
} <BR>
break; <BR>
// CUT <BR>
case 0x58: // `X' <BR>
case 0x78: // `x' <BR>
case VK_DELETE: <BR>
// if this is a shift delete OR CTRL-X/x <BR>
if((nChar == VK_DELETE &amp;&amp; (sShift &amp; 0x8000)) || <BR>
((nChar == 0x58 || nChar == 0x78) &amp;&amp; (sControl &amp; 0x8000))) <BR>
{ <BR>
this-&gt;CopyDataToClipboard(); <BR>
// clear the string since this is a CUT operation <BR>
delete [] m_lptstrCaption; <BR>
// NULL terminate the string reference <BR>
m_lptstrCaption = new TCHAR[1]; <BR>
m_lptstrCaption[0] = `\0'; <BR>
// fire the global change event <BR>
this-&gt;FireChange(); <BR>
// force the control to repaint itself <BR>
this-&gt;FireViewChange(); <BR>
// this-&gt;InvalidateControl(); &lt;== MFC Version <BR>
// we don't need to pass this key to the base implementation <BR>
bHandled = TRUE; <BR>
} <BR>
break; <BR>
} <BR>
return TRUE; <BR>
} </TT></FONT></P>
<P>In addition to the code that you added to trap the keystrokes, you need to add
four methods for dealing with the Clipboard transfers. You will examine these four
methods in detail in the next section.</P>
<P><TT>CopyDataToClipboard</TT> will, as the name implies, get the data from the
control and, using the helper function, <TT>PrepareDataForTransfer</TT>, package
the data and put it on the Clipboard.</P>
<P><TT>GetDataFromClipboard</TT> will open the Clipboard and look for data formats
that the control understands. Upon finding a suitable format, <TT>GetDataFromClipboard</TT>
will use the helper function <TT>GetDataFromTransfer</TT> to store the data in the
control.</P>
<P>When you enable the control for Drag and Drop support, you are aided by the fact
that the data transfer functions are separated into two separate methods for each
type of transfer, to and from the Clipboard, and then each type of transfer is further
broken into two separate steps. Because the basic data transfer mechanism is the
same between the Clipboard and Drag and Drop, you are able to rely on a large portion
of shared code for each implementation. <B><BR>
<BR>
Using Built-In Clipboard Formats</B> <SPACER TYPE="HORIZONTAL" SIZE="10">As we point
out in <A HREF="ch07.htm">Chapter 7</A>, the Windows OS supports a number of built-in
formats for transferring data via the Clipboard. Your first implementation is to
transfer the caption of your control by using the <TT>CF_TEXT</TT> format, which
is the built-in format for transferring ANSI text. There are two aspects to using
the Clipboard: being a Clipboard source and being a Clipboard target. Being a Clipboard
source refers to an application's capability to copy data <I>to</I> the Clipboard.
Being a Clipboard target refers to an applications capability to copy data <I>from</I>
the Clipboard. You first look at enabling your control as a Clipboard source. <B><I><BR>
<BR>
Enabling a Control as a Clipboard Source</I></B> <SPACER TYPE="HORIZONTAL" SIZE="10">A
<I>Clipboard source</I> is an application that puts data on the Clipboard for other
applications to copy. An application must support two COM interfaces, <TT>IDataObject</TT>
and <TT>IEnumFORMATETC</TT>, in order to qualify as a valid Clipboard source. When
copying data to the Clipboard, the <TT>OnKeyDown</TT> implementation takes advantage
of several helper functions: <TT>CopyDataToClipboard</TT>,<TT> PrepareDataForTransfer</TT>,
and <TT>CopyStgMedium</TT>. <TT>CopyStgMedium</TT>, <TT>CopyDataToClipboard</TT>,
and <TT>PrepareDataForTransfer</TT> are used to prepare your data structures--the
member variables <TT>sTextFormatEtc</TT> and <TT>sTextStgMedium</TT>--for a potential
paste operation. The member variable <TT>ulFORMATETCElement</TT> is the internal
counter for the <TT>IEnumFORMATETC</TT> interface. First you need to add the two
function prototypes to the <TT>CATLControlWin</TT> class declaration (see Listing
9.21).
<H3><A NAME="Heading29"></A>Listing 9.21<SPACER TYPE="HORIZONTAL" SIZE="10"> ATLCONTROLWIN.H--Helper
Functions and Member Variables for Clipboard Support</H3>
<P><FONT COLOR="#0066FF"><TT>. . . <BR>
void CopyDataToClipboard(void); <BR>
void PrepareDataForTransfer(void); <BR>
void CopyStgMedium(LPSTGMEDIUM lpTargetStgMedium, <BR>
LPSTGMEDIUM lpSourceStgMedium, CLIPFORMAT cfSourceFormat); <BR>
ULONG ulFORMATETCElement; <BR>
private: <BR>
FORMATETC sTextFormatEtc; <BR>
STGMEDIUM sTextStgMedium; <BR>
}; </TT></FONT></P>
<P>When the user initiates a data transfer via the Clipboard, a reference to the
control's <TT>IDataObject</TT> interface is placed on the Clipboard. At the time
the interface is placed on the Clipboard, you have to take a snapshot of the data
that the control contains and place it in a <TT>STGMEDIUM</TT> object. You do this
because the data may not be copied from the Clipboard immediately; the data needs
to reflect the state of the control when the copy operation was initiated rather
than when the paste operation takes place. Once the <TT>IDataObject</TT> interface
is on the Clipboard, you simply wait until someone requests the data. If a supported
data format is requested, you copy the data from your <TT>STGMEDIUM</TT> structure
to the <TT>STGMEDIUM</TT> structure that was passed to you.</P>
<P>The <TT>IDataObject</TT> interface is already included in your control's inheritance
hierarchy. The <TT>IEnumFORMATETC</TT> interface, however, must be added (see Listing
9.22). Since you will be implementing various member functions of the <TT>IDataObject</TT>
and the <TT>IEnumFORMATETC</TT> interfaces, you must add the function prototypes
to the class declaration of your control. Note that you need to add prototypes for
only those functions that you intend to implement; the remainder are left to their
default implementations.
<H3><A NAME="Heading30"></A>Listing 9.22 <SPACER TYPE="HORIZONTAL" SIZE="10">ATLCONTROLWIN.H--IEnumFORMATETC
Interface Added to theClass Inheritance Hierarchy</H3>
<P><FONT COLOR="#0066FF"><TT>. . . <BR>
public IPerPropertyBrowsingImpl&lt;CATLControlWin&gt;, <BR>
public IEnumFORMATETC <BR>
{ <BR>
public: <BR>
. . . <BR>
// IDataObject <BR>
STDMETHOD(GetData)(LPFORMATETC, LPSTGMEDIUM); <BR>
STDMETHOD(EnumFormatEtc)(DWORD, LPENUMFORMATETC*); <BR>
// IEnumFORMATETC <BR>
STDMETHOD(Next)(ULONG celt, FORMATETC __RPC_FAR * rgelt, <BR>
ULONG __RPC_FAR * pceltFetched); <BR>
STDMETHOD(Skip)(ULONG celt); <BR>
STDMETHOD(Reset)(void); <BR>
STDMETHOD(Clone)(IEnumFORMATETC __RPC_FAR *__RPC_FAR * ppenum); <BR>
. . . </TT></FONT></P>
<P>The two member variables, <TT>sTextFormatEtc</TT> and <TT>sTextStgMedium</TT>,
must be initialized in the constructor of your class so that they will not contain
meaningless data the first time that they are used (see Listing 9.23).
<H3><A NAME="Heading31"></A>Listing 9.23 <SPACER TYPE="HORIZONTAL" SIZE="10">ATLCONTROLWIN.H--Member
Initialization in the Class Constructor</H3>
<P><FONT COLOR="#0066FF"><TT>. . . <BR>
// set the initial state of the ReadyState property <BR>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线不卡视频| 日韩欧美国产一二三区| 国产九九视频一区二区三区| 日韩 欧美一区二区三区| 亚洲一区二区视频| 一区二区久久久| 一区二区三区在线观看动漫| 亚洲精选免费视频| 日韩毛片一二三区| 伊人性伊人情综合网| 亚洲激情中文1区| 一区二区三区在线播| 亚洲福利视频一区| 日韩中文欧美在线| 久久国产精品99久久人人澡| 狠狠色狠狠色综合日日91app| 韩国v欧美v亚洲v日本v| 岛国av在线一区| 91丝袜美女网| 欧美老肥妇做.爰bbww| 欧美精品 日韩| 精品少妇一区二区三区在线播放 | 国产超碰在线一区| 成人福利在线看| 色综合久久综合中文综合网| 欧美午夜精品免费| 日韩欧美一区二区免费| 色8久久精品久久久久久蜜| 欧美男男青年gay1069videost| 日韩欧美国产综合| 日本一区二区三区在线不卡| 亚洲欧美在线观看| 午夜视频一区二区| 国产在线不卡一区| 一本色道久久综合亚洲91| 欧美日韩高清一区二区不卡| 久久综合久久综合久久| 亚洲欧美日韩一区二区 | 免费观看日韩av| 国产精品白丝jk白祙喷水网站| 91视频在线观看| 日韩一区二区不卡| 国产精品久久久久久久第一福利| 亚洲综合一区在线| 久久99热狠狠色一区二区| www.欧美精品一二区| 欧美精品一二三| 中文字幕欧美区| 日韩av一级电影| 99久久综合国产精品| 日韩三级中文字幕| 亚洲视频在线一区| 精品一区二区三区在线播放视频| a在线播放不卡| 日韩三级视频在线看| 亚洲免费观看高清在线观看| 欧美aaaaa成人免费观看视频| 91网页版在线| 国产视频视频一区| 日韩中文字幕亚洲一区二区va在线| 成人深夜在线观看| 日韩精品中文字幕在线不卡尤物 | 婷婷国产在线综合| eeuss影院一区二区三区| 日韩一区二区三区高清免费看看 | 精品一区二区av| 欧洲另类一二三四区| 中文字幕不卡在线播放| 另类专区欧美蜜桃臀第一页| 在线免费观看一区| 国产精品久久久久久久久搜平片| 另类欧美日韩国产在线| 欧美亚洲国产怡红院影院| 国产日产精品1区| 久久国产精品99久久人人澡| 欧美日韩另类一区| 亚洲另类在线制服丝袜| 国产91丝袜在线播放0| 精品国产区一区| 日本中文字幕不卡| 欧美视频一区在线观看| **欧美大码日韩| 成人午夜电影小说| 久久精品亚洲麻豆av一区二区| 日本美女视频一区二区| 欧美年轻男男videosbes| 一区二区三区 在线观看视频| voyeur盗摄精品| 国产精品乱人伦一区二区| 国产在线观看一区二区| 欧美成人福利视频| 美女一区二区在线观看| 欧美喷水一区二区| 丝袜美腿高跟呻吟高潮一区| 欧美在线播放高清精品| 亚洲少妇中出一区| 色综合色狠狠综合色| 亚洲免费av观看| 色视频一区二区| 亚洲一二三专区| 欧美日韩一区小说| 亚洲成人激情av| 欧美日韩一区二区三区不卡 | 在线免费观看不卡av| 一区二区三区四区激情| 欧美性受极品xxxx喷水| 亚洲电影你懂得| 91精品国产福利| 日韩av一二三| 久久综合狠狠综合久久综合88 | 日韩av一区二区三区| 91精品国产综合久久精品app| 视频精品一区二区| 日韩一区二区精品葵司在线| 久久爱www久久做| 久久亚洲精品小早川怜子| 国产成人精品免费网站| 中文欧美字幕免费| 91麻豆高清视频| 亚洲电影视频在线| 日韩精品一区二区三区中文不卡 | 精品久久久久久久久久久久包黑料| 蜜臀久久99精品久久久久宅男| 日韩精品在线一区| 粉嫩av亚洲一区二区图片| 亚洲欧美一区二区三区久本道91| 日本电影欧美片| 日本欧美久久久久免费播放网| 精品88久久久久88久久久| 成人一级片在线观看| 亚洲黄色在线视频| 日韩小视频在线观看专区| 国产高清精品网站| 亚洲免费电影在线| 欧美一区二区成人| 国产黄色成人av| 亚洲主播在线播放| 精品女同一区二区| proumb性欧美在线观看| 婷婷久久综合九色国产成人 | 狠狠狠色丁香婷婷综合激情| 国产精品免费丝袜| 日本黄色一区二区| 久久99久久精品| 亚洲欧洲日韩在线| 4hu四虎永久在线影院成人| 国产专区综合网| 一区二区三区日韩精品视频| 日韩视频一区二区三区| 波多野结衣中文字幕一区 | 欧美性大战xxxxx久久久| 久久国产精品第一页| 国产无一区二区| 欧美日韩在线免费视频| 国产成人精品免费视频网站| 天堂久久久久va久久久久| 亚洲国产高清在线观看视频| 欧美人体做爰大胆视频| 波多野结衣视频一区| 日本欧美一区二区三区乱码| 亚洲视频1区2区| 久久免费视频色| 69堂亚洲精品首页| 99综合影院在线| 国内精品视频666| 亚洲成av人片www| 亚洲欧美在线视频观看| 久久综合久久99| 欧美一区二区女人| 91黄色免费版| 不卡影院免费观看| 久久精品国产精品亚洲精品 | 欧美中文字幕不卡| 成人免费看片app下载| 男女性色大片免费观看一区二区| 亚洲色图19p| 国产精品久久久久久亚洲毛片 | 精品午夜久久福利影院 | 在线免费观看日韩欧美| 国产91综合网| 国产精品综合在线视频| 美女爽到高潮91| 香蕉成人啪国产精品视频综合网| 一区在线观看视频| 国产日产欧美一区二区三区 | 另类综合日韩欧美亚洲| 亚洲18影院在线观看| 亚洲精品水蜜桃| 国产精品卡一卡二| 国产日韩精品一区| 久久蜜桃av一区精品变态类天堂| 这里只有精品视频在线观看| 欧洲亚洲国产日韩| 94-欧美-setu| 99免费精品在线| av在线不卡观看免费观看| 国产精品1区2区| 国产成人免费视频网站| 国产一区二区三区免费在线观看| 精品一区二区综合|