⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csdn_文档中心_银弹制造:开发最灵活的软件(一).htm

📁 csdn10年中间经典帖子
💻 HTM
📖 第 1 页 / 共 4 页
字号:
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN><SPAN style="COLOR: blue">return</SPAN> 
                  hr;<o:p></o:p></SPAN></P>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN>}<o:p></o:p></SPAN></P>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">GetEventIID(&amp;m_iidEvents);<o:p></o:p></SPAN></P>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">//</SPAN><SPAN 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">激活客户端对象部分略</SPAN></P></TD></TR></TBODY></TABLE>
            <P class=2 style="MARGIN: auto 0cm auto 18pt"><FONT face=宋体 
            size=3>上述代码中的<SPAN lang=EN-US>CWFControlWrapper</SPAN>是另外一个重要的类<SPAN 
            lang=EN-US>CWinFormsView</SPAN>(从使用<SPAN lang=EN-US>MFC Application 
            Project with .NET Support 1.0 </SPAN>为我们的<SPAN lang=EN-US>Visual 
            Studio.NET 2003</SPAN>的<SPAN lang=EN-US>VC++</SPAN>项目模板中添加的<SPAN 
            lang=EN-US>”MFC Project with .NET Support”</SPAN>向导生成任何一个应用程序的<SPAN 
            lang=EN-US>”UserControlView.cpp”</SPAN>里的映射可以看到他们的对应关系)包含的一个子类,类定义如下:</FONT></P>
            <TABLE border=1 cellPadding=0 cellSpacing=0 class=MsoNormalTable 
            style="BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: auto auto auto 5.4pt; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext">
              <TBODY>
              <TR 
              style="HEIGHT: 30.75pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
                <TD 
                style="BACKGROUND-COLOR: transparent; BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; HEIGHT: 30.75pt; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; WIDTH: 414pt; mso-border-alt: solid windowtext .5pt" 
                vAlign=top width=552>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="COLOR: blue; FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">class</SPAN><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-spacerun: yes">&nbsp; </SPAN>CWFControlWrapper : 
                  <SPAN style="COLOR: blue">public</SPAN> 
                  CWnd<o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN>{<o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN><SPAN 
                  style="COLOR: blue">public</SPAN>:<o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN>CWFControlWrapper();<o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN><SPAN style="COLOR: blue">virtual</SPAN> 
                  ~CWFControlWrapper(<SPAN style="COLOR: blue">void</SPAN>); 
                  <o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN>IUnknown * pUnkControl ;<o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN>IUnknown * GetManagedControl() { <SPAN 
                  style="COLOR: blue">return</SPAN> pUnkControl; 
                  }<o:p></o:p></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN 
                  style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN><SPAN style="COLOR: blue">void</SPAN><SPAN 
                  style="mso-spacerun: yes">&nbsp; 
                  </SPAN>SetControlSite(COleControlSite * pSite) { m_pCtrlSite = 
                  pSite; }<o:p></o:p></SPAN></P>
                  <P class=2 style="MARGIN: auto 0cm"><SPAN lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 宋体"><SPAN 
                  style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; 
                  </SPAN>};<BR>CWinFormsView::CWFControlWrapper::CWFControlWrapper():pUnkControl(NULL){}<BR>//</SPAN><SPAN 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 宋体">析构函数略<SPAN 
                  lang=EN-US><o:p></o:p></SPAN></SPAN></P></TD></TR></TBODY></TABLE>
            <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'"><SPAN 
            style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
            <P class=MsoNormal 
            style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: 2.95pt; mso-char-indent-count: .28"><SPAN 
            style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT 
            size=3>我们必须重写</FONT></SPAN><SPAN 
            style="COLOR: green; FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"> 
            </SPAN><SPAN lang=EN-US 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">CreateControl</SPAN><SPAN 
            style="FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt"><FONT 
            size=3>方法</FONT></SPAN><SPAN 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">以调用<SPAN 
            lang=EN-US>CreateManagedControl</SPAN>方法;在这段方法实现中,如果<SPAN 
            lang=EN-US>hr = CreateManagedControl(clsid, pPersist, bStorage, 
            bstrLicKey)</SPAN>成功完成,创建托管资源窗口<SPAN 
            lang=EN-US>/UserControl</SPAN>,然后,作为<SPAN 
            lang=EN-US>OLE</SPAN>就地激活对象,它需要被激活;<SPAN 
            lang=EN-US><o:p></o:p></SPAN></SPAN></P>
            <P class=MsoNormal 
            style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: 2.5pt; mso-char-indent-count: .28"><SPAN 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">插曲:<SPAN 
            lang=EN-US><o:p></o:p></SPAN></SPAN></P>
            <P class=MsoNormal 
            style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: 2.5pt; mso-char-indent-count: .28"><SPAN 
            lang=EN-US 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">COLEControlSite</SPAN><SPAN 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">对象是一个<SPAN 
            lang=EN-US>OLE</SPAN>容器文档对象,在这个容器文档中可以任意创建托管项。开发人员在容器文档中创建托管项后会频繁激活这个对象,以便对其进行编辑。<SPAN 
            lang=EN-US><o:p></o:p></SPAN></SPAN></P>
            <P class=MsoNormal 
            style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: 2.5pt; mso-char-indent-count: .28"><SPAN 
            lang=EN-US 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><o:p>&nbsp;</o:p></SPAN></P>
            <P class=MsoNormal 
            style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: 2.5pt; mso-char-indent-count: .28"><SPAN 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">借助在<SPAN 
            lang=EN-US>CWFControlWrapper</SPAN>中的方法<SPAN 
            lang=EN-US>SetControlSite</SPAN>使得<SPAN 
            lang=EN-US>CWnd</SPAN>的保护成员<SPAN 
            lang=EN-US>m_pCtrlSite</SPAN>得以获得新的托管资源:<SPAN 
            lang=EN-US><o:p></o:p></SPAN></SPAN></P>
            <P class=MsoNormal 
            style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt; mso-char-indent-count: 2.0"><SPAN 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">部分代码如下:<SPAN 
            lang=EN-US><o:p></o:p></SPAN></SPAN></P>
            <TABLE border=1 cellPadding=0 cellSpacing=0 class=MsoNormalTable 
            style="BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: auto auto auto 5.4pt; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext">
              <TBODY>
              <TR 
              style="HEIGHT: 39pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
                <TD 
                style="BACKGROUND-COLOR: transparent; BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; HEIGHT: 39pt; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; WIDTH: 414pt; mso-border-alt: solid windowtext .5pt" 
                vAlign=top width=552>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">CWinFormsView::CWFControlWrapper 
                  * pWndCtrlLocal = <SPAN 
                  style="COLOR: blue">dynamic_cast</SPAN>&lt;CWinFormsView::CWFControlWrapper 
                  *&gt;(pWndCtrl);<SPAN 
                  style="COLOR: green"><o:p></o:p></SPAN></SPAN></P>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">m_pWndCtrl 
                  = pWndCtrlLocal;<o:p></o:p></SPAN></P>
                  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                  lang=EN-US 
                  style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">pWndCtrlLocal-&gt;SetControlSite(<SPAN 
                  style="COLOR: blue">this</SPAN>);<o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
            <P class=2 style="MARGIN: auto 0cm auto 18pt"><FONT face=宋体 
            size=3>接下来的问题是,如何将<SPAN lang=EN-US> Windows </SPAN>窗体控件用作<SPAN 
            lang=EN-US> MFC </SPAN>视图类。 首先自然要在<SPAN 
            lang=EN-US>CWinFormView</SPAN>类中创建</FONT><SPAN lang=EN-US 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 宋体">CWFControlSite</SPAN><SPAN 
            style="FONT-FAMILY: 新宋体; FONT-SIZE: 9pt; mso-hansi-font-family: 宋体">对象,如果创建成功,就把它画在客户区,代码实现如下:<SPAN 
            lang=EN-US><o:p></o:p></SPAN></SPAN></P>
            <TABLE border=1 cellPadding=0 cellSpacing=0 class=MsoNormalTable 
            style="BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: auto auto auto 23.4pt; WIDTH: 405pt; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" 
            width=540>
              <TBODY>
              <TR 
              style="HEIGHT: 24pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
                <TD 
                style="BACKGROUND-COLOR: transparent; BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; HEIGHT: 24pt; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; WIDTH: 405pt; mso-border-alt: solid windowtext .5pt" 
                vAlign=top width=540>
                  <P align=left class=MsoNormal 
                  style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"><SPAN 
                  lang=EN-US 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -