2

我似乎在用 C# 实现 SetMapMode 时遇到了一些问题。不是 C# 方面的专家,所以我看到错误并不太惊讶。即使认为编译很好 DrawLine 也会抛出 InvalidOperationException。有任何想法吗 ?

[DllImport("gdi32.dll")]
static extern int SetMapMode(IntPtr hdc, int fnMapMode);

myPen = new Pen(Color.Black, 1);
formGraphics = envMap.CreateGraphics();
IntPtr hdc = formGraphics.GetHdc();
SetMapMode(hdc, 3); // MM_LOMETRIC
formGraphics.DrawLine(myPen, (2 * rect.Right - 60) - 15, 8, (2 * rect.Right - 60), 0);
formGraphics.DrawLine(myPen, (2 * rect.Right - 60), 0, (2 * rect.Right - 60) - 15, -8);

提前致谢

4

1 回答 1

2

最接近的事情是PageUnitGraphics对象上设置。据我所知,没有等同于MM_LOMETRIC,但有Millimeter

您可能可以将其与ScaleTransform获得所需的效果相结合。

于 2011-11-01T06:00:55.443 回答