The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
3 Code Libraries Source Code &nbsp


NOTE: this code has been superceded by the version at the new site.



&nbsp

Tiling Bitmaps into PictureBoxes, UserControls, Forms and MDI Form backgrounds

[Bitmap Tiling Tester Project]

UpdatedUpdated!
2 January 1999: No tiling occurred unless the source of the image was a file on disk. Now tiling works correctly regardless of the image source. Thanks to Wayne McWhorter for spotting this bug.

Download the cBmpTile DLL only (14kb)

Download the Bitmap Tiling DLL source code and demonstration project (50kb)

&nbsp Source Code Note &nbsp
&nbsp This DLL is a binary compatible component which works with all other samples. If you compile your own copy of this DLL yourself please make sure you change the name. See disclaimer and license for more details. &nbsp
&nbsp Before you Begin &nbsp
&nbsp This project requires the SSubTmr.DLL component. Make sure you have loaded and registered this before trying the project. &nbsp

This article provides a bitmap tiling component which allows you to:

  • Tile any Device Context with a bitmap
  • Automatically tile the background area of an MDI form
Here is a quick overview on how to draw whatever you like on the background of an MDI form.

The steps are as follows:
  1. Obtain the hWnd of the background of the MDI form. This is the first child of the MDI form's hWnd.
  2. Subclass the WM_PAINT message for the MDI form's background window, and make sure you receive it before the default window handler.
  3. On receipt of the WM_PAINT message:
    • Call BeginPaint to get the DC of the MDI form's background window.
    • Call GetClientRect to get the size of the window
    • Draw on the DC you obtained with BeginPaint
    • Call EndPaint to commit your changes and remove the invalid parts from the areas to be repainted.
  4. If you want to force a refresh of the window, call GetClientRect to receive the size, and then call InvalidateRect on this area. This will cause a WM_PAINT message to be sent to your WM_PAINT handler.
You can use these techniques to achieve other effects when you paint the MDI background. For example, InstallShield put their www addresses at the bottom right hand corner of the MDI background.



TopBack to top

Source Code - What We're About!Back to Source Code

&nbsp

AboutContributeSend FeedbackPrivacy

Copyright 1998-1999, Steve McMahon ( steve@vbaccelerator.com). All Rights Reserved.
Last updated: 2 January 1999