About changing the icon of executable generated file.

Just starting out? Need help? Post your questions and find answers here.
User avatar
takis76
Enthusiast
Enthusiast
Posts: 143
Joined: Tue Aug 30, 2011 1:31 pm
Location: Athens - Greece

About changing the icon of executable generated file.

Post by takis76 »

Hello :D

I would like to ask , when I compile my executable file of my game(s) , how I would able to change the icon of the .exe file and put something else than the default one?

Thank you.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: About changing the icon of executable generated file.

Post by MachineCode »

Compiler menu -> Compiler Options.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: About changing the icon of executable generated file.

Post by Zach »

It is located under Compiler Options. I am assuming if you assign an icon without and open project, it will be the default for any compiled EXE, but if you open compiler options while you have a project open, it should use the icon unique to that project. You can tell if you have a project open and are doing it properly, if you get an additional side panel that lists your Compile targets (the default for any project will be listed as Debug)

Or maybe it has no bearing on the project currently open? I'm not sure. In either case here is a picture of what you need.
Image
User avatar
takis76
Enthusiast
Enthusiast
Posts: 143
Joined: Tue Aug 30, 2011 1:31 pm
Location: Athens - Greece

Re: About changing the icon of executable generated file.

Post by takis76 »

Thank you very very much.
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: About changing the icon of executable generated file.

Post by TI-994A »

MachineCode wrote:Compiler menu -> Compiler Options.
Sorry to bump this thread, but could this setting be done programmatically?

Also, this setting reverses the following code, which suppresses the icon:

Code: Select all

wFlags = #WS_OVERLAPPEDWINDOW | #WS_VISIBLE | 1
OpenWindow(1, 0, 0, 300, 200, "No Window Icon", wFlags)
SetWindowLong_(WindowID(1), #GWL_EXSTYLE, #WS_EX_DLGMODALFRAME)
HideWindow(1, 0)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Should we assume that it would not be possible to have a window with no icon if we set the EXE icon?

Thank you.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
takis76
Enthusiast
Enthusiast
Posts: 143
Joined: Tue Aug 30, 2011 1:31 pm
Location: Athens - Greece

Re: About changing the icon of executable generated file.

Post by takis76 »

Yes the fullscreen window don't have any icon.
If the game is in window it will have icon.

But yet changing the application .exe file icon.

I will test this, thank you very very much.
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: About changing the icon of executable generated file.

Post by Bisonte »

TI-994A wrote:Should we assume that it would not be possible to have a window with no icon if we set the EXE icon?
You mean something like that ?

Code: Select all

; directly from RSBasic's WinAPI Library
If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  SendMessage_(WindowID(0),#WM_SETICON,#False,5) 
  
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
or use this

Code: Select all

Procedure SetWindowIcon(Window, Image) ; Set a new window icon
  If IsWindow(Window) And IsImage(Image)
    SendMessage_(WindowID(Window),#WM_SETICON,#False,ImageID(Image))   
  EndIf
EndProcedure
So I can set an icon by compiler options and have a window with no - icon... or have I something misunderstood ?
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: About changing the icon of executable generated file.

Post by TI-994A »

Bisonte wrote:So I can set an icon by compiler options and have a window with no - icon... or have I something misunderstood ?
Hi Bisonte. Thank you for the examples (both of them show icons in the window). Setting the icon for the window is not a problem. I was trying to find a way to set the icon of the compiled executable (the EXE file) as it appears in the Windows Explorer by code. Currently, this is done using PureBasic's Compiler Menu --> Compiler Options --> Use Icon.

Furthermore. if we do not want to have any icon in the window, this compiler "Use Icon" setting will override the #WS_EX_DLGMODALFRAME setting.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: About changing the icon of executable generated file.

Post by TI-994A »

Looks like too many questions confusing the main issue, so I'll just summarise:

Is there any way, using code, to set the icon for the compiled executable? (not the window)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Primoz128
Enthusiast
Enthusiast
Posts: 212
Joined: Sat Sep 10, 2011 8:25 pm
Location: Slovenia

Re: About changing the icon of executable generated file.

Post by Primoz128 »

Use a program from google for that, it's very simple.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: About changing the icon of executable generated file.

Post by MachineCode »

A commandline switch to set the icon's executable would be good.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
takis76
Enthusiast
Enthusiast
Posts: 143
Joined: Tue Aug 30, 2011 1:31 pm
Location: Athens - Greece

Re: About changing the icon of executable generated file.

Post by takis76 »

There are some icon changer programs which do this, but sometimes icon changers will mess up all your applications icons.

I think, when you compile your program, PureBasic changes the main icon of your application. I don't thing there is a problem about the .exe file icon.

I had posted this and Zach answered my question.

:)
Post Reply