【问题标题】:How to use Font as a variable?如何使用字体作为变量?
【发布时间】:2014-06-05 01:31:48
【问题描述】:

我有一个简单的问题: 我必须在视觉 C++/CLR 项目中包含什么才能使用 Font^ ? 我试图创建一个 ref 类,如下所示:

[SerializableAttribute]
[ComVisibleAttribute(true)]
[TypeConverterAttribute(typeof(FontConverter))]
public ref class Font sealed : public MarshalByRefObject, 
    ICloneable, ISerializable, IDisposable

(从这里得到它: http://msdn.microsoft.com/en-us/library/system.drawing.font.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1)

我正在做一个项目,如果我必须能够打印一些东西,所以我的编码非常类似于这样的东西: http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.print(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp

我尝试为Font^ 使用命名空间,如下所示:

using namespace System;
using namespace System::IO;
using namespace System::Drawing;
using namespace System::Drawing::Printing;
using namespace System::Windows::Forms;

或者我尝试使用 dll。文件以便能够使用 Font^ 作为变量(特别是 #using <System.Drawing.dll>

但似乎没有一个成功... 所以我需要使用Font^ 作为变量,如下所示:

Font^ printFont = new System.Drawing.Font("Arial", 10);
SolidBrush myBrush = new SolidBrush(Color.Black);

谁能提出一种允许使用 Font^ 的方法,因为在我的错误列表中它说 Font^ printFont 是未识别的。

附:我是c++初学者,真的不知道怎么用Font^作为变量

【问题讨论】:

    标签: c++ fonts clr


    【解决方案1】:

    我必须:

    System::Drawing::Font ^printFont = gcnew System::Drawing::Font("Arial", 10);
    

    而不是:

    Font ^printFont = gcnew System::Drawing::Font("Arial", 10);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多