VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Easy tiled-image form backgrounds

Tom Honaker  (3 Submissions)   Custom Controls/Forms/Menus   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021


This code, which was inspired by a similar snippet of code by Ian Ippolito, permits tiling an image onto a form's background. This variant, though, resides in a module and is called by a form instead of residing within the form's code itself. This permits using the feature project-wide without redundant code all over the place.

Inputs
Three inputs are required in the actual sub call: frm: The name of the form to tile an image onto picholder: The name of a PictureBox control on that same form, which will be used to hold the image to tile. (See the explanation for required settings) bkgdfile: The image file to load, with complete path. The best place to put the call I find is in the form's Form_Paint() event.

Assumes
To use this code, you'll need to create a PictureBox control on your target form and set its AutoRedraw, AutoSize, and ClipControls properties to TRUE, and its Visible property to FALSE. When you call the sub, you'll be passing the form's name and the name of this PictureBox to the sub.

Returns
Nothing returned.

Side Effects
Larger forms (read: INSANELY large forms) might take some time to refresh on slow systems. Also, very small images take noticeably longer to tile than larger ones, so aim for about 125x125 pixel sizes for the tilable images. Finally, although this code can use GIFs, interlaced GIFs tend to produce a single-pixel horizontal banding effect. So convert 'em to non-interlaced, etc. Also, this does NOT work on MDI parent forms, although it works great on MDI child forms.

API Declarations

Rate Easy tiled-image form backgrounds (43(43 Vote))
Easy tiled-image form backgrounds.bas

Easy tiled-image form backgrounds Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters