473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why capGetStatus & capDriverGetCaps doesn't work?

Hi, I've semi-successfully converted my old VB6 project to VB.NET2003
http://wuhenry.beigetower.org/vbVideoInspection.rar ,it is a simple
webcam program that works flawlessly on VB6. Now I'm having
difficulties with the capGetStatus & capDriverGetCaps function to
work, all of the capGetStatus's & capDriverGetCaps' properites ends up
zero! Thus leaving some of my IF statements non-working.

The capGetStatus "Gets the capabilities of the capture driver" while
the capDriverGetCaps "Gets the capture window attributes .. width and
height".

Anyone working on the avicap32.dll to preview videos on their webcam
or any capture card? It'll really be great if I can get this two
functions to work. I've searched the internet for samples, I saw some
that are .NET converted, but they never did use the capGetStatus &
capDriverGetCaps.

The link above is my VB.NET project, with the AVICAP code of E. J.
Bantz Jr., modified to work on the .NET framework......w/ capGetStatus
& capDriverGetCaps NOT working. Video preview on webcam is working.

Thanks,
Henry
Nov 20 '05 #1
12 6537
"Henry Wu" <he***********@hotmail.com> schrieb
Hi, I've semi-successfully converted my old VB6 project to
VB.NET2003 http://wuhenry.beigetower.org/vbVideoInspection.rar
Maybe you'll get an answer if you provide it as Zip file, (I can't extract
rar's) or the uncompressed file.
,it is
a simple webcam program that works flawlessly on VB6. Now I'm
having difficulties with the capGetStatus & capDriverGetCaps function
to work, all of the capGetStatus's & capDriverGetCaps' properites
ends up zero! Thus leaving some of my IF statements non-working.


Did you upgrade the code using the wizard or did you copy&paste the source
code?

What's your declaration of both functions?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
i modifed from vb6 to vb.net. i already done in vb6 with fully loaded
that i modified. i really loved it
i never had problem.
Function capGetStatus(ByVal lwnd As Integer, ByVal s As Integer, ByVal
wSize As Short) As Boolean
capGetStatus = SendMessage(lwnd, WM_CAP_GET_STATUS, wSize, s)
End Function
Function capDriverGetCaps(ByVal lwnd As Integer, ByVal s As Integer,
ByVal wSize As Short) As Boolean
'The capDriverGetCaps macro returns the hardware capabilities of the
capture driver currently connected to a capture window.
capDriverGetCaps = SendMessage(lwnd, WM_CAP_DRIVER_GET_CAPS, wSize, s)
End Function

above is vfw i had now error problem.
right now i have 5 error problems so far i will do it later. i have read
ur posted stating that u wanted mnuvideofrm to child or mdiparent. but
u can't changed it becaue if that it is constant.
Public Const WS_CHILD As Integer = &H40000000
if u removed it u will get parent but not child.
in ur case u can remove const to dim or private and if not betst way to
do is property get/set procedure events.
i am working on. but i have to fixed errors problem first.
i can help u.
regards


Henry Wu wrote:
Hi, I've semi-successfully converted my old VB6 project to VB.NET2003
http://wuhenry.beigetower.org/vbVideoInspection.rar ,it is a simple
webcam program that works flawlessly on VB6. Now I'm having
difficulties with the capGetStatus & capDriverGetCaps function to
work, all of the capGetStatus's & capDriverGetCaps' properites ends up
zero! Thus leaving some of my IF statements non-working.

The capGetStatus "Gets the capabilities of the capture driver" while
the capDriverGetCaps "Gets the capture window attributes .. width and
height".

Anyone working on the avicap32.dll to preview videos on their webcam
or any capture card? It'll really be great if I can get this two
functions to work. I've searched the internet for samples, I saw some
that are .NET converted, but they never did use the capGetStatus &
capDriverGetCaps.

The link above is my VB.NET project, with the AVICAP code of E. J.
Bantz Jr., modified to work on the .NET framework......w/ capGetStatus
& capDriverGetCaps NOT working. Video preview on webcam is working.

Thanks,
Henry


Nov 20 '05 #3
> Maybe you'll get an answer if you provide it as Zip file
Hi here's the Zip file link:
http://wuhenry.beigetower.org/vbVideoInspection.zip
Did you upgrade the code using the wizard or did you copy&paste the source
code? I did not use the .NET wizard to upgrade my code, I did it again from
scratch since I wanted to learn .NET from scratch too :)
What's your declaration of both functions?


