Skip to main content

History: Change of a icon and caption of the Application

Source of version: 5 (current)

Copy to clipboard
            __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:
{CODE(wrap="1", colors="c++")} /**********************************************************************************
 *  SetMainWindowInfo.h
 *  Смена значка и имени окна OGRE DirectX и OpenGL [my.name (my.work(a)inbox.ru)]
 ***********************************************************************************/
 
 #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);
         }
     }
 }
 
 #endif
{CODE}

Now in your project in the beginning add:
{CODE(wrap="1", colors="c++")} #include "SetMainWindowInfo.h"{CODE}

And at initialization start a method:
{CODE(wrap="1", colors="c++")} g_setMainWindowInfo("Моя игра", IDI_MYGAME);{CODE}

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



Добавленно [mailto:my.friends@inbox.ru|my.name]

[http://www.ogre3d.org.ru|русскоязычный сайт по OGRE]