Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dim lpszName As New VBFixedStringAttribute(100)

Status
Not open for further replies.

andyburrow

Programmer
Joined
Apr 15, 2005
Messages
14
Location
GB
Does anyone know how else I can put this?

The error message received is:

'Value' is not a member of 'Microsoft.VisualBasic.VBFixedStringAttribute'.

This refers to the 'lpszName.Value' calls... check out the Sub below.. lines 12 and 14.


Sub MapWebcamToWindow(ByRef lWidth As Integer, ByRef lHeight As Integer, ByRef hWnd As Integer)
Dim lpszName As New VBFixedStringAttribute(100)
Dim bmp As BITMAPINFO
With bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24
End With
capGetDriverDescriptionA(0, lpszName.Value, 100, Nothing, 100)
lwndC = capCreateCaptureWindowA(lpszName.Value, _
WS_VISIBLE Or WS_CHILD, 0, 0, lWidth, lHeight, hWnd, 0)
If capDriverConnect(lwndC, 0) Then
capPreviewRate(lwndC, 66)
capPreview(lwndC, True)
capSetVideoFormat(lwndC, bmp, Len(bmp))
SetWindowPos(lwndC, 0, 0, 0, bmp.bmiHeader.biWidth, _
bmp.bmiHeader.biHeight, SWP_NOMOVE Or SWP_NOZORDER)
End If
End Sub
 
how about, don't use .Value

What type is the capGetDriverDescription's 2nd parameter?

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
The Funcation is as follows:

Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean

Is that what you mean?

Yeah I used .Length instead and it seemed to accept it, but now I get:

An unhandled exception of type 'System.NullReferenceException' occured in Webcam Application.exe
 
Why are you using .Length? .Length will return the integer number of elements in the array. The function is looking for a string.

If it HAS to be 100 chars, I would say:
Code:
dim lpszName as string
'populate lpszName
lpszName &= spc(100)
lpszName = lpszName.supstring(0,99)
[code]

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question, 
please don't do it in the VB.Net forum[banghead]

[URL unfurl="true"]http://www.ringdev.com[/URL]
[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Ok I put that code in, but now it says:

Operator '&' is not defined for types 'String' and 'Microsoft.VisualBasic.SpcInfo' and also 'supstring' is not a member of 'String'.

I also changed the .Length back to .Value as you rightly advised, as I don't need to return the number of Chars in the String, only the String itself.

Sub MapWebcamToWindow(ByRef lWidth As Integer, ByRef lHeight As Integer, ByRef hWnd As Integer)
Dim lpszName As String
lpszName &= SPC(100)
lpszName = lpszName.supstring(0, 99)
Dim bmp As BITMAPINFO
With bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24
End With
capGetDriverDescriptionA(0, lpszName.Value, 100, Nothing, 100)
lwndC = capCreateCaptureWindowA(lpszName.Value, _
WS_VISIBLE Or WS_CHILD, 0, 0, lWidth, lHeight, hWnd, 0)
If capDriverConnect(lwndC, 0) Then
capPreviewRate(lwndC, 66)
capPreview(lwndC, True)
capSetVideoFormat(lwndC, bmp, Len(bmp))
SetWindowPos(lwndC, 0, 0, 0, bmp.bmiHeader.biWidth, _
bmp.bmiHeader.biHeight, SWP_NOMOVE Or SWP_NOZORDER)
End If
End Sub

Sub CloseWebcam()
capDriverDisconnect(lwndC)
End Sub
 
supstring is a type-o, that should be SubString

and change spc(100) to space(100)

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Ok that seemed to do the trick.

The only thing coming up now is 'Value' is not a member of 'String'

i.e. capGetDriverDescriptionA(0, lpszName.Value, 100, Nothing, 100)
lwndC = capCreateCaptureWindowA(lpszName.Value, _
WS_VISIBLE Or WS_CHILD, 0, 0, lWidth, lHeight, hWnd, 0)

Appreciate your help with this Rick..
 
remove the .Value

.Value would return the string value of the fixed length string in VB6. Since you have a string already, you don't need the .Value of anything.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
VB.NET excepted all of the statements, however it's thrown and unhandled exception.

"An unhandled exception of type 'System.NullReferenceException' occured in Webcam Application.exe"

"Additional Information: Object reference not set to an instance of an object."

It's highlighted the following in yellow:

"Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal _
eventArgs As System.EventArgs) Handles MyBase.Load
MapWebcamToWindow(camSrc.Width, camSrc.Height, _
camSrc.Handle.ToInt32)
End Sub"

When I mouse over camSrc, it = 'nothing'.

camSrc is a Picturebox.

I think that relates to:

"capGetDriverDescriptionA(0, lpszName, 100, Nothing, 100)
lwndC = capCreateCaptureWindowA(lpszName, _
WS_VISIBLE Or WS_CHILD, 0, 0, lWidth, lHeight, hWnd, 0)"

Where it says Nothing lol

 
Okay, I'll bite. Hot google action.

Heres a sample on how to pull back a device list(capGetDriverDescriptionA):
Code:
Private Sub LoadDeviceList()
    Dim strName As String
    Dim strVer As String
    Dim iReturn As Boolean
    Dim x As Long
    
    x = 0
    strName = Space(100)
    strVer = Space(100)
    '
    ' Load name of all avialable devices into the lstDevices
    '

    Do
        '
        '   Get Driver name and version
        '
        iReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)

        '
        ' If there was a device add device name to the list
        '
        If iReturn Then lstDevices.AddItem Trim$(strName)
        x = x + 1
    Loop Until iReturn = False
End Sub

Once you have the value x for the device you want, you can use this:
Code:
hHwnd = capCreateCaptureWindowA(x, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
        480, PictureBox.hwnd, 0)

I'm a little rusty on my API calls, but you'll need a hwnd for the picture box you want to display stuff in. I don't think .Net objects have a .hwnd though, so you may have to do some searching on how to get it.

-Rick


----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top