I'm so confused!!! [RESOLVED]
Code:
Option Explicit
Public Function LoadGraphics(FileName As String, PosX As Long, PosY As Long, Width As Long, Height As Long) As Long
On Error GoTo ErrHandler
Dim DC As Long
Dim DestDC As Long
Dim Image As Long
Dim NewTile As Integer
NewTile = frmMain.MapTiles.Count
Load frmMain.MapTiles(NewTile)
frmMain.MapTiles(NewTile).Visible = True
frmMain.MapTiles(NewTile).Move Rnd * 1000, Rnd * 1000
FileName = App.Path & "\Maps\" & FileName
DestDC = GetDC(frmMain.MapTiles(NewTile).hwnd)
DC = CreateCompatibleDC(DestDC)
Image = LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
SelectObject DC, Image
BitBlt DestDC, 0, 0, Width, Height, DC, PosX, PosY, SRCCOPY
DeleteDC DC
DeleteDC DestDC
DeleteObject Image
Exit Function
ErrHandler:
MsgBox Err.Number & Err.Description
End Function
That's my code to retrieve a part of an image and put it in a picture box. But it's not working :(!! WHHHHHYYY???? WHHHHHHHHHHYYYYYYYY GOOOOOOOOOODDD!!!! Can someone please check it out for me or give me SIMPLE WORKING CODE. thank you!