Click here to Skip to main content
15,910,121 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bitmap problem Pin
Nishad S8-Jan-08 19:14
Nishad S8-Jan-08 19:14 
GeneralRe: Bitmap problem Pin
trioum8-Jan-08 19:19
trioum8-Jan-08 19:19 
GeneralRe: Bitmap problem Pin
Nishad S8-Jan-08 19:48
Nishad S8-Jan-08 19:48 
GeneralRe: Bitmap problem Pin
trioum8-Jan-08 21:24
trioum8-Jan-08 21:24 
QuestionRe: Bitmap problem Pin
CPallini8-Jan-08 21:44
mveCPallini8-Jan-08 21:44 
GeneralRe: Bitmap problem Pin
uusheikh8-Jan-08 21:26
uusheikh8-Jan-08 21:26 
GeneralRe: Bitmap problem Pin
trioum8-Jan-08 23:05
trioum8-Jan-08 23:05 
QuestionProblem with BitBlt form the Service Application Pin
ashishbhatt8-Jan-08 17:33
ashishbhatt8-Jan-08 17:33 
Hi All,,

I am making the Windows Service with the help VC++. I want to perform the some tasks like capture desktop screen from the service.For that I have writen below code which gives unwanted result.

<br />
<br />
void SendCapturedScreen()<br />
{<br />
	FILE *f;<br />
	f = fopen("E:\\CaptureLog.txt","w");<br />
	char *str = (char *)malloc(2000);<br />
<br />
	RECT rect;<br />
<br />
	rect.left		= GetSystemMetrics(SM_XVIRTUALSCREEN);<br />
	rect.top		= GetSystemMetrics(SM_YVIRTUALSCREEN);<br />
	rect.right		= rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);<br />
	rect.bottom		= rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);<br />
<br />
        m_hrootdc = ::GetDC(NULL);<br />
        m_hmemdc = CreateCompatibleDC(m_hrootdc);<br />
        <br />
        int iWidth = rect.right - rect.left;<br />
	int iHeight = rect.bottom - rect.top;<br />
<br />
        HBITMAP new_Bitmap = CreateCompatibleBitmap(m_hrootdc,iWidth,iHeight);<br />
	HBITMAP temp_Bitmap = (HBITMAP)SelectObject(m_hmemdc,new_Bitmap);<br />
	if(temp_Bitmap == NULL)<br />
	{<br />
		sprintf(str,("Failed to get HBITMAP from SelectObject"));<br />
		fwrite(str,strlen(str),1,f);<br />
	}<br />
<br />
        BOOL blitok = BitBlt(<br />
		m_hmemdc,      				    <br />
		0,<br />
		0,<br />
		rect.right - rect.left,<br />
		rect.bottom - rect.top,<br />
		m_hrootdc,<br />
		rect.left, rect.top,<br />
		SRCCOPY);<br />
<br />
	int err = GetLastError();<br />
	<br />
        if(blitok)<br />
	{<br />
		sprintf(str,("\nBitBlt Successed\nError Code:%d"),err);<br />
		fwrite(str,strlen(str),1,f);<br />
	}<br />
	else<br />
	{<br />
		sprintf(str,("\nBitBlt Failed\nError Code:%d"),err);<br />
		fwrite(str,strlen(str),1,f);<br />
	}<br />
<br />


Here what happens I dont get the BitBlt function's success. It fails and the GetLastError() function returns the code no 6 means invalid handle.So I want to ask you form the service I can not perform this operation. And I also check that both handles are not null.

Plz give any suggesion you have.
Thanks in Advance.

Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.

GeneralRe: Problem with BitBlt form the Service Application Pin
Hamid_RT8-Jan-08 18:00
Hamid_RT8-Jan-08 18:00 
QuestionRe: Problem with BitBlt form the Service Application Pin
ashishbhatt8-Jan-08 18:41
ashishbhatt8-Jan-08 18:41 
GeneralRe: Problem with BitBlt form the Service Application Pin
Nishad S8-Jan-08 20:01
Nishad S8-Jan-08 20:01 
GeneralRe: Problem with BitBlt form the Service Application Pin
ashishbhatt8-Jan-08 20:54
ashishbhatt8-Jan-08 20:54 
GeneralRe: Problem with BitBlt form the Service Application Pin
Nishad S8-Jan-08 21:38
Nishad S8-Jan-08 21:38 
GeneralRe: Problem with BitBlt form the Service Application Pin
ashishbhatt8-Jan-08 21:59
ashishbhatt8-Jan-08 21:59 
GeneralRe: Problem with BitBlt form the Service Application Pin
Nishad S8-Jan-08 22:14
Nishad S8-Jan-08 22:14 
GeneralRe: Problem with BitBlt form the Service Application Pin
ashishbhatt8-Jan-08 22:28
ashishbhatt8-Jan-08 22:28 
GeneralRe: Problem with BitBlt form the Service Application Pin
Mark Salsbery9-Jan-08 7:30
Mark Salsbery9-Jan-08 7:30 
Questionhow to take the path dynamically when connecting to the database using SQLConfigDataSource function. Pin
viritha8-Jan-08 15:43
viritha8-Jan-08 15:43 
Generali want to change system time(TrayClockWClass) windows's width Pin
lgbean8-Jan-08 12:54
lgbean8-Jan-08 12:54 
Generalweird error on defining a friend method Pin
gizmokaka8-Jan-08 11:44
gizmokaka8-Jan-08 11:44 
GeneralRe: weird error on defining a friend method Pin
Mark Salsbery8-Jan-08 12:00
Mark Salsbery8-Jan-08 12:00 
GeneralRe: weird error on defining a friend method Pin
gizmokaka8-Jan-08 22:05
gizmokaka8-Jan-08 22:05 
GeneralRe: weird error on defining a friend method Pin
Mark Salsbery9-Jan-08 6:32
Mark Salsbery9-Jan-08 6:32 
QuestionSaving image in database Pin
reza_a8-Jan-08 11:04
reza_a8-Jan-08 11:04 
QuestionRe: Saving image in database Pin
Mark Salsbery8-Jan-08 12:01
Mark Salsbery8-Jan-08 12: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.