Solved

Colors of image in PictureBox

Posted on 1998-06-19
5
176 Views
Last Modified: 2010-05-03
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
Comment
Question by:jsullivan
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Jagar
ID: 1463814
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
 

Author Comment

by:jsullivan
ID: 1463815
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
 
LVL 2

Expert Comment

by:Jagar
ID: 1463816
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
 

Author Comment

by:jsullivan
ID: 1463817
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
 

Accepted Solution

by:
TpB earned 100 total points
ID: 1463818
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question