Icons

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Lillo

Icons

Post 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?
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post 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
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

in DevCpp its even easier. Just go to project settings and click on the choose icon button.
a screen cap is worth 0x100000 DWORDS
Simo

Post 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?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post 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.
a screen cap is worth 0x100000 DWORDS
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Well, perhaps they are still working on that.. :)
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

HWND hwnd= FindWindow (0, "Your caption");

And it's strange but Resource Hacker doesn't see app's resources :?:
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Simo

Post 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.
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

i think that you would also have to recompile the engine for that... dunno :?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post 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
a screen cap is worth 0x100000 DWORDS
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

I'd like to change it when running in windowed mode
oh-- you mean change the icon WHILE the program is running?
a screen cap is worth 0x100000 DWORDS
Simo

Post 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.
Guest

Post 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
Zaelsius
Posts: 38
Joined: Sat Aug 23, 2003 12:02 pm
Location: Alicante, Spain
Contact:

Post by Zaelsius »

Forgot to log in :oops:
Post Reply