Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC - GetPixel Doesnt Work - HELP!

Status
Not open for further replies.

ITHODVGK

Programmer
May 7, 2003
5
IN
In an SDI application I created a new Class, say, CTest.

In one of the member functions of CTest I included the following code -

Code:
void CTest::SomeFunc(...)
{ 
     ...
  
     int x;
  
     int y;
     ...

     CFrameWnd* pFrame = (CFrameWnd*)(AfxGetApp()->m_pMainWnd);
     CMyAppView* pView = (CMyAppView*)(pFrame->GetActiveView());
     CClientDC dc(pView);

     COLORREF pix = dc.GetPixel(x, y);
  
     ...
}

But the function GetPixel doent return the correct value of the the pixel color at (x,y);

when I debugged it pix always had the value 0xffffffff.

Please help...
 
You have the wrong idea of how a device context works. When you create one it is empty and is meant to be used to draw to the device or to transfer data to the device memory i.e., video memory.

So you can't just create one that has all the data in it that has already been transfered to the video memory.

-pete
I just can't seem to get back my IntelliSense
 
So How do I implement a GetPixel Function from an external class?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top