Newsgroup: it.comp.lang.visual-basic
Titolo: come impostare la ripetizione di un immagine di sfondo ?

Vorrei sapere come si puņ riempire il background di un form con un immagine
piccola, facendola quindi ripetere fino a coprire lo sfondo interamente!!.
Grazie by lujx

 piccola, facendola quindi ripetere fino a coprire lo sfondo interamente!!.
Sito Comune, nella firma.
Bye, G.
--
    Le risposte alle tue domande le trovi sul Sito Comune
    di questo NewsGroup: 
http://it-lang-vb.net/
    ... e nell'help in linea !

 Vorrei sapere come si può riempire il background di un form con un immagine



Prova così:
Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub Form_Paint()
    Dim rc     As RECT
    Dim hBrush As Long
 
    hBrush = CreatePatternBrush(Picture1.Picture.Handle)
    Call GetClientRect(Me.hWnd, rc)
    Call FillRect(Me.hdc, rc, hBrush)
    Call DeleteObject(hBrush)
End Sub
Ricordati di inserire una picture nella
Form contenente l'immagine e imposta la 
proprietà visible a false.
Bye Bye
------------------------------------------
Posted via web GlobalNews
www.globalnews.it
------------------------------------------

 piccola, facendola quindi ripetere fino a coprire lo sfondo interamente!!.
Metodo Pal, più veloce, con le API:
______________________________________
Public Sub TilePic()
    On Error GoTo errman
    Dim TileIt As Long
    Dim x As Integer, Y As Integer
    Dim MaxX As Integer, MaxY As Integer
    Dim TileW As Integer, TileH As Integer
    Dim NumOfImg As Integer
    time1 = Timer
    With frmV
        .picBacks.Cls
        .picSrc.Picture = LoadPicture(MyFile)
        TileW = .picSrc.Width \ SX
        TileH = .picSrc.Height \ SY
        MaxX = .picBacks.ScaleWidth \ SX
        MaxY = .picBacks.ScaleHeight \ SY
        For Y = 0 To MaxY Step TileH
            For x = 0 To MaxX Step TileW
                TileIt = BitBlt(.picBacks.hDC, x, Y, TileW, TileH, _
.picSrc.hDC, 0, 0, SRCCOPY)
'                TileIt = BitBlt(.hDC, X, Y, TileW, TileH, frmV.GvbWP.hDC, _
0, 0, SRCCOPY)
                NumOfImg = NumOfImg + 1
            Next
        Next
    End With
    msgbox NumOfImg & " imgs -- " & _
        Format(Timer - time1, "###,###,##0.###") & " secs"
    Exit Sub
errman:    MsgBox Error
End Sub
_______________________________
Metodo 2, con puro VB:
_____________________________
    Dim NumeroX As Integer
    Dim NumeroY As Integer
    Dim LarghIm As Integer
    Dim AltIm As Integer
    Dim N As Integer
    Dim M As Integer
    Me.AutoRedraw = True
    Image1 = LoadPicture("c:\windows\bollicine.bmp")
    LoadPicture ("c:\windows\bollicine.bmp")
    LarghIm = Image1.Width
    AltIm = Image1.Height
    NumeroX = Me.Width \ LarghIm
    NumeroY = Me.Height \ AltIm
    For N = 0 To NumeroX
        For M = 0 To NumeroY
            Me.PaintPicture Image1, N * LarghIm, M * AltIm, LarghIm, AltIm
        Next M
    Next N
    Image1 = LoadPicture()
____________________________
Per "variazioni sul tema", guarda l'help di PaintPicture.
Bye, G.