Thread: Screenshots

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    Screenshots

    Hi!

    I want to write a code to capture the current screen. How can I do this please?

    Thanks.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Press Print Screen
    Open up your fav paint program.
    Edit->Paste as New Image.

    As far as code goes...I'm sure it has something to do with the Windows clipboard.

  3. #3
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    I'm trying the below code, but it's not working. And could anyone please explain the "capture driver index" parameter of capDriverConnect()?

    Code:
    #include "stdafx.h"
    #pragma comment(lib, "vfw32")
    #include<vfw.h>
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    	HWND hwnd = capCreateCaptureWindow ( "Capture Window", 
    		WS_VISIBLE , 0, 0, 200, 200, NULL, 0);
    
    	if(!capDriverConnect (hwnd, 0))
    		MessageBox(NULL, "error", NULL,0);
    
    	if(!capGrabFrameNoStop(hwnd))
    		MessageBox(NULL, "error", NULL,0);
    
    	if(!capFileSaveDIB(hwnd, "cap.bmp"))
    		MessageBox(NULL, "error", NULL,0);
    		
    	return 0;
    }

  4. #4
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Funnily enough I did a little search on this board and look at what I found
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  5. #5
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    Thanks.
    After I've got the bitmap in a DC, how can I save it as a bmp file on the disk?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Study the file format
    Use WriteFile
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screenshots
    By Dae in forum Windows Programming
    Replies: 4
    Last Post: 07-08-2009, 01:21 AM
  2. New screenshots from engine
    By VirtualAce in forum Game Programming
    Replies: 48
    Last Post: 11-30-2004, 09:30 PM
  3. screenshots of your games
    By stallion in forum Game Programming
    Replies: 94
    Last Post: 03-26-2003, 08:56 PM
  4. Screenshots in RealOne
    By harryP in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-05-2002, 01:30 PM
  5. Screenshots of Upcoming "Mists of Avalon"
    By harry_p in forum C++ Programming
    Replies: 62
    Last Post: 08-02-2002, 11:37 AM