CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    May 2001
    Posts
    165

    how to capture a part of the screen from second monitor

    hello all,
    i made an app to save part of my screen to a jpeg... it works great on single monitor... but if i pass a rect thats not within the main monitor the image will be black... anyone know they easy way to get part of the screen on any monitor... thx...
    •SlimGradey•

  2. #2
    Join Date
    Jun 2006
    Location
    Chile
    Posts
    13

    Re: how to capture a part of the screen from second monitor

    So how do you get the second monitor screen ?
    Pumpobee is prolounced as mumbolee

  3. #3
    Join Date
    May 2001
    Posts
    165

    Re: how to capture a part of the screen from second monitor

    this the code i use to take snap shot of my screen and crop it to the rect i want.. then save as jpeg...
    works fine on single monitor... how can i change this to work on dual monitors...

    Code:
    	HDC WinDC;
    	HDC CopyDC;
    	HBITMAP hBitmap;
    	ULONG bWidth,bHeight;
    	WinDC = ::GetDC(NULL);
    	CopyDC = CreateCompatibleDC(WinDC);
    
    	bWidth =  GetDeviceCaps(WinDC, HORZRES);
    	bHeight = GetDeviceCaps(WinDC, VERTRES);
    
    	hBitmap = CreateCompatibleBitmap(WinDC,bWidth,bHeight);
    
    	SelectObject(CopyDC,hBitmap);
    
    	BitBlt(CopyDC,0,0,bWidth,bHeight,WinDC,0,0,SRCCOPY);
    
    	::ReleaseDC(NULL,WinDC);
    	DeleteDC(CopyDC);
    
    
    	HDC hSrc = CreateCompatibleDC(NULL);
    	SelectObject(hSrc,hBitmap);
    	HDC hNew = CreateCompatibleDC(hSrc);
    	HBITMAP hBmp = CreateCompatibleBitmap(hSrc,width,height);
    	HBITMAP hOld = (HBITMAP)SelectObject(hNew,hBmp);
    	BitBlt(hNew,0,0,width,height,hSrc,left,top, SRCCOPY);
    	SelectObject(hNew,hOld);
    
           //code to save jpeg here....
    
    	DeleteDC(hSrc);
    	DeleteDC(hNew);
    	DeleteObject(hOld);
    	DeleteObject(hBmp);
    	DeleteObject(hBitmap);
    •SlimGradey•

  4. #4
    Join Date
    May 2001
    Posts
    165

    Re: how to capture a part of the screen from second monitor

    i still need help with this...
    trying find way to get bitmap of the second monitor...
    and make it work in the code above...
    thx...
    •SlimGradey•

  5. #5
    Join Date
    Jan 2016
    Posts
    1

    Re: how to capture a part of the screen from second monitor


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured