1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-13 17:34:08 +02:00

Update RichTextLabel to use RichTextBox v5 and add URL wrapper

This commit is contained in:
chylex 2016-04-11 01:50:38 +02:00
parent 0c7d625391
commit 383a7c8aac
2 changed files with 26 additions and 0 deletions

View File

@ -13,6 +13,28 @@ public static string Wrap(string str){
return rtf;
}
/// <summary>
/// Wraps URL tags around a link.
/// </summary>
public static string AddLink(string url){
return @"{\field{\*\fldinst{HYPERLINK """+url+@"""}}{\fldrslt{\ul\cf1 "+url+@"}}}";
}
/// <summary>
/// Uses v5 of RichTextBox, which fixes URLs and other crap.
/// </summary>
protected override CreateParams CreateParams{
get{
CreateParams createParams = base.CreateParams;
if (Program.LoadLibrary("msftedit.dll") != IntPtr.Zero){
createParams.ClassName = "RICHEDIT50W";
}
return createParams;
}
}
public RichTextLabel(){
InitializeComponent();

View File

@ -2,6 +2,7 @@
using System;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using TweetDick.Configuration;
using TweetDick.Core;
@ -29,6 +30,9 @@ static Program(){
UserConfig = UserConfig.Load(Path.Combine(StoragePath,"TD_UserConfig.cfg"));
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr LoadLibrary(string name);
[STAThread]
private static void Main(){
Application.EnableVisualStyles();