Not able to change the current directory while capturing the specific window in c++ using win 32 api

-1

I want to capture a specific window in C++ using the Win32 API.

void CaptureActiveWindow(int i)
{
    RECT ActWndRect;
    RECT newwinrwc;

    WCHAR buf [100],buf1[20];char str[256];
    int xSrc=0,ySrc=0;
    int DepcWidth=10, DepcHeight=5;
    OutputDebugString(L"Start capture act window ");     
    HDC ActWndDC = GetDC(hWndActWnd);               //DC for the window you have 
    clicked on  

    MemDC = CreateCompatibleDC(ActWndDC);           //Memory DC Compatible with 
    Above DC

    GetWindowRect(hWndActWnd,&ActWndRect);          //Will Store the Windows Are 
    in Rectangle 

    wsprintf(buf,L"x1 = %d , y1 = %d, x2 = %d y2 =%d",ActWndRect.left,ActWndRect.top,ActWndRect.right,ActWndRect.bottom);
    OutputDebugString(buf); 

    int Width = ActWndRect.right-ActWndRect.left;       //Width of the Window
    int Height = ActWndRect.bottom-ActWndRect.top;      //Hight of the Window

    if(GetWindowText(hWndActWnd,buf1,20) >0)
    {
        OutputDebugString(buf1);
    }
    if(CaptureControl)
    {
        ySrc= DepcWidth = DepcHeight = 0;
    }

    HBITMAP hBitmap = CreateCompatibleBitmap(DlgDC,Width-DepcWidth,Height-DepcHeight);//Will Create Bitmap Comatible With Our Window
    SelectObject(MemDC,hBitmap);

    //PrintWindow (hWndActWnd,ActWndDC,PW_CLIENTONLY);
    //PrintWindow (hWndActWnd,ActWndDC,0x00000003);
    //if(PrintWindow(hWndActWnd,ActWndDC,NULL))
    //today comment if(PrintWindow(hWndActWnd,ActWndDC,0x00000003))
        //PrintWindow(hWndActWnd,ActWndDC,0x00000003);
        PrintWindow(hWndActWnd,ActWndDC,NULL);
        //PrintWindow(hWndActWnd,ActWndDC,CAPTUREBLT );
    //today comment {

    //  PrintWindow (hWndActWnd,ActWndDC,PW_RENDERFULLCONTENT);

    BitBlt(MemDC,0,0,Width,Height,ActWndDC,xSrc,ySrc,SRCCOPY /*| CAPTUREBLT*/);//Will Copy the Window into Mem DC

    //BitBlt(DeskDC,110,110,Width,Height,MemDC,Begpt.x,Begpt.y,SRCCOPY);

    //PW_RENDERFULLCONTENT

    //  newwinhan = GetForegroundWindow();

    itoa(i,str,10);
    strcat(str,".bmp");
    SaveBitmap(MemDC, hBitmap,str); // will Save DC into .bmp File  


    //today comment }     

    //GetWindowRect(newwinhan,&newwinrwc);



    //ShowImage();                              //Will Show u the .bmp File in MSPAINT.
    DeleteDC (ActWndDC);
    //ReleaseDC(hWndActWnd,ActWndDC);
}

But while capturing the window using PrintWindow(hWndActWnd,ActWndDC,0x00000003), I can capture every window, but I am not able to switch to another directory. But if I pass NULL instead of this flag (0x00000003) in PrintWindow(hWndActWnd,ActWndDC,NULL), I am able to switch to another directory, but I can't capture Google Chrome.

Can anyone help show me how to switch to another folder while capturing a Chrome window?

https://www.codeproject.com/Articles/20367/Screen-Capture-Simple-Win32-Dialog-Based.

c++
win32gui
asked on Stack Overflow Oct 7, 2019 by Venkatesh Nagaraju • edited Oct 7, 2019 by Remy Lebeau

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0