Added LoadIcon method.

Made SHFILEINFO non-public.
Modified WinGLNative.cs to use Icon.ExctractAssociatedIcon() to set the application icon (needs work).
This commit is contained in:
the_fiddler 2009-10-14 22:48:19 +00:00
parent ef1a4488d0
commit 4abe4416a8
2 changed files with 33 additions and 19 deletions

View file

@ -813,11 +813,22 @@ namespace OpenTK.Platform.Windows
#endregion
#region IsWindowVisible
[DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr intPtr);
#endregion
#region LoadIcon
[DllImport("user32.dll")]
public static extern HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName);
#endregion
#endregion
#region Display settings
#region ChangeDisplaySettings
@ -2701,7 +2712,7 @@ namespace OpenTK.Platform.Windows
#region ShFileInfo
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SHFILEINFO
struct SHFILEINFO
{
public IntPtr hIcon;
public int iIcon;

View file

@ -588,26 +588,29 @@ namespace OpenTK.Platform.Windows
// Gets the shell application icon for the executing process or the default icon, if not available.
Icon GetApplicationIcon()
{
IntPtr retval = IntPtr.Zero;
try
{
SHFILEINFO info = new SHFILEINFO();
info.szDisplayName = "";
info.szTypeName = "";
//return Icon.FromHandle(Functions.LoadIcon(Process.GetCurrentProcess().Handle, ""));
try { return Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().CodeBase); }
catch { return null; }
//IntPtr retval = IntPtr.Zero;
//try
//{
// SHFILEINFO info = new SHFILEINFO();
// info.szDisplayName = "";
// info.szTypeName = "";
int cbFileInfo = Marshal.SizeOf(info);
ShGetFileIconFlags flags = ShGetFileIconFlags.Icon | ShGetFileIconFlags.SmallIcon | ShGetFileIconFlags.UseFileAttributes;
string path = System.Reflection.Assembly.GetEntryAssembly().CodeBase;
// int cbFileInfo = Marshal.SizeOf(info);
// ShGetFileIconFlags flags = ShGetFileIconFlags.Icon | ShGetFileIconFlags.SmallIcon | ShGetFileIconFlags.UseFileAttributes;
// string path = System.Reflection.Assembly.GetEntryAssembly().CodeBase;
retval = Functions.SHGetFileInfo(path, 256, ref info, (uint)cbFileInfo, flags);
return Icon.FromHandle(info.hIcon);
}
catch
{
// Shallow exceptions and fall-back to default icon.
Debug.Print("SHGetFileInfo failed, return value: {0}", retval);
return null;
}
// retval = Functions.SHGetFileInfo(path, 256, ref info, (uint)cbFileInfo, flags);
// return Icon.FromHandle(info.hIcon);
//}
//catch
//{
// // Shallow exceptions and fall-back to default icon.
// Debug.Print("SHGetFileInfo failed, return value: {0}", retval);
// return null;
//}
}
#endregion