Solved

Colors of image in PictureBox

Posted on 1998-06-19
5
173 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now