Releasing DCs! Kedaman, anyone?
What is the correct way to release a memory DC? I tried ReleaseDC and DeleteDC but both seem to leave a memory lack...
Here's my code:
Code:
Function LoadDC(iFileName As String) As Long
Dim Temp As IPictureDisp
Dim DC As Long
'Create compatible DC
DC = CreateCompatibleDC(MainWindow.hdc)
'Load bitmap
Set Temp = LoadPicture(iFileName)
SelectObject DC, Temp
'Apply values
LoadDC = DC
'Release memory
DeleteObject Temp
Set Temp = Nothing
End Function
Sub UnloadDC(iDC As Long)
'Release DCs
ReleaseDC MainWindow.hWnd, iDC
DeleteDC iDC
End Sub
The mistake maybe elsewhere, but I assume it's somewhere around this functions...
I also noticed Windows does free the resources lost as soon as I close VB..