Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to caputure scrollview including unvisible area?

how to caputure scrollview including unvisible area?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rambojanggoon
    wrote on last edited by
    #1

    Hi, I'd like to how caputre scrollview area, incluing unvisible area... scrollview size is nomally big than actually monito's resoluton, unvisible area don't captured...

    CRect rect;
    HWND	hWnd = m\_hWnd; // m\_hWnd is hanle of scrollview. 
    if (hWnd == NULL) return;
    
    HDC hScrollView = ::GetWindowDC(hWnd);
    HDC hCaptureDC = CreateCompatibleDC(hScrollView);
    
    CRect m\_rDrawingSurface;	
    ::GetWindowRect(hWnd,&m\_rDrawingSurface);
    
    BITMAPINFOHEADER BMIH; 
    HBITMAP m\_hCaptureBitmap;
    BYTE\* m\_pDrawingSurfaceBits;
    
    CDC\* pDC = GetDC();
    if(pDC != NULL)
    {
    	BMIH.biSize = sizeof(BITMAPINFOHEADER);
    	BMIH.biBitCount = 24;
    	BMIH.biPlanes = 1;
    	BMIH.biCompression = BI\_RGB;
    	BMIH.biWidth = m\_rDrawingSurface.Width();
    	BMIH.biHeight = m\_rDrawingSurface.Height();
    	BMIH.biSizeImage = ((((BMIH.biWidth \* BMIH.biBitCount) + 31) & ~31) >> 3) \* BMIH.biHeight;
    	m\_hCaptureBitmap = CreateDIBSection(pDC->GetSafeHdc(), (CONST BITMAPINFO\*)&BMIH, DIB\_RGB\_COLORS, (void\*\*)&m\_pDrawingSurfaceBits, NULL, 0);
    	ReleaseDC(pDC);
    }
    
    SelectObject(hCaptureDC,m\_hCaptureBitmap); 
    BitBlt(hCaptureDC,
    	0,
    	0,
    	m\_rDrawingSurface.Width(),
    	m\_rDrawingSurface.Height(),
    	hScrollView,0, 0,SRCCOPY|CAPTUREBLT); 
    
    CxImage \*image = new CxImage();
    if(m\_hCaptureBitmap)
    {
    	image->CreateFromHBITMAP(m\_hCaptureBitmap);
    	bool retval;
    
    	retval = image->Save("c:\\\\ss.bmp", CXIMAGE\_FORMAT\_JPG);
    }
    if (image) delete image;
    
    
    
    ::ReleaseDC(hWnd,hDesktopDC);
    DeleteDC(hCaptureDC);
    DeleteObject(m\_hCaptureBitmap); :)
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups