Thread View: borland.public.cppbuilder.nativeapi
9 messages
9 total messages
Started by Bashar Termanini
Fri, 04 Jan 2008 21:57
How can I take a screen shot?
Author: Bashar Termanini
Date: Fri, 04 Jan 2008 21:57
Date: Fri, 04 Jan 2008 21:57
1 lines
1031 bytes
1031 bytes
How can I take a screen shot and save it to a bmp file?
Re: How can I take a screen shot?
Author: Remy Lebeau (TeamB)
Date: Fri, 04 Jan 2008 22:31
Date: Fri, 04 Jan 2008 22:31
11 lines
1289 bytes
1289 bytes
"Bashar Termanini" <bashar-t@scs-net.org> wrote in message news:477eabc5@newsgroups.borland.com... > How can I take a screen shot and save it to a bmp file? This has been asked and answered many times before. Please go to http://www.deja.com and search the newsgroup archives. Gambit
Re: How can I take a screen shot?
Author: Asger Joergensen
Date: Sat, 05 Jan 2008 00:43
Date: Sat, 05 Jan 2008 00:43
11 lines
1098 bytes
1098 bytes
Hi Bashar Bashar Termanini says: > How can I take a screen shot and save it to a bmp file? I think if You use GetDC(NULL) You will get a HDC to the screen and then You can use BitBlt to copy the screen to a Bitmap. Kind regards Asger
Re: How can I take a screen shot?
Author: Bashar Termanini
Date: Fri, 11 Jan 2008 21:44
Date: Fri, 11 Jan 2008 21:44
23 lines
1648 bytes
1648 bytes
"Asger Joergensen" <junk@Asger-P.dk> wrote in message news:MPG.21e8f11d54bf16ac9899c6@newsgroups.borland.com... > > Hi Bashar > > Bashar Termanini says: >> How can I take a screen shot and save it to a bmp file? > > I think if You use GetDC(NULL) You will get a HDC to the screen > and then You can use BitBlt to copy the screen to a Bitmap. > > Kind regards > Asger I use this code to capture the screen HWND hWnd = GetDesktopWindow(); HWND hDC = GetWindowDC( hWnd ); Image1->Width = Screen->Width; Image1->Height = Screen->Height; BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, hDC, 0, 0, SRCCOPY ); It works first time. But when the Desktop change it still give me the first screen shot.
Re: How can I take a screen shot?
Author: Alan Bellingham
Date: Fri, 11 Jan 2008 22:14
Date: Fri, 11 Jan 2008 22:14
21 lines
1691 bytes
1691 bytes
"Bashar Termanini" <bashar-t@scs-net.org> wrote: >I use this code to capture the screen >HWND hWnd = GetDesktopWindow(); >HWND hDC = GetWindowDC( hWnd ); >Image1->Width = Screen->Width; >Image1->Height = Screen->Height; >BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, hDC, 0, >0, SRCCOPY ); >It works first time. But when the Desktop change it still give me the first >screen shot. Hmmm. You don't call the release functions - ReleaseDC() for example. So next time you call this, you say you're getting the same results as previous? Alan Bellingham -- Team Browns <url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions <url:http://www.borland.com/newsgroups/netiquette.html> netiquette
Re: How can I take a screen shot?
Author: Jonathan Benedicto
Date: Fri, 11 Jan 2008 22:39
Date: Fri, 11 Jan 2008 22:39
37 lines
1926 bytes
1926 bytes
Bashar Termanini wrote:
> I use this code to capture the screen
> HWND hWnd = GetDesktopWindow();
> HWND hDC = GetWindowDC( hWnd );
First, a device context handle isn't a HWND. You should use HDC.
> Image1->Width = Screen->Width;
> Image1->Height = Screen->Height;
> BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, hDC,
> 0,
> 0, SRCCOPY );
> It works first time. But when the Desktop change it still give me the
> first
> screen shot.
Because the TImage component isn't redrawing the updated image to the
screen.
Try this code instead:
HDC dc = GetDC( NULL );
if( dc )
{
Image1->Width = Screen->Width;
Image1->Height = Screen->Height;
BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, dc,
0, 0, SRCCOPY );
ReleaseDC( NULL, dc );
Image1->Repaint();
}
HTH
Jon
Re: How can I take a screen shot?
Author: Bashar Termanini
Date: Mon, 14 Jan 2008 12:39
Date: Mon, 14 Jan 2008 12:39
24 lines
1666 bytes
1666 bytes
> Try this code instead:
>
> HDC dc = GetDC( NULL );
> if( dc )
> {
> Image1->Width = Screen->Width;
> Image1->Height = Screen->Height;
>
> BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height,
> dc, 0, 0, SRCCOPY );
> ReleaseDC( NULL, dc );
>
> Image1->Repaint();
> }
>
> HTH
>
> Jon
This code work fine.
But when the screen resolution is 800 * 600 and a game run at 1024 * 768
this code capture only 800 * 600 and ignore the rest of the desktop.
Re: How can I take a screen shot?
Author: Jonathan Benedicto
Date: Mon, 14 Jan 2008 16:59
Date: Mon, 14 Jan 2008 16:59
16 lines
1661 bytes
1661 bytes
Bashar Termanini wrote: > This code work fine. > > But when the screen resolution is 800 * 600 and a game run at 1024 * 768 > this code capture only 800 * 600 and ignore the rest of the desktop. I'd guess that the best way to handle this is not to use Screen->Width and Screen->Height, but something like this: int ScreenWidth = GetDeviceCaps( dc, HORZRES ); int ScreenHeight = GetDeviceCaps( dc, VERTRES ); You'll have to put this code after the GetDC call, as it needs the device context handle of the screen. Jon
Re: How can I take a screen shot?
Author: Joe C. Hecht
Date: Mon, 21 Jan 2008 18:42
Date: Mon, 21 Jan 2008 18:42
16 lines
1542 bytes
1542 bytes
> But when the screen resolution is 800 * 600 and a game run at 1024 * 768 this code capture only 800 * 600 and ignore the rest of > the desktop. Search the groups at google advanced group search for Joe Hecht and ScreenShot for some very good screenshot code Joe -- Delphi, graphics, and printing specialist available - $60/hr http://www.code4sale.com/codeit/index.htm Joe Hecht Associates 121 Louise Drive Crestview, FL 32536
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads