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]