Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Does anyone out there knows how to set the layer in the georeferencing toolbar. There is no information in the object models. Using ICommandItem ic = ArcMap.Application.Document.CommandBars.Find(uid, false, false) as ICommandItem; I found that type is georeferencing_Layerslistcontrol. Any ideas?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I am afraid you will not be able to do so. These commands are placed in the esriGeoreferenceUI library, for which the documentation states

This library is meant for internal use only. There is no public API exposed.

After some investigation, I have found that there is also an extension (IExtension) running in ArcMap named "Georeferencing" (ProgId is esriGeoReferenceUI.RectifyExt, ClassId is {C50D33D1-DBED-11D3-B9BD-00C0F0567A4A}. I am quite sure this is the key place on which all the georefencing commands and tools operate, but its interfaces seem to be internal to the esriGeoreferenceUI library and are not exposed.

share|improve this answer
    
Thanks a lot Petr, I looked here help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… and it says "This library is meant for internal use only. There is no public API exposed." –  user1266 Nov 18 '10 at 21:15

I had the same problem and this is how I solved it for ArcGIS 9.3.1 with VBA. The same way should work with ArcGIS 10 and .NET.

Option Explicit

Private Declare Function WindowFromPoint Lib "user32" (ByVal _
      xPoint As Long, ByVal IyPoint As Long) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Function setGeorefDest(sDestLayerName As String) As Long

    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    Dim pDoc As IDocument
    Set pDoc = pMxDoc

    Dim pCommandBars As ICommandBars
    Set pCommandBars = pDoc.CommandBars

    Dim pWinPos As IWindowPosition
    Dim pBar As ICommandBar

    Set pBar = pCommandBars.Find(arcid.Georeferencing_ToolBar)
    Set pWinPos = pBar

    If not pBar.IsVisible Then Exit Function

    ' -- Find Window Handle of GeoRef-Toolbar
    '    CAVEAT: Must be positioned horizontally!
    '            Assumes the Layer-Listbox to be under the mid/mid point of the toolbar
    Dim lHandle As Long
    lHandle = WindowFromPoint(pWinPos.Left + pWinPos.Width / 2, pWinPos.Top + pWinPos.Height / 2)

    '
    Const CB_BASE As Long = &H140
    Const CB_GETLBTEXTLEN = CB_BASE + &H9
    Const CB_GETLBTEXT As Long = &H148
    Const CB_SETCURSEL As Long = &H14E
    Const CB_GETCOUNT As Long = &H146   '= 326
    Const CB_ERR As Long = -1
    Const CB_GETCURSEL = CB_BASE + &H7
    Const WM_KEYDOWN = &H100
    Const WM_KEYUP = &H101
    Const CBN_SELCHANGE As Long = &H1

    ' See how many entries the ComboBox has.
    Dim nListCount As Long
    nListCount = SendMessage(lHandle, CB_GETCOUNT, 0, 0)

    Dim n As Long
    Dim nDestIndex As Long
    Dim lRet As Long
    Dim sCmbEntry As String


    ' Look for the index of sDestLayerName
    ' by iterating all ListItems
    For n = 0 To nListCount - 1            
        sCmbEntry = Space(1024)
        lRet = SendMessage(lHandle, CB_GETLBTEXT, n, ByVal sCmbEntry)
        If lRet <> CB_ERR Then
            sCmbEntry = Left$(sCmbEntry, lRet)
        End If
        If (sCmbEntry = sDestLayerName) Then
            nDestIndex = n
            Exit For
        End If
    Next n

    ' if more then 1 and we want the first:
    ' select 2nd and move one up to trigger events
    If nDestIndex = 0 And nListCount > 1 Then
        SendMessage lHandle, CB_SETCURSEL, 1, 0
        SendMessage lHandle, WM_KEYUP, vbKeyUp, 0&
    ElseIf nDestIndex > -1 Then
        ' move to previous an move one down           
        SendMessage lHandle, CB_SETCURSEL, nDestIndex - 1, 0
        SendMessage lHandle, WM_KEYDOWN, vbKeyDown, 0&            
    End If
End Function
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.