阅读:4346回复:13
VC+AE中如果给IPAGELAYOUTCONTROL中增加文字
我在给IPAGELAYOUTCONTROL中增加文字,用下面的代码在最后面出错,估计是接口转换问题,那为朋友给看看:(vb的代码可以通过)<br>IElementPtr pElement(CLSID_TextElement); <br>ITextElementPtr pTextElement = pElement; <br>ITextSymbolPtr pTextSym(CLSID_TextSymbol); <br>BSTR bstrText; <br>bstrText = CComBSTR("Text"); <br>IGeometryPtr pGeom; <br>pGeom = pEnv.GetInterfacePtr(); <br><br>pElement->put_Geometry(pGeom); <br>pTextElement->put_Text(bstrText); <br>pTextElement->put_Symbol(pTextSym); <br><br>VARIANT varGeom; <br>varGeom.punkVal = (IUnknownPtr)pGeom; <br>VARIANT varTextSym; <br>varTextSym.punkVal = (IUnknownPtr)pTextSym; <br>VARIANT varText; <br>varText.bstrVal = CComBSTR("Text1"); <br>VARIANT varElem; <br>varElem.punkVal = (IUnknownPtr)pElement; <br>m_PageLayoutCtrl.AddElement(pElement,varGeom,varTextSym,varText,0);//执行错误<br><br>m_PageLayoutCtrl.Refresh(esriViewGraphics,varElem,varGeom); <br>
[此贴子已经被作者于2007-9-17 15:27:33编辑过]
|
|
1楼#
发布于:2007-12-27 09:06
<P>我想对输出的文字进行编辑,ITexeSymbolEditor有一个EditorTextSymbol方法,显示文字编辑对话框,可是vb中可以,vc中就不显示。是怎么回事呢?</P>
<P>这句话我的代码是<FONT face=Arial>hr=pTextSymbolEditor->EditTextSymbol(;pTextSymbol,m_pPageLayoutControl.GetHWnd(),;m_bok);</FONT> </P> <P>还想问下<FONT face=Verdana color=#61b713><STRONG>gzstyxb仁兄,</STRONG><FONT color=#0c0508>代码中的</FONT></FONT><FONT face="Times New Roman">dlg.m_lfFont.lfFaceName,dlg是自定义的对话框么,要怎么做,怎么做那些字体类型之类的东西呢?</FONT></P> |
|
2楼#
发布于:2007-11-07 09:07
还有,我想问如果要对输入文本进行编辑,应该怎么做呢?
|
|
3楼#
发布于:2007-11-06 17:02
<P>嗯 可以在上面添加文字了</P>
<P>我错在:在IPageLayout 接口对象(pPageLayout)上添加 </P> <P>正确的应该是在:和控件相连的变量(m_ipPageLayout)上添加对象</P> <P>这两个不都是对控件的操作么?有什么区别呢</P> <P>还有我觉得那个AO的帮助文档解释的很是不清楚 或者就是我理解能力不够</P> |
|
4楼#
发布于:2007-11-06 15:49
<P>对于文本输入我的方法是:</P>
<P>弹出一个对话框,输入文字,但是少于13个字符时,它都显示为FNT呢?</P> <P>奇怪</P> <P>代码为:</P> <P> CTextDlg textdlg;<BR> textdlg.DoModal();<BR> CString m_text;<BR> m_text=textdlg.m_textedit;<BR> BSTR text=_bstr_t(m_text); </P> <P>不知道是不是_bstr_t类型转换的原因,哪位高手知道呢?</P> <P>谢谢哈</P> |
|
5楼#
发布于:2007-11-06 15:46
<P>还有一个要注意的问题是:</P>
<P><BR>pTextElement->put_Text(bstrText);<BR>pTextElement->put_Symbol(pTextSym);</P> <P>一定要放到pElement->put_Geometry(pGeom);这句话之后 </P> <P>我理解的是,要先确定位置,不知道对不对</P> |
|
6楼#
发布于:2007-11-06 13:48
可以的,我上面那就是先打开mxd文件,然后在pagelayout里面加文字,上面已经有代码了
|
|
7楼#
发布于:2007-11-06 10:05
<P> 我知道 我那段代码 没能输出文本的原因在于没有确定包络多边形 是吧?</P>
<P>现在可以输入文字了 </P> <P>可是如果我在控件中先添加一个mxd文件,再添加文字的话,为什么文字就不出现了呢?</P> <img src="images/post/smile/dvbbs/em02.gif" /> |
|
8楼#
发布于:2007-11-06 09:11
呀 先谢谢哈:)
|
|
9楼#
发布于:2007-11-05 17:43
<P 0cm 0cm 0pt"><FONT face="Times New Roman"> CComPtr<IFontDisp> pFont; <p></p></FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman"> HRESULT hr= CoCreateInstance(CLSID_StdFont, NULL, CLSCTX_ALL, IID_IFontDisp, (void **);pFont); <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> _ASSERTE(SUCCEEDED(hr)); <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> IFontPtr ipFont;<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> pFont->QueryInterface(IID_IFont, (void **);ipFont);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> _ASSERTE(pFont); <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ipFont->put_Name(CComBSTR(dlg.m_lfFont.lfFaceName));<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ipFont->put_Underline(dlg.m_lfFont.lfUnderline);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ipFont->put_Bold(dlg.m_lfFont.lfItalic);<p></p></FONT></P> <P 0cm 0cm 0pt"><p><FONT face="Times New Roman"> </FONT></p></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> IFontDispPtr ipFontDisp = ipFont;<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ISimpleTextSymbolPtr textSymbol(CLSID_TextSymbol);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ITextElementPtr txtElem(CLSID_TextElement);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> textSymbol->put_Font(ipFontDisp);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> textSymbol->put_Size(dlg.m_lFontSize);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> textSymbol->put_HorizontalAlignment(dlg.m_horizAlignment);//);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> textSymbol->put_VerticalAlignment(esriTVACenter);<p></p></FONT></P> <P 0cm 0cm 0pt"><p><FONT face="Times New Roman"> </FONT></p></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> IColorPtr ipColor(CLSID_RgbColor); <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ipColor->put_RGB(dlg.m_crFontColor);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> textSymbol->put_Color(ipColor);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> txtElem->put_ScaleText(VARIANT_FALSE); // VARIANT_FALSE</FONT>表示文字随图形放大而放大<p></p></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> txtElem->put_Text(CComBSTR(dlg.m_strData)); // <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> txtElem->put_Symbol(textSymbol);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> <p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> IElementPtr element = txtElem;<p></p></FONT></P> <P 0cm 0cm 0pt"><p><FONT face="Times New Roman"> </FONT></p></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> element->put_Geometry(ipGeometry);<p></p></FONT></P> <P 0cm 0cm 0pt"><FONT face="Times New Roman"> ipGraphicsContainer->AddElement(element, 0);<p></p></FONT></P> |
|
|
上一页
下一页