Changing BlitzMax Exe, Taskbar, Titlebar icon

Started by NRJ, September 12, 2017, 11:10:45

Previous topic - Next topic

NRJ

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

sphinx

#1
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

TomToad

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.

NRJ

#3
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

Kippykip

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.

NRJ

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

col

#6
I've just tried this via Resource Hacker on a Win7 unit and it worked well.



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:


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
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

GW

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.

fielder

#8
just tried to replace the small icon on top-left of the main window...

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


                                            V-- here
SendMessageW(GetActiveWindow(), WM_SETICON, 1 , icon)

Brucey

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)

fielder


Scaremonger


GW

Just a quick zombie fyi ..
With BmaxNG and windows you will still need to use the method Col posted to set the window icon at runtime.

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

Derron

Newer BMK's make.bmk uses "APP_ICON" rather than "101".
So I assume your code would fail then.



bye
Ron

GW

I tested it before posting.
"101 "Works for me with the latest bmk and I needed to add that code to get a window icon.