dcsimg
Results 1 to 6 of 6

Thread: Classic VB - How can I set my exe icon using a resource file?

  1. #1

    Thread Starter
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Classic VB - How can I set my exe icon using a resource file?

    Usually under most circumstances you can set an icon for one of your forms and use it as the executable's icon. However when you are not using a form in your project (classe(s) and module(s) only) you dont have the option of setting an executable icon from the Application Icon propert dropdown list (Fig. 1). There are two methods for setting an executable icon: Using a Resource File and using API code. Below are the steps for using a Resource File.

    Fig. 1




    So one way around this limitation is to use a resource file and embed an icon for your executable.

    If you dont have the Resouce Editor AddIn loaded then you can load it by clicking on the AddIn menu > AddIn Manager ... (Fig. 2). Check the Loaded / Unloaded and Load at startup checkboxes.

    Fig. 2




    Then click on the Project menu > Add new Resource File ... and browse to the location where you would like to save the resource file to your file system. Once there give it a name and click OK. You will see a new folder located in your project explorer called "Related Documents" and it will contain the new resource file (Fig. 3).

    Fig. 3




    Once the resource file is added you need to bring up the Resource Editor so we can add an icon to it. Click the Tools menu > Resource Editor ... Then click on the Add Icon toolbar button (Fig. 4).

    Fig. 4




    Now we will want to browse and select an icon file to use as our executable icon (Fig. 5).

    Fig. 5




    You will see that there is now a new entry named "101" under the Icon folder (Fig. 6).

    Fig. 6




    We need to rename this entry ID by right clicking on it and clicking Properties (Fig. 7).

    Fig. 7




    Name the ID to "APPICON" and click Ok.

    Fig. 8




    We can see the new changes (Fig. 9).

    Fig. 9




    Now lets test it out by compiling our project into an executable. Make sure if you do use this method with a project with forms in it that there is no form selected in the Application Icon property. After compiling the executable we can see our executable file now makes use of our custom icon (Fig. 10).

    Fig. 10




    Enjoy!
    Last edited by si_the_geek; Oct 9th, 2006 at 11:39 AM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Classic VB - How can I set my exe icon using a resource file?

    My only problem with this method (and I think it should be pointed out) is that VB6's resource editor accepts icons with color depth upto 256 colors. So if you have icons with True colors (not to mention XP and Alphas) then this method is going to fail [unfortunately] - Resource Editor will throw an error "Invalid Icon File".

    On the other hand you may assign True and even XP colors icons to form directly - Whether or not proper colors are shown could be another topic but at least VB form does accept those colors depths.
    Last edited by si_the_geek; Oct 24th, 2006 at 10:17 AM. Reason: merged replies

  3. #3
    New Member Super Beast's Avatar
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    15

    Re: Classic VB - How can I set my exe icon using a resource file?

    When I first started programming in VB (albeit a few months ago) I couldn't figure out how to change the icons, so I used Resource Hacker to change the icon in the .exe. This process works fairly well as you don't have to face the colours restrictions that you do in VB 6.
    Last edited by si_the_geek; Nov 9th, 2006 at 04:04 PM.

  4. #4
    Lively Member fifo's Avatar
    Join Date
    Dec 2005
    Location
    HaiPhong, Vietnam
    Posts
    77

    Re: Classic VB - How can I set my exe icon using a resource file?

    i have a answer for this problem!

    If you want to use more color depths Icons, you should not use VB resource editor to add those Icons, you can use 2 file RC.exe, RCDLL.dll to combile your own resource file, and then add this file to VB Project.

    You can use those icon in the same way as VB resource editor's icon.
    !Have fun!

  5. #5
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    298

    Re: Classic VB - How can I set my exe icon using a resource file?

    Is there any way to modify or add any resource files, such as using the windows API?list all sources,add,edit,update ?

  6. #6
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    298

    Re: Classic VB - How can I set my exe icon using a resource file?

    vb6 support 48*48,256*256(24bit ),In the desktop large icon display, visible around 200 pixels, in addition to the edge is not too smooth, but also perfect support for large icons and transparency.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width