program
DESCRIPTION
Program. Color Changer. #include< afxwin.h > class myframe:public CFrameWnd { public: myframe () { CString mywindowclass ; CBrush mybrush ; mybrush.CreateSolidBrush (RGB(255,255,255)) ; mywindowclass = AfxRegisterWndClass (CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,0,MYBRUSH,0;) - PowerPoint PPT PresentationTRANSCRIPT
Program
Color Changer
#include<afxwin.h>class myframe:public CFrameWnd{public:
myframe(){
CString mywindowclass;CBrush mybrush;mybrush.CreateSolidBrush(RGB(255,255,255)) ;mywindowclass=AfxRegisterWndClass(CS_HREDRAW
| CS_VREDRAW | CS_DBLCLKS,0,MYBRUSH,0;)Create(mywindowclass,"Double Clicking The
Left Mouse Button");
void OnLButtonDown (UINT flag,CPoint pt);{
CClientDC d(this);d.SetBkMode(TRANSPARENT);d.SetTextColor(RGB(0,0,255));d.TextOut(pt.x,pt.y,"Hello",5);
}void OnLButtonDbClk(UINT flag,CPoint pt){
CClientDC d(this);d.SetBkMode(TRANSPARENT);d.SetTextColor(RGB(25,0,0));d.TextOut(pt.x,pt.y,"Hello",5);
}DECLARE_MESSAGE_MAP()
};
Message Map
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)ON_WM_LBUTTONDOWN()ON_WM_LBUTTONDBLCLK()END_MESSAGE_MAP()
class myapp:public CWinApp
{public:
int InitInstance()
{my frame *p;
p=new myframe;
p->ShowWindow(1);
return1;
}
};myapp a;
Draw Line With Mouse
Movement
#include<afxwin.h>class myframe:public CFrameWnd{private:
CPoint startpoint,endpoint;public:
myframe(){
Create(0,"Click Left Mouse Button in Tje Left Area");}void OnLButtonDown(UINT flag,CPoint pt){
endpoint=startpoint=pt;}
void OnMouseMove(UINT flag,CPoint pt){
CClientDC d(this);if(flag==MK_LBUTTON){
d.SetROP2(R2_NOTXORPEN);//erase lined.MoveTo(startpoint);d.LineTo(endpoint);//draw lined.MoveTo(startpoint);d.LineTo(pt).endpoint=pt;
}
void OnLButtonUp (UINT flag,CPoint pt){
CClientDC d(this);d.MoveTo(startpoint);d.LineTo(endpoint);
}DECLARE_MESSAGE_MAP()
};BEGIN_MESSAGE_MAP(myframe,CFrameWnd)ON_WM_LBUTTONDOWN()ON_WM_MOUSEMOVE()ON_WM_LBUTTONUP()
END_MESSAGE_MAP()
class myapp:public CWinApp{public:
int InitInstance(){
my frame *p;p=new myframe;p->ShowWindow(1);return1;
}};myapp a;