Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Icon changer for bundled thinBasic files

  1. #1

    Icon changer for bundled thinBasic files

    Until Roberto has a chance to modify the thinBasic bundler to allow user-specified icons, here is a simple program that will allow the existing icon to be changed after a bundle has been created.

    This routine was created using FBSL version 3, and is based on one originally written by Gerome Guillemin to change the icon on FBSL files. The GUI-based routine is, however, limited to the use of 32x32x16 color (766 byte) icons.

    Don
    Attached Files Attached Files
    XPS 1710

  2. #2

    Re: Icon changer for bundled thinBasic files

    awesome thank you so much

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Icon changer for bundled thinBasic files

    Don,

    works good!
    Thank you very much!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Icon changer for bundled thinBasic files

    Thanks a lot Don.

    To be honest I do not like too much to have a FBSL bundled exe that change an icon in a thinBasic bundled exe, but that's it: we have to survive

    Maybe we can make a thinBasic application that does the job. I will study it.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5

    Re: Icon changer for bundled thinBasic files

    Eros:

    I agree with your feelings about using a FBSL program to modify a thinBasic bundled script. I had my own misgivings about this as well, but I needed a way to get the job done and it worked. I must admit that it was pure luck that I stumbled on the capability of this routine to change icons in bundled thinBasic scripts. This was an example of serendipity in action. The only modification I made to the original FBSL procedure was the window title.

    Don
    XPS 1710

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Icon changer for bundled thinBasic files

    The following thinBasic code does change the icon of whatever EXE.
    Again: limitation to 32x32 16 colors icons

    Attention: for safety reasons, original exe is never touched and a new exe is created.

    Maybe someone would like to add a nice user interface and a better error checking.

    Ciao
    Eros

    [code=thinbasic]
    USES "FILE"
    USES "UI"

    '---binary marker inside the exe used to identify icon position
    $IconMarker = chr$(&H28, &H00, &H00, &H00, &H20, &H00, &H00, &H00, &H40, &H00)

    %ICONSTART = &h16
    %ICONMAXSIZE = &h2FE

    '---Ask about EXE file
    DIM sExeFile AS STRING
    DIM sExeBuffer AS STRING
    sExeFile = Dialog_OpenFile(0, "Choose thinBasic bundled EXE", _
    DIR_GetCurrent, "Exe (*.EXE)|*.EXE", "EXE", _
    %OFN_FILEMUSTEXIST OR %OFN_HIDEREADONLY or %OFN_ENABLESIZING)

    if sExeFile = "" then
    msgbox 0, "Empty Exe file."
    stop
    end if

    '---Ask about ICO file
    DIM sIcoFile AS STRING
    DIM sIcoBuffer AS STRING
    sIcoFile = Dialog_OpenFile(0, "Choose Icon file", _
    DIR_GetCurrent, "ICO (*.ICO)|*.ICO", "ICO", _
    %OFN_FILEMUSTEXIST OR %OFN_HIDEREADONLY or %OFN_ENABLESIZING)

    if sIcoFile = "" then
    msgbox 0, "Empty icon file."
    stop
    end if

    '---Full load EXE and ICO into string buffers
    sExeBuffer = file_load(sExeFile)
    sIcoBuffer = file_load(sIcoFile)

    '---Check the sizeof the ICO
    if len(sIcoBuffer) <> %ICONMAXSIZE then
    msgbox 0, "Icon is not a 32x32 16 colour icon: " & str$(len(sIcoBuffer)) & str$(%ICONMAXSIZE)
    stop
    end if


    dim lPos as long
    Dim iSize as long

    '---Determine where inside EXE buffer icon marker is placed
    lPos = instr(sExeBuffer, $IconMarker)
    if lPos = 0 then
    msgbox 0, "Icon position inside EXe file not found."
    stop
    end if


    '---If we are here it means all is ok so make some little tuning ...
    iSize = len(sIcoBuffer)
    If iSize > %ICONSTART Then iSize = iSize - %ICONSTART

    '---...substitute current icon inside EXE buffer with the new icon data
    mid$(sExeBuffer, lPos, iSize) = mid$(sIcoBuffer, %ICONSTART+1, iSize)

    '---Save the new exe
    file_save(sExeFile & ".exe", sExeBuffer)

    '---All done.
    [/code]
    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: Icon changer for bundled thinBasic files

    Thanks Eros.

    It seems to be working fine here for me.

    Don
    XPS 1710

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Icon changer for bundled thinBasic files

    Perfect.

    Motivation can let you (me) climb up any ... mountain

    Anyhow, I'm not sure if the used method is correct or not, I do not have experience on EXE format.
    I just follow FBSL example. Hope it is a safe method.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #9
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Icon changer for bundled thinBasic files

    PE explorer reports it as an error, so its a hack.

    I think the checksum for that chunk needs recalculating.


    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  10. #10

    Re: Icon changer for bundled thinBasic files

    Quote Originally Posted by GSAC3
    Until Roberto has a chance to modify the thinBasic bundler to allow user-specified icons, here is a simple program that will allow the existing icon to be changed after a bundle has been created.
    Hi Don,

    It worked for me on Vista - but just to say if I view folder's contents that contains the changed icon in medium or large icons display then the icon reverts back to the regular thinbasic "box" icon as normal...

    Regards,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

Page 1 of 2 12 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •