Solved

Colors of image in PictureBox

Posted on 1998-06-19
5
172 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA: Add rows to listbox based on criteria 7 64
Using "ScreenUpdating" 6 45
VBA filters 2 37
Add a task in Outlook from access 11 32
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
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…

744 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

17 Experts available now in Live!

Get 1:1 Help Now