capDriverGetCaps declaration:
---------------------------------

Public Function capDriverGetCaps(ByVal lwnd As Integer, ByVal s As
Integer, ByVal wSize As Short) As Boolean
capDriverGetCaps = SendMessage(lwnd, WM_CAP_DRIVER_GET_CAPS,
wSize, s)
End Function
---------------------------------
capDriverGetCaps usage:
---------------------------------
capDriverGetCaps(lwndC, VarPtrAny(Caps), Len(Caps))

Debug.WriteLine(Caps.wDeviceIndex & "-wDeviceIndex")
Debug.WriteLine(Caps.fHasOverlay & "-fHasOverlay")
Debug.WriteLine(Caps.fHasDlgVideoSource &
"-fHasDlgVideoSource")
Debug.WriteLine(Caps.fHasDlgVideoFormat &
"-fHasDlgVideoFormat")
Debug.WriteLine(Caps.fHasDlgVideoDisplay &
"-fHasDlgVideoDisplay")
Debug.WriteLine(Caps.fCaptureInitialized &
"-fCaptureInitialized")
Debug.WriteLine(Caps.fDriverSuppliesPalettes &
"-fDriverSuppliesPalettes")
Debug.WriteLine(Caps.hVideoIn & "-hVideoIn")
Debug.WriteLine(Caps.hVideoOut & "-hVideoOut")
Debug.WriteLine(Caps.hVideoExtIn & "-hVideoExtIn")
Debug.WriteLine(Caps.hVideoExtOut & "-hVideoExtOut")
Debug.WriteLine(CInt(False) & "-False")
Debug.WriteLine(CInt(True) & "-True")
---------------------------------

Using VarPtrAny as:
---------------------------------
Public Function VarPtrAny(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle =
System.Runtime.InteropServices.GCHandle.Alloc(o,
System.Runtime.InteropServices.GCHandleType.Pinned )
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
---------------------------------

capGetStatus declaration
---------------------------------
Public Function capGetStatus(ByVal lwnd As Integer, ByVal s As
Integer, ByVal wSize As Short) As Boolean
capGetStatus = SendMessage(lwnd, WM_CAP_GET_STATUS, wSize, s)
End Function
---------------------------------

capGetStatus usage
---------------------------------
Dim CAPSTATUS As CAPSTATUS
Dim ImageWidth As Integer
Dim ImageHeight As Integer

If capGetStatus(lwnd, VarPtrAny(CAPSTATUS), Len(CAPSTATUS)) Then
'//Set title of the parent form
ImageWidth = CAPSTATUS.uiImageWidth
ImageHeight = CAPSTATUS.uiImageHeight
SetWindowText(frmVideoPreviewGlobal.Handle.ToInt32 , "Video
Preview: " & CAPSTATUS.uiImageWidth & "x" & CAPSTATUS.uiImageHeight &
" Resolution")
End If
---------------------------------
capDriverGetCaps always renders 0 or False, even if I see a streaming
video preview. And also capGetStatus doesn't work either because
CAPSTATUS.uiImageWidth & CAPSTATUS.uiImageHeight renders "Video
Preview: 0x0 Resolution", but again, I have a nice clean video stream
of 640x480 or 320x240 or whatever video format I set my webcam to.

Hoping for some help, I'm really stuck, it's a bit hard to find the
culprit w/o any errors showing up :(

Thanks,
Henry
Nov 20 '05 #4
Hi!

I believe we have the same declarations on both functions. That's so
weird, you said yours is working? I wonder why mine doesn't? Below is
my Form Load code, my problem is that all of the capDriverGetCaps
values turns out Zero or False, I use Debug.WriteLine to test them all
out.

Thanks,
Henry

Private Sub frmVideoPreview_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Dim FormBorderStyle As Long
Dim lpszName As String = Space(100)
Dim lpszVer As String = Space(100)
Dim Caps As CAPDRIVERCAPS

'//Create Capture Window
capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100)

'// Retrieves driver info
lwndC = capCreateCaptureWindowA(lpszName, WS_VISIBLE Or
WS_CHILD, 0, 0, DefaultWidth, DefaultHeight,
Me.PictureBox1.Handle.ToInt32, 0)

'// Set driver name to status bar
Me.stbVideoPreview.Text = "Video Driver: " & lpszName

'// Set the video stream callback function
capSetCallbackOnStatusDelegate(lwndC, AddressOf
MyStatusCallback)
capSetCallbackOnErrorDelegate(lwndC, AddressOf
MyErrorCallback)

'// Connect the capture window to the driver
If capDriverConnect(lwndC, 0) Then
'/////
'// Only do the following if the connect was successful.
'// if it fails, the error will be reported in the call
'// back function.
'/////

'// Get the capabilities of the capture driver
capDriverGetCaps(lwndC, VarPtrAny(Caps), Len(Caps))

Debug.WriteLine(Caps.wDeviceIndex & "-wDeviceIndex")
Debug.WriteLine(Caps.fHasOverlay & "-fHasOverlay")
Debug.WriteLine(Caps.fHasDlgVideoSource &
"-fHasDlgVideoSource")
Debug.WriteLine(Caps.fHasDlgVideoFormat &
"-fHasDlgVideoFormat")
Debug.WriteLine(Caps.fHasDlgVideoDisplay &
"-fHasDlgVideoDisplay")
Debug.WriteLine(Caps.fCaptureInitialized &
"-fCaptureInitialized")
Debug.WriteLine(Caps.fDriverSuppliesPalettes &
"-fDriverSuppliesPalettes")
Debug.WriteLine(Caps.hVideoIn & "-hVideoIn")
Debug.WriteLine(Caps.hVideoOut & "-hVideoOut")
Debug.WriteLine(Caps.hVideoExtIn & "-hVideoExtIn")
Debug.WriteLine(Caps.hVideoExtOut & "-hVideoExtOut")
Debug.WriteLine(CInt(False) & "-False")
Debug.WriteLine(CInt(True) & "-True")

'// Stretch preview video always
capPreviewScale(lwndC, True)

'// Set the preview rate in milliseconds
capPreviewRate(lwndC, 66)

'// Start previewing the image from the camera
capPreview(lwndC, True)

End If

End Sub
Nov 20 '05 #5
i have problem about variable not declare: i don't what variables is this.

'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
Private Declare Function SendMessageAsAny Lib "user32" Alias
"SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As Any) As Integer
'UPGRADE_ISSUE: StrPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
lStrCpy(StrPtr(sStatusText), ipstrStatusText) '// Copy message into String
'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2070"'
usStatusText = StrConv(sStatusText, vbUnicode)

i will do from scratch because i'm using GDI. i will not be using controls.
regards,

Henry Wu wrote:
Hi!

I believe we have the same declarations on both functions. That's so
weird, you said yours is working? I wonder why mine doesn't? Below is
my Form Load code, my problem is that all of the capDriverGetCaps
values turns out Zero or False, I use Debug.WriteLine to test them all
out.

Thanks,
Henry

Private Sub frmVideoPreview_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Dim FormBorderStyle As Long
Dim lpszName As String = Space(100)
Dim lpszVer As String = Space(100)
Dim Caps As CAPDRIVERCAPS

'//Create Capture Window
capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100)

'// Retrieves driver info
lwndC = capCreateCaptureWindowA(lpszName, WS_VISIBLE Or
WS_CHILD, 0, 0, DefaultWidth, DefaultHeight,
Me.PictureBox1.Handle.ToInt32, 0)

'// Set driver name to status bar
Me.stbVideoPreview.Text = "Video Driver: " & lpszName

'// Set the video stream callback function
capSetCallbackOnStatusDelegate(lwndC, AddressOf
MyStatusCallback)
capSetCallbackOnErrorDelegate(lwndC, AddressOf
MyErrorCallback)

'// Connect the capture window to the driver
If capDriverConnect(lwndC, 0) Then
'/////
'// Only do the following if the connect was successful.
'// if it fails, the error will be reported in the call
'// back function.
'/////

'// Get the capabilities of the capture driver
capDriverGetCaps(lwndC, VarPtrAny(Caps), Len(Caps))

Debug.WriteLine(Caps.wDeviceIndex & "-wDeviceIndex")
Debug.WriteLine(Caps.fHasOverlay & "-fHasOverlay")
Debug.WriteLine(Caps.fHasDlgVideoSource &
"-fHasDlgVideoSource")
Debug.WriteLine(Caps.fHasDlgVideoFormat &
"-fHasDlgVideoFormat")
Debug.WriteLine(Caps.fHasDlgVideoDisplay &
"-fHasDlgVideoDisplay")
Debug.WriteLine(Caps.fCaptureInitialized &
"-fCaptureInitialized")
Debug.WriteLine(Caps.fDriverSuppliesPalettes &
"-fDriverSuppliesPalettes")
Debug.WriteLine(Caps.hVideoIn & "-hVideoIn")
Debug.WriteLine(Caps.hVideoOut & "-hVideoOut")
Debug.WriteLine(Caps.hVideoExtIn & "-hVideoExtIn")
Debug.WriteLine(Caps.hVideoExtOut & "-hVideoExtOut")
Debug.WriteLine(CInt(False) & "-False")
Debug.WriteLine(CInt(True) & "-True")

'// Stretch preview video always
capPreviewScale(lwndC, True)

'// Set the preview rate in milliseconds
capPreviewRate(lwndC, 66)

'// Start previewing the image from the camera
capPreview(lwndC, True)

End If

End Sub


Nov 20 '05 #6
never mind. the vb.net has changed. so i don't see 2 api calls @ same
time, so i have to used rem
thank to vb.net.
regards,

Supra wrote:
i have problem about variable not declare: i don't what variables is this.

'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
Private Declare Function SendMessageAsAny Lib "user32" Alias
"SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As Any) As Integer
'UPGRADE_ISSUE: StrPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
lStrCpy(StrPtr(sStatusText), ipstrStatusText) '// Copy message
into String
'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2070"'
usStatusText = StrConv(sStatusText, vbUnicode)

i will do from scratch because i'm using GDI. i will not be using controls.
regards,

Henry Wu wrote:
Hi!

I believe we have the same declarations on both functions. That's so
weird, you said yours is working? I wonder why mine doesn't? Below is
my Form Load code, my problem is that all of the capDriverGetCaps
values turns out Zero or False, I use Debug.WriteLine to test them all
out.

Thanks,
Henry

Private Sub frmVideoPreview_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Dim FormBorderStyle As Long
Dim lpszName As String = Space(100)
Dim lpszVer As String = Space(100)
Dim Caps As CAPDRIVERCAPS

'//Create Capture Window
capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100)
'// Retrieves driver info
lwndC = capCreateCaptureWindowA(lpszName, WS_VISIBLE Or
WS_CHILD, 0, 0, DefaultWidth, DefaultHeight,
Me.PictureBox1.Handle.ToInt32, 0)

'// Set driver name to status bar
Me.stbVideoPreview.Text = "Video Driver: " & lpszName

'// Set the video stream callback function
capSetCallbackOnStatusDelegate(lwndC, AddressOf
MyStatusCallback)
capSetCallbackOnErrorDelegate(lwndC, AddressOf
MyErrorCallback)

'// Connect the capture window to the driver
If capDriverConnect(lwndC, 0) Then
'/////
'// Only do the following if the connect was successful.
'// if it fails, the error will be reported in the call
'// back function.
'/////

'// Get the capabilities of the capture driver
capDriverGetCaps(lwndC, VarPtrAny(Caps), Len(Caps))
Debug.WriteLine(Caps.wDeviceIndex & "-wDeviceIndex")
Debug.WriteLine(Caps.fHasOverlay & "-fHasOverlay")
Debug.WriteLine(Caps.fHasDlgVideoSource &
"-fHasDlgVideoSource")
Debug.WriteLine(Caps.fHasDlgVideoFormat &
"-fHasDlgVideoFormat")
Debug.WriteLine(Caps.fHasDlgVideoDisplay &
"-fHasDlgVideoDisplay")
Debug.WriteLine(Caps.fCaptureInitialized &
"-fCaptureInitialized")
Debug.WriteLine(Caps.fDriverSuppliesPalettes &
"-fDriverSuppliesPalettes")
Debug.WriteLine(Caps.hVideoIn & "-hVideoIn")
Debug.WriteLine(Caps.hVideoOut & "-hVideoOut")
Debug.WriteLine(Caps.hVideoExtIn & "-hVideoExtIn")
Debug.WriteLine(Caps.hVideoExtOut & "-hVideoExtOut")
Debug.WriteLine(CInt(False) & "-False")
Debug.WriteLine(CInt(True) & "-True")

'// Stretch preview video always
capPreviewScale(lwndC, True)

'// Set the preview rate in milliseconds
capPreviewRate(lwndC, 66)

'// Start previewing the image from the camera
capPreview(lwndC, True)

End If

End Sub



