您的位置:首页 > 其它

WinForm的自动缩放(跟随系统字体大小的改变)

2009-03-02 16:35 696 查看
当我们把系统的字体改为大字号的话,如果我们的Form上的text和control不跟着变大的话,那会使我们的界面很难看。但是很幸运的是在WinForm中已经提供了这个功能,使用也很方便,只需要在Form的Load事件中从新设置Form的字体为系统的字体。

二 请看效果如下:(均为系统字体为特大号时)

修改后:using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WinFormAutoScale

namespace WinFormAutoScale

(注意上面代码中的Form的AutoScaleMode属性的设置)

四 求助:在MFC中的Dialog并没有提供类似的功能,要实现Dialog的自动的缩放,要使Dialog上texts和controls都随着系统的字体大小缩放,而且还不仅跟字体有关。那位有好的办法,谢谢!

五 参考:
http://www.cppblog.com/mzty/archive/2006/11/13/15131.html http://msdn2.microsoft.com/en-us/library/ms229605.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: