mhdhallak
asked on
Tiling an image
how do I tile an image on the form making it look like a background?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'tile an image on a form
'1) Place an image control on a form and give it a picture
'2) Set the forms AutoRedraw to False
'3) Place this code in the Form Paint Event
Dim intX As Integer
Dim intY As Integer
For intX = 0 To Me.Width Step Image1.Width
For intY = 0 To Me.Height Step Image1.Height
PaintPicture Image1, intX, intY
Next intY
Next intX
'1) Place an image control on a form and give it a picture
'2) Set the forms AutoRedraw to False
'3) Place this code in the Form Paint Event
Dim intX As Integer
Dim intY As Integer
For intX = 0 To Me.Width Step Image1.Width
For intY = 0 To Me.Height Step Image1.Height
PaintPicture Image1, intX, intY
Next intY
Next intX
ASKER
This is for emoreau,
I used your code and it did tile the image except that there was a little small gap between the tiled images.
Where specifically in your code can you delete this gap?
(Note: The gap is not caused by the image because the image tiled perfectly when I used it as a wallpaper.
I used your code and it did tile the image except that there was a little small gap between the tiled images.
Where specifically in your code can you delete this gap?
(Note: The gap is not caused by the image because the image tiled perfectly when I used it as a wallpaper.
emoreau uses imgBackGround.Height and .Width. What you should use is imgBackGround.Picture.Heig ht and imgBackGround.Picture.Widt h. Or make sure the image control is borderless and autosizing.
Oh yes, as Jeremy_D said, my Picture control (imgBackGround) is set to AutoSize.
You can also just add the Microsoft Forms 2.0 Object library to your project and use the Image control that comes with the library. There is a PictureTiling Property that you can set to true.
The picure will automatically be tiled to whatever the image size is...
You can add this to your project by right-clicking the toolbox and selecting "Components..." then select Microsoft Forms 2.0 Object library from the list.
Cheers!
The picure will automatically be tiled to whatever the image size is...
You can add this to your project by right-clicking the toolbox and selecting "Components..." then select Microsoft Forms 2.0 Object library from the list.
Cheers!
www.planet-source-code.com is superb for these kind of standardized tasks. There are some additional codes too to archieve tiled bitmaps but this seems to be the most popular.