Nov 20 '05 #7
> 'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
Private Declare Function SendMessageAsAny Lib "user32" Alias
"SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As Any) As Integer
Change "ByRef lParam As Any" To "ByRef lParam As Object"

'UPGRADE_ISSUE: StrPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
lStrCpy(StrPtr(sStatusText), ipstrStatusText) '// Copy message >into String
Use the following code for all VarPtr & StrPtr.
So, the function "lStrCpy(StrPtr(sStatusText), ipstrStatusText)" will
be "lStrCpy(VarPtrAny(sStatusText), ipstrStatusText)"

-------------------------------------------------------------
Public Function VarPtrAny(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle =
System.Runtime.InteropServices.GCHandle.Alloc(o,
System.Runtime.InteropServices.GCHandleType.Pinned )
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
-------------------------------------------------------------
'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2070"'
usStatusText = StrConv(sStatusText, vbUnicode)


VB.NET is already in Unicode, no conversions is necessary.
So "usStatusText = StrConv(sStatusText, vbUnicode)" should just be
"usStatusText = sStatusText"
Hope this helps.
Henry

If anyone's able to duplicate or replicate my problem, I'll be relieve
and hopefully someone has a solution for it :) , I'm still scratching
head here :)

Thanks again,
Henry
Nov 20 '05 #8
thank. it works now.
regards,

Henry Wu wrote:
'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
Private Declare Function SendMessageAsAny Lib "user32" Alias
"SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As Any) As Integer

Change "ByRef lParam As Any" To "ByRef lParam As Object"
'UPGRADE_ISSUE: StrPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
lStrCpy(StrPtr(sStatusText), ipstrStatusText) '// Copy message >into String

Use the following code for all VarPtr & StrPtr.
So, the function "lStrCpy(StrPtr(sStatusText), ipstrStatusText)" will
be "lStrCpy(VarPtrAny(sStatusText), ipstrStatusText)"

-------------------------------------------------------------
Public Function VarPtrAny(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle =
System.Runtime.InteropServices.GCHandle.Alloc(o,
System.Runtime.InteropServices.GCHandleType.Pinned )
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
-------------------------------------------------------------

'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2070"'
usStatusText = StrConv(sStatusText, vbUnicode)

VB.NET is already in Unicode, no conversions is necessary.
So "usStatusText = StrConv(sStatusText, vbUnicode)" should just be
"usStatusText = sStatusText"
Hope this helps.
Henry

If anyone's able to duplicate or replicate my problem, I'll be relieve
and hopefully someone has a solution for it :) , I'm still scratching
head here :)

Thanks again,
Henry


Nov 20 '05 #9
Supra, Armin,

any news on how to get the current video's width & height? ex: 320x240

and also on how to get if the current capture device has video source
dialog box, video format dialog box, etc.?

all in VB.NET.

Still stuck,
Henry
Nov 20 '05 #10
Hi,

Declare sendmessage as shown. Use it as below. You can have multiple
versions of sendmessage.

Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As
Integer, _
ByRef lParam As CAPSTATUS) As Boolean

Dim bReturn As Boolean
Dim wSize As Integer
Dim s As CAPSTATUS
bReturn = SendMessage(hHwnd, WM_CAP_GET_STATUS,
Marshal.SizeOf(s), s)
Debug.WriteLine(String.Format("Video Size {0} x {1}",
s.uiImageWidth, s.uiImageHeight))

Here is a link to an example.
http://www.onteorasoftware.com/downloads/webcam.zip
Ken
-----------------

"Henry Wu" <he***********@hotmail.com> wrote in message
news:86*************************@posting.google.co m:
Supra, Armin,

any news on how to get the current video's width & height? ex: 320x240

and also on how to get if the current capture device has video source
dialog box, video format dialog box, etc.?

all in VB.NET.

Still stuck,
Henry


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Nov 20 '05 #11
Thanks Ken Tucker!!!

I'll be ending my posted question here by typing down the functions
that worked for me.
================================================== ====================
Place in a Module
--------------------------------

Public capstatusC As CAPSTATUS
Public capdrivercapsC As CAPDRIVERCAPS

Public Declare Function SendMessageC Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As CAPSTATUS) As Boolean

Public Declare Function SendMessageC Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As CAPDRIVERCAPS) As Boolean
'------------------------------------------
Public Function capDriverGetCaps(ByVal lwnd As Integer) As Boolean
Dim s As CAPDRIVERCAPS
capDriverGetCaps = SendMessageC(lwnd, WM_CAP_DRIVER_GET_CAPS,
System.Runtime.InteropServices.Marshal.SizeOf(s), s)
If capDriverGetCaps = True Then capdrivercapsC = s
End Function
'------------------------------------------

