Click here to Skip to main content
15,887,361 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Adam Roderick J29-Jul-09 20:23
Adam Roderick J29-Jul-09 20:23 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Madhu_Rani29-Jul-09 21:43
Madhu_Rani29-Jul-09 21:43 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Madhu_Rani29-Jul-09 23:17
Madhu_Rani29-Jul-09 23:17 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Adam Roderick J29-Jul-09 23:35
Adam Roderick J29-Jul-09 23:35 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Madhu_Rani29-Jul-09 23:41
Madhu_Rani29-Jul-09 23:41 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Adam Roderick J30-Jul-09 0:00
Adam Roderick J30-Jul-09 0:00 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Madhu_Rani30-Jul-09 0:05
Madhu_Rani30-Jul-09 0:05 
AnswerRe: Win32API/MFC to capture desktop as an image [modified] Pin
Adam Roderick J30-Jul-09 0:31
Adam Roderick J30-Jul-09 0:31 
Who will call the paint?

clue
1. Some one should call painting, isnt Smile | :)

Just simple, usually it is not done to give the whole code,
well check the below code.

HBITMAP CopyScreen( LPRECT lpRect_i )
{
HDC hDesktopDC, hMemDC;
int nXPos = 0, nYPos = 0;
int nWidth = 0, nHeight = 0;
HGDIOBJ hOldBitmap, hBitmap;

// check for an empty rectangle
if ( IsRectEmpty( lpRect_i ))
{
return NULL;
}

// create a DC for the screen and create
// a memory DC compatible to screen DC
hDesktopDC = CreateDC( _T( "DISPLAY" ), NULL, NULL, NULL );
hMemDC = CreateCompatibleDC( hDesktopDC ); // get points of rectangle to grab
nXPos = lpRect_i->left;
nYPos = lpRect_i->top;
nWidth = lpRect_i->right - lpRect_i->left;
nHeight = lpRect_i->bottom - lpRect_i->top ;

// create a bitmap compatible with the screen DC
hBitmap = CreateCompatibleBitmap( hDesktopDC, nWidth, nHeight );
// select new bitmap into memory DC
hOldBitmap = SelectObject ( hMemDC, hBitmap );
// bitblt screen DC to memory DC
BitBlt( hMemDC, 0, 0, nWidth, nHeight, hDesktopDC, nXPos, nYPos, SRCCOPY );
// select old bitmap back into memory DC and get handle to
// bitmap of the screen
hBitmap = SelectObject( hMemDC, hOldBitmap );
// clean up
DeleteDC( hDesktopDC );
DeleteDC( hMemDC );
// return handle to the bitmap
return ( HBITMAP )hBitmap;
}


void CSlideshawDlg::OnFirst()
{
RECT rect;
rect.left = 150;
rect.bottom = 500;
rect.top = 150;
rect.right = 500;
HBITMAP hBit = CopyScreen( &rect );
CDC memdc1;
CClientDC dc(this);
memdc1.CreateCompatibleDC(&dc);
memdc1.SelectObject( hBit );
dc.BitBlt(150,150,500,500,&memdc1,0,0,SRCCOPY);
}

Величие не Бога может быть недооценена.

modified on Thursday, July 30, 2009 7:01 AM

GeneralRe: Win32API/MFC to capture desktop as an image Pin
Madhu_Rani30-Jul-09 1:59
Madhu_Rani30-Jul-09 1:59 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Madhu_Rani30-Jul-09 2:05
Madhu_Rani30-Jul-09 2:05 
GeneralRe: Win32API/MFC to capture desktop as an image Pin
Asharudeed16-Feb-10 4:23
Asharudeed16-Feb-10 4:23 
QuestionemBDA.sys BSOD!!! [modified] Pin
Kiran Satish29-Jul-09 19:00
Kiran Satish29-Jul-09 19:00 
QuestionCRect Pin
kumar sanghvi29-Jul-09 18:45
kumar sanghvi29-Jul-09 18:45 
Questionhow to convert the matlab left matrix division \ into cv++ with opencv? Pin
DevelopmentNoob29-Jul-09 16:23
DevelopmentNoob29-Jul-09 16:23 
Question"Assertion Failed" with thread and device context Pin
nautilusvn29-Jul-09 16:11
nautilusvn29-Jul-09 16:11 
AnswerRe: "Assertion Failed" with thread and device context Pin
Richard Andrew x6429-Jul-09 16:51
professionalRichard Andrew x6429-Jul-09 16:51 
GeneralRe: "Assertion Failed" with thread and device context Pin
nautilusvn29-Jul-09 17:25
nautilusvn29-Jul-09 17:25 
GeneralRe: "Assertion Failed" with thread and device context Pin
Richard Andrew x6429-Jul-09 17:31
professionalRichard Andrew x6429-Jul-09 17:31 
GeneralRe: "Assertion Failed" with thread and device context Pin
Richard Andrew x6429-Jul-09 17:35
professionalRichard Andrew x6429-Jul-09 17:35 
GeneralRe: "Assertion Failed" with thread and device context Pin
nautilusvn29-Jul-09 20:27
nautilusvn29-Jul-09 20:27 
GeneralRe: "Assertion Failed" with thread and device context Pin
Richard Andrew x6430-Jul-09 4:14
professionalRichard Andrew x6430-Jul-09 4:14 
AnswerRe: "Assertion Failed" with thread and device context Pin
krmed30-Jul-09 6:53
krmed30-Jul-09 6:53 
QuestionPassing multi-dimensional array from C# to Win32 C++ dll? [modified] [MOVED TO C++/CLI] Pin
devvvy29-Jul-09 16:03
devvvy29-Jul-09 16:03 
AnswerRe: Passing multi-dimensional array from C# to Win32 C++ dll? Pin
Richard Andrew x6429-Jul-09 16:48
professionalRichard Andrew x6429-Jul-09 16:48 
Questionerror C1083 Pin
shabbychic29-Jul-09 15:57
shabbychic29-Jul-09 15:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.