阅读:2308回复:6
选择Element工具怎么做?
选择Element工具怎么做?
|
|
1楼#
发布于:2004-05-25 15:13
说详细点吗!
|
|
|
2楼#
发布于:2004-05-25 16:01
<P>就是象Arcmap工具条上的Select Element按钮的功能</P>
|
|
3楼#
发布于:2004-05-25 17:07
<P>改动一下下面的代码,试试:</P><P>Private Sub CmdSelect_Click()
On Error GoTo ErrorHandler Dim pSelectTool As ICommandItem Dim pCommandBars As ICommandBars ' The identifier for the Select Graphics Tool Dim u As New Uid u.Value = "{C22579D1-BC17-11D0-8667-0000F8751720}"</P><P> Set pCommandBars = pAppMain.Document.CommandBars Set pAppMain.CurrentTool = Nothing Set pSelectTool = pCommandBars.Find(u) 'Set the current tool of the application to be the Select Graphics Tool Set pAppMain.CurrentTool = Nothing Set pAppMain.CurrentTool = pSelectTool 'DoRefreshGraLineLists Exit Sub ErrorHandler: ModCommon.ShowError End Sub</P> |
|
|
4楼#
发布于:2004-05-26 08:44
是我少说了,我是用VB+MAPCONTROL开发的。你这个代码好象是VBA的。我的里面是没有pAppMain的。
|
|
5楼#
发布于:2004-05-26 09:14
噢,原来如此。再看看。
|
|
|
6楼#
发布于:2004-05-26 20:05
<P>Private Sub Page1_OnMouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long, ByVal pageX As Double, ByVal pageY As Double)
If selflag = True Then Dim pa As IActiveView Dim pdis As IScreenDisplay Dim pr As IRubberBand Dim pEnv As IEnvelope Dim pgra As IGraphicsContainer Set pgra = Page1.PageLayout Set pa = Page1.PageLayout Set pdis = pa.ScreenDisplay Set pr = New RubberEnvelope Set pEnv = pr.TrackNew(pdis, Nothing) Dim peenum As IEnumElement Set peenum = pgra.LocateElementsByEnvelope(pEnv) If peenum Is Nothing Then Exit Sub Dim pElement As IElement peenum.Reset 'Grab hold of the IElement interface through the first located element Set pElement = peenum.Next Dim pSelectionTracker As ISelectionTracker 'Loop through the located elements Do While Not pElement Is Nothing 'Grab hold of the ISelectionTracker interface through the element Set pSelectionTracker = pElement.SelectionTracker 'Display the elements selection tracker Dim pDisplay As IDisplay 'Grab hold of the IDisplay interface through the PageLayoutControls active view Set pDisplay = Page1.ActiveView.ScreenDisplay 'Start drawing to the display pDisplay.StartDrawing pDisplay.hDC, esriNoScreenCache 'Draw the selection tracker on the display pSelectionTracker.Draw pDisplay, pDisplay.hDC, esriTrackerDominant 'Finish drawing to the display pDisplay.FinishDrawing </P><P> 'Exit so only one element with a selection tracker Exit Do Set pElement = peenum.Next Loop pa.PartialRefresh esriViewGraphicSelection, Nothing, Nothing End If End Sub</P><P>建议你去看看那些DEMO,里面有这些例子 </P><P>注: page1 为pagelayout</P> |
|
|