|
-
May 18th, 2000, 06:24 AM
#1
Thread Starter
Frenzied Member
I have this problem that I am sure is cause by this
Code:
Dim SButtons As Long
Dim SkinTop As Long
Dim SBody As Long
Dim hBitmap As BITMAP
Dim ButtonsBitmap As BITMAP
SButtons = CreateCompatibleDC(0)
SkinTop = CreateCompatibleDC(0)
SBody = CreateCompatibleDC(0)
imgTemp = LoadImage(ByVal 0&, bmpName, 0, 0, 0, LR_LOADFROMFILE Or LR_CREATEDDIBSECTION)
SelectObject SBody, imgTemp
GetObjectAPI imgTemp, Len(hBitmap), hBitmap
DeleteObject imgTemp
BitBlt frmTechAmp.picBody.hdc, 0, 0, me.picBody.ScaleWidth, me.picBody.ScaleHeight, SBody, 0, 0, vbSrcCopy
DeleteDC SButtons
DeleteDC SkinTop
DeleteDC SBody
It doesn't happen right away but after a bunch of compiles VB will give me an out of memory error. Any ideas why? Or is there away to be sure that while unloading that everything that is taking up memory gets released?
-
May 18th, 2000, 06:38 AM
#2
Frenzied Member
Code:
Dim SButtons As Long
Dim SkinTop As Long
Dim SBody As Long
Dim hBitmap As BITMAP
Dim ButtonsBitmap As BITMAP
SButtons = CreateCompatibleDC(0)
SkinTop = CreateCompatibleDC(0)
SBody = CreateCompatibleDC(0)
imgTemp = LoadImage(ByVal 0&, bmpName, 0, 0, 0, LR_LOADFROMFILE Or LR_CREATEDDIBSECTION)
SelectObject SBody, imgTemp
GetObjectAPI imgTemp, Len(hBitmap), hBitmap
DeleteObject imgTemp
BitBlt frmTechAmp.picBody.hdc, 0, 0, me.picBody.ScaleWidth, me.picBody.ScaleHeight, SBody, 0, 0, vbSrcCopy
DeleteDC SButtons
DeleteDC SkinTop
DeleteDC SBody
when you use select object it replaces the object attatched to the DC with the new object and returns the old object's handle
change this to
Code:
Dim SButtons As Long
Dim SkinTop As Long
Dim SBody As Long
Dim hBitmap As BITMAP
Dim ButtonsBitmap As BITMAP
SButtons = CreateCompatibleDC(0)
SkinTop = CreateCompatibleDC(0)
SBody = CreateCompatibleDC(0)
imgTemp = LoadImage(ByVal 0&, bmpName, 0, 0, 0, LR_LOADFROMFILE Or LR_CREATEDDIBSECTION)
DeleteObject SelectObject(SBody, imgTemp)
GetObjectAPI imgTemp, Len(hBitmap), hBitmap
DeleteObject imgTemp
BitBlt frmTechAmp.picBody.hdc, 0, 0, me.picBody.ScaleWidth, me.picBody.ScaleHeight, SBody, 0, 0, vbSrcCopy
DeleteDC SButtons
DeleteDC SkinTop
DeleteDC SBody
and that should solve your problem
-
May 18th, 2000, 06:55 AM
#3
Thread Starter
Frenzied Member
That seems to have worked thanks
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
|