浪花闪闪
路人甲
路人甲
  • 注册日期2005-10-12
  • 发帖数28
  • QQ
  • 铜币244枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1447回复:3

如何实现ArcMap里面的复制视图到剪贴板的功能!

楼主#
更多 发布于:2006-01-04 10:33
如何实现ArcMap里面的复制视图到剪贴板的功能!斑竹出手啊!
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-01-05 10:13
<P>上面是以前发的,没用到clipboard</P>
<P>下面这个用了</P><PRE>'sample VB code for clipboard, this is not tested
'you can look up the relevant Win32 api functions

Dim hMemoryDC As Long
Dim hBitmap As Long
Dim lWidth As Long, lHeight As Long

'get the width and height of the map, make sure its in pixels, watch out for 3D borders etc.
lWidth = MapControl1.Width
lHeight = MapControl1.Height


hMemoryDC = CreateCompatibleDC(0)  'screen DC
hBitmap = CreateCompatibleBitmap(hMemoryDC, lWidth, lHeight)

If hBitmap <> 0 Then

   'select the bitmap into the DC
   SelectObject hMemoryDC, hBitmap

   'draw the map to the DC
   pActiveView.Draw(hMemoryDC, Nothing)

   'open clipboard, use whatever hWnd you like
   OpenClipboard Form1.hWnd

   'clear out clipboard
   EmptyClipboard

   'copy the bits to the clipboard
   SetClipboardData CF_BITMAP, hBitmap

   'close clipboard
   CloseClipboard

End If

'cleanup
DeleteDC hMemoryDC
DeleteObject hBitmap
</PRE>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2006-01-05 10:07
<FONT color=#0000ff>Public Sub</FONT> CopyAndOverwriteMap()<BR>    <BR>  <CODE><FONT color=#008000>'Get IObjectCopy interface</FONT></CODE><BR>  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pObjectCopy <CODE><FONT color=#0000ff>As</FONT></CODE> IObjectCopy<BR>  <CODE><FONT color=#0000ff>Set</FONT></CODE> pObjectCopy = <CODE><FONT color=#0000ff>New</FONT></CODE> ObjectCopy<BR><BR>  <CODE><FONT color=#008000>'Get IUnknown interface (map to copy)</FONT></CODE><BR>  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pToCopyMap <CODE><FONT color=#0000ff>As</FONT></CODE> IUnknown<BR>  <CODE><FONT color=#0000ff>Set</FONT></CODE> pToCopyMap = PageLayoutControl1.ActiveView.FocusMap<BR><BR>  <CODE><FONT color=#008000>'Get IUnknown interface (copied map)</FONT></CODE><BR>  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pCopiedMap <CODE><FONT color=#0000ff>As</FONT></CODE> IUnknown<BR>  <CODE><FONT color=#0000ff>Set</FONT></CODE> pCopiedMap = pObjectCopy.Copy(pToCopyMap)<BR><BR>  <CODE><FONT color=#008000>'Get IUnknown interface (map to overwrite)</FONT></CODE><BR>  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pToOverwriteMap <CODE><FONT color=#0000ff>As</FONT></CODE> IUnknown<BR>  <CODE><FONT color=#0000ff>Set</FONT></CODE> pToOverwriteMap = MapControl1.Map<BR>  <BR>  <CODE><FONT color=#008000>'Overwrite the MapControl's map</FONT></CODE><BR>  pObjectCopy.Overwrite pCopiedMap, pToOverwriteMap<BR> <BR>  SetMapExtent<BR><BR><CODE><FONT color=#0000ff>End Sub<BR></FONT></CODE>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
浪花闪闪
路人甲
路人甲
  • 注册日期2005-10-12
  • 发帖数28
  • QQ
  • 铜币244枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-01-04 20:36
没人能揭贴,试问天下高手在和处,帝国?
举报 回复(0) 喜欢(0)     评分
游客

返回顶部