Page 1 of 2

Icons

Posted: Sun Jan 04, 2004 2:51 pm
by Lillo
I searched all the Tech Demo but I didn't find the way to add an Icon to my application. How can I?

Posted: Sun Jan 04, 2004 5:10 pm
by rt

Posted: Mon Jan 05, 2004 9:01 am
by VeneX
Project -> add to project -> New -> resource script
Left at your C++ code there is a tab added called resources, select this.
right click on the resources map and chose import to load your .ico

Posted: Mon Jan 05, 2004 2:47 pm
by keless
in DevCpp its even easier. Just go to project settings and click on the choose icon button.

Posted: Thu Jan 08, 2004 8:58 pm
by Simo
Finally I made it! Thanks to everybody. I was wondering if there's a way to set also the small icon on the left of the window when running in windowed mode. And if I'm not asking too much there's a way to get the HWND pointer to the window used by Irrlicht?

Posted: Thu Jan 08, 2004 9:22 pm
by keless
you can use gui_environment->draw2DImage to paste an image to the screen (on top of anything being rendered in 3d).

you cant get the hDC from IrrLicht normally. you'd have to change the engine's code and recompile it. someone is actually doing this already to make IrrLicht render to a specific window, and using MFC for other things.

Posted: Thu Jan 08, 2004 9:25 pm
by Boogle
Well, perhaps they are still working on that.. :)

Posted: Thu Jan 08, 2004 9:58 pm
by Serg Nechaeff
HWND hwnd= FindWindow (0, "Your caption");

And it's strange but Resource Hacker doesn't see app's resources :?:

Posted: Fri Jan 09, 2004 3:28 pm
by Simo
Probably you didn't undertand me but I was asking if there's a way to change the small icon on the left of the title bar, left of the title. By default I have the win32 application icon but I'd like to change it when running in windowed mode, as it was possible in win32 programming.

Posted: Fri Jan 09, 2004 3:39 pm
by qwe
i think that you would also have to recompile the engine for that... dunno :?

Posted: Fri Jan 09, 2004 4:27 pm
by keless
Simo wrote:Probably you didn't undertand me but I was asking if there's a way to change the small icon on the left of the title bar, left of the title. By default I have the win32 application icon but I'd like to change it when running in windowed mode, as it was possible in win32 programming.
If you look at the first post by Venex, and the first post by me, we already answered your question. The window's icon is something called a 'Resource' which you compile into your project. This is true for all Win32 programs, and it has nothing to do with IrrLicht itself.
In the DevCpp compiler-- this is absolutely simple. As I said. For MSVC, do what Venex said:
Project -> add to project -> New -> resource script
Left at your C++ code there is a tab added called resources, select this.
right click on the resources map and chose import to load your .ico

Posted: Fri Jan 09, 2004 4:34 pm
by keless
I'd like to change it when running in windowed mode
oh-- you mean change the icon WHILE the program is running?

Posted: Sat Jan 10, 2004 10:05 am
by Simo
Not while program is running. I'll try to explain better and I'm planning to improve my english knowledge. Well thanks to your suggest I'm able to change the icon of my executable but not the small icon I'm talking about. I'm looking at Internet Explorer now and the icon is in the upper left corner in the title bar, is represented by a small paper sheet and the classic IE icon. When programming in Win32 while creating a window there's a way to declare that icon so I'm asking if there's a way also in Irrlicht to set that icon as I made for the executable, and I think that should be done before starting the device...

I'm using MSVC 6.0 if this could be of any help.

Posted: Sat Jan 10, 2004 3:53 pm
by Guest
Here is what I think must be used(from MSDN), using Win32:

Code: Select all

An application sends the WM_SETICON message to associate a new large or small icon with a window. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption. 

To send this message, call the SendMessage function with the following parameters. 

SendMessage( 
  (HWND) hWnd,              // handle to destination window 
  WM_SETICON,               // message to send
  (WPARAM) wParam,          // icon type
  (LPARAM) lParam           // handle to icon (HICON)
);

So, supposing you have resource-based icon called IDR_MYICON, you should write this:

Code: Select all

HICON hIcon = LoadIcon(my_instance, IDR_MYICON);
// Set big icon (ALT+TAB)
SendMessage(my_hwnd,WM_SETICON,ICON_BIG,hIcon);
// Set little icon (titlebar) 
SendMessage(my_hwnd,WM_SETICON,ICON_BIG,hIcon);
If you can access my_instance and my_hwnd from outside Irrlicht, you don't have to modify the engine. Othewise, you'd have to insert this code into the window-creation engine's code.

In case you use MFC, this is the code:

Code: Select all

BOOL MyApp::InitInstance()
{
...
pFrame->SetIcon(LoadIcon(IDR_MAINFRAME),false);
pFrame->SetIcon(LoadIcon(IDR_MAINFRAME),true);
}

Please try it and tell me if it finally worked :P

Posted: Sat Jan 10, 2004 3:54 pm
by Zaelsius
Forgot to log in :oops: