Skip to content

Commit 1c5a816

Browse files
authored
Merge pull request #673 from stevencohn/672-fix-hanging-bubble-window
672 Fix hanging MoreBubbleWindow
2 parents f0f1dc1 + b08ee8c commit 1c5a816

File tree

4 files changed

+78
-23
lines changed

4 files changed

+78
-23
lines changed

OneMore/OneMore.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@
629629
<Compile Include="UI\MoreLinkLabel.cs">
630630
<SubType>Component</SubType>
631631
</Compile>
632+
<Compile Include="UI\MoreRichLabel.cs">
633+
<SubType>Component</SubType>
634+
</Compile>
632635
<Compile Include="UI\ProgressDialog.cs">
633636
<SubType>Form</SubType>
634637
</Compile>

OneMore/UI/MoreBubbleWindow.Designer.cs

Lines changed: 21 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OneMore/UI/MoreBubbleWindow.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public MoreBubbleWindow()
4242

4343
public void SetMessage(string text)
4444
{
45-
textBox.Text = text;
45+
messageBox.Text = text;
4646
}
4747

4848

@@ -54,6 +54,13 @@ public static DialogResult Show(IWin32Window owner, string text)
5454
}
5555

5656

57+
private void PauseTimer(object sender, EventArgs e)
58+
{
59+
timer.Stop();
60+
Opacity = 100;
61+
}
62+
63+
5764
private void Tick(object sender, EventArgs e)
5865
{
5966
time += timer.Interval;
@@ -73,6 +80,12 @@ private void Tick(object sender, EventArgs e)
7380
}
7481

7582

83+
private void Unclick(object sender, EventArgs e)
84+
{
85+
okButton.Focus();
86+
}
87+
88+
7689
protected override void OnLoad(EventArgs e)
7790
{
7891
base.OnLoad(e);
@@ -117,11 +130,6 @@ private void CloseWindow(object sender, EventArgs e)
117130
timer.Stop();
118131
timer.Dispose();
119132
Close();
120-
121-
// attempt to reactive OneNote window and text caret...
122-
// doesn't fully activate but at least sets focus
123-
using var one = new OneNote();
124-
Native.SetForegroundWindow(one.WindowHandle);
125133
}
126134
}
127135
}

OneMore/UI/MoreRichLabel.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//************************************************************************************************
2+
// Copyright © 2022 Steven M Cohn. All rights reserved.
3+
//************************************************************************************************
4+
5+
namespace River.OneMoreAddIn.UI
6+
{
7+
using System.ComponentModel;
8+
using System.Windows.Forms;
9+
10+
11+
internal class MoreRichLabel : RichTextBox
12+
{
13+
private const int WM_SETFOCUS = 0x0007;
14+
private const int WM_KILLFOCUS = 0x0008;
15+
16+
17+
public MoreRichLabel()
18+
: base()
19+
{
20+
21+
}
22+
23+
24+
/// <summary>
25+
/// Gets or sets whether text can be selected. Default is false.
26+
/// </summary>
27+
[DefaultValue(false)]
28+
public bool Selectable { get; set; } = false;
29+
30+
31+
protected override void WndProc(ref Message m)
32+
{
33+
if (m.Msg == WM_SETFOCUS && !Selectable)
34+
{
35+
m.Msg = WM_KILLFOCUS;
36+
}
37+
base.WndProc(ref m);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)