6/24/10

Text at mouse clicked position (MFC)

Buzz It
#include
#include
int x=-11,y=-11;
class myframe:public CFrameWnd
{
CButton btn,cb,rb,gb;
CListBox l;
public:
myframe()
{
Create(0,"Mouse clickers");
}
void OnPaint()
{
CClientDC d(this);
if(x!=-11)
{
d.TextOut (x,y,"friendship");
}
}
void OnLButtonDown(UINT flags,CPoint p)
{
x=(int)p.x;
y=(int)p.y;
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe, CFrameWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
class myapp:public CWinApp
{
public:
int initInstance()
{
myframe *p;
p=new myframe;
p->ShowWindow(1);
m_pMainWnd=p;
return 1;
}
};
myapp a;



Output

0 comments:

Post a Comment