|
-
Apr 6th, 2001, 08:20 PM
#1
Thread Starter
Frenzied Member
I have been attempting to paint part of an image over the Systray clock using BitBlt. I can get the size and
position of the clock, but when I try to paint part of the image, I only get a black box painted over the clock.
Here is my code. On Form1, just insert a picturebox and timer.
Code:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private 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
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Dim tRECT As RECT
Dim lDC As Long
Dim lHwnd As Long
lHwnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0, "TrayNotifyWnd", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0, "TrayClockWClass", vbNullString)
lDC = GetWindowDC(lHwnd)
Call GetWindowRect(lHwnd, tRECT)
Call BitBlt(lDC, 0, 0, tRECT.Right - tRECT.Left, tRECT.Bottom - tRECT.Top, Picture1.hdc, 0, 0, SRCCOPY)
Call ReleaseDC(lHwnd, lDC)
End Sub
-
Apr 7th, 2001, 07:34 AM
#2
transcendental analytic
SRCCOPY probably not declared as a constant 
you could use vbsrccopy
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.
-
Apr 7th, 2001, 09:41 AM
#3
Thread Starter
Frenzied Member
Hey, it works.
How can I get rid of flashing?
How can I paint the pic if the form is minimized or
is hidden?
-
Apr 7th, 2001, 11:15 AM
#4
transcendental analytic
hmm it's going to flash every time it updates, you could subclass it though but not using vb.
set autoredraw on on the source picturebox
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|