'------------------------------------------
Public Function capGetStatus(ByVal lwnd As Integer) As Boolean
Dim s As CAPSTATUS
capGetStatus = SendMessageC(lwnd, WM_CAP_GET_STATUS,
System.Runtime.InteropServices.Marshal.SizeOf(s), s)
If capGetStatus = True Then capstatusC = s
End Function
'------------------------------------------

================================================== ====================

capDriverGetCaps TEST
--------------------------------------------

If capDriverConnect(lwndC, 0) Then
capDriverGetCaps(lwndC)
Debug.WriteLine(capdrivercapsC.wDeviceIndex &
"-wDeviceIndex")
Debug.WriteLine(capdrivercapsC.fHasOverlay &
"-fHasOverlay")
Debug.WriteLine(capdrivercapsC.fHasDlgVideoSource &
"-fHasDlgVideoSource")
Debug.WriteLine(capdrivercapsC.fHasDlgVideoFormat &
"-fHasDlgVideoFormat")
Debug.WriteLine(capdrivercapsC.fHasDlgVideoDisplay &
"-fHasDlgVideoDisplay")
Debug.WriteLine(capdrivercapsC.fCaptureInitialized &
"-fCaptureInitialized")
Debug.WriteLine(capdrivercapsC.fDriverSuppliesPale ttes &
"-fDriverSuppliesPalettes")
Debug.WriteLine(capdrivercapsC.hVideoIn & "-hVideoIn")
Debug.WriteLine(capdrivercapsC.hVideoOut & "-hVideoOut")
Debug.WriteLine(capdrivercapsC.hVideoExtIn &
"-hVideoExtIn")
Debug.WriteLine(capdrivercapsC.hVideoExtOut &
"-hVideoExtOut")
Debug.WriteLine(CInt(False) & "-False")
Debug.WriteLine(CInt(True) & "-True")
End If
--------------------------------------------
capGetStatus TEST
--------------------------------------------
If capGetStatus(lwnd) = True Then
Debug.WriteLine(String.Format("Video Size {0} x {1}",
capstatusC.uiImageWidth, capstatusC.uiImageHeight))
--------------------------------------------

================================================== ====================

Thanks again Ken Tucker for the solution!!!
I wonder why the original functions (below) wont work?
--------------------------------------------
Public Function capDriverGetCaps(ByVal lwnd As Integer, ByVal s As
Integer, ByVal wSize As Short) As Boolean
capDriverGetCaps = SendMessage(lwnd, WM_CAP_DRIVER_GET_CAPS,
wSize, s)
End Function

Public Function capGetStatus(ByVal lwnd As Integer, ByVal s As
Integer, ByVal wSize As Short) As Boolean
capGetStatus = SendMessage(lwnd, WM_CAP_GET_STATUS, wSize, s)
End Function
--------------------------------------------

Calling them like so:
--------------------------------------------
capDriverGetCaps(lwndC, VarPtr(Caps), Len(Caps))
capGetStatus(lwnd, VarPtr(CAPSTATUS), Len(CAPSTATUS))

While using VarPtr as:
--------------------------------------------
Public Function VarPtr(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle =
System.Runtime.InteropServices.GCHandle.Alloc(o,
System.Runtime.InteropServices.GCHandleType.Pinned )
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
--------------------------------------------
Both of them uses VarPtr, maybe that's the culprit??
Well, it works now, but it'll be a great added knowledge to know what
went wrong.

Henry
Nov 20 '05 #12

Henry Wu wrote:
*Thanks Ken Tucker!!!

I'll be ending my posted question here by typing down the functions
that worked for me.
================================================== ====================
Place in a Module
--------------------------------

Public capstatusC As CAPSTATUS
Public capdrivercapsC As CAPDRIVERCAPS

Public Declare Function SendMessageC Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As CAPSTATUS) As Boolean

Public Declare Function SendMessageC Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal
wParam As Integer, ByRef lParam As CAPDRIVERCAPS) As Boolean
'------------------------------------------
Public Function capDriverGetCaps(ByVal lwnd As Integer) As Boolean
Dim s As CAPDRIVERCAPS
capDriverGetCaps = SendMessageC(lwnd, WM_CAP_DRIVER_GET_CAPS,
System.Runtime.InteropServices.Marshal.SizeOf(s), s)
If capDriverGetCaps = True Then capdrivercapsC = s
End Function
'------------------------------------------

