Screenshots

This is a discussion on Screenshots within the Windows Programming forums, part of the Platform Specific Boards category; Hi! I want to write a code to capture the current screen. How can I do this please? Thanks....

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    374

    Screenshots

    Hi!

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

    Thanks.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    374
    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
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    374
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 08:30 PM
  3. screenshots of your games
    By stallion in forum Game Programming
    Replies: 94
    Last Post: 03-26-2003, 07: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21