[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Colors of image in PictureBox

I have created some 256 color images which I have put into picturebox controls in my VB5 app.  I created them with Paint Shop Pro and used the "standard palette" which I assume is the Windows standard palette.  The pictures look fine until I load another app like Internet Explorer.  Then the colors get all whacked out.  Even after exiting Internet Explorer, the colors don't go back to normal.  I have to restart the application to get them to go back.

This is only a problem when I have my display properties set to 256 colors, but most of our clients run at 256 so I have to figure this out.

I tried to do a PictureBox.Refresh but that didn't seem to help.  I also turned on the AutoRedraw property but that didn't seem to have an effect.   I have seen references in the help file to Palette and PaletteMode properties but I have never used these.  What exactly do these do?  Can they help my problem?

I don't mind if the colors of the app go wild while you are running another graphical program.  But I was hoping that there was a way to get the colors to go back to normal when you switched back to our app, or at least when you closed the other app.

Any ideas would be appreciated.
0
jsullivan
Asked:
jsullivan
  • 2
  • 2
1 Solution
 
JagarCommented:
Try this I don't know if this will work, but on the FORM_Activate event put this line picturebox1.palette = loadpicture("c:\YourApp\YourPicture.GIF")

0
 
jsullivanAuthor Commented:
This is odd, the VB documentation says that Palette is a valid propery for the PictureBox control but when I try to code it, it's not a valid property.  It won't compile.

Any other ideas?
0
 
JagarCommented:
Try using the palette property of the form instead of the picture property (that one does exist).  You are right though supposidely you can do it with the picturebox control.
0
 
jsullivanAuthor Commented:
I can't use the Palette property of the form because it is an MDI form and they don't have that property.  I probably wouldn't want to use this approach anyway because I don't want to have to distribute the images with our application.

I found a different solution.  I dropped an Image control on the form and displayed one of our pictures in it.  Now the app will re-paint properly after switching back to it.  My guess is that VB sees that it has to display a picture in an Image control and so it re-loads the appropriate palette.  I do not know why it wouldn't do the same thing for the PictureBox control.

Thanks anyway for your help.  I'll leave this question out there for a while so you can read my response and then I'll delete the question.

0
 
TpBCommented:
Interesting to note... Microsoft had the same issue with the gradient colors on the MS-Office shortcut bar. The issue is a known "un-documented feature i.e. bug." The issue lies in how the windows OS draw's the screen.

If you wish to see for yourself, play with Office, or hit the MS KB and querry on the "Off97 shortcut bar gradient fill" and you will see that when the gradient fill is used, it screws up other graphice if the resolution is at 266 colors.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now