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: Custom Icon and Cursor
View page
Source of version: 4
(current)
{maketoc} !!Creating a Custom Icon and Mouse Cursor for an Ogre App [MS Windows] __Note:__ Both methods listed below work only on Microsoft Windows. However, if you are targeting the windows platform for a release of your application, they are quite useful. Also, both of the below code fragments should be called only after Ogre has created the default window for your application via ''mRoot->initialise( ... )''. !!Icon Here is a much cleaner and simpler way of setting or changing an icon for a window on the fly: __Note:__ Make sure you have created an icon resource in Visual Studio, and that the ID is IDI_ICON1 (or just change IDI_ICON1 to whatever you'd like in the below code). {CODE(wrap="1", colors="c++")} #ifdef WIN32 HWND hwnd; mRenderWindow->getCustomAttribute("WINDOW", &hwnd); HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); SetClassLong (hwnd, GCL_HICON, (LONG)LoadIcon (hInst, MAKEINTRESOURCE (IDI_ICON1))); #endif{CODE} !!Cursor Very similar code can also be used for changing the mouse cursor for a window: __Note:__ Make sure you have created a cursor resource in Visual Studio, and that the ID is IDC_POINTER (or just change IDC_POINTER to whatever you'd like in the below code). {CODE(wrap="1", colors="c++")} #ifdef WIN32 HWND hwnd; mRenderWindow->getCustomAttribute("WINDOW", &hwnd); HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); SetClassLong (hwnd, GCL_HCURSOR, (LONG)LoadCursor (hInst, MAKEINTRESOURCE (IDC_POINTER))); #endif{CODE} __Note:__ If you're using OIS, by default your mouse is in exclusive mode, so the cursor is hidden. If you want to show your cursor (which will make your cursor dependent upon Windows), use the following parameters when initialising your OIS parameter list: {CODE(wrap="1", colors="c++")} paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" ))); paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));{CODE} !!Icon & Cursor Both of the above can also be combined to set both an icon and a cursor with minimal code: {CODE(wrap="1", colors="c++")} #ifdef WIN32 HWND hwnd; mRenderWindow->getCustomAttribute("WINDOW", &hwnd); HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); SetClassLong (hwnd, GCL_HICON, (LONG)LoadIcon (hInst, MAKEINTRESOURCE (IDI_ICON1))); SetClassLong (hwnd, GCL_HCURSOR, (LONG)LoadCursor (hInst, MAKEINTRESOURCE (IDC_POINTER))); #endif{CODE}
Search by Tags
Search Wiki by Freetags
Latest Changes
One Function Ogre
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
...more
Search
Find
Advanced
Search Help
Online Users
333 online users