From: BeeJ on
Here is the first part of the sub (real code).
This code never has a problem in XP but always hangs in Vista.
Hangs == in IDE or EXE the app cannot be closed or killed and a PC boot
is required.
m_lWebCamhWnd=223540
m_lWebCamID = 0 ' a default. Same value used in XP and in
Vista.

Now, in the case of XP PC there is a webcam installed.
In the case of Vista PC, there is no webcam.

But I need to detect if there is a webcam or not. Don't know how.
So if my only recourse is to bypass this code in Vista (or XP) then I
will do that.
Once I get this working, I will install a webcam and debug that.

But why the hang?
Why does SendMessage not return a zero?
Is there some pretest I can do?
capCreateCaptureWindow seems to do its job by returning a hWnd.

Private Function CameraStillsStart() As Boolean

On Error GoTo CameraStillsStartErr

Dim sErrMsg As String
Dim lRet As Long
Dim bRet As Boolean
Dim bConnected As Boolean
'Getting handle of camera window

m_lCamWidth = IIf(m_lCamWidth, m_lCamWidth, 640)
m_lCamHeight = IIf(m_lCamHeight, m_lCamHeight, 480)

If m_lWebCamID = -1 Then Exit Function

m_lWebCamhWnd = capCreateCaptureWindow(m_lWebCamID, 0, 0, 0,
m_lCamWidth, m_lCamHeight, Me.hWnd, 0)
If (m_lWebCamhWnd <> 0) Then
'send the connection message
' @@@ Vista hangs here
lRet = SendMessage(m_lWebCamhWnd, CONNECT, m_lWebCamID, 0)
If (lRet = 0) Then
CameraStillsStop
sErrMsg = cCamConnectErr
CameraStillsStart = False
Else
bConnected = True
CameraStillsStart = True
End If
Else
sErrMsg = cCamConnectErr
CameraStillsStart = False
End If


From: Kevin Provance on
Top posted:

What's your declare for SendMessage? If the lParam is declared as Any, pass
it as ByVal.

Check out SendMessageTimeout. Perhaps an alternative?


"BeeJ" <nospam(a)live.com> wrote in message
news:i3pacg$6tq$1(a)speranza.aioe.org...
: Here is the first part of the sub (real code).
: This code never has a problem in XP but always hangs in Vista.
: Hangs == in IDE or EXE the app cannot be closed or killed and a PC boot
: is required.
: m_lWebCamhWnd=223540
: m_lWebCamID = 0 ' a default. Same value used in XP and in
: Vista.
:
: Now, in the case of XP PC there is a webcam installed.
: In the case of Vista PC, there is no webcam.
:
: But I need to detect if there is a webcam or not. Don't know how.
: So if my only recourse is to bypass this code in Vista (or XP) then I
: will do that.
: Once I get this working, I will install a webcam and debug that.
:
: But why the hang?
: Why does SendMessage not return a zero?
: Is there some pretest I can do?
: capCreateCaptureWindow seems to do its job by returning a hWnd.
:
: Private Function CameraStillsStart() As Boolean
:
: On Error GoTo CameraStillsStartErr
:
: Dim sErrMsg As String
: Dim lRet As Long
: Dim bRet As Boolean
: Dim bConnected As Boolean
: 'Getting handle of camera window
:
: m_lCamWidth = IIf(m_lCamWidth, m_lCamWidth, 640)
: m_lCamHeight = IIf(m_lCamHeight, m_lCamHeight, 480)
:
: If m_lWebCamID = -1 Then Exit Function
:
: m_lWebCamhWnd = capCreateCaptureWindow(m_lWebCamID, 0, 0, 0,
: m_lCamWidth, m_lCamHeight, Me.hWnd, 0)
: If (m_lWebCamhWnd <> 0) Then
: 'send the connection message
: ' @@@ Vista hangs here
: lRet = SendMessage(m_lWebCamhWnd, CONNECT, m_lWebCamID, 0)
: If (lRet = 0) Then
: CameraStillsStop
: sErrMsg = cCamConnectErr
: CameraStillsStart = False
: Else
: bConnected = True
: CameraStillsStart = True
: End If
: Else
: sErrMsg = cCamConnectErr
: CameraStillsStart = False
: End If
:
:

From: BeeJ on
That's all new to me. Thanks, I will check that out!


From: BeeJ on
Public Declare Function SendMessage Lib "USER32" _
Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long

Will try
ByVal lParam