Results 1 to 5 of 5

Thread: [RESOLVED] How to capture Video Screen to Clipboard?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Resolved [RESOLVED] How to capture Video Screen to Clipboard?

    I used mciSendString to create a child window to display the video. How to capture Video Screen and save into Clipboard?
    I used the Spy+ to get the MCIDTZ_Window and VideoRender Window's hWnd,but BitBlt seems no function.

    CommandString:
    open mpegvideo!C:\test.avi alias cMCIMedia wait parent 8979684 shareable style child
    Attached Images Attached Images  
    Last edited by Jonney; Jun 10th, 2010 at 06:22 AM. Reason: update picture

  2. #2
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    Re: How to capture Video Screen to Clipboard?

    A window's HWnd will not always be the same, so your command string
    with a hard coded HWnd will not work. You will need to do your
    FindWindow calls and build your command string with the resultant HWnd.

    As for the screen capture:
    Code:
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Const VK_SNAPSHOT = &H2C
    Const FullScreen = 0
    Const AppScreen = 1 'the app with focus (i. e. Alt-Print Screen)
    
    Private Sub Command1_Click()
       Picture1.Refresh
       DoEvents
       Call keybd_event(VK_SNAPSHOT, AppScreen, 0&, 0&) 'screen to clipboard
       DoEvents
       Picture1.Picture = Clipboard.GetData
    End Sub

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: How to capture Video Screen to Clipboard?

    Quote Originally Posted by VBClassicRocks View Post
    A window's HWnd will not always be the same, so your command string
    with a hard coded HWnd will not work. You will need to do your
    FindWindow calls and build your command string with the resultant HWnd.
    Spy++ get those hWnds when the demo is running without closing. I write down the hwnd,I use GetDC(hWnd) API to get the DC,then I use BitBlt to draw into a Memory DC (or a picturebox) and save it. I am sure the logic is right. But I can get NOTHING.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: How to capture Video Screen to Clipboard?

    Here are the codes I get the picture using mciSendString command. The DestDC can be any DC e.g. UserControl.hDC or PictureBox.hDC or Form.hDC or even a memory DC.

    Code:
    Public Function MCI_UpdatehDC(ByVal DeviceAlias As String, ByVal DestDC As Long) As Boolean
    
       Dim lngReturn As Long
        '//Make sure Media is Open already before calling this function
        If Not m_bUseUnicode Then
             lngReturn = mciSendString("update " & DeviceAlias & " hdc " & CStr(DestDC), vbNullString, 0&, 0&)
        Else
            lngReturn = mciSendStringW(StrPtr("update " & DeviceAlias & " hdc " & CStr(DestDC)), StrPtr(vbNullString), 0&, 0&)
        End If
        
        If lngReturn = 0 Then
            MCI_UpdatehDC = True
        Else
            MCI_UpdatehDC = False
        End If
    
    End Function
    Code:
    Screen.MousePointer = vbHourglass
            Set odib32 = New cDIB
            odib32.Create m_lMCIRealWidth, m_lMCIRealHeight, [32_BPP]
            If m_oMCIMedia.MCI_UpdatehDC(m_sDeviceName, odib32.hDC) = True Then
                odib32.CopytoClipboard
                Set odib32 = Nothing
            End If
            Screen.MousePointer = vbDefault

  5. #5
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    Re: [RESOLVED] How to capture Video Screen to Clipboard?

    Use Spy++ to get the CLASSNAME, not the hwnd. In your app, use
    FindWindow using the above ClassName as the first arg and
    vbNullString as the 2nd arg, to get the HWnd. Then build your
    Command String with this HWnd.

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