SetTextCharacterExtra() 示例: [DllImport("gdi32.dll", CharSet=CharSet.Auto)] public static extern int SetTextCharacterExtra( IntPtr hdc, // handle to DC int nCharExtra // extra-space value ); Font f= new Font("宋体",20); Brush b= new SolidBrush(Color.Green); String s="11111";IntPtr hwnd = new IntPtr(); hwnd = this.Handle; Graphics g = Graphics.FromHwnd(hwnd);IntPtr hdc = g.GetHdc(); SetTextCharacterExtra(hdc,40);using(Graphics gg = Graphics.FromHdc(hdc)) { gg.DrawString(s,f,b,0,0); }g.ReleaseHdc(hdc);g.Dispose();
示例:
[DllImport("gdi32.dll", CharSet=CharSet.Auto)]
public static extern int SetTextCharacterExtra(
IntPtr hdc, // handle to DC
int nCharExtra // extra-space value
);
Font f= new Font("宋体",20);
Brush b= new SolidBrush(Color.Green);
String s="11111";IntPtr hwnd = new IntPtr();
hwnd = this.Handle;
Graphics g = Graphics.FromHwnd(hwnd);IntPtr hdc = g.GetHdc();
SetTextCharacterExtra(hdc,40);using(Graphics gg = Graphics.FromHdc(hdc))
{
gg.DrawString(s,f,b,0,0);
}g.ReleaseHdc(hdc);g.Dispose();