'------------------------------------------
Public Function capGetStatus(ByVal lwnd As Integer) As Boolean
Dim s As CAPSTATUS
capGetStatus = SendMessageC(lwnd, WM_CAP_GET_STATUS,
System.Runtime.InteropServices.Marshal.SizeOf(s), s)
If capGetStatus = True Then capstatusC = s
End Function
'------------------------------------------

================================================== ====================

capDriverGetCaps TEST
--------------------------------------------

If capDriverConnect(lwndC, 0) Then
capDriverGetCaps(lwndC)
Debug.WriteLine(capdrivercapsC.wDeviceIndex &
"-wDeviceIndex")
Debug.WriteLine(capdrivercapsC.fHasOverlay &
"-fHasOverlay")
Debug.WriteLine(capdrivercapsC.fHasDlgVideoSource &
"-fHasDlgVideoSource")
Debug.WriteLine(capdrivercapsC.fHasDlgVideoFormat &
"-fHasDlgVideoFormat")
Debug.WriteLine(capdrivercapsC.fHasDlgVideoDisplay &
"-fHasDlgVideoDisplay")
Debug.WriteLine(capdrivercapsC.fCaptureInitialized &
"-fCaptureInitialized")
Debug.WriteLine(capdrivercapsC.fDriverSuppliesPale ttes &
"-fDriverSuppliesPalettes")
Debug.WriteLine(capdrivercapsC.hVideoIn & "-hVideoIn")
Debug.WriteLine(capdrivercapsC.hVideoOut & "-hVideoOut")
Debug.WriteLine(capdrivercapsC.hVideoExtIn &
"-hVideoExtIn")
Debug.WriteLine(capdrivercapsC.hVideoExtOut &
"-hVideoExtOut")
Debug.WriteLine(CInt(False) & "-False")
Debug.WriteLine(CInt(True) & "-True")
End If
--------------------------------------------
capGetStatus TEST
--------------------------------------------
If capGetStatus(lwnd) = True Then
Debug.WriteLine(String.Format("Video Size {0} x {1}",
capstatusC.uiImageWidth, capstatusC.uiImageHeight))
--------------------------------------------

================================================== ====================

Thanks again Ken Tucker for the solution!!!
I wonder why the original functions (below) wont work?
--------------------------------------------
Public Function capDriverGetCaps(ByVal lwnd As Integer, ByVal s As
Integer, ByVal wSize As Short) As Boolean
capDriverGetCaps = SendMessage(lwnd, WM_CAP_DRIVER_GET_CAPS,
wSize, s)
End Function

Public Function capGetStatus(ByVal lwnd As Integer, ByVal s As
Integer, ByVal wSize As Short) As Boolean
capGetStatus = SendMessage(lwnd, WM_CAP_GET_STATUS, wSize, s)
End Function
--------------------------------------------

Calling them like so:
--------------------------------------------
capDriverGetCaps(lwndC, VarPtr(Caps), Len(Caps))
capGetStatus(lwnd, VarPtr(CAPSTATUS), Len(CAPSTATUS))

While using VarPtr as:
--------------------------------------------
Public Function VarPtr(ByVal o As Object) As Integer
Dim GC As System.Runtime.InteropServices.GCHandle =
System.Runtime.InteropServices.GCHandle.Alloc(o,
System.Runtime.InteropServices.GCHandleType.Pinned )
Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32
GC.Free()
Return ret
End Function
--------------------------------------------
Both of them uses VarPtr, maybe that's the culprit??
Well, it works now, but it'll be a great added knowledge to know
what
went wrong.

Henry *

Henry,

You wouldn't happen to have an idea on how to save the preview to an
AVI or some other video file.

Thanks,
Sam

--
Oakking1
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message778768.html

Nov 21 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: brian.vincent | last post by:
I'm trying to use the ssh2 functions to run a graphical app. I have no problem opening ssh2_shell and running something like "/bin/ls /tmp". However when I try to do something like:...
1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
27
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
1
by: Oodini | last post by:
Hello, Could anyone explain me the following preprocessor sentences: ---------------------------------------------------------------- #if (defined(__STDC__) && !defined(NO_PROTOTYPE)) ||...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.