-
Notifications
You must be signed in to change notification settings - Fork 4
/
HandleUtility.cs
57 lines (48 loc) · 1.98 KB
/
HandleUtility.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace Menees.Windows
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
#endregion
/// <summary>
/// Methods for working with windows and dialogs using an IntPtr window handle.
/// </summary>
/// <remarks>
/// This provides low-level APIs that need to be shared with Menees.Windows.Forms
/// and Menees.Windows.Presentation.
/// </remarks>
public static class HandleUtility
{
#region Public Properties
/// <summary>
/// Gets whether the current application is active (i.e., owns the foreground window).
/// </summary>
public static bool IsApplicationActivated => NativeMethods.IsApplicationActivated;
#endregion
#region Public Methods
/// <summary>
/// Sets the show state of a window without waiting for the operation to complete by
/// posting a ShowWindow command to the message queue of the given window.
/// </summary>
/// <param name="hWnd">The handle of the window to post to.</param>
/// <param name="command">The command to post.</param>
/// <returns>True if the command was posted; false otherwise.</returns>
public static bool PostShowWindowCommand(IntPtr hWnd, ShowWindowCommand command)
=> NativeMethods.PostShowWindowCommand(hWnd, command);
/// <summary>
/// Selects a file system path and allows the user to type in a path if necessary.
/// </summary>
/// <param name="ownerHandle">The handle of the owner of the displayed modal dialog.</param>
/// <param name="title">A short description of the path being selected.</param>
/// <param name="initialFolder">The initial path to select.</param>
/// <returns>The path the user selected if they pressed OK. Null otherwise (e.g., the user canceled).</returns>
public static string? SelectFolder(IntPtr? ownerHandle, string? title, string? initialFolder)
=> NativeMethods.SelectFolder(ownerHandle, title, initialFolder);
#endregion
}
}