forked from goupviet/ManagedWin32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IconPickerDialog.cs
39 lines (29 loc) · 871 Bytes
/
IconPickerDialog.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
using ManagedWin32.Api;
using Microsoft.Win32;
using System;
using System.Text;
namespace ManagedWin32
{
public class IconPickerDialog : CommonDialog
{
const int MAX_PATH = 260;
public string FileName { get; set; }
public int IconIndex { get; set; }
protected override bool RunDialog(IntPtr OwnerWindow)
{
var pathBuffer = new StringBuilder(FileName, MAX_PATH);
int i;
var result = Shell32.SHPickIconDialog(OwnerWindow, pathBuffer, MAX_PATH, out i);
if (!result)
return false;
FileName = Environment.ExpandEnvironmentVariables(pathBuffer.ToString());
IconIndex = i;
return true;
}
public override void Reset()
{
FileName = null;
IconIndex = 0;
}
}
}