100 likes | 193 Views
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;)
E N D
Program ColorChanger
#include<afxwin.h> class myframe:publicCFrameWnd { public: myframe() { CStringmywindowclass; CBrushmybrush; 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;
#include<afxwin.h> class myframe:publicCFrameWnd { private: CPointstartpoint,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 line d.MoveTo(startpoint); d.LineTo(endpoint); //draw line d.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:publicCWinApp { public: intInitInstance() { my frame *p; p=new myframe; p->ShowWindow(1); return1; } }; myapp a;