Click here to Skip to main content
12,943,904 members (60,393 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi every one i got a little problem i need to create a app capture image with directshow and c++ here the details
i need to capture image autodetect and manual
ability to configure the output and camera zoom etc ...
i have reached the phase of capturing image and save it in bmp
and i have stopped seeking in msdn without any stuff
may i haven't understand directshow very well [what fitler to use and how to combine between those filters ]
i hope i will find a refuge for my questions
and the second question is if there is any way to design the user's interface without instead of creating every component by hand in win32 ?
Posted 9-Aug-12 2:20am
First part is not a question, and the last line is not a valid question, because everything is "by hand". If you need something like a visual designer, using it is even more "by hand" than writing code; so, what are you looking for?
Volynsky Alex 10-Aug-12 5:01am
See also this link:
merousoft 10-Aug-12 6:18am
screen shot isn't what i'm looking for .
how to configure filter // IBaseFilter to get more detail about input Pin to be able to handle it except if i need to create my own filter
and what is the filter that i can use to produce a render that shows a rectangle
to detect face like this
merousoft 10-Aug-12 6:20am
sorry i wasn't so precise
here is the question how to use or which filter i need to create a render that captures users's faces ?
like this way
Volynsky Alex 10-Aug-12 6:24am
Yes, I understand merousoft
My advice is to read the information on DS
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you want simulate the printscreen in C++.
Try this small example then...

#include <windows.h>
char EditText[256];
int EditTextLength;
/*  Declare Windows procedure  */
/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nCmdShow)
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */ = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Clipboard Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               544,                 /* The programs width */
               375,                 /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hThisInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
        /* Translate virtual-key messages into character messages */
        /* Send message to WindowProcedure */
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;

/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    static HWND hwndButton;
    static HWND hwndEdit;
    HGLOBAL hGlobal;
    PSTR pGlobal;
    switch (message)                  /* handle the messages */
    case WM_CREATE:
        hwndButton = CreateWindow ( TEXT ("button"),"Cut Text",WS_CHILD|WS_VISIBLE|1,55,100,100,25,hwnd,(HMENU) 1,((LPCREATESTRUCT) lParam) -> hInstance,NULL);
        hwndEdit = CreateWindow (TEXT ("edit"),NULL,WS_CHILD| ES_LEFT|WS_BORDER| WS_VISIBLE,55, 50, 100, 25, hwnd,
                                 (HMENU) 1,((LPCREATESTRUCT) lParam) -> hInstance ,NULL);
        return 0;
    case WM_COMMAND:
        switch (wParam)
        case 1:
            EditTextLength = GetWindowTextLength(hwndEdit) +1;
            GetWindowText(hwndEdit, EditText, EditTextLength);
            hGlobal = GlobalAlloc(GHND|GMEM_SHARE,
                                  EditTextLength*sizeof (char));
            pGlobal = (char*)GlobalLock (hGlobal);
            strcpy (pGlobal, EditText);
            SetClipboardData(CF_TEXT, hGlobal);
        return 0;
    case WM_DESTROY:
        PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
    default:                      /* for messages that we don't deal with */
        return DefWindowProc (hwnd, message, wParam, lParam);
    return 0;

merousoft 10-Aug-12 5:45am
yes i did that Alex the thing is i have to create buttons & listboxes & and image to set the captured image there and to show it to the users
so i need to handle events on those constrols it's hard to manage to components
in win32
CreateWindow("BUTTON", "continuer", WS_CHILD | WS_VISIBLE,
400, 50, 100, 30, hwnd, (HMENU)RELEASE, myCurrentApp, NULL);
secondly please i need to better understand each filter specificity !!! cause i suffer from the lack of info ^_^
Volynsky Alex 10-Aug-12 6:20am
Info about DirectShow you can find here:
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

i have used the ISampleGrabber to get buffer and convert it to image

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 4,643
CHill60 2,970
Maciej Los 2,348
Jochen Arndt 1,900
ppolymorphe 1,765

Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100