Tuesday 30 October 2018

arcobjects - Workaround for AxMapControl painting issue (only problematic at certain screen resolutions)?


I have a .NET application dependent on ArcGIS 9.3.1 which I am upgrading to ArcGIS 10.


I have an AxMapControl sat in a panel in a split container on a tab. The Dockstyle is set to Fill.


Since upgrading to ArcGIS 10 from 9.3.1, the painting of the map inside the map control has become inconsistent.



The initial size of the map as painted is 'wrong' and the map ends up only filling, say, half the panel, and a second vertical scrollbar appears beside the map. This second scrollbar is a glitch; you cannot use it, and it is eventually painted over. The issue with the the map seems to be painting only: all other information presented (for example in the legend) is as if the map were painted correctly across the whole panel.


After a few operations (such as zooming in/out etc.) the map painting seems to 'catch up' and the map is painted correctly, filling the whole panel. This 'catching up' seems to get faster each time I run the application which leads me to suspect some sort of timing or caching issue.


There is no consistency about when the problem manifests. Sometimes adjusting the screen resolution affects it, other times not.


This seems to be a problem internal to the control. Does anyone have a workaround (other than reverting to the 9.3.1 DLLS)?


UPDATE: I have tried the following without success:




Answer




The IScreenDisplay interface has a ScaleContents property; set this to true




As this question reveals, ESRI changed the default behaviour of the map control at ArcGIS 10.



Less redrawing in data view


In previous versions of ArcMap, if you changed the size of the ArcMap display while working in data view, either by resizing the ArcMap window or by docking/undocking/resizing a dockable window, by default your map was completely redrawn to fit inside the available display area. So the scale changed and the extent stayed the same (although you may have seen some extra geographic coverage based on how well the extent fit inside the new shape of the display area). At version 10, the default drawing behavior in data view has been changed so that when the display size is changed, your map is no longer completely redrawn to fit inside the display. Instead, the scale stays the same and the extent will change. If you make the display bigger, you'll see a larger geographic extent, and vice versa.


This has the performance advantage that the portion of the display unaffected by resizing doesn't need to be redrawn at all. For example, if you close a docked window, only the portion of the display that was obscured by the window needs to be redrawn. It is also easier to work with the display because geographic features on your map don't move around as you dock and undock windows. Features on your map remain in the same location in the display until you manually pan or zoom the map.



(src: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_s_new_for_map_display_and_navigation/00qp0000001w000000/)



You can reverse this change by using the IScreenDisplay interface to set the ScaleContents property to true. This can be set once the map is loaded into the control.


For me, the line of code would read:



mapControl.ActiveView.ScreenDisplay.ScaleContents = True;


This restores the old map redrawing behaviour - and as a side-effect, cures the redrawing problem explained here!


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...