🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14923

Re: screen capture

#14923
From: Ed Mulroy [TeamB]
Date: Sun, 27 Jul 2003 17:19
55 lines
2989 bytes
Why would you have to search MSDN to find keybd_event when the help files
that came with the compiler already document it?

The current desktop is at least partially covered by other windows. If you
press the Print Screen key you will also get the image of those other
windows.  This should get you the desktop image in a bitmap or be very
close.  I leave it to you to figure out what you want to do with it after
that.

.  Ed

---------------------------------
#include <windows.h>

HBITMAP GetDeskBmp()
  {
  HBITMAP membmp;
  HDC memdc;
  BITMAP bm;
  HWND desk_hwnd = GetDesktopWindow();
  HDC  desk_hdc = GetDC(desk_hwnd);
  int  save_1;

  // create a device context (an DC) in memory which is compatible with
  // that of the desktop and also create an associated bitmap

  memdc = CreateCompatibleDC(desk_hdc); // create it
  save_1 = SaveDC(memdc); // save its state
  GetObject(desk_hdc, sizeof(bm), &bm); // get size of bitmap
  // create bitmap
  membmp = CreateCompatibleBitmap(desk_hdc, bm.bmWidth, bm.bmHeight);
  SelectObject(memdc, membmp); // make the DC use that bitmap

  // copy the desktop image to the bitmap
  BitBlt(memdc, 0, 0, bm.bmWidth, bm.bmHeight, desk_hdc, 0, 0, SRCCOPY);

  RestoreDC(memdc, save_1); // restore original DC state
  DeleteDC(memdc); // delete the DC
  return membmp; // return the bitmap containing the image
  }
---------------------------------

"micheal davis" <micheal_davis@hotmail.com> wrote in message
news:3f23bee4@newsgroups.borland.com...
> hi all,
>
> I am trying to get a screen capture of the current desktop and
> then save it to a bitmap file from my application, after searching
> msdn, I found the keybd_event()   function, although it takes a
> screen shot of my current program windows, can anyone tell me
> please how to make it take a shot for all of the desktop...
>
> I am using the code
>
> keybd_event(VK_SNAPSHOT, 0, 0, 0);
Technical Details
Message-ID: <3f2409b9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f23bee4@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3421856959936173
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-27 10:39:28 PST
From: "Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f23bee4@newsgroups.borland.com>
Subject: Re: screen capture
Date: Sun, 27 Jul 2003 13:19:40 -0400
Lines: 57
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <3f2409b9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059326393 24.74.175.102 (27 Jul 2003 10:19:53 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail