Change of a icon and caption of the Application         Simple way (Windows)

Change of a icon and caption of the Application

The code was tested under OpenGL and DirectX, version OGRE 1.2.2 Dagon, but I think with old versions of problems will not be.

Create file SetMainWindowInfo.h and add next code:

 *  SetMainWindowInfo.h
 *  Смена значка и имени окна OGRE DirectX и OpenGL [ (]
 #ifndef __SetMainWindowInfo_H__
 #define __SetMainWindowInfo_H__
 #include "windows.h"
 #include "resource.h"
 void g_setMainWindowInfo(char *strWindowCaption, unsigned int uIconResourceID)
     HWND hWnd = ::FindWindow("OgreD3D9Wnd", "OGRE Render Window");
     if (!::IsWindow(hWnd)) hWnd = ::FindWindow("OgreGLWindow", "OGRE Render Window");
     if (::IsWindow(hWnd)) {
         if (strWindowCaption) ::SetWindowText(hWnd, strWindowCaption);
         // берем имя нашего экзешника
         char buf[1024];
         ::GetModuleFileName(0, (LPCH)&buf, 1024);
         // берем инстанс нашего модуля
         HINSTANCE instance = ::GetModuleHandle(buf);
         // побыстрому грузим иконку
         HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(uIconResourceID));
         if (hIcon) {
             ::SendMessage(hWnd, WM_SETICON, 1, (LPARAM)hIcon);
             ::SendMessage(hWnd, WM_SETICON, 0, (LPARAM)hIcon);

Now in your project in the beginning add:

#include "SetMainWindowInfo.h"

And at initialization start a method:

g_setMainWindowInfo("Моя игра", IDI_MYGAME);

The note: the Icon should be added in resources of the project (in studio of programming).


русскоязычный сайт по OGRE