gpt4 book ai didi

c# -\charscalexN 不适用于 RichTextBox

转载 作者:太空宇宙 更新时间:2023-11-03 14:53:39 24 4
gpt4 key购买 nike

图片:

我的代码:

private void BtnSetContent_Click(object sender, EventArgs e)
{
string fn = @"C:\Users\User\Documents\보통 글자.rtf";
string towrite = "";
StreamReader sr = new StreamReader(fn);
while (sr.Peek() >= 0)
{
towrite += sr.ReadLine() + " ";
}
sr.Close();
MessageBox.Show(towrite);
RTBMainText.Rtf = towrite;
}

我想在 RichTextBox 上显示 200% 拉伸(stretch)的文本(例如 {\charscalex200 Stretched}),但是这个关键字似乎被忽略了,所以 charscalex显示的文本没有变化。

是否有任何解决方案(普通的或一些额外的库)来显示拉伸(stretch)的文本?

最佳答案

您需要使用最新版本的 RichText 库。创建您自己的 RichTextBox 控件并覆盖 CreateParams 属性:

using System.Runtime.InteropServices;

public class RichBox : RichTextBox {

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr LoadLibrary(string lpFileName);

protected override CreateParams CreateParams {
get {
var cp = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero) {
cp.ClassName = "RICHEDIT50W";
}
return cp;
}
}
}

结果:

enter image description here

重建您的解决方案并使用此控件代替标准 RichTextBox 控件。

此外,您可以只使用 LoadFile 方法:

richTextBox1.LoadFile(@"C:\Users\User\Documents\보통 글자.rtf");

关于c# -\charscalexN 不适用于 RichTextBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50650909/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com