Cbomb
Jun 22nd, 2000, 03:51 AM
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.
TalZ
Jun 22nd, 2000, 04:53 AM
you want to get the desktop pic and then del her?
you can use
me.cls
'or
picture1.cls
you mean that?
kedaman
Jun 22nd, 2000, 06:01 AM
Are you using Bitblt or what? show your code
Cbomb
Jun 22nd, 2000, 06:07 AM
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:
'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]
kedaman
Jun 22nd, 2000, 06:41 AM
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
Cbomb
Jun 22nd, 2000, 06:48 AM
Oh jeese i feel stupid.....ok anyway thanks : )
TalZ
Jun 22nd, 2000, 03:52 PM
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...
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...