program

10
Program Color Changer

Upload: austine-janus

Post on 31-Dec-2015

19 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: Program

Program

Color Changer

Page 2: Program

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

Page 3: Program

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

};

Page 4: Program

Message Map

BEGIN_MESSAGE_MAP(myframe,CFrameWnd)ON_WM_LBUTTONDOWN()ON_WM_LBUTTONDBLCLK()END_MESSAGE_MAP()

Page 5: Program

class myapp:public CWinApp

{public:

int InitInstance()

{my frame *p;

p=new myframe;

p->ShowWindow(1);

return1;

}

};myapp a;

Page 6: Program

Draw Line With Mouse

Movement

Page 7: Program

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

Page 8: Program

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;

}

Page 9: Program

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

Page 10: Program

class myapp:public CWinApp{public:

int InitInstance(){

my frame *p;p=new myframe;p->ShowWindow(1);return1;

}};myapp a;