为什么LOGFONT总是显示null或0 [英] Why does LOGFONT always show null or 0

查看:60
本文介绍了为什么LOGFONT总是显示null或0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

I have the following code:

[StructLayout(LayoutKind.Sequential)]
        public struct LOGFONT
        {
            public long lfHeight;
            public long lfWidth;
            public long lfEscapement;
            public long lfOrientation;
            public long lfWeight;
            public byte lfItalic;
            public byte lfUnderline;
            public byte lfStrikeOut;
            public byte lfCharSet;
            public byte lfOutPrecision;
            public byte lfClipPrecision;
            public byte lfQuality;
            public byte lfPitchAndFamily;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string lfFaceName;

        }
        private void button1_Click(object sender, EventArgs e)
        {
            Font f = new Font("Arial", 12);
            LOGFONT LF = new LOGFONT();
            f.ToLogFont(LF);

        }


不管我使用什么字体名称,LF的所有值都为0,除了lfFaceName为空.看来f.ToLogFont行在调试器中执行,但实际上没有执行任何操作.任何帮助将不胜感激.


and no matter what font name I use all the values of LF are 0 with the exception of lfFaceName which is null. It appears that the f.ToLogFont line executes in the debugger but doesn''t actually do anything. Any help would be greatly appreciated.

推荐答案

请参见
See here I believe that if you add the CharSet attribute, it will work for you.


这篇关于为什么LOGFONT总是显示null或0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