Author Topic: Changing BlitzMax Exe, Taskbar, Titlebar icon  (Read 1897 times)

Offline NRJ

  • Jr. Member
  • **
  • Posts: 75
  • English is not my mother tongue...
Changing BlitzMax Exe, Taskbar, Titlebar icon
« on: September 12, 2017, 11:10:45 AM »
I have searched a lot of posts on wasted.nz on the same and I have found these useful threads below.

1. http://wasted.nz/posts.php?topic=53816

2. http://wasted.nz/posts.php?topic=68309

3. http://wasted.nz/codearcs.php?code=1345

The code and explanations given in these threads are very complicated for me and goes over my head. Most of the links contained in these threads are dead now.

Can someone please explain me about the process of applying own icon in blitz max.

Though, I have successfully applied the Taskbar Icon using the code given in the third link.
IF YOU CAN DREAM IT,  YOU CAN DO IT...

http://www.nksoftgames.blogspot.com

Offline sphinx

  • Full Member
  • ***
  • Posts: 183
    • Ancientsoft
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #1 on: September 12, 2017, 11:56:23 AM »
Well, just download this tool

http://www.angusj.com/resourcehacker/

after installing and run it and follow:

1 -Open your EXE file
2- Open Action menu
3- Click on Add Single Binary or Image Resource...
4- Click on Select File... button
5- Choose your Icon
6- Type the word ICON in the resource name field
7- Save

That's it!
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

Online TomToad

  • Sr. Member
  • ****
  • Posts: 340
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #2 on: September 12, 2017, 12:05:51 PM »
I don't remember where I got this from, but find it useful. Download and extract the IconMaker.7z file below.  Use a program that saves in .ico format, such as Graphics Gale, and save your icon as icon.ico in the IconMaker directory, overwriting the one there.  Double click the build.bat file.  You then end up with icon_import.o, copy that to your project directory.  Then type #import "icon_import.o" at the top of your program.  This will give you an icon for Windows Explorer as well as the task bar.  Doesn't change the icon in upper left corner of window.

This is better than using resource hacker as you only need to do the process once, instead of every time you compile your source.
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline NRJ

  • Jr. Member
  • **
  • Posts: 75
  • English is not my mother tongue...
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #3 on: September 12, 2017, 01:05:47 PM »
Thanks for the quick reply...      :)

@Sphinx

I have downloaded the resource hacker few months ago, but never used that. 
Thank you for helping , your method worked perfectly.   :)


@TomToad

Thank you Tomtoad. 

I have downloaded icon maker and applied the method you described, it works like a charm and the icon is successfully shown on both the Taskbar and exe file.   :)


Changing the Titlebar icon is not my priority though.
 ::)
IF YOU CAN DREAM IT,  YOU CAN DO IT...

http://www.nksoftgames.blogspot.com

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 74
    • Kippykip Forums!
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #4 on: October 14, 2017, 12:45:52 PM »
I know the BLIde IDE has an option for icons, but looking back I can't find a download to the free one anymore. Might reupload it sometime.

Offline NRJ

  • Jr. Member
  • **
  • Posts: 75
  • English is not my mother tongue...
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #5 on: October 14, 2017, 06:58:41 PM »
Resource hacker and iconmaker is very simple and easy to use, but it can not change the titlebar icon of the exe.
If blide ide can change the Titlebar icon then it will be useful.
IF YOU CAN DREAM IT,  YOU CAN DO IT...

http://www.nksoftgames.blogspot.com

Offline col

  • Sr. Member
  • ****
  • Posts: 405
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #6 on: October 14, 2017, 08:05:43 PM »
I've just tried this via Resource Hacker on a Win7 unit and it worked well.

Code: [Select]

Strict
Import pub.win32

Graphics(800,600)
Const ResourceName:String = "MYICON" ' Make sure this matches the resource name that you choose in Resource Hacker

Local icon:Int = LoadIconW(GetModuleHandleW(Null), ResourceName)
SendMessageW(GetActiveWindow(), WM_SETICON, 0, icon) '

While Not AppTerminate()
If KeyDown(KEY_ESCAPE) Exit

Cls
DrawText icon,0,0
Flip
Wend

Once you've built .exe then use Resource Hacker to set the icon, choose the same resource name that you have in the code - above should have the icon resource name of MYICON.

The code just extracts and sets the icon from the exe resources. It shows the icon value, if it shows 0 then the LoadIconW function hasn't found the icon under that name in the .exe. If it shows any other value then you should see your icon.
Its best that the icon has a full set of sizes associated with it - https://msdn.microsoft.com/en-us/library/windows/desktop/dn742485(v=vs.85).aspx

I suppose that you could use TomToad solution to create an object file once that you can then Import, as opposed to using RH - you'd use the same code as above to extract and set the icon as needed. Best of both worlds.

Have fun  :P

EDIT:
To do it the TomToad way, which I personally think makes more sense for a better workflow, you can use the ordinal integer number in the resource file to get the resource:
Code: [Select]

Strict
Import pub.win32
Import "icon_import.o"

Graphics(800,600)

Local icon:Int = LoadIconW(GetModuleHandleW(Null), Short Ptr(101)) ' Use the ordinal number in the resource file
SendMessageW(GetActiveWindow(), WM_SETICON, 0, icon)

While Not AppTerminate()
If KeyDown(KEY_ESCAPE) Exit

Cls
DrawText icon,0,0
Flip
Wend
Any bugs in my code are proof of its hand-coded nature.
https://github.com/davecamp

Offline GW

  • Full Member
  • ***
  • Posts: 150
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #7 on: October 15, 2017, 06:37:34 PM »
The method I use is based from this:  https://web.archive.org/web/20120802002029/http://homepage.ntlworld.com/config/max/appiconguide.htm
imo, It's the better method than setting the icon at runtime.

Offline fielder

  • Jr. Member
  • **
  • Posts: 37
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #8 on: April 11, 2018, 09:35:21 AM »
just tried to replace the small icon on top-left of the main window...

replacing 0 with 1 ... (BIG to SMALL) is working :)

Code: [Select]
                                            V-- here
SendMessageW(GetActiveWindow(), WM_SETICON, 1 , icon)

Offline Brucey

  • Jr. Member
  • **
  • Posts: 56
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #9 on: April 12, 2018, 04:14:09 PM »
The latest bmk (that BlitzMax NG uses, but is also compatible with legacy BlitzMax) now includes the ability to generate a manifest and resource (including icon) and link it into your win32 application as part of the build.

https://github.com/bmx-ng/bmk

It makes some assumptions :

  • windres.exe is in the MinGW bin dir - it's there in the mingw-w64 distro
  • The optional .ico file has the same name as your app .bmx file
  • The optional .settings file (where you can specify version, company, etc details) has the same name as your app .bmx file

I am of the opinion that as a developer, you probably don't want to be having to rinse/repeat tasks such as these if the build system can automate it for you instead..

It should *just work*, but if not, raise an issue on github and I can get it resolved for you.

:o)

Offline fielder

  • Jr. Member
  • **
  • Posts: 37
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #10 on: April 15, 2018, 05:01:49 PM »
very thank you Brucey

Offline Scaremonger

  • Jr. Member
  • **
  • Posts: 68
    • ITSpeedway - Ramblings of a geek!
Re: Changing BlitzMax Exe, Taskbar, Titlebar icon
« Reply #11 on: April 16, 2018, 07:56:50 PM »
Nice one Brucey.
Follow me at ITSpeedway.net.