Results 1 to 37 of 37

Thread: Releasing DCs! Kedaman, anyone?

Threaded View

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    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..
    Last edited by Fox; Jul 8th, 2001 at 10:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width