Click here to Skip to main content
15,898,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to read a file continuously using CFile Pin
Luc Pattyn6-Sep-10 6:53
sitebuilderLuc Pattyn6-Sep-10 6:53 
AnswerRe: how to read a file continuously using CFile Pin
Gurux Ltd7-Sep-10 3:39
Gurux Ltd7-Sep-10 3:39 
AnswerRe: how to read a file continuously using CFile Pin
MatrixDud7-Sep-10 3:51
MatrixDud7-Sep-10 3:51 
AnswerRe: how to read a file continuously using CFile Pin
ken_m7-Sep-10 12:39
ken_m7-Sep-10 12:39 
Questiontr1 is_member_function_pointer Pin
Doc Lobster6-Sep-10 1:08
Doc Lobster6-Sep-10 1:08 
AnswerRe: tr1 is_member_function_pointer Pin
Niklas L6-Sep-10 1:34
Niklas L6-Sep-10 1:34 
AnswerRe: tr1 is_member_function_pointer Pin
Aescleal6-Sep-10 1:38
Aescleal6-Sep-10 1:38 
QuestionHow to use ClientDC::GetPixel to get the pixel's RGB value when I call TextOut? Pin
wangningyu5-Sep-10 23:18
wangningyu5-Sep-10 23:18 
Hello !

I debug along time.but isn't success!

it isn't output "Call GetPixel Failed !", but isn't goto the other judgment.

the code like this:
class CTestDlg : public CDialog
{
public:
	// ......

public:
	void TextOutPut(CString str,
					HFONT	hNew,
					HFONT	&hOld,
					SIZE	&szt)
	{
		CClientDC	dc(this);
		
		// Set the back and text color 
		GetWindowRect(&rt);
		dc.SetBkColor(RGB(255,255,255));
		dc.SetTextColor(RGB(0,0,0));
		dc.SetMapMode(MM_TEXT);

		// Use CClientDC::TextOut
		hOld = (HFONT)::SelectObject(dc,hNew);
		dc.TextOut(0,0,str);

		// I can use this function to get the szt's value like 32*33
		GetTextExtentPoint32(dc,str,str.GetLength(),&szt);

		COLORREF cr;
		POINT	 pt;

		// Now start to find the pixcel's RGB value.
		for (int i=0; i<szt.cy; i++)
		{
			for (int j=0; j<szt.cx; j++)
			{
				pt.x = j;
				pt.y = i;
				cr = dc.GetPixel(pt);

				if( -1 == cr )
				{
					TRACE("Call GetPixel Failed !\r\n");
				}
				else if( RGB(255,255,255) == cr )
				{
					CString str;
					str.Format("cur pix position: x=%d y=%d is white.",j,i);
					TRACE(str);
					// Do something.
				}
				else if( RGB(0,0,0) == cr )
				{
					CString str;
					str.Format("cur pix position: x=%d y=%d is black.",j,i);
					TRACE(str);
					// Do something.
				}
			}
		}
	}
};


I think this maybe the GetPixel 's parents is wrong.

How to solve this problem ?


Thanks for your reply !
Best regards !
QuestionRe: How to use ClientDC::GetPixel to get the pixel's RGB value when I call TextOut? Pin
CPallini5-Sep-10 23:58
mveCPallini5-Sep-10 23:58 
AnswerRe: How to use ClientDC::GetPixel to get the pixel's RGB value when I call TextOut? Pin
wangningyu6-Sep-10 2:35
wangningyu6-Sep-10 2:35 
QuestionRe: How to use ClientDC::GetPixel to get the pixel's RGB value when I call TextOut? Pin
CPallini6-Sep-10 2:43
mveCPallini6-Sep-10 2:43 
Questionenumerating active TCP/UDP connections Pin
Chesnokov Yuriy5-Sep-10 20:27
professionalChesnokov Yuriy5-Sep-10 20:27 
AnswerRe: enumerating active TCP/UDP connections Pin
CPallini6-Sep-10 0:15
mveCPallini6-Sep-10 0:15 
Questionerror C2872: 'IAccessible' : ambiguous symbol Pin
learningvisualc5-Sep-10 20:12
learningvisualc5-Sep-10 20:12 
AnswerRe: error C2872: 'IAccessible' : ambiguous symbol Pin
«_Superman_»5-Sep-10 21:13
professional«_Superman_»5-Sep-10 21:13 
AnswerRe: error C2872: 'IAccessible' : ambiguous symbol Pin
Cool_Dev5-Sep-10 21:13
Cool_Dev5-Sep-10 21:13 
QuestionMFC dialog box blocked while threads are running... Pin
mashhur5-Sep-10 14:13
mashhur5-Sep-10 14:13 
AnswerRe: MFC dialog box blocked while threads are running... Pin
Dave Calkins5-Sep-10 17:13
Dave Calkins5-Sep-10 17:13 
GeneralRe: MFC dialog box blocked while threads are running... Pin
mashhur5-Sep-10 19:11
mashhur5-Sep-10 19:11 
AnswerRe: MFC dialog box blocked while threads are running... Pin
mashhur5-Sep-10 18:54
mashhur5-Sep-10 18:54 
QuestionRe: MFC dialog box blocked while threads are running... Pin
Niklas L5-Sep-10 22:07
Niklas L5-Sep-10 22:07 
Questionhow to ensure usb bulk transfer Pin
Oliver Arold5-Sep-10 11:19
Oliver Arold5-Sep-10 11:19 
AnswerRe: how to ensure usb bulk transfer Pin
«_Superman_»5-Sep-10 17:57
professional«_Superman_»5-Sep-10 17:57 
QuestionReading .CDFS audio: Where to start Pin
Danzy835-Sep-10 5:32
Danzy835-Sep-10 5:32 
AnswerRe: Reading .CDFS audio: Where to start Pin
sashoalm8-Sep-10 4:49
sashoalm8-Sep-10 4:49 

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.