可能是类似这样的:
Graphics g = CreateGraphics();
IntPtr hRefDC = g.GetHdc();
Metafile m = new Metafile( textBox1.Text, hRefDC );
g.ReleaseHdc( hRefDC );
Graphics gMeta = Graphics.FromImage( m );
gMeta.DrawLine( Pens.Blue, 0, 0, 1000, 1000 );
----
如有任何问题,请回复本贴。
亨利上
p.s.: 我将C#翻译成VB.NET, 你看能不能用?
Dim g As Graphics = CreateGraphics()
Dim hRefDC As IntPtr = g.GetHdc()
Dim m As Metafile = New Metafile(textBox1.Text, hRefDC)
g.ReleaseHdc(hRefDC)
Dim gMeta As Graphics = Graphics.FromImage(m)
gMeta.DrawLine(Pens.Blue, 0, 0, 1000, 1000)
I got this from web by c#, you can convert to vb.net easily, but I had no time to test it, pls try it yourself.
To create a metafile for writing, use one of the constructors which takes an HDC as a parameter (IntPtr). You can get the IntPtr from a
Graphics.GetHdc() call.
Maybe like this:
Graphics g = CreateGraphics();
IntPtr hRefDC = g.GetHdc();
Metafile m = new Metafile( textBox1.Text, hRefDC );
g.ReleaseHdc( hRefDC );
Graphics gMeta = Graphics.FromImage( m );
gMeta.DrawLine( Pens.Blue, 0, 0, 1000, 1000 );