Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DisabledPicture can not equal Picture for command button
Message
 
To
12/05/2005 09:23:16
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01013356
Message ID:
01013388
Views:
12
>Has anyone noticed that if one sets the DisabledPicture to the same image file name as the Picture property, the DisabledPicture image is ignored?
>
>My workaround is to create a copy of the Picture image and point to that copy of the file.
>
>I'm wondering if there's a more elegant way to handle this or if this is just one of those things we live with?
>
>Thanks,
>Malcolm

Malcolm,

This is due to VFP's image caching. The Picture property is loaded into memory and cached. When you disable the button, VFP attempts to load the DisabledPicutre. It first checks the cache for the filename. It finds it there and uses the cached image. One solution (and probably the best/easiest) is doing what you have done. Another would be to add an Access method to both the Picture and DisabledPicture properties with code like:
CLEAR RESOURCES (this.Picture)
RETURN this.Picture
OR
CLEAR RESOURCES (this.DisabledPicture)
RETURN this.DisabledPicture
The filename clause of the CLEAR RESOURCES is new to 9 (I think) and this also will fall down if anything else holds a reference to the filename. The code above isn't tested and may not work if the button still has a reference to the Picture when it retrieve's the DisabledPicture and vice versa. You may have to clear the Picture property value, then CLEAR RESOURCES, let the DisabledPicture get cached, and then set the Picture value back.

I've enhanced our button classes to create Image controls for each of the four picture properties of the button. On Init, the picture properties are cleared, loaded into Image controls, then reset. This was done because we use PNG images for our buttons and only Image controls display them properly. The one downside is the issue you ran into with using the same image multiple times. Our current work around is making a copy of the file with a different name.

HTH,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform