Advertisement
2_2002-2004 Custom Controls/ Forms/ Menus #117259

Tiled backgrounds on an MDI parent form? Yep!

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...

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Sub TileMDIBkgd(MDIForm As Form, bkgdtiler As Form, bkgdfile As String)
  
  If bkgdfile = "" Then Exit Sub
  Dim ScWidth%, ScHeight%
  
  ScWidth% = Screen.Width / Screen.TwipsPerPixelX
  ScHeight% = Screen.Height / Screen.TwipsPerPixelY
  Load bkgdtiler
  bkgdtiler.Height = Screen.Height
  bkgdtiler.Width = Screen.Width
  bkgdtiler.ScaleMode = 3
  
  bkgdtiler!Picture1.Top = 0
  bkgdtiler!Picture1.Left = 0
  bkgdtiler!Picture1.Picture = LoadPicture(bkgdfile)
  bkgdtiler!Picture1.ScaleMode = 3
  For n% = 0 To ScHeight% Step bkgdtiler!Picture1.ScaleHeight
    For o% = 0 To ScWidth% Step bkgdtiler!Picture1.ScaleWidth
      bkgdtiler.PaintPicture bkgdtiler!Picture1.Picture, o%, n%
    Next o%
  Next n%
  
  MDIForm.Picture = bkgdtiler.Image
  Unload bkgdtiler
End Sub

Upload
I saw no point in uploading a one liner so here is how you open other programs from your delphi program.
In the <b>uses</b> make sure you add ShellAPI.
The folllowing lines opens up notepad 
<br>
<table align=center cellpadding=0 cellspacing=0 border=1 bordercolor=blue>
<tr>
<td>ShellExecute(Handle, 'Open', 'notepad', nil, nil, SW_SHOW);</td>
</tr>
</table>
<br>
To open the broswer and to go to a specific page use the following line.
<br>
<table align=center cellpadding=0 cellspacing=0 border=1 bordercolor=blue>
<tr>
<td>ShellExecute(Handle, 'Open', 'www.somesite.com', nil, nil, SW_SHOW);</td>
</tr>
</table>
Rate this superb article :P
Original Comments (3)
Recovered from Wayback Machine