- Labornetzteil AliExpress         
Ergebnis 1 bis 2 von 2

Thema: Programm in Visual Basic Programm einbetten

  1. #1
    Erfahrener Benutzer Roboter-Spezialist
    Registriert seit
    01.10.2004
    Ort
    Aschbach
    Alter
    36
    Beiträge
    223

    Programm in Visual Basic Programm einbetten

    Anzeige

    LiFePo4 Akku selber bauen - Video
    Hi Leute,

    ich habe das Problem, dass ich einen Webcamstream nur mit einem gewissen Programm über die Konsole öffnen kann. Ich wollte dieses Fenster in meinem Visual Basic Programm öffnen und an einen gewisse Stelle einbinden will. Hat jemand eine Idee, wie ich dies einprogrammieren könnte, sodass diese über die Konsole aufgerufene Fenster genau an einer gewissen Stelle meines Visual Basic Programms aufgeht?

    Mfg
    Sven

  2. #2
    Erfahrener Benutzer Roboter Genie Avatar von robocat
    Registriert seit
    18.07.2006
    Beiträge
    935
    als ich noch eine webcam hatte, habe ich mir folgenden code abgewandelt (ist eigentlich für borland c++). je nachdem wie fit du mit win32 bist, kannst du damit evtl etwas anfangen.

    Code:
    //---------------------------------------------------------------------------
    /*
     * Copyright (c) Allan Petersen, 2001.
     * This is a tutorial for a simple capture system using the win32 api
     * for accessing your webcam
     *
     * (c) Copyright 2001, Allan Petersen
     * ALL RIGHTS RESERVED
     * Permission to use, copy, modify, and distribute this software for
     * any purpose and without fee is hereby granted, provided that the above
     * copyright notice appear in all copies and that both the copyright notice
     * and this permission notice appear in supporting documentation, and that
     * the name of Allan Petersen not be used in advertising
     * or publicity pertaining to distribution of the software without specific,
     * written prior permission.
     *
     * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
     * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
     * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
     * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL ALLAN
     * PETERSEN BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
     * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
     * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
     * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
     * THIRD PARTIES, WHETHER OR NOT ALLAN PETERSEN HAS BEEN
     * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
     * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
     * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
     *
     * Contact Allan Petersen at <support@allanpetersen.com> or visit
     * www.allanpetersen.com
     *
     */
    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include <stdio.h>
    #include "c_cap.h"
    
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    
    __fastcall TCap::TCap (HWND Handle)
    {
        // create video capture window
        ParentHandle = Handle;
        hwndVideo = capCreateCaptureWindow(
                        (LPSTR) "My Capture Window",
                        WS_CHILD | WS_VISIBLE,
                        0, 0, 300, 200,
                        (HWND) Handle,
                        (int) 1);
    
        pStringCapDrivers = new TStringList;
        SelectedDevice = -1;
    }
    
    
    __fastcall TCap::~TCap ()
    {
    
        delete pStringCapDrivers;
    
        capPreview(hwndVideo, FALSE); // end preview
        capDriverConnect(hwndVideo, SelectedDevice);
        capDriverDisconnect(hwndVideo); // disconnect from driver
    }
    
    //---------------------------------------------------------------------------
    // enumerate the installed capture drivers
    //---------------------------------------------------------------------------
    int TCap::EnumCapDrv ()
    {
    	char szDeviceName[80]; // driver name
    	char szDeviceVersion[80]; // driver version
    	char str[161]; // concatinated string
    	int xcap; // counter
    
        xcap = 0;
        pStringCapDrivers->Clear ();
        do  {
            if (capGetDriverDescription(xcap, szDeviceName, sizeof(szDeviceName),
    									szDeviceVersion, sizeof(szDeviceVersion))){
    
                sprintf (str, "%s, %s", szDeviceName, szDeviceVersion);
                pStringCapDrivers->AddObject (str, (TObject *)xcap);
                }
            else {
                break;
                }
            xcap++;
            } while (true);
    
        return 0;
    }
    
    //---------------------------------------------------------------------------
    //  connecting to selected device and starts preview
    //---------------------------------------------------------------------------
    void TCap::Connect (int Selected)
    {
        CAPSTATUS CapStatus;
        int       hsize;
    
          // capDlgVideoDisplay(hwndVideo);
          // connect to the driver
        if (SelectedDevice != -1) {
            capPreview (hwndVideo, FALSE);
            capDriverConnect(hwndVideo, SelectedDevice);
            }
    
        if (!capDriverConnect(hwndVideo, Selected)) {
            // ---- Unable to connect to driver
            return;
            }
    
        // update the driver capabilities
        capDriverGetCaps (hwndVideo, sizeof(CAPDRIVERCAPS), &CapDrvCaps);
    
        capDlgVideoFormat(ParentHandle);
    
        // Are there new image dimensions
        capGetStatus(hwndVideo, &CapStatus, sizeof(CAPSTATUS));
    
        hsize = GetSystemMetrics(SM_CYMENU);
        hsize += GetSystemMetrics(SM_CYCAPTION);
    
        // ---- Rescaling the windows
        SetWindowPos(hwndVideo, NULL, 0, 0, CapStatus.uiImageWidth,
                    CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
        SetWindowPos(ParentHandle, NULL, 0, hsize, CapStatus.uiImageWidth,
                    CapStatus.uiImageHeight+hsize, SWP_NOZORDER | SWP_NOMOVE);
    
        // set preview rate to 33.3 miliseconds, or 30 FPS
        capPreviewRate (hwndVideo, 33.3);
    
        // start preview video
        capPreview (hwndVideo, TRUE);
    
        // ---- Remember selected device
        SelectedDevice = Selected;
    }
    
    //---------------------------------------------------------------------------
    //  Get access to the video source format box
    //---------------------------------------------------------------------------
    void TCap::Format ()
    {
        int       hsize;
    
        CAPSTATUS CapStatus;
    
        capDlgVideoFormat(hwndVideo);
        // Are there new image dimensions
        capGetStatus(hwndVideo, &CapStatus, sizeof(CAPSTATUS));
    
        hsize = GetSystemMetrics(SM_CYMENU);
        hsize += GetSystemMetrics(SM_CYCAPTION);
    
        SetWindowPos(ParentHandle, NULL, 0, hsize, CapStatus.uiImageWidth,
                    CapStatus.uiImageHeight+hsize, SWP_NOZORDER | SWP_NOMOVE);
        SetWindowPos(hwndVideo, NULL, 0, 0, CapStatus.uiImageWidth,
                    CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
    }
    //---------------------------------------------------------------------------
    //  Get access to the video source dialog box
    //---------------------------------------------------------------------------
    void TCap::Source ()
    {
        capDlgVideoSource(hwndVideo);
    }
    
    //---------------------------------------------------------------------------
    //  capture a frame and save it
    //---------------------------------------------------------------------------
    void TCap::CaptureFrame (char *FileName)
    {
        capFileSaveDIB (hwndVideo, FileName);
    }
    du kannst auch mit region-skinning ein loch in dein anwendungsfenster machen, so dass dort der inhalt des anderen fensters zu sehen ist. oder du kannst dir ein handle auf das begehrte fenster besorgen und den inhalt in dein eigenes streamen. das geht aber beides nur als dirty-workaround durch

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

12V Akku bauen