1 / 10

Program

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;)

Download Presentation

Program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Program ColorChanger

  2. #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");

  3. 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() };

  4. Message Map BEGIN_MESSAGE_MAP(myframe,CFrameWnd) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONDBLCLK() END_MESSAGE_MAP()

  5. class myapp:public CWinApp { public: int InitInstance() { my frame *p; p=new myframe; p->ShowWindow(1); return1; } }; myapp a;

  6. Draw Line With Mouse Movement

  7. #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; }

  8. 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; }

  9. 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()

  10. class myapp:publicCWinApp { public: intInitInstance() { my frame *p; p=new myframe; p->ShowWindow(1); return1; } }; myapp a;

More Related