ControlsMapMeasureToolClass button visibility problem -deals with EnableVisualStyles?

483
3
09-07-2010 07:30 AM
TimB
by
New Contributor III
I am trying to implement my own toolbar that calls multiple commands (some ESRI, and some my own). 

I use the following pattern to call most of the ESRI commands:

ICommand command; //command to see
command = new ControlsMapMeasureToolClass();
command.OnCreate(_mapControl.Object);
_mapControl.CurrentTool = (ITool)command;

However, when implementing my own call to the ControlsMapMeasureToolClass, the window shows up, but the button images on that window are not visible (see attached image).  If I add this command to a normal AxToolbarControl, the window appears fine and all button images are visible. 

Another clue: when I comment out the call (in Program.cs) to 'Application.EnableVisualStyles' the window images appear fine in my custom call to the measure tool.  This is not a viable option, however, as many of my forms are using the new visual styles allowed for in XP and beyond.

Any ideas how to fix this?  I looked at interfaces for ITool and ICommand, and could not find anything to clue me in if I was missing additional properties or calls to set when calling this particular command (ControlsMapMeasureToolClass).
0 Kudos
3 Replies
CharlieMatherne
New Contributor II
If you're using Arc10, make sure you have the latest service packs installed.  We just ran into the same problem.  We noticed that installing SP2 for Arc10 corrected the problem.  However, now the measure tool window is showing up twice when you select another measuring option.  See thread http://forums.arcgis.com/threads/39405-.NET-Toolstrip-with-Measure-Tool-Issue-in-ArcEngine-10?highli...
0 Kudos
JohnHauck
Occasional Contributor II
Please verify that you are using 10.0 SP2. With 10.0 final and SP1 we had the following issue.

NIM061664: Issues with �??ControlsMapMeasureTool�?? as a customized button on the menu strip in an ArcEngine application

The solution was to Add the Common Controls 6.0 specification to all the controls and the Measure Tool.

To work around this issue prior to SP2 you could modify the manifest file and add the version 6.0 Common Control Library specification there instead of relying on Enabling Visual Styles.

For example here is how I was able to get this to work for a similar question:
- Create a new MapControl Template.
- Right-click on the project, select add new item
- Add an Application Manifest File
- Add the following to the Manifest:

 <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="X86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
     />
    </dependentAssembly>
  </dependency>
  
So your full manifest would look like this:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="X86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
     />
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the 
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            If you want to utilize File and Registry Virtualization for backward 
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>
0 Kudos
zhenliu
New Contributor II
Please verify that you are using 10.0 SP2. With 10.0 final and SP1 we had the following issue.

NIM061664: Issues with �??ControlsMapMeasureTool�?? as a customized button on the menu strip in an ArcEngine application

The solution was to Add the Common Controls 6.0 specification to all the controls and the Measure Tool.

To work around this issue prior to SP2 you could modify the manifest file and add the version 6.0 Common Control Library specification there instead of relying on Enabling Visual Styles.

For example here is how I was able to get this to work for a similar question:
- Create a new MapControl Template.
- Right-click on the project, select add new item
- Add an Application Manifest File
- Add the following to the Manifest:

 <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="X86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
     />
    </dependentAssembly>
  </dependency>
  
So your full manifest would look like this:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="X86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
     />
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the 
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            If you want to utilize File and Registry Virtualization for backward 
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>


Very Good & Thanks! Your answer solve this headache problem.
I meet this problem today and my development environment is AE9.3 + VS2008 C#.
0 Kudos