mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-05-30 10:27:14 +00:00
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:
parent
a8231a5eb4
commit
cb1c73e827
|
@ -813,11 +813,22 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IsWindowVisible
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool IsWindowVisible(IntPtr intPtr);
|
public static extern bool IsWindowVisible(IntPtr intPtr);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region LoadIcon
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Display settings
|
#region Display settings
|
||||||
|
|
||||||
#region ChangeDisplaySettings
|
#region ChangeDisplaySettings
|
||||||
|
@ -2701,7 +2712,7 @@ namespace OpenTK.Platform.Windows
|
||||||
#region ShFileInfo
|
#region ShFileInfo
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||||
public struct SHFILEINFO
|
struct SHFILEINFO
|
||||||
{
|
{
|
||||||
public IntPtr hIcon;
|
public IntPtr hIcon;
|
||||||
public int iIcon;
|
public int iIcon;
|
||||||
|
|
|
@ -588,26 +588,29 @@ namespace OpenTK.Platform.Windows
|
||||||
// Gets the shell application icon for the executing process or the default icon, if not available.
|
// Gets the shell application icon for the executing process or the default icon, if not available.
|
||||||
Icon GetApplicationIcon()
|
Icon GetApplicationIcon()
|
||||||
{
|
{
|
||||||
IntPtr retval = IntPtr.Zero;
|
//return Icon.FromHandle(Functions.LoadIcon(Process.GetCurrentProcess().Handle, ""));
|
||||||
try
|
try { return Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().CodeBase); }
|
||||||
{
|
catch { return null; }
|
||||||
SHFILEINFO info = new SHFILEINFO();
|
//IntPtr retval = IntPtr.Zero;
|
||||||
info.szDisplayName = "";
|
//try
|
||||||
info.szTypeName = "";
|
//{
|
||||||
|
// SHFILEINFO info = new SHFILEINFO();
|
||||||
|
// info.szDisplayName = "";
|
||||||
|
// info.szTypeName = "";
|
||||||
|
|
||||||
int cbFileInfo = Marshal.SizeOf(info);
|
// int cbFileInfo = Marshal.SizeOf(info);
|
||||||
ShGetFileIconFlags flags = ShGetFileIconFlags.Icon | ShGetFileIconFlags.SmallIcon | ShGetFileIconFlags.UseFileAttributes;
|
// ShGetFileIconFlags flags = ShGetFileIconFlags.Icon | ShGetFileIconFlags.SmallIcon | ShGetFileIconFlags.UseFileAttributes;
|
||||||
string path = System.Reflection.Assembly.GetEntryAssembly().CodeBase;
|
// string path = System.Reflection.Assembly.GetEntryAssembly().CodeBase;
|
||||||
|
|
||||||
retval = Functions.SHGetFileInfo(path, 256, ref info, (uint)cbFileInfo, flags);
|
// retval = Functions.SHGetFileInfo(path, 256, ref info, (uint)cbFileInfo, flags);
|
||||||
return Icon.FromHandle(info.hIcon);
|
// return Icon.FromHandle(info.hIcon);
|
||||||
}
|
//}
|
||||||
catch
|
//catch
|
||||||
{
|
//{
|
||||||
// Shallow exceptions and fall-back to default icon.
|
// // Shallow exceptions and fall-back to default icon.
|
||||||
Debug.Print("SHGetFileInfo failed, return value: {0}", retval);
|
// Debug.Print("SHGetFileInfo failed, return value: {0}", retval);
|
||||||
return null;
|
// return null;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue