Max IDE - Window Icon

BlitzMax Forums/BlitzMax Programming/Max IDE - Window Icon

EOF(Posted 2005) [#1]
[EDIT] New guide here:

Adding icons to BlitzMax Win32 executables



I re-compiled the IDE with some of the tweaks available from Perty etc..
What I noticed to my suprise is the exe still retains it's program icon in both the exe file and the IDE window.

Anyone know how this occurs? I see the following in the source:
?win32
Import "maxicons.o"
Import "-luser32"
?
Is this the 'magic' part which attaches the icons?
Anyone clued up on how I can create my own "icon.o" file?


Perturbatio(Posted 2005) [#2]
it looks like it's using a precompiled resource file.


taxlerendiosk(Posted 2005) [#3]
This is the code I've got to get the icon from the exe (insert with reshacker) to be used by a window:
?Win32

Import BRL.MaxGUI
Import "-lshell32"

Extern "Win32"
	Function LoadIcon:Int(hWnd:Int, file$z, index:Int) = "ExtractIconA@12"
	Function SetClassLong:Int(hWnd:Int, nIndex:Int, dwNewLong:Int) = "SetClassLongA@12"
End Extern

?

Function Win32_WindowIconFromExe(Window:TGadget)
?Win32
	Local hWnd:Int = Query(Window, 1)
	Local icon:Int = LoadIcon(hWnd,AppFile,0)
	SetClassLong(hWnd,-14,icon)
?
End Function

Is this not necessary with the .o file then?


Perturbatio(Posted 2005) [#4]
Is this not necessary with the .o file then?

MaxIDE certainly doesn't do that.


FlameDuck(Posted 2005) [#5]
Anyone clued up on how I can create my own "icon.o" file?
There is a resource compiler that comes with MinGW. If you have your own .ico files and a suitable .rc file it will generate the .o file for you.


EOF(Posted 2005) [#6]
FD,
Ok, I have got the following 2 files by mucking around with ResHack:

> file: resfile.rc

which contains this entry:
1 ICON "Icon_1.ico"

> file: Icon_1.ico
the icon I want to import
Any chance of a quick tutorial detailing how I generate the *.o file?


Yan(Posted 2005) [#7]
Create a text file containing the following...
<the resource name you want for the icon> ICON <full path of icon file (use forward slashes)>

save this as resourcefile.rc file.

From the command console...
<MinGW path>\bin\windres -i <full path>/resourcefile.rc -o <ouput path>/mycoff.o

That should work, but you'll have to make sure there are no spaces in the filepaths.


EOF(Posted 2005) [#8]
YanCanCode,

It works.
Just had to strip out double-quotes and add in the full path to the icon in the *.rc file.

Great help. Thank you.


Yan(Posted 2005) [#9]
Oops...Sorry, you have to use forward slashes in the file paths (in the .rc file too).

Oh, and you can use '1' as the resource name.

[edit]
Ahhh...Okay, glad you got it working.

(and corrected previous post)
[/edit]


taxlerendiosk(Posted 2005) [#10]
I'm trying to set one window to one icon and another window to another, in the same app, but it never works properly - either they both get set to the same icon, or it's correct in the windows but wrong in the start bar and alt-tab bar, or there's no icons at all. Is this something that can be fixed or is it an inevitable consequence of how MaxGUI works, or what?


T-Light(Posted 2005) [#11]
Yeah, what denzilquixode said.

By the way, appreciate that these window icons don't/won't can't show up in other os's outside of windows, but I really thought we'd have some way of including icons for our own code directly within max.

Is this due out in an update? You can't really release a GUI app with a blank box for an icon, it would look amateurish.


po(Posted 2005) [#12]
I've managed to get a .o working so that I can have a 32x32 icon. But I don't know how to combine both the 32x32 and the 16x16 icons together in one icon group(like the blitzide has it set up). Any help would be great.


FlameDuck(Posted 2005) [#13]
I use Microangelo, but I'm sure any similar icon editor will do the same.


po(Posted 2005) [#14]
Well I'm sure there is a way of doing it in the .rc file. I don't mind using MinGW, reshacker, command prompt, and Irfanview to get the job done.

The BlitzIDE one has it set up so that there are 2 icons, both the 32x32 executable one (which I can do) and the 16x16 one. In reshacker they are both under seperate folders under 'Icons'. I can get this far by making my .rc file like so:
1 ICON C:/icons/fonteye.ico
2 ICON C:/icons/fonteyemini.ico

But the BMX one also has one folder under 'Icon Groups' with one file that is a combination of the two different icons. This is the part I am having trouble with. When I use the .rc file above, it makes two different folders under 'Icon Groups' with two different files, rather than one icon group with one combination file. So I think it is just a question of putting the right stuff in my .rc file. I tried looking up .rc files but no luck. Anybody know?

Did that make sense or...?

I currently have one 32x32 .ico and one 16x16 .ico


Yan(Posted 2005) [#15]
A single .ico file can contain icons of varying colours depths and sizes.

There are a few free icon editors about (google for 'snidesoft') that will help you put the icons into one .ico file.


po(Posted 2005) [#16]
ah, ok, thanks.


po(Posted 2005) [#17]
Sorry to be a bother, but I still can't get it to work. :(
I used SnIcon to make an icon with both the images combined, made it into a .o file, then tried it in blitz, but the 16x16 icon still didn't work(the 32x32 one did). Well, it did sorta work, because you see the little icon when the exe is displayed in list form in explorer. But I still can't see the icon in the title bar of my blitzGUI app. I compared both my .exe and the BlitzIDE .exe in ResHack:

They are almost identical except for the actual names of the icons. Any ideas?


skidracer(Posted 2005) [#18]
You must use the same group name (101).


po(Posted 2005) [#19]
Errmm... How do I do that? I tried putting it in the .rc file:
101 ICON C:/icons/icon.ico
but it doesn't change a thing.


Grisu(Posted 2005) [#20]
Can someone help here please, we can't get this working!


po(Posted 2005) [#21]
*bump*


Jay Kyburz(Posted 2006) [#22]
hey, ive just beeing trying to do this for my app. Anybody found a nice neat way of setting the windows icons for the app.

Sounds like this would make a good mod for somebody. hint hint.


assari(Posted 2006) [#23]
Try this tutorial from Eikon Adding icons to BlitzMax Win32 executables


Jay Kyburz(Posted 2006) [#24]
thansk


Moogles(Posted 2006) [#25]
still didnt work. the one that did was a post which told me to edit line 49 of d3d7graphics.bmx and after that it all worked. Just so people know. :)
http://blitzmax.com/Community/posts.php?topic=53816
Theres teh link.