在C#中使用GetCharWidth32(BOOL GetCharWidth32(
HDC hdc, // handle to DC
UINT iFirstChar, // first character in range
UINT iLastChar, // last character in range
LPINT lpBuffer // buffer for widths
);),怎样修改GetCharWidth32的HDC的字体信息比如GetCharWidth32(e.Graphics.GetHdc(), 0, 255, buffer);
只能获得系统默认字体宽度。
HDC hdc, // handle to DC
UINT iFirstChar, // first character in range
UINT iLastChar, // last character in range
LPINT lpBuffer // buffer for widths
);),怎样修改GetCharWidth32的HDC的字体信息比如GetCharWidth32(e.Graphics.GetHdc(), 0, 255, buffer);
只能获得系统默认字体宽度。
解决方案 »
- 求一地址重写的正则(.Net)
- 用户 'sa' 登录失败。求解决!!!
- c#报表里面那个图表插件可以实现:放大曲线的功能,鼠标移到上面显示值,不像mschart那样是个死图片
- 关于集合元素中元素的访问更改问题
- HttpWebRequest提交的数据中包含特殊字符,如"&",导致提交的数据只有一部分,怎么解决
- datalist分页,datatable为数据源,总是出错,提示对象名 'dt' 无效。大家帮忙!
- 能推荐一下有什么C#的好书吗
- 一个很基本的问题,或许是一个菜鸟问题。在线等。。。。
- 这个类是怎么使用的?
- [讨论]<< Programming Microsoft Windows with C# >>
- 帮帮忙在线等 如何将 ds 和 ds1中的表 放入新建的一个DataSet中
- 高手指教,拿分请进!!!分不够可追加!!!
public static extern int GetCharWidth32 (
int hdc,
int iFirstChar,
int iLastChar,
ref int lpBuffer
);
见Graphics.MeasureString
Font font = new Font("宋体", 10);
System.IntPtr aaaa = SelectObject(e.Graphics.GetHdc(), font.ToHfont());
int[] arrint= new int[256];
GetCharWidth(e.Graphics.GetHdc(), 0, 255, arrint);
这个不对,有什么错误吗?
System.IntPtr aaaa = SelectObject(e.Graphics.GetHdc(), font.ToHfont());
int width;
GetCharWidth(e.Graphics.GetHdc(), 0, 255, ref width);
DeleteObject(...不过你的意图是什么,为什么把第二三个参数设置为0和255?
此外为什么非得用GDI的函数?上个回复里已经说过GDI+提供了这种功能,见Graphics.MeasureString方法