Skip to content

Commit 1d7ffca

Browse files
authored
set onenote to foreground after clicking a page link (#1905)
#1902
1 parent 8e49cc8 commit 1d7ffca

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

OneMoreCalendar/OneNoteProvider.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace OneMoreCalendar
1111
using System.Globalization;
1212
using System.IO;
1313
using System.Linq;
14+
using System.Runtime.InteropServices;
1415
using System.Threading.Tasks;
1516
using System.Xml.Linq;
1617

@@ -21,6 +22,10 @@ namespace OneMoreCalendar
2122
/// </summary>
2223
internal class OneNoteProvider
2324
{
25+
[DllImport("user32.dll")]
26+
[return: MarshalAs(UnmanagedType.Bool)]
27+
public static extern bool SetForegroundWindow(IntPtr hWnd);
28+
2429

2530
/// <summary>
2631
/// Export an EMF representation of the specified page to the TEMP folder
@@ -232,6 +237,7 @@ public async Task NavigateTo(string pageID)
232237
if (!string.IsNullOrEmpty(url))
233238
{
234239
await one.NavigateTo(url);
240+
SetForegroundWindow(one.WindowHandle);
235241
}
236242
}
237243
}

0 commit comments

Comments
 (0)