44using System . Windows . Automation ;
55using System . Runtime . InteropServices ;
66using System . IO ;
7+ using System . Drawing ;
78using WindowTextExtractor . Extensions ;
89using WindowTextExtractor . Utils ;
910
1011namespace 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