Results 1 to 3 of 3

Thread: BitBlt from Resource File

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    13

    BitBlt from Resource File

    I want be bitblt stuff from bitmaps located in a resource file. As far as I know, the bitmaps are STDPICTUREs. However, bitblt only deals with DCs.

    How do I make a DC for the picture in the resource file?

    What's the deal with DC's anyway (I know they stand for device context, whatever that means)?

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You dont make the DC - you get it. The DC is a reference to that surface, like a link to a site .

    Now to your problem:

    I dont know if resource bitmaps are of StdPicture, but the following function will load IPictureDisp -pictures and get the DC, maybe it will work with StdPics too

    Code:
    Function LoadDC(iFileName As String) As Long
        Dim DC As Long
        Dim Temp As IPictureDisp 'Change to StdPicture
        
        'Create compatible DC
        DC = CreateCompatibleDC(frmMain.hdc)
        
        'Error: Can't create compatible DC
        If DC < 1 Then: Exit Function
        
        'Load bitmap
        Set Temp = LoadPicture(iFileName) 'Put your bitmap resource here
        SelectObject DC, Temp
        
        'Apply values
        LoadDC = DC
        
        'In case you need the Size
        'w = frmMain.ScaleX(Temp.Width)
        'h = frmMain.ScaleY(Temp.Height)
        
        'Release memory
        DeleteObject Temp
        Set Temp = Nothing
    End Function

  3. #3
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    The Above code will work fine with resource files, I have used them myself with the same code, all you need to do is to replace:

    Set Temp = LoadPicture(iFileName) 'Put your bitmap resource here

    with:

    Set Temp = LoadResPicture(indexNo)
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

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