I am using ArcGIS 10.0/ArcObjects and Python 2.6. I am trying to get the usage of the ITextSymbol.GetTextSize method correct. The syntax, as established in an earlier question, is:
dblx, dbly = pTextSymbol.GetTextSize(pDisplay.hDC, pDisplay.DisplayTransformation, txt)
and the outparameters are returned just fine. My problem is in figuring out how to use this method so that it does not screw up ArcMap's screen cache. ESRI documentation indicates that it should be surrounded by calls to IDisplay.StartDrawing and IDisplay.FinishDrawing so that the input hDC will be correct. (Indeed, calling GetTextSize without the start and finish drawing results in an invalid hDC.) The syntax that I am using for StartDrawing is as follows:
pDisplay.StartDrawing(0, esriDisplay.esriNoScreenCache)
I have tried both 0 (as discussed in documentation) and pDipsplay.hDC for the first parameter of StartDrawing, but the ArcMap screen still gets stuck in one place. (Panning just causes a redraw from cache right back to the same place.) Either input for the first parameter results in valid outparams but a stuck screen. The problem could also be with the esirNoScreenCache constant, I suppose, but I don't see how. I am not trying to draw anything to the screen at this point. I'm just operating on a TextSymbol, not a TextElement or the like. pDisplay and txt are both valid, in-process objects, so the problem, I think, is with the hDC or the screen cache. I'm at a loss to figure out which. Any insights are greatly welcomed.