Wednesday, December 17, 2008

VFP: Grid Header Pictures

Those following along on Twitter know that I am working with Craig Boyd's GridExtras class in one of my customer projects. This is an interesting tool that is making me look really proactive to my customers.

One of the features is the ability for users to double-click on the header and the RecordSource is sorted on the column in the grid. Jody Meyer enhanced this to toogle from ascending to descending to no order. The columns can also be filtered which is an awesome feature because Craig mimics the dialogs to work like column filtering in Microsoft Excel. Both of these features put images in the headers of the columns to give the users a visual clue of what is going on for the grid.

For some reason I was not getting the images in my grids. Obviously it is working for Craig because the sample app he ships has the images displayed. It is not a VFP 9 SP2 thing, because I could run his app in VFP 9 SP2 without any issue.

On a whim I moved the images from the gridextras folder I have under a different directory tree on the same drive, and put them into an images folder underneath the project. I then removed all the pointers in the project to the image files and added the images from the new folder into the project. Rebuilt the EXE and presto, the images show up in the grid header. Nice.

My question is why? All the images are compiled into the EXE either way as I did not exclude them in the Project Manager. VFP should be able to find the images in the EXE. Is there a logical answer, or is this one of the VFP quirks I have to remember to work around in the future?

Labels: ,

2 Comments:

At 12/18/2008 02:11:00 PM, Blogger Mike said...

Hi Rick,

I you type just the file name in the property sheet, or use the lookup button for the property, VFP adds a relative path to the file name. If that path isn't relative to the project file, VFP can't seem to resolve it in a compiled application. The way we get around that is to enter just the filename (no path) as an expression. You can do that by setting the property programmatically, or by entering it in the property sheet like this:
="Image.BMP"
Note the equal (=) and the string delimiters ("). During development, the file will be found as long as it is anywhere in your VFP path. When the image is compiled into an application, the app can always find it.

 
At 12/18/2008 02:55:00 PM, Blogger Rick Schummer said...

Hi Mike,

Yes, I completely agree with your comments here, and this is exactly what was happening in the code. But no images were shown until I put them in a folder underneath the project folder.

 

Post a Comment

<< Home