[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Tiling an image

Posted on 1999-11-23
7
Medium Priority
?
245 Views
Last Modified: 2010-05-02
how do I tile an image on the form making it look like a background?
0
Comment
Question by:mhdhallak
7 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2229979
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=893

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.
0
 
LVL 71

Accepted Solution

by:
Éric Moreau earned 60 total points
ID: 2230155
I have this code to tile a bitmap from an image on a form:

Public Sub PaintBackground(ByRef pfrmDestination As Form)
Dim intFormHeight As Integer
Dim intFormWidth As Integer
Dim intImgHeight As Integer
Dim intImgWidth As Integer
Dim intX As Integer
Dim intY As Integer

    intFormHeight = pfrmDestination.Height
    intFormWidth = pfrmDestination.Width
    intImgWidth = frmAccueil.imgBackGround.Width
    intImgHeight = frmAccueil.imgBackGround.Height
    For intX = 0 To intFormWidth Step intImgWidth
        For intY = 0 To intFormHeight Step intImgHeight
'            Debug.Print intX & " - " & intY
            pfrmDestination.PaintPicture frmAccueil.imgBackGround, intX, intY
        Next intY
    Next intX
''    'tile left side (Method 2)
'    For intY = 0 To intFrmHeight Step intImgHeight
'        PaintPicture imgBackGround, 0, intY
'    Next intY
End Sub
0
 
LVL 4

Expert Comment

by:Juilette
ID: 2230295
'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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:mhdhallak
ID: 2230338
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.
0
 
LVL 4

Expert Comment

by:Jeremy_D
ID: 2230773
emoreau uses imgBackGround.Height and .Width. What you should use is imgBackGround.Picture.Height and imgBackGround.Picture.Width. Or make sure the image control is borderless and autosizing.
0
 
LVL 71

Expert Comment

by:Éric Moreau
ID: 2231140
Oh yes, as Jeremy_D said, my Picture control (imgBackGround) is set to AutoSize.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2232802
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!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question