Results 1 to 7 of 7

Thread: Blt to desktop probs.

  1. #1

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    Lightbulb

    Ok heres what I have. You start my test prog and hit a button. It Blt's a bitmap to the desktop. Ok now heres where I'm stuck, how do I clear that? I want what I just Blted to be erased and whats under it to be left intact. I hope that made sence. Thanks in advance.
    Cbomb
    Techie

  2. #2
    Junior Member
    Join Date
    Jun 2000
    Posts
    16

    Question i dont know if i understand ???

    you want to get the desktop pic and then del her?

    you can use

    Code:
    me.cls
    'or
    picture1.cls
    you mean that?
    Tal Zur!

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Are you using Bitblt or what? show your code
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    Not quite.

    Ok heres what happens:

    1. I drew a drew of a bitmap of circle in MSPaint and saved it.
    2. My app starts up and places the circle in an off screen DC.
    3. The app then takes contents of that DC and paint it on the desktop.

    Ok now heres the problem. I'm going to be doing some animation and movement with this circle, but when I go to Blt different frames of the animation to the desktop the original circle remains. I need to clear away that old circle. I hope I clarified things.

    Here's the code:

    Code:
    'in a module
    
    Public Declare Function GetDesktopWindow Lib "user32" () As Long
    Public Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Public 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
    Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    
    Function LoadDC(iFileName As String, iW As Long, iH As Long) As Long
        Dim DC As Long
        Dim Temp As IPictureDisp
        
        'Create compatible DC
        DC = CreateCompatibleDC(Form1.hdc)
        
        If DC < 1 Then
            'Error: Can't create compatible DC
        
            Exit Function
        End If
        
        'Load bitmap
        Set Temp = LoadPicture(iFileName)
        SelectObject DC, Temp
        
        'Apply values
        LoadDC = DC 'Return the device context
        
        iW = Form1.ScaleX(Temp.Width) 'Return size of the
        iH = Form1.ScaleY(Temp.Height) 'bitmap scaled to pixel
        
        'Release memory
        DeleteObject Temp
        Set Temp = Nothing
    End Function
    
    'in Form1
    
    Dim StopD As Boolean
    Dim pW As Long
    Dim pH As Long
    Dim mW As Long
    Dim mH As Long
    Dim destDC As Long
    Dim Pic As Long
    Dim Picmask As Long
    
    Private Sub RefForm_Click()
        Form1.Refresh
    End Sub
    
    Private Sub PlacePic_Click()
        Pic = LoadDC("C:\Graphics\desktoy.bmp", pW, pH)
        Picmask = LoadDC("C:\Graphics\desktoymask.bmp", mW, mH)
        destDC = GetWindowDC(GetDesktopWindow)
        BitBlt destDC, 10, 20, mW, mH, Picmask, 0, 0, vbSrcPaint
        BitBlt destDC, 10, 20, pW, pH, Pic, 0, 0, vbSrcAnd
    End Sub
    
    Private Sub STOPIT_Click()  'Not yet
        StopD = True            'Implemented
    End Sub                     '
    Please excuse the sloppyness

    [Edited by Cbomb on 06-22-2000 at 07:10 PM]
    Cbomb
    Techie

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hehe, youre drawing on the desktop, well it erases as soon as something covers it as "i don't know why". I had the inverted problem i while ago, i wanted the picture to stay but it's not. well i guess it's easy just refresh the desktop
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    Oh...duh

    Oh jeese i feel stupid.....ok anyway thanks : )
    Cbomb
    Techie

  7. #7
    Junior Member
    Join Date
    Jun 2000
    Posts
    16

    Question

    i think i have a solution for you...

    like the last guy said , if you move a window on it,
    it just erase... so you can insert this to your code...

    Code:
    Private Sub STOPIT_Click()  'Not yet
        StopD = True            'Implemented
    
        lastleft = Me.Left 'save the left pos
        lasttop = Me.Top   'save the top pos
        Me.Move 0, 0       'put the window on the pic (erase it)
        Me.Move lastleft, lasttop 'move the win back...
    End Sub
    Hope i helped...
    Tal Zur!

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