|
-
May 4th, 2003, 10:23 AM
#1
Thread Starter
Addicted Member
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!
Last edited by INF3RN0666; May 18th, 2003 at 03:13 PM.
-
May 4th, 2003, 10:31 AM
#2
Have you set the AutoRedraw property of the picture box? A picture box also have a hDC property so you don't really have to call GetDC.
-
May 4th, 2003, 10:38 AM
#3
Thread Starter
Addicted Member
Umm the autoredraw feature is on but now it just gives me grey squares!
-
May 4th, 2003, 10:55 AM
#4
Thread Starter
Addicted Member
PLEH
WELL...I know what's causing the problem, but I don't know how i'm gonna fix it! If I give the code the DC of the form, it works fine! but if i give it the DC of the image box, it's messed up! Is it because it's a control array?
-
May 4th, 2003, 11:59 AM
#5
Re: PLEH
Originally posted by INF3RN0666
WELL...I know what's causing the problem, but I don't know how i'm gonna fix it! If I give the code the DC of the form, it works fine! but if i give it the DC of the image box, it's messed up! Is it because it's a control array?
Is it an image box and not a picture box?
-
May 4th, 2003, 01:54 PM
#6
Your code works for me if I include a line to refresh the new control before the code to load the image.
Load frmMain.MapTiles(NewTile)
frmMain.MapTiles(NewTile).Visible = True
frmMain.MapTiles(NewTile).Move Rnd * 1000, Rnd * 1000
frmMain.MapTiles(NewTile).Refresh
...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|