# Saturday, August 13, 2005

Sometime ago I incorporated VFPSkin elements into a project I was working on. This was when VFPSkin had first come out (version 1.0?) and was still free and open source. I was pretty impressed with VFPSkin as I had never seen skinning for Visual FoxPro applications prior to this. It was a little buggy and I made a lot of modifications, but overall the idea was sound and ingenious. (Just for the record, I made it a point not to look at VFPSkin's source code while I created the example for this blog entry. I admit having been exposed to VFPSkin and thus influenced by it, but the code and parts of this example were created from scratch.)

So, that was extent of my exposure to skins in Visual FoxPro... fast forward to today. I decided to take a look at creating a simplified way to skin Visual FoxPro screens. Why? Well, as with most of my ideas and side projects, sometimes it's the challenge and other times I just have an idea for something that might be helpful to the Visual FoxPro Community and I want to explore it a little. In this case, as in most, it was a little of both. I call this project "Green Screen".

The idea was to take a single ordinary bitmap that has a unique background color (transparency key if you will), use it for the picture property of a form, and then carve out everything at runtime based on that unique color. In this case I chose green for the color -- just like in the movies (that's where I got the idea, though these days I think Hollywood uses mostly blue) -- and I created a simple sample skin that I could use during development.


Green Screen Skin Bmp

Using some API calls (CreateRectRgn and CombineRgn in GDI32 and SetWindowRgn in USER32) the project quickly progressed and I soon had a form that displayed just the intended portion of the bitmap skin. Next it was time to create a routine that would allow Visual FoxPro developers to use their own bitmaps and create "skin definition files" based on them. I decided to incorporate this portion into my example form as well.

This is just a quick initial stab at it... consider it a pretty decent proof of concept. My ultimate goal for this portion was to show Visual FoxPro developers how skinning can be accomplished in a simple, straightforward way. It took much less than a day to get this far, so imagine what can be done given time. Next up on my todo list will be the ability to resize the form (as well as maximize and minimize) and also the ability to skin/unskin on demand as well as the ability to change skins on the fly. I will be keeping an eye towards simplicity throughout, as I want this to be a very painless tool for Visual FoxPro developers to use.

A couple of quick final notes: The two methods in the example form that you'll want to take a look at are createskindefinition and readskindefinition. Though I chose green as the unique color, it can be anything. The readskindefinition method will look at a single pixel in the bottom left of your bitmap to determine the color that should be carved out of the form. All in all, I think you might be surprised at minimal amount of code it took to actually pull this off. Here's a screen shot of the example and the customary download link.

Download Green Screen Example (10 KB approx.)

Saturday, August 13, 2005 12:43:02 PM (GMT Daylight Time, UTC+01:00)  #    Comments [12]
Tuesday, August 23, 2005 6:23:08 PM (GMT Daylight Time, UTC+01:00)
Craig

Simply brilliant. Been looking for something simple like this for ages. I can think of some great effects.

One thing I noticed, if the form is large with a large picture, then the Wait Window that shows up when you click the button to generate the points, seems to interfear with the points, such that once the points are generated and you rerun the form pointing to the txt file, the part of the form that the Wait Window was over still remains green. So on my form I had this U-Beaut form with a floating green rectangle in the top right. So I just changed the WAIT WINDOW position using AT X,Y to appear over the bitmap and there was my form in all its "shapely" glory.

Another thing, suppose there was a part of the form INSIDE the bitmap that I needed to CUT OUT, how'd I go about that?

Waiting for your next article on GDI+. Wonder what you'll come up with this time :)
Wednesday, September 07, 2005 8:38:50 AM (GMT Daylight Time, UTC+01:00)
The whole is just so plain simple. A Delight to use.

I still have a slight problem however as i wish to use the skinning for "desktop" applets. The bitmap get tainted with "white boxes" when moved around "in desktop". Is there a way to force a more aggressive refresh strategy...

François
Francois
Monday, September 19, 2005 8:32:09 PM (GMT Daylight Time, UTC+01:00)
No funciona en VFP 6.0 :(
Mauricio Henao Romero
Saturday, October 01, 2005 9:48:43 AM (GMT Daylight Time, UTC+01:00)
Bernard,

Good point on the wait window... I'll remember that for the next version. And, I'l have to get back to you on cutting out the center of the form... with this technique I don't know if that's possible.

Francois,

Can you email me a simple screen that reproduces the white boxes you're seeing? I can't reproduce at this end. Also, if you can include the display/graphics specs for the machine you are seeing this on, that would help me as well. Thanks.

Mauricio,

I haven't tried this, but I'd say that the problem you are running into is because I am using TRANSFORM() command in the code. Switch those lines to use ALLTRIM(STR()). The only other thing that I can think of that isn't compatible is that animated gif since you won't have morphfox.gif or the new features available in the VFP 9 image control. If it still doesn't work, then have a look at the SYS() functions I am using in there as perhaps one of them wasn't in VFP 6. If it still doesn't work then post the errors you are getting to the blog and I will see what I can do to help you out. You might also want to consider upgrading to VFP 9 - it truly is worth the price of admission.
Thursday, October 06, 2005 10:11:48 AM (GMT Daylight Time, UTC+01:00)
Mr. Boyd,
Great work this.
Thank you very much for sharing it with the VFP community.
Cheers,
Rajesh
Rajesh Jayaraman
Friday, October 07, 2005 7:54:16 PM (GMT Daylight Time, UTC+01:00)
VERY DESPERATE TO FIND SOMETHING TO SKIN VFP.

HOWEVER, WHEN I RUN YOUR SAMPLE, I KEEP GETTING A "FUNCTION ARGUMENT VALUE,TYPE OR COUNT IS INVALID".

I'M TRYING TO RUN IT IN VFP. COULD YOU HELP ME GET AROUND THIS ERROR?

THANKS,

JIM C.
JIM CAMPISI
Friday, October 07, 2005 9:01:57 PM (GMT Daylight Time, UTC+01:00)
Sorry, trying to run it in VFP 8.0.
JIM CAMPISI
Sunday, October 09, 2005 5:35:28 AM (GMT Daylight Time, UTC+01:00)
Hi Jim,

There are some VFP 9 specific commands in most of the examples I post on this weblog. Could you tell me which line you are seeing the error on and maybe I could help you find an equivalent for VFP 8.
Friday, May 12, 2006 12:02:09 PM (GMT Daylight Time, UTC+01:00)
Hey Craig. This is really great. An elegant solution. Thanks for sharing it!
Jos
Thursday, January 31, 2008 6:50:44 PM (GMT Standard Time, UTC+00:00)
Hi, Mr Craig Boyd, I am trying to change my forms look through the skin and the green screen, the problem that comes to my mind is not whether there is any limitation on the size of the background image for the form, because what happens to me is that if we say occupies a large image size of 908 Pixel width and 650 high, the edges on the right and the bottom edge not look good, if I change the image to another size say 781 wide and 504 high all goes well.

Working with VFP 9.0 SP1 Win Pro SP2

I can give any comments or suggestions

Regards,

Javier Parada

Javier Parada
Saturday, March 22, 2008 3:58:58 PM (GMT Standard Time, UTC+00:00)
hi sir, me and my classmates are working hard on how to apply skins on VFP. we had been given some class by our Profsor but could not proprly incorporate it. there are many errors. hope ur file could help us....im gonna try ths as soon as i got home...
agnes galinato
Tuesday, March 03, 2009 10:49:08 PM (GMT Standard Time, UTC+00:00)
So long, so far, since this article was posting.

I'd like to know if there was a new version with form resize features.

Thanks in advance, and my congratulations for your excelente work.
Héctor Quinteros
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789