Skip to content

Commit c3ad7ca

Browse files
committed
Set a default font name and size.
1 parent 0111ec6 commit c3ad7ca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

WindowTextExtractor/Forms/MainForm.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
using System.Windows.Automation;
55
using System.Runtime.InteropServices;
66
using System.IO;
7+
using System.Drawing;
78
using WindowTextExtractor.Extensions;
89
using WindowTextExtractor.Utils;
910

1011
namespace WindowTextExtractor.Forms
1112
{
1213
public partial class MainForm : Form, IMessageFilter
1314
{
15+
private const string DEFAULT_FONT_NAME = "Courier New";
16+
private const int DEFAULT_FONT_SIZE = 10;
17+
1418
private readonly int _processId;
1519
private readonly int _messageId;
1620
private bool _isButtonTargetMouseDown;
@@ -28,9 +32,21 @@ public MainForm()
2832
protected override void OnLoad(EventArgs e)
2933
{
3034
base.OnLoad(e);
35+
3136
Application.AddMessageFilter(this);
37+
3238
menuItemAlwaysOnTop_Click(this, EventArgs.Empty);
3339

40+
var font = new Font(DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, FontStyle.Regular, GraphicsUnit.Point);
41+
if (font.Name == DEFAULT_FONT_NAME)
42+
{
43+
txtContent.Font = font;
44+
}
45+
else
46+
{
47+
font.Dispose();
48+
}
49+
3450
#if WIN32
3551
if (Environment.Is64BitOperatingSystem)
3652
{
@@ -192,7 +208,7 @@ public bool PreFilterMessage(ref Message m)
192208
NativeMethods.QueryPasswordEdit();
193209
NativeMethods.UnsetHook(Handle, elementHandle);
194210
}
195-
}
211+
}
196212
else
197213
{
198214
var text = element.GetTextFromConsole() ?? element.GetTextFromWindow();

0 commit comments

Comments
 (0)