|
-
Dec 3rd, 2001, 02:13 PM
#1
Thread Starter
Hyperactive Member
Out of Memory
'I'm using the following example and put it in my mousemove event. I am continually getting an "Out of Memory" error. Any Idea's?
'VB code:
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Dim memdc As Long
Dim membmp As Long
Dim i As Single, j As Single
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'create a memory DC for this form
memdc = CreateCompatibleDC(Me.hdc)
'create a bitmap for this form
membmp = CreateCompatibleBitmap(Me.hdc, Picture1.ScaleWidth, Picture1.ScaleHeight)
'select that bitmap into the memory dc
SelectObject memdc, membmp
'paste the picture from the picture onto the memory DC.
'Because we selected the bitmap in the memory DC, it'll
'be pasted on the bitmap
BitBlt memdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hdc, 0, 0, SRCCOPY
'now paste the contents of the memory DC on this form
Refresh
BitBlt Me.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, memdc, i, j, SRCCOPY
i = i + 1
If i > 320 Then
j = j + 1
i = 0
Picture1.Refresh
End If
DeleteObject memdc
DeleteObject membmp
End Sub
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
|