OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Set icon of Window (Mogre)
View page
Source of version: 2
(current)
This snippet is about how to set the icon of a RenderWindow. For questions use [http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=9375|this thread]. {CODE(wrap="1", colors="c#")} [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 }{CODE} You can get the handle of a RenderWindow instance like this: {CODE(wrap="1", colors="c#")} IntPtr hwnd = new IntPtr(); MyRenderWindow.GetCustomAttribute("WINDOW", out hwnd);{CODE} Then it's just a matter of {CODE(wrap="1", colors="c#")} SetIcon(new System.Drawing.Icon("myicon.ico"), hwnd);{CODE} Another interesting thing you could do is create an [http://msdn.microsoft.com/en-us/library/bb383977.aspx|extension method] for RenderWindow... ''If you know where to get free icons it would be nice if you add the link here'' (-; A great place for free icons is [http://www.iconarchive.com/|Iron Archive]
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
50 online users