🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: screen capture

#14924
From: micheal davis
Date: Sun, 27 Jul 2003 22:17
79 lines
3659 bytes
hi ed,

thanks a lot for your example, I tried to run the code with the following
function although it doesn't work

void __fastcall TForm2::FormShow(TObject *Sender)
{
  Graphics::TBitmap *Bitmap2 = new Graphics::TBitmap();
  Bitmap2->Handle = GetDeskBmp();

  Image1->Picture->Assign(Bitmap2);
  ShowMessage("done");

}
//--------------------------------------------------------------------------
-

I used the code of yours as is, just copy and paste....so what I am doing
wrong here !!!

"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> wrote in message
news:3f2409b9$1@newsgroups.borland.com...
> 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: <3f244f6b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f23bee4@newsgroups.borland.com> <3f2409b9$1@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 15:21:25 PST
From: "micheal davis" <micheal_davis@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f23bee4@newsgroups.borland.com> <3f2409b9$1@newsgroups.borland.com>
Subject: Re: screen capture
Date: Sun, 27 Jul 2003 14:17:13 -0800
Lines: 81
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.1165
NNTP-Posting-Host: 212.103.167.4
Message-ID: <3f244f6b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059344235 212.103.167.4 (27 Jul 2003 15:17:15 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail