NxJonny
26-02-2009 00:17:18
Here is my tiny contribution to the community
You can get the handle of a RenderWindow instance like this:
Then it's just a matter of
Another interesting thing you could do is create an extension method for RenderWindow...
I'd put this on the wiki, but I wasn't sure where it should go...Is there a code snippets page for Mogre? Should I create one?
![Smile :)]({SMILIES_PATH}/icon_smile.gif)
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
private static extern int DrawMenuBar(int currentWindow);
private const int WM_SETICON = 0x80;
private const int ICON_SMALL = 0;
/// <summary>
/// Sets the icon of a window using it's handle.
/// </summary>
/// <param name="icon">The System.Drawing.Icon you wish to use as the window's icon.</param>
/// <param name="hwnd">The window's handle.</param>
public static void SetIcon(System.Drawing.Icon icon, IntPtr hwnd)
{
if (icon == null || hwnd == null || hwnd == IntPtr.Zero) // check parameters
return;
SendMessage(hwnd, WM_SETICON, (IntPtr)ICON_SMALL, (IntPtr)icon.Handle); // Set the icon with SendMessage
DrawMenuBar((int)hwnd); // Force windows to update the icon
}
You can get the handle of a RenderWindow instance like this:
IntPtr hwnd = new IntPtr();
MyRenderWindow.GetCustomAttribute("WINDOW", out hwnd);
Then it's just a matter of
SetIcon(new System.Drawing.Icon("myicon.ico"), hwnd);
Another interesting thing you could do is create an extension method for RenderWindow...
I'd put this on the wiki, but I wasn't sure where it should go...Is there a code snippets page for Mogre? Should I create one?