Click here to Skip to main content
15,949,686 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RunModalLoop problem Pin
hrishiS8-Dec-08 0:17
hrishiS8-Dec-08 0:17 
QuestionHow to prevent execution of multiple instances of my application ? Pin
kapardhi30-Nov-08 22:37
kapardhi30-Nov-08 22:37 
AnswerRe: How to prevent execution of multiple instances of my application ? Pin
_AnsHUMAN_ 30-Nov-08 22:43
_AnsHUMAN_ 30-Nov-08 22:43 
AnswerRe: How to prevent execution of multiple instances of my application ? Pin
David Crow1-Dec-08 10:48
David Crow1-Dec-08 10:48 
Questionextending or customizing printer dialog progrmmatically in VC++[modified] Pin
Member 372884130-Nov-08 21:45
Member 372884130-Nov-08 21:45 
AnswerRe: extending or customizing printer dialog progrmmatically in VC+ Pin
SandipG 30-Nov-08 22:03
SandipG 30-Nov-08 22:03 
GeneralRe: extending or customizing printer dialog progrmmatically in VC+ Pin
Member 372884114-Dec-08 17:10
Member 372884114-Dec-08 17:10 
QuestionDesktop screen shot function failed in RDP Pin
onlyjaypatel30-Nov-08 20:59
onlyjaypatel30-Nov-08 20:59 
Hi All,

I have one program thats taking the screen shot of desktop and
save in a file.But this program is running on remote machine.I connect this machine with RDP.Problem is When i connected to machine program is working fine and taking screen shots ,but when i disconnected from RDP or minimized it it failed.

I found that,
The Bitblt function of the following sample code is falied with
Error 6.Otherwise its working fine when i m connected to it.

Error 6 means Invalid handle.

Can anybody tell why its failed of any other method of taking screen shot of desktop.?

Thanx in advance..

//////////////////////////////////////////
BOOL CBitmapFile::SaveDesktopAsFile(LPTSTR szFile, int nFileType)
{
CString strFileName, strError = "";
CWnd* pWnd = CWnd::GetDesktopWindow();
CBitmap bitmap;
CWindowDC dc(pWnd);
CDC memDC;
CRect rect;

strFileName = (CString)szFile;
memDC.CreateCompatibleDC(&dc);

pWnd->GetWindowRect(rect);

bitmap.CreateCompatibleBitmap(&dc, rect.Width(),rect.Height() );

CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
memDC.BitBlt(0, 0, rect.Width(),rect.Height(), &dc, 0, 0, SRCCOPY);

// Create logical palette if device support a palette
CPalette pal;
if( dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE )
{
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 256);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = 0x300;

pLP->palNumEntries =
GetSystemPaletteEntries( dc, 0, 255, pLP->palPalEntry );

// Create the palette
pal.CreatePalette( pLP );

delete[] pLP;
}


// Convert the bitmap to a DIB
HANDLE hDIB = DDBToDIB( bitmap, BI_RGB, &pal );

if( hDIB == NULL )
return FALSE;

// DrawGreyScale( &memDC, hDIB );

memDC.SelectObject(pOldBitmap);

// Write it to file
// Write it to file
if(nFileType == BMP_FILE)
WriteDIB( szFile, hDIB );
else
JpegFromDib(hDIB, 100, strFileName, &strError);

// Free the memory allocated by DDBToDIB for the DIB
GlobalFree( hDIB );
return TRUE;
}
//////////////////////////////////////////
AnswerRe: Desktop screen shot function failed in RDP Pin
Code-o-mat1-Dec-08 5:53
Code-o-mat1-Dec-08 5:53 
QuestionRe: Desktop screen shot function failed in RDP Pin
David Crow1-Dec-08 10:53
David Crow1-Dec-08 10:53 
GeneralRe: Desktop screen shot function failed in RDP Pin
onlyjaypatel1-Dec-08 18:06
onlyjaypatel1-Dec-08 18:06 
QuestionButton TabStop Pin
cpvc++30-Nov-08 19:59
cpvc++30-Nov-08 19:59 
AnswerRe: Button TabStop Pin
Hamid_RT30-Nov-08 20:21
Hamid_RT30-Nov-08 20:21 
GeneralRe: Button TabStop Pin
cpvc++30-Nov-08 20:24
cpvc++30-Nov-08 20:24 
GeneralRe: Button TabStop Pin
Hamid_RT30-Nov-08 20:30
Hamid_RT30-Nov-08 20:30 
GeneralRe: Button TabStop Pin
User 21559730-Nov-08 22:54
User 21559730-Nov-08 22:54 
JokeRe: Button TabStop Pin
_AnsHUMAN_ 30-Nov-08 20:23
_AnsHUMAN_ 30-Nov-08 20:23 
GeneralRe: Button TabStop Pin
cpvc++30-Nov-08 20:24
cpvc++30-Nov-08 20:24 
GeneralRe: Button TabStop Pin
Hamid_RT30-Nov-08 20:27
Hamid_RT30-Nov-08 20:27 
GeneralRe: Button TabStop Pin
_AnsHUMAN_ 30-Nov-08 20:38
_AnsHUMAN_ 30-Nov-08 20:38 
GeneralRe: Button TabStop Pin
Hamid_RT30-Nov-08 20:51
Hamid_RT30-Nov-08 20:51 
GeneralRe: Button TabStop Pin
cpvc++30-Nov-08 20:57
cpvc++30-Nov-08 20:57 
GeneralRe: Button TabStop Pin
_AnsHUMAN_ 30-Nov-08 21:36
_AnsHUMAN_ 30-Nov-08 21:36 
Questionget montior resolution.....??? Pin
shaina223130-Nov-08 19:44
shaina223130-Nov-08 19:44 
AnswerRe: get montior resolution.....??? Pin
Perspx30-Nov-08 20:01
Perspx30-Nov-08 20:01 

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.