Register for your free account! | Forgot your password?

Go Back   elitepvpers › Coders Den › .NET Languages
You last visited: Today at 11:33

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[VB 2012] Webcam Application & grundligende Fragen

Discussion on [VB 2012] Webcam Application & grundligende Fragen within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
AquaFama's Avatar
 
elite*gold: 0
Join Date: Mar 2012
Posts: 37
Received Thanks: 5
Exclamation [VB 2012] Webcam Application & grundligende Fragen

Hi comm, ich habe 2 Fragen.

1. Ich möchte meine Webcam in einer Picturebox anzeigen lassen. Mein Code bis jetzt:

PHP Code:
Public Class Form1
    
Const WM_CAP As Short = &H400S
    
Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
    
Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
    
Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
    
Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
    
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
    
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
    
Const WS_CHILD As Integer = &H40000000
    
Const WS_VISIBLE As Integer = &H10000000
    
Const SWP_NOMOVE As Short = &H2S
    
Const SWP_NOSIZE As Short = 1
    
Const SWP_NOZORDER As Short = &H4S
    
Const HWND_BOTTOM As Short = 1
    Dim iDevice 
As Integer = 0
    Dim hHwnd 
As Integer
    
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Object) As Integer
    
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
    
Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
    
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer
    
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

    
Private Sub LoadDeviceList()
        
Dim strName As String = Space(100)
        
Dim strVer As String = Space(100)
        
Dim bReturn As Boolean
        Dim x 
As Integer = 0
        
Do
            
bReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)
            If 
bReturn Then lstDevices.Items.Add(strName.Trim)
            
x += 1
        Loop Until bReturn 
= False
    End Sub

    
Private Sub OpenPreviewWindow()
        
Dim iHeight As Integer = picCapture.Height
        Dim iWidth 
As Integer = picCapture.Width
        hHwnd 
= capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, picCapture.Handle.ToInt32, 0)
        Try
            If 
SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
                SendMessage
(hHwnd, WM_CAP_SET_SCALE, True, 0)
                
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
                
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
                
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, picCapture.Width, picCapture.Height, SWP_NOMOVE Or SWP_NOZORDER)
                
btnSave.Enabled = True
                btnStop
.Enabled = True
                btnStart
.Enabled = False
            
Else
                
DestroyWindow(hHwnd)
                
btnSave.Enabled = False
            End 
If
        Catch 
ex As Exception

        End 
Try
        
    
End Sub

    
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim data 
As IDataObject
        Dim bmap 
As Image
        SendMessage
(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
        
data = Clipboard.GetDataObject()
        If 
data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
            bmap 
= CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
            
picCapture.Image = bmap
            ClosePreviewWindow
()
            
btnSave.Enabled = False
            btnStop
.Enabled = False
            btnStart
.Enabled = True
            
If sfdImage.ShowDialog = DialogResult.OK Then
                bmap
.Save(sfdImage.FileName, Imaging.ImageFormat.Bmp)
            
End If
        
End If
    
End Sub

    
Private Sub ClosePreviewWindow()
        
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
        
DestroyWindow(hHwnd)
    
End Sub

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

    
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        OpenPreviewWindow
()
        
btnStart.Enabled = False
        btnStop
.Enabled = True
    End Sub

    
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        ClosePreviewWindow
()
        
btnStart.Enabled = True
        btnStop
.Enabled = False
    End Sub
End 
Class 
Leider tritt folgender Fehler auf:
Quote:
PInvokeStackImbalance wurde erkannt.
... und das Debugging wird beendet.

2. Ich habe einen TCP/IP chat erstellt. Jeder der beiden Computer gibt jeweils die IP des anderen ein. Das ganze läuft über PORT 44444. Wenn nun einer der beiden nur auf Port 44444 lauscht und die IP des anderen nicht weis, erhält dann der lauscher trotzdem die Nachricht wenn ein PC an seine IP über den selben Port eine Nachricht sendet? Oder muss er selbst speziell auf diese IP lauschen?

ICH FREUE MICH AUF SCHNELLE HILFE THX IM VORRAUS
AquaFama is offline  
Old   #2
 
elite*gold: 456
Join Date: Jan 2011
Posts: 18
Received Thanks: 4
Zu Punkt 2:
Wenn ich dich richtig verstanden habe (was ich nicht glaube):
Wenn man die TCP Verbindung richtig aufbaut geht das natürlich...
Erkläre das bitte nochmal genauer^^
cin0s is offline  
Old   #3
 
elite*gold: 0
Join Date: May 2010
Posts: 793
Received Thanks: 268
zu 1:
der fehler bedeutet das du die Funtionen aus den dlls (die mit "Declare Function ... Lib ... " ) falsch aufgerufen hast, z.B. falsche Argumente, falsche calling convention, falscher characterset etc.

zu 2:

eine Tcp verbindung baut an normalerweise so auf:
1) Pc1 Lauscht an port ***.
2) Pc2 fragt an pc1, port *** eine verbindung aufzubauen
3) Pc1 sagt ja
4) Es besteht eine verbindung zwischen den beiden Pcs.
5) durch diese Verbindung können nun daten gesendet werden (in beide Richtungen).
pc1 nennt man auch den "server" und pc2 den "client"

dazu muss Pc1 garnix wissen, nur Pc2 muss die ip adresse des pc1 wissen, und dne port an dem das prog lauscht.
nkkk is offline  
Reply


Similar Threads Similar Threads
[Release] Operation7 Application Hack 2012
03/30/2014 - General Gaming Releases - 5 Replies
Operation7 Application Hack 2012 - YouTube Version: Europe State: Undetected Date: 20.02.2012 Type: Application ------------------------------------------------- ------ Download: File-Upload.net - Operation7-Application-Hack.exe Virustotal: https://www.virustotal.com/file/4db2f61beb093ae0b1 251cae149e912e9fd90a7ea96038e90d7d19e16680afcd/ana lysis/1329684722/
[NEW MARCH 2012 UPDATE] The Sims Social Hack 2012 (Facebook) Cheat Bot Tool 2012
09/23/2012 - Facebook - 10 Replies
The Sims Social Hack 2012 (Facebook) Cheat Bot Tool 2012 – Unlimited Simoleons,Simcash,Social Point, Energy, XP The Sims Social Hack tool 2012 is a very useful tool designed to boost your gaming techniques in Facebook game called The Sims Social. Now you can beat your friends in no time. This specially coded tool programmed to get maximum cheats. Now without doing much work, you can get unlimited Energy, experience level, simoleons, simcash and much more. The Sims Social Hack tool is 100%...
C# Windows Form Application How To Save And Run As Application?
02/18/2010 - CO2 Private Server - 4 Replies
How can I save the project and run it as a exe and not .resx or whatever?



All times are GMT +1. The time now is 11:34.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.