adding icon to executable

Just starting out? Need help? Post your questions and find answers here.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

adding icon to executable

Post by thefool »

Hi!

Im thinking about writing an EXE Bundler. I have created a method
to pack and unpack file with filenames, so no problem there. But now i wonder, how can i let the user choose the icon of the final exe?
The final exe is built like this:

Uncompresser
Packed files+filetag

Its like an exe that gets a packed file in the end, and then it can uncompress those files and run and delete them..

How do i let the user change the icon of my uncompresser (the program the enduser runs.)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

well i guess you dont answer because you cant do it.. :(
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

I can( figure out how to find the icon"s handle when the app is running.

I searched WinAPI docs but nothing answers well right now.

I will let it open some more time and try again.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1400
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

The API doesn't help, because ResourceChange don't work under 9X-Systems (and the unicode-dll doesn't work, or i don't see any working code).

ResHacker can change Resourcen and it has a script-support.

When you use jaPBe:

Hold shift (don't release!)
Projekt>Create executeable
Select a name
OK

During the compiling DON'T RELEASE shift.

After some times, a dos-box should appear with the linker-commands. Now go to the purebasic\compilers directory and copy all the lib, obj which are named in the dos-box. Also copy the complete command-string out of the dos-box.
Now you have the to link files and the command-string to create the exe and to change the icon.
the icon is in the _japbe_0.obj (the source for this resource you found in _japbe_0.rc) Change the source of this obj, create a obj-file (for example with gorc), then start the linker with command-string and you get a exe with your own icon and your own version string, and so on...
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i also searched the api.

Well, i belive pb can do anything. So who knows how to do this?
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

...,

If you would like the user to be able to change the program icon, you may find your way looking there and adapting the code. You will need to g further with API to understand how to get compatible icons from files or generate it by yourself.

Here I use a tip to change program icon on the fly using standard icons which constants are numbered from 32512 to 32517 !

Code: Select all

;
; Main starts here
;
  Quit = #FALSE
  WindowXSize = 320
  WindowYSize = 240

  Resource.l = #IDI_APPLICATION

  tz = GetTickCount_()
  If OpenWindow(0, 0, 0, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered, "MyWindow")
      AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
      Repeat
        Select WindowEvent()
          Case #PB_Event_CloseWindow
            Quit = #TRUE
          Case #PB_Event_Menu
            Select EventMenuID()
              Case #PB_Shortcut_Escape
                Quit = #TRUE
            EndSelect
          Case #PB_EventGadget
            Select EventGadgetID()
            EndSelect
          Case #WM_LBUTTONDOWN
            ReleaseCapture_()
            SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
          Default
        EndSelect
        If GetTickCount_() - tz > 1000
            Resource + 1
            If Resource > #IDI_WINLOGO
                Resource = #IDI_APPLICATION
            EndIf
            DestroyIcon_(hIcon)
            hIcon = LoadIcon_(0, Resource)
            SendMessage_(WindowID(), #WM_SETICON, 0, hIcon)
            tz = GetTickCount_()
        EndIf
        Delay(1)
      Until Quit
  EndIf
  TerminateProcess_(GetCurrentProcess_(), 0)
End
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

thanks fweil and gpi. :D

will test it out later.
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Thanks fweil . :D
Post Reply