Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form background imgage

Status
Not open for further replies.

ms777

Programmer
Jan 22, 2010
13
0
0
CA
Hi,

I'm hoping somebody can help. I have a form with all my text boxes and commandboxes and dropdown, etc. I would like to put a background image on my form which would appear in the back of all these. Basically, instead of having backcolor=212,208,200 I want to have a nice image.

Simply put, I want an image which is in jpg to be the background of my form.

Any ideas on how to do so? Also, in your experience, does it slow down the app? Will the image be distorted in any way?

How can I do so? Please let me know.

Thanks,
MS7
 
This is pretty easy. Just set the form's Picture property to the name of the image file. The file needs to be either bound into the executable, or available on the search path at runtime, or include the full path name.

No, it won't slow down the app (well, not by a noticeable amount).

If you are using a recent version of VFP, then most current image formats will work. With older versions, you might need to convert it to a BMP or perhaps some others.

Hope this helps.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You would simply set the picture property. It doesn't effect the performance. Just be sure to create a jpg that is big enough for your form, otherwise it is tiled and it would be unlikely what you desire.

Cetin Basoz
MS Foxpro MVP, MCP
 
I did that and I'm getting the "tiles" effect. Anything I can do for that to make the image 'autosize' to the form size?

Thanks,
MS7
 
Yes, instead of form's (or _screen if app wise) picture property you might add an Image control to your base form class and set its stretch property. It might get distorded.

Cetin Basoz
MS Foxpro MVP, MCP
 
Yeah, it gets distorted.

I guess I really have to find an image the exact size of my form or "resize" my image thru a 3rd party image editor.

Any other suggestions?

Thanks,
MS7
 
If you use the Image control, set the Stretch property to "isometric". That will avoid the distortion. But then you will need to ensure that the ratio of the picture's height and width match that of your form's. Either that, or put up with the fact that the picture won't cover the entire form.

Alternatively, start at the other end. Find a picture that's right for the application, and design the form to accommodate it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Just another thought ....

The usual reason for adding an image to a form is to provide some sort of background texture or effect, such as a gradient or a pattern. In those cases, the tiled effect is what you want.

It's not so usual to use a picture, such as a person or scene. If you did, it could make the form cluttered and the controls difficult to see.

So, perhaps we ought to ask you exactly why you want to add a picture, and what effect you want to achieve?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike, I'd not say the tiled effect is what you want even whn you only use a backgroubnd picture for a gradient effect. But yes, I'd also rather use an image that would be used in that way and looks okay distorted.

And there's another reason why using an image the exact right size will only be sub optimal: You can do and should do VFP forms resizable. There's not much work in VFP9 to do that with the Anchor property of controls and you can easily have an editbox getting bigger in a resied form or whatever would add a little extra benefit to resizing the vfp form. A fixed size form is somewhat ugly, typically you'd use the main form maximised anyway, and people have different desktop sizes. So a fixed size background image does not work well at least for a main form.

Add an image control, use Menu:Format->Send to back, to put it in the background and then choose a picture also looking good distorted, something abstract like a gradient or pattern, some fog or perhaps flowers, trees, something for which distortion does not make it look bad. Still best in 4:3 aspect ratio, even though 16:9 monitor aspect ratios get more common.

I'd only go for fixed size if it's a littel helper utility or gadget. or a modal dialog form within an app, if it would not contain anything, which woudl have a benefit from being resizable.

Bye, Olaf.
 
Hi Mike,

I simply wanna put a "Background Image" which I would like to use as my "Login" form which is usually only has 2 textboxes (username,password) and 2 push buttons (login, quit). The window itself is small I guess but I'd like to have some sort background picture to make it look pretty cool.

What's your opinion about that ? Please let me know what you think.

 
Olaf,

I'd not say the tiled effect is what you want even whn you only use a backgroubnd picture for a gradient effect.

I was guessing what MS7 wanted. Personally, I wouldn't bother with a background image, whether for a gradient effect or anything else.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
MS77,

I simply wanna put a "Background Image" which I would like to use as my "Login" form

Well, if the login form is fixed size, why not just create an image that's the same size as the form (minus the title bar and borders), then go with my original suggestion of using the form's Picture property?

That would be the simplest approach, and the issues of distortion and tiling woulnd't apply.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Yup, that's what I'll do. The login form is a fixed size, so I'll just create an image that's the same size as the form (minus the title bar and borders) & go with the original suggestion of using the form's Picture Property.


Thanks,
MS7
 
Finally:) Wish you took time to read replies in the first place:

"You would simply set the picture property. It doesn't effect the performance. Just be sure to create a jpg that is big enough for your form, otherwise it is tiled and it would be unlikely what you desire. "

Cetin Basoz
MS Foxpro MVP, MCP
 
Cbasoz,

That's what I said on:
19 Feb 10 13:44

(look at post previously above)


Thanks everybody for your help :)
MS7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top