Program
-
Upload
austine-janus -
Category
Documents
-
view
19 -
download
0
description
Transcript of Program
![Page 1: Program](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/1.jpg)
Program
Color Changer
![Page 2: Program](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/2.jpg)
#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](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/3.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/4.jpg)
Message Map
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)ON_WM_LBUTTONDOWN()ON_WM_LBUTTONDBLCLK()END_MESSAGE_MAP()
![Page 5: Program](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/5.jpg)
class myapp:public CWinApp
{public:
int InitInstance()
{my frame *p;
p=new myframe;
p->ShowWindow(1);
return1;
}
};myapp a;
![Page 6: Program](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/6.jpg)
Draw Line With Mouse
Movement
![Page 7: Program](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/7.jpg)
#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](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/9.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022072014/56812ed3550346895d94740c/html5/thumbnails/10.jpg)
class myapp:public CWinApp{public:
int InitInstance(){
my frame *p;p=new myframe;p->ShowWindow(1);return1;
}};myapp a;