🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: screen capture

#14926
From: micheal davis
Date: Sun, 27 Jul 2003 22:29
72 lines
3395 bytes
Ed,

I even tried to check on the GetDeskBmp() return values to see if it returns
anything by using

HBITMAP MyPicture;
MyPicture=GetDeskBmp();
 if(MyPicture==NULL) { ShowMessage("Null"); }  else { ShowMessage("Not
Null"); }

in my code and unfortunatly it returns NULL....


"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: <3f245245@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!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:31:34 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:29:25 -0800
Lines: 74
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: <3f245245@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059344965 212.103.167.4 (27 Jul 2003 15:29:25 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail