[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
Last edited by Jonney; Jun 10th, 2010 at 06:22 AM.
Reason: update picture
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
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.
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
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.