VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Tiled backgrounds on an MDI parent form? Yep

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 an MDI parent form's background. Getting an image onto an MDI parent is easy. Getting a tiled one is another story. We could try using a Clipboard operation, or build a big tiled background and save it and then laod it into the MDI parent's Picture property, but these are nasty, anal-retentive, and likely to simply not work. This code, however, works...

Inputs
Three inputs are required in the actual sub call: MDIForm: The name of the MDI parent form to tile an image onto. bkgdtiler: The name of a form that is used to generate the tiled background. Check the rest of the docs for the -required- parameters. bkgdfile: The image file to load, with complete path. The best place to put the call I find is in the form's Form_Load() event.

Assumes
To use this code, you'll need to create a conventional (not an MDI parent or child) form and place PictureBox control on the form. Set the PictureBox's Name to Picture1, AutoRedraw, AutoSize, and ClipControls properties to TRUE, and its Visible property to FALSE. The form also has certain requirements. Set its AutoRedraw and ClipControls properties to TRUE, its ControlBox and Visible properties to FALSE, remove its Caption, and set its BorderStyle property to 0 - None. When you call the sub, you'll be passing the form's name to the sub. The sub loads the form, tiles it, transfers the results to the MDI parent, and unloads the form. DO NOT use this form for anything else as it's not kept in memory.

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 forms other than MDI parent forms. I've submitted the non-MDI version of this code to this same location and this is the one for non-MDI-parent forms.

API Declarations

Rate Tiled backgrounds on an MDI parent form? Yep (5(5 Vote))
Tiled backgrounds on an MDI parent form? Yep.bas

Tiled backgrounds on an MDI parent form? Yep Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters