Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2005, 06:15 AM
Authorized User
 
Join Date: May 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to saravananedu
Default how to find assigned images of controls?

Hi All,

  I have used images in my forms, particularly on buttons. i have assigned those images at the design time itself through property page. Those images are picked up from app.path & "/Images" folder.

On that "/Images" folder, now there are lot of unused images also there. i want to remove them. To do so, first i have removed the entire Images folder and try to make exe.

Surprisingly, the exe got created! and the images are there in the forms. how this is possible? are the images be embedded with the .frx file itself? if so, dont i need the Images folder at all while making package?

pls give me clarifications reg. this.

Thanks & Regards,
Saran.
__________________
Best Regards,
Saran.
 
Old July 28th, 2005, 06:28 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello

The Image controls supplied in VB holds the image
when you add it to the control in design time,
and when you make exe file the images are part
of the exe. so you dont have carry the physical
image file.

When you load the images to the control logically
through code then you have to ship the image folder
which contains the images with the package.

Well, that is it.

It is a best practice to use resource files to hold
the images rather than putting in the image folder
and taking it from there. If you are giving the user
a option to pick of his/her own then it is fine.
If you are using if for the title banner or image
on the button or changing the image logically
(if i select this then this image should appear
just for the look) then resource file are best.


Hope this helps

With Regards,
Raghavendra Mudugal
 
Old July 28th, 2005, 07:30 AM
Authorized User
 
Join Date: May 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to saravananedu
Default

Quote:
quote:Originally posted by Raghavendra_Mudugal
[br
It is a best practice to use resource files to hold
the images rather than putting in the image folder
and taking it from there. If you are giving the user
a option to pick of his/her own then it is fine.
If you are using if for the title banner or image
on the button or changing the image logically
(if i select this then this image should appear
just for the look) then resource file are best.

Thanks Raghav!

    Could u tell me in detail how to create / include resource files in my vb project. i want to move all my images into resource file.


Best Regards,
Saran.
 
Old July 28th, 2005, 08:07 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello

The resource file is to be created in the VC++ editor.

Open the VC++ Editor
1. click file new
2. in the File tab, select resource templet
3. you will see a folder Temp1
4. right click on that and click Insert from the menu
5. Import as many as images as you want. (select all files from the type combo box for diff image type
only bmp and jpg can be imported)
AS YOU IMPORT, right click on that image and select
properties, in the ID field enter the ID like 101,
102, 103 and so on as you add images.
6. save the file
7. click save as again and save it as a .res file
(select this option from type the combo box)
8. close all open windows in the Editor.
9. Again open the file that you saved with .res
10. now you have that exavt res file to use

And using this in VB
1. Click project explorer and click Add File
2. select that .res file you saved.
3. It add into the VB project
4. Save the project.

And using the images from the res file
for ex:- if you want to load a image from .res file
to Picture Control...
Picture1.Picture = LoadResPicture (101, vbResBitmap)
101 is the ID of the image file that you give it to
the image in the property window.ID should be always
a number.

OKay try this out and let me know

Hope this helps.

With Regards,
Raghavendra Mudugal
 
Old July 28th, 2005, 11:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dear Raghavendra Mudugal,
I do not agree that putting images in the resource file is the best idea, infact I stopped doing it short after using VB. Can you explain why you think so?

To Saran: images added to controls are stored internally in the frx (or ctx) file. If you open the frm (or ctl) file in notepad, you'll see that the picture properties are just an address in the ..x file. So images do not need to be distributed with you app, unless you load them at run time (someone prefers to do that) But in any case, do not remove the original images from you disk, because otherwise you cannot change them in the future (if you can edit them, like icons and cursors) we keep th eoriginal images under SourceSafe just to be sure we do not lose them. There are however applications (I have one) that extract images from the ..x files, just in case.

Marco
 
Old July 28th, 2005, 11:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi guys:
Like marco said, i dont agree that res file are the better option.
In my case, b/c a lot of program use the same icons, I build a dll with all the icons inside and i get the picture from them...

the only bad things about putting the images inside the exe if when you use the same image in several forms, b/c if will put the image several times, it will not use the same. For that case i build a form with all the images to load from...

HTH

Gonzalo
 
Old July 28th, 2005, 10:58 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Marco,

using .res files are best idea because when you add
.res file in your vb project which contains images
and you make an .exe of it, .res file in now a part
of the .exe. Here we do not need to any extra .dll
files (as said by gbianchi) or a folder that holds the images that is shipped with application where ever it goes. In .res files images are safe. an no one can explicitly delete them and the application need not worry if those images are available when it runs.

If your application is written for displaying images
in the toolbar or in the treeview and if you are
using the Imagelist loaded with the images for these
controls you need to add them in the design time
or at the runtime using the physical files. Now
consider those image files are deleted accidently.
now tell me what is the state of your appilcation?
In such situation i say .res files are best, THE BEST
to use. and images are loaded to imagelist at the
runtime from .res files and then image list is used
by thoso controls which desrves them. Now application
is safe in such cases.

If possible , just give a try in using a imagelist,
add some 10 to 15 images and then reffer it to the
toolbar, then try to change the images in the
imagelist (as if you dont like those images and you
need to add different one). Make the list of steps
that you do. Now do the same with .res files, and
check the diff. Its very comfortable to use it,
BECAUSE IT HAS NO EXTRANEL DEPENDENCIES that app
needs to worry.

I am very much interested in using .res files when
it comes to deal with images (icons, cursors, bmps)
So it is called a RESOURCE file (resources are never
waste) and i dont feel anything wrong in using or
it is not a childish behavior or a WRONG approach.

I am used .res files in so many apps that i have
done in vb. Till know i never felt it has a problem
or never came accros a problem and i feel satisfied.

If you look in the VS.NET, there .res file is still
improved to the present what i am using in the VB.
ITS NO LONGER A WASTE.

Okay

Hope this helps.



With Regards,
Raghavendra Mudugal
 
Old July 29th, 2005, 12:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks very much dear Raghavendra Mudugal for your explanation, I love to exchange ideas.

What you said is true, and I already knew that stuff, that is what MicroSoft is trying to teach us... I still am not convinced. We used res files at the beginning because of internationalization (as M$ suggested...) before finding out what a pain was (and now we are using satellite dll's, and we are SO happy with the solution!) Now we leave all the images in the frx (in image lists or image controls) and never had any problems. But we do not have many of them (some custom cursors and few icons for tree view and list view), and we use a third party toolbar that stores its images internally.

My best regards,
Marco

PS I forgot to answer you question. We add images in a image list control at design time (so we do not have to distribute the image files) and we keep the original image files under SourceSafe control to be safe (and in case we want to edit/change them). I guess the resource file has the same problem too (it can be lost/corrupted), so even that needs to be under a source control.
 
Old July 29th, 2005, 01:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi guys..

im reading your ideas.. the use of dlls come in when you need to ship the same graphics for several diferents aplications on clients.
we have here at least 40 modules that the user can use independently, and of course all the modules use the same visual architecture. using res file will implie that every image if shipped inside the exe, so you have the same image in every app, and if you want to change an image you have to ship every app again!

and of course it come very handly when your developers are in several places (not only inside a building, inside a country like us)...

HTH

Gonzalo
 
Old July 29th, 2005, 01:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ciao Gonzalo,
nice idea indeed.
That is what we do for internationalization. All strings are in satellite dll's, one per language. With a new translation, we just have to ship another dll, without having to recompile one line of code. Distributing few dll's more is not a problem for us (our applications are already huge, almost 300 files, between exe, oxc, dll) Never thought to store images as well though (but as I said we do not have many).
Marco





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using different images for controls rsearing ASP.NET 3.5 Basics 1 August 26th, 2008 09:38 AM
find all the controls inside any table amartya_mandal ASP.NET 1.0 and 1.1 Professional 10 October 24th, 2006 08:35 AM
Notice: Only variables should be assigned by refer harpua Beginning PHP 0 August 22nd, 2006 10:47 AM
variable used before it has been assigned a value BenCh BOOK: ASP.NET Website Programming Problem-Design-Solution 1 February 10th, 2006 02:03 PM
iis cannot find images in relative path vhrao ASP.NET 1.x and 2.0 Application Design 4 November 30th, 2004 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.