如何使用Font作为变量? [英] How to use Font as a variable?
问题描述
我会有一个快速的问题:
我必须包含到一个视觉C ++ / CLR项目,以便能够使用 Font ^
?
我试图创建一个ref类,像这样:
I would have a quick question :
What do I have to include into a visual C++/CLR project to be able to use Font^
?
I have tried to create a ref class, something like this :
[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.printing.printdocument.print(v = vs.110).aspx?cs-save-lang = 1& cs-lang = cpp
I am working on a project were I have to be able to print something, so my coding is really similiar to something like this : http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.print(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp
我试图为 Font ^
使用命名空间,类似这样:
I tried to use a namespace for the Font^
, something like this :
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
>
OR I tried to use a dll. file in order to be able to use a Font^ as a variable (specifically #using <System.Drawing.dll
>
但没有一个似乎工作了...
所以我需要的是使用 Font ^
作为一个变量,像这样:
But none seemed to work out ...
So what I would need is to use Font^
as a variable, something like this :
Font^ printFont = new System.Drawing.Font("Arial", 10);
SolidBrush myBrush = new SolidBrush(Color.Black);
任何人都可以建议一种方式允许使用字体^,因为在我的错误列表它表示Font ^ printFont是不明的。
Could anyone suggest a way to allow Font^ to be used, because in my error list it says that Font^ printFont is unidentified.
PS我是一个初学者在c + +,我真的不知道如何使用字体^作为一个变量
P.S. I am a beginner in c++, I really do not know how to use the Font^ as a variable
推荐答案
我必须有:
System::Drawing::Font ^printFont = gcnew System::Drawing::Font("Arial", 10);
而不是:
Font ^printFont = gcnew System::Drawing::Font("Arial", 10);
这篇关于如何使用Font作为变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!