Results 1 to 4 of 4

Thread: Paint Pic over Systray clock using BitBlt

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question

    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

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Thumbs up

    Hey, it works.

    How can I get rid of flashing?

    How can I paint the pic if the form is minimized or
    is hidden?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
  •  



Click Here to Expand Forum to Full Width