Code: Alles auswählen
#WM_CAP_START = #WM_USER 
#WM_CAP_DRIVER_CONNECT = #WM_CAP_START + 10 
#WM_CAP_DRIVER_DISCONNECT = #WM_CAP_START + 11 
#WM_CAP_FILE_SAVEDIBA = #WM_CAP_START + 25 
#WM_CAP_GRAB_FRAME = #WM_CAP_START + 60 
#WM_CAP_STOP = #WM_CAP_START + 68 
#WM_CAP_SET_CALLBACK_ERRORA = #WM_CAP_START + 2 ; define your callback constant 
#IDS_CAP_DRIVER_ERROR = 418  ; Driver specific error message 
Global hWndC 
Procedure myWindowCallback(hwnd, msg, wParam, lParam) 
  Shared dlgClosed 
  result = #PB_ProcessPureBasicEvents 
  
  ; handle video source dialog (here we close it by sending Escape key) 
  ; kind of messy right now but it seems to work 
  
  If hwnd = WindowID(0) And msg = #WM_KILLFOCUS And driverConnected = #False 
    hDlg = FindWindowEx_(0, 0, "#32770", "Video Source") ; get the handle to the dialog 
  EndIf 
  
  If hDlg <> 0 And driverConnected = #False 
    If dlgClosed = #False 
      dlgClosed = #True ; this ensures we send Escape key one time only 
      keybd_event_(#VK_ESCAPE, 0, 0, 0) 
      keybd_event_(#VK_ESCAPE, 0, #KEYEVENTF_KEYUP, 0) 
    EndIf 
  EndIf 
  
  ProcedureReturn result 
EndProcedure 
Procedure MyCapErrorCallback(hwnd.l, nId.l, lpsz.l) 
  If nId = #IDS_CAP_DRIVER_ERROR 
    MessageRequester("Error", "Error connecting to capture device." + Chr(10)+Chr(13) + "Application will now close", #MB_ICONERROR) 
    CloseWindow(0) 
  Else 
    MessageRequester("Error", "Unspecified capture device error (" + Str(nId) + ")", #MB_ICONERROR) 
  EndIf 
EndProcedure 
Procedure SnapShot() 
  If OpenWindow(0,0,0,0,0,"test",#PB_Window_SystemMenu) 
    
    If OpenLibrary(0, "avicap32.dll") 
      *capAddress = GetFunction(0, "capCreateCaptureWindowA") 
      hWndC = CallFunctionFast(*capAddress, "", #WS_CHILD, 10, 10, 320, 240, WindowID(0),1) 
      SendMessage_(hWndC, #WM_CAP_SET_CALLBACK_ERRORA, 0, @MyCapErrorCallback())    
      SendMessage_(hWndC, #WM_CAP_DRIVER_CONNECT, 0, 0) 
      SendMessage_(hWndC, #WM_CAP_GRAB_FRAME, 0, 0) 
      SendMessage_(hWndC, #WM_CAP_FILE_SAVEDIBA, 0, "test.bmp") 
      SendMessage_(hWndC, #WM_CAP_STOP, 0, 0) 
      SendMessage_(hWndC, #WM_CAP_DRIVER_DISCONNECT, 0, 0) 
      DestroyWindow_(hWndC) 
      CloseLibrary(0) 
    EndIf 
    
  EndIf 
  
EndProcedure 
  
SnapShot()
Nun pass auf.
Wenn ich meine Kamera benutze und Nero schon drauf zugreift, kommt erst ein Device-Auswahl-Fenster, danach die Meldung, dass die Kamera schon verwendet wird.
Videoquelle : Auswahl
Error
Error connecting to capture device.
Application will now close
Jetzt hab ich Nero ausgemacht, damit die Kamera nicht verwendet wird.
Und das Programm erneut gestartet und da kamen 4 Fehlermeldungen:
Error
Unspecified capture device error (439)
Error
Unspecified capture device error (0)
Error
Unspecified capture device error (406)
Error
Unspecified capture device error (0)
Hast eine Ahnung, wie ich das umstellen kann, dass es für Webcams und DV-Kameras funktioniert?
Könnte mir auch vorstellen, mehrere Videoquellen gleichzeitig über USB und FireWire (IEEE1394) anzusteuern. (Stereo-Sehen oder Überwachungssoftware)
Gruppenkonferenz im selben Zimmer  
 
>>Nachtrag
Hab meine Lego-Cam rausgekramt und da ist folgendes Problem:
Die Legowebcam kann an und ausgeschaltet werden.
Das geschiet jedoch software-mäßig irgendwie.
Im Arbeitsplatz habe ich zwei neue Symbole.
Eins für meine USB-Webcam (Lego) und eins für meine DV-Kamera.
Klicke ich auf die LegoCam leuchtet eine rote Lampe an der Kamera.
Starte ich nur die PB-Software, knipst diese ein schwarzes Bild, weil sie wohl die Kamera vorher nicht richtig anschaltet.
Ganz klar, wenn die rote Lampe leuchtet und die Sache vom Arbeitsplatz ausgeht, dann kann ich wieder vom PB-Programm nicht drauf zugreifen.  
 
 
 