ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1466回复:9

急急急:帮我看看这段代码

楼主#
更多 发布于:2005-08-25 15:27
<P>这段代码是改变Pagelayout背景颜色的,运行时出错,应该怎样改?</P>
<P>Private Sub BackGroundColor_Click()<br>Dim pPage As IPage<br>Set pPage = PageLayoutControl1.Page</P>
<P>Dim m_pBackgroundColorSelector As IStyleSelector<br>Set m_pBackgroundColorSelector = New BackgroundSelector</P>
<P>m_pBackgroundColorSelector.DoModal PageLayoutControl1.hWnd</P>
<P>Dim pBackgroundColor As IBackground<br>Set pBackgroundColor = m_pBackgroundColorSelector.GetStyle(0)</P>
<P><FONT color=#ff3300>pPage.BackGroundColor = pBackgroundColor           '这句类型不一致,该怎样改</FONT><br>PageLayoutControl1.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing<br>End Sub</P><br><img src="images/post/smile/dvbbs/em12.gif" />
[此贴子已经被作者于2005-8-29 11:10:20编辑过]
喜欢0 评分0
ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2005-08-31 13:55
<P>谢谢老大,我实现了.</P>
<img src="images/post/smile/dvbbs/em12.gif" /><img src="images/post/smile/dvbbs/em12.gif" /><img src="images/post/smile/dvbbs/em12.gif" />
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2005-08-31 11:20
<P>  Set pFillSymbol = New SimpleFillSymbol<BR>  Set pRgbColor = New RgbColor<BR>  pRgbColor.Blue = 200<BR>  pRgbColor.Green = 130<BR>  pFillSymbol.Color = pRgbColor<BR>  pSymbolBackground.FillSymbol = pFillSymbol<BR>  pMapFrame.Background = pSymbolBackground</P>
<P>看来你还没理会这个,这里已经设置了颜色的!</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2005-08-30 16:58
改变Background我会,但改变BackgroundColor就不能实现了.
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
4楼#
发布于:2005-08-30 15:12
<P>How to use: <BR>Paste this macro into VBA. <BR>Modify the color as desired. <BR>Run the macro. <BR>Works in both layout view and data view. <BR>          Public Sub ChangeMapFrameBackground()<BR>  Dim pActiveView As IActiveView<BR>  Dim pFillSymbol As IFillSymbol<BR>  Dim pLayoutGraphicsContainer As IGraphicsContainer<BR>  Dim pMapFrame As IFrameElement<BR>  Dim pMxDoc As IMxDocument<BR>  Dim pRgbColor As IRgbColor<BR>  Dim pSymbolBackground As ISymbolBackground<BR>  <BR>  'Get a reference to the layout's graphics container<BR>  Set pMxDoc = Application.Document<BR>  Set pLayoutGraphicsContainer = pMxDoc.PageLayout<BR>  <BR>  'Find the map frame associated with the focus map<BR>  Set pMapFrame = pLayoutGraphicsContainer.FindFrame(pMxDoc.FocusMap)<BR>  If pMapFrame Is Nothing Then Exit Sub<BR>  <BR>  'Associate a SymbolBackground with the frame<BR>  Set pSymbolBackground = pMapFrame.Background<BR>  If pSymbolBackground Is Nothing Then<BR>    Set pSymbolBackground = New SymbolBackground<BR>  End If<BR>  Set pFillSymbol = New SimpleFillSymbol<BR>  Set pRgbColor = New RgbColor<BR>  pRgbColor.Blue = 200<BR>  pRgbColor.Green = 130<BR>  pFillSymbol.Color = pRgbColor<BR>  pSymbolBackground.FillSymbol = pFillSymbol<BR>  pMapFrame.Background = pSymbolBackground<BR>  <BR>  'Refresh the map frame<BR>  Set pActiveView = pMxDoc.FocusMap<BR>  pActiveView.PartialRefresh esriViewBackground, Nothing, Nothing<BR>End Sub<BR></P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
5楼#
发布于:2005-08-30 15:11
<STRONG>How to use:</STRONG>
<DIV>
<OL>
<LI>Paste this macro into VBA.
<LI>Modify the color as desired.
<LI>Run the macro.
<LI>Works in both layout view and data view. </LI></OL></DIV>
<DIV><PRE>          <DEVELOPENV>Public Sub ChangeMapFrameBackground()
  Dim pActiveView As IActiveView
  Dim pFillSymbol As IFillSymbol
  Dim pLayoutGraphicsContainer As IGraphicsContainer
  Dim pMapFrame As IFrameElement
  Dim pMxDoc As IMxDocument
  Dim pRgbColor As IRgbColor
  Dim pSymbolBackground As ISymbolBackground
  
  'Get a reference to the layout's graphics container
  Set pMxDoc = Application.Document
  Set pLayoutGraphicsContainer = pMxDoc.PageLayout
  
  'Find the map frame associated with the focus map
  Set pMapFrame = pLayoutGraphicsContainer.FindFrame(pMxDoc.FocusMap)
  If pMapFrame Is Nothing Then Exit Sub
  
  'Associate a SymbolBackground with the frame
  Set pSymbolBackground = pMapFrame.Background
  If pSymbolBackground Is Nothing Then
    Set pSymbolBackground = New SymbolBackground
  End If
  Set pFillSymbol = New SimpleFillSymbol
  Set pRgbColor = New RgbColor
  pRgbColor.Blue = 200
  pRgbColor.Green = 130
  pFillSymbol.Color = pRgbColor
  pSymbolBackground.FillSymbol = pFillSymbol
  pMapFrame.Background = pSymbolBackground
  
  'Refresh the map frame
  Set pActiveView = pMxDoc.FocusMap
  pActiveView.PartialRefresh esriViewBackground, Nothing, Nothing
End Sub</DEVELOPENV>
</PRE></DIV>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2005-08-30 14:04
<P>要怎么定义,我看了GetStyle(0)得到的样式与IColor没有关联</P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
7楼#
发布于:2005-08-30 11:51
<P>那也要先定义了</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
8楼#
发布于:2005-08-30 09:14
但是我想要把GetStyle(0)选择的颜色赋给BackGroundColor,而不是使用固定的某种颜色.
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
9楼#
发布于:2005-08-29 15:07
<P><FONT color=#ff3300>先定义一个颜色pBackgroundColor ,:)</FONT></P>
<P><FONT color=#ff3300></FONT> </P>
<P>    Dim <FONT color=#ff3300>pBackgroundColor</FONT> As IColor<BR>    Set <FONT color=#ff3300>pBackgroundColor</FONT> = New RgbColor<BR>    <FONT color=#ff3300>pBackgroundColor</FONT>.RGB = RGB(255, 0, 0)</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部