🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: screen capture

#14928
From: Hugo Oliveira Dias
Date: Mon, 28 Jul 2003 00:07
95 lines
4015 bytes
GetObject(desk_hdc, sizeof(bm), &bm) is not returning correct width and
heigth.
I don't know why...

Try this :

RECT rect;
GetClientRect(desk_hwnd,&rect);

Replace bm.Width and bm.Height for rect.right and rect.bottom.

Hugo Oliveira Dias



"micheal davis" <micheal_davis@hotmail.com> wrote in message
news:3f245245@newsgroups.borland.com...
> 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: <3f246919@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f23bee4@newsgroups.borland.com> <3f2409b9$1@newsgroups.borland.com> <3f245245@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 17:09:24 PST
From: "Hugo Oliveira Dias" <hugo.dias@no-spam.pluricanal.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f23bee4@newsgroups.borland.com> <3f2409b9$1@newsgroups.borland.com> <3f245245@newsgroups.borland.com>
Subject: Re: screen capture
Date: Mon, 28 Jul 2003 01:07:51 +0100
Lines: 97
Organization: Synchron Systems
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 213.58.167.9
Message-ID: <3f246919@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059350809 213.58.167.9 (27 Jul 2003 17:06:49 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail