Hexagon Geospatial
MENU

Shared Samples

GeoMedia, a comprehensive and dynamic GIS, extracts compelling intelligence from geospatial data and integrates it to present actionable information. Please note a HGDN subscription is required to download code samples
Showing results for 
Search instead for 
Do you mean 

Adding Ribbon Commands to GeoMedia

by Technical Evangelist ‎09-17-2015 08:49 AM - edited ‎09-21-2015 02:06 AM (2,448 Views)

Customizing the Ribbon Interface

Starting from version 2013, GeoMedia introduced a new modern UI that logically groups commands into a ribbon control similar to those in Microsoft Office or ERDAS Imagine. All GeoMedia Add-ons now have their own tab. The classic interface was removed completely in version 2014. That version also brings a support for embedding 3rd party custom commands into the Ribbon bar.

General Ribbon Resources Requirements

For GeoMedia Desktop, the command's Ribbon resource is loaded directly through the Ribbon bar's LoadFromResource method at application startup. To be able to do this, you must:

  1. Create a resource only dll that contains:
    • The required ribbon resource - Resource View in Visual Studio 2013, which creates a Ribbon definition XML file (ex: ribbon1.mfcribbon-ms). After the Ribbon bar is created, you will have to edit the .mfcribbon-ms file through the Solution Explorer view in Visual Studio. When you Open this file in Visual Studio you can then select "Format the whole document" on the XML Editor toolbar to see a readable version of the XML file. At this point the Add-on product should edit the XML file so it only contains the definition for its Category, Panels, and Elements
    • Two image strips that contain the bitmaps used by the ribbon resource for the Large and Small icons that are displayed on the Ribbon bar - the bitmaps for the Large and Small buttons defined in this resource must contain the bitmaps for all the commands concatenated together into one Large 32h x Nw image strip and one Small 16h x Nw image strip. Each individual command button is 32 x 32 for large and 16 x 16 for small.
  2. Provide an application commands .xml and registration information, that contains the Add-on command information. These files are usually generated by the Command Wizard.
  3. Provide a command mapping .xml file that maps the command ProgIDs to the command values listed in the .mfcribbon-ms file. Sample:

 

<?xml version="1.0" encoding="UTF-8"?>
<CommandMapping xmlns="http://www.intergraph.com/GeoMedia/Mappings" xmlns:xsi="http:/
/www.w3.org/2001/XMLSchema-instance" version="1.0">
   <Category name="RibbonTab1">
     <Command>
        <ProgID>GeoMediaCommand.Sample1</ProgID>
        <Value>40100</Value>
      </Command>
      <Command>
        <ProgID>GeoMediaCommand.Sample2</ProgID>
        <Value>40200</Value>
      </Command>
</Category> 
   <Category name="RibbonTab2">
      <Command>
         <ProgID>GeoMediaCommand.Sample3</ProgID>
         <Value>40400</Value>
      </Command>
   </Category> 
</CommandMapping>
  1. Create new registry entries to inform GeoMedia where to find these files. The format is:
    HKEY_LOCAL_MACHINE\Software\Wow6432Node\Intergraph\GeoMediaTierName\14.00 where GeoMediaTierName can be one of the following
    • GeoMedia Professional
    • GeoMedia Advantage
    • GeoMedia Essentials

    Your command installation package will need to create registry entries under every GeoMedia tier it needs to run with.

    • ApplicationCommands - key
      • Uniquea Application - key, e.g.: "Geomedia3d"
        • "Location" - path to the folder containing the XML configuration files for the Add-on product's commands (appcommands1.xml, appcommands2.xml, ...)
        • "AppCmdDllPath" - path to the folder containing the DLL files that implement the commands listed in the XML files (and bitmaps) above.
    • RibbonCategories - key
      • Unique Application - key, e.g. "GeoMedia 3D"
        • "Resource" - Full path to resource containing the simplified version of the Ribbon bar resource and the Small and Large image bitmaps needed by the Ribbon Bar.
        • "CommandMappings - Full path to the XML that contains the ProgID to Ribbon Bar resource "Value" mapping for the commands in each category.
        • "RibbonResourceID" - The numeric value assigned to your ribbon resource. This can be found in your resource.h file. For example, the GeoMedia 3D ribbon resource is IDRGM3D_RIBBON and the value for this in resource.h is 306. "306" would be the value to put here.

Furhter information can be found in the GeoMedia Customization – Ribbon Bar Customization for Developers help file.

Using the sample: Registering the command into custom Ribbon bar

For simplicity, the resources project had been already prepared. The project is a C++ resource-only DLL library and is named MyRibbonResources.

  1. Download the Ribbon project:
    HGDN | Cmd_MyRibbonResources2015CPP or use git command git fetch && git checkout Cmd_MyRibbonResources2015CPP
  2. You must have either Visual Studio 2013 Professional or other editition supporting MFC libraries in order to open and build the project. Open MyRibbonResources.sln and get a basic idea how the resources are organized.
    If you don't have VC++, you can directly open \MyRibbonResources\ribbon1.mfcribbon-ms file with an XML editor. You will also have to use the already built dll file from the Debug subfolder. Skip to step 3.
    1. Navigate to MyRibbonResources > Resource Files and double click on MyRibbonResources.rc.
      Resource View tab will appear.
    2. Navigate to MyRibbonResources > Ribbon and double click on IDR_RIBBON1.
    3. Walk through the controls placed on the Ribbon bar and observe the properties in Properties window.
    4. Click on the first button called Hello GeoMedia and check the value of ID property.
      This is the value that will be used in the command mapping XML file.
      RibbonPreviewVS.png
    5. Close the resource preview and switch back to Solution Explorer. Double-click on ribbon1.mfcribbon-ms file.
      This is a resource XML file that contains definitions of Tabs, Elemenents, Panels and other items and properties.
    6. Build the project and close the solution.
  3. Open in editor the file ...\AppCommandXML\Ribbon.XML
    This file contains mappings between Ribbon resource command ID and command ProgID which was generated by the GeoMedia Command Wizard.
  4. Run Registry Editor as Administrator.
  5. Download, build and install (using cmd_files\register.bat file) the sample command Hello GeoMedia from BitBucket:
    HGDN | Cmd_HelloGeoMedia_2015CS or use git command git fetch && git checkout Cmd_HelloGeoMedia_2015CS
  6. Navigate to
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Intergraph\GeoMedia Professional\15.00\ApplicationCommands\Hello. Change the RibbonCmd value from 1 to 0.
    This registry entry is created by the InstallAppCmd tool, changing the RibbonCmd value causes the command to remove from the My Workflow tab but it will remain visible for GeoMedia framework.
  7. Navigate to HKLM\SOFTWARE\Wow6432Node\Intergraph\GeoMedia Professional\15.00\RibbonCategories. Create new Key GMClass Commands.
  8. In this key, create new string values:
    • CommandMappings: use the location of the ...\AppCommandXML\ribbon.xml file
    • Resource: use the location of …\MyRibbonResources\Debug\MyRibbonResources.dll file
    • RribbonResourceId: use value 101
      The Ribbon resource ID is automatically generated when creating a new VC++ resource DLL project. You will find it in resources.h file. In our project, it is the value of IDR_RIBBON1.
  9. Launch GeoMedia and open a GeoWorkspace. The new Ribbon tab called GMClass Commands should appear.
  10. Click on Hello GeoMedia command icon to see if the command launches correctly.
    RibbonCommand.png

Knowledge level:

Advanced

Source codes

 

Comments
by Navaneeth
on ‎03-24-2016 05:24 AM

Hi,

 

The value we specify in the command mapping xml and the resource xml (in the above case 40100 or  32771) is this anyway related to the command registration ID. If I give numbers in the range 1300 to 1320 the toolbar shows up in geomedia, but I see diffrent tooltips and different command gets invoked. Is there any recommended range or how to decide on this number? especially when installing on different computers.

 

As per the document I undersand that,

1- Geomedia loads the resource from the dll using the resource Id specified in the registry 

2- Buttons have resourceId which is mapped to the command mapping xml values.

3- And from this command mapping xml matching progId is taken and the command is activated.

 

But I am almost certain that this resource Ids cannot be random (even if I map it in the command mapping xml). Can anyone elaborate this resource numbering or Id mapping more?

 

Thanks

 

 

by amarques
on ‎02-14-2017 08:50 AM

Hi.

 

Based on your post i was able to create a custom ribbon bar and it to GeoMedia Professional 2015.

However when trying to put it on another virtual machine, that is a replica of the one where I developed the commands and ribbon, my ribbon bar isn't showed.

The commands are there (if I change the RibbonCmd parameter in regedit I can see them in My Workflow ribbon) but not the ribbon.

 

Is there any requirements for the installation of the ribbon?

 

TIA

by Technical Evangelist
on ‎02-16-2017 01:51 AM

Hi Antonio,

 

Please double- or even triple-check all related registry entries and XML files to make sure that the configuration is valid. In most cases the problem is hidden there.

 

Thanks,

Jan

by amarques
on ‎02-16-2017 01:57 AM

Thanks Jan.

 

I managed to figure out what was the problem.

I changed the property "Use of MFC" of the Ribbon Resources project to "Use MFC in a Static Library" and after that it started to work properly in all other machines.

 

Best regards,

António

Overview
Contributors