Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i load image into temporary DC. the pixel[15,50]is green on the control .But in the temporary dc, It is [15,80].

It as if my image is go down in temp DC.
I don't now why?.
Could anyone help me?
my first control, use this:
C++
void myfunction(CPoint point,CDC *dc)
{      CDC dcMem;
	dcMem.CreateCompatibleDC(dc);
	dcMem.SelectObject(bmpCOM);
	HDC hdcMem=dcMem;
	COLORREF clr= GetPixel(hdcMem,point.x,point.y);
}

My Second control, i click directly onn control with LBUTTONDOWN.
C++
void CDirectClickCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	HWND hWnd=this->GetSafeHwnd();
	COLORREF clr=GetPixel(::GetDC(hWnd),point.x,point.y);

	COleControl::OnLButtonDown(nFlags, point);
}
Posted
Updated 2-Oct-15 0:13am
v3
Comments
Richard MacCutchan 2-Oct-15 8:03am    
You may need to adjust your mouse location to take account of the screen/window position. Check the documentation to see what the Y axis value is relative to.
Tokia 2-Oct-15 19:41pm    
Thank a lot. I will search for it.
Tokia 3-Oct-15 23:41pm    
i did search but i got nothing. Please help me.

1 solution

It is common for images to be flipped vertically, when you load them into memory.

Use the SetMapMode and SetViewPort functions to define the pixel coordinates and sizes for your DCs.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900