Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Colors of image in PictureBox

Posted on 1998-06-19
5
Medium Priority
?
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 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