status bar & drawing

3
Status Bar #include<afxwin.h> #include<afxext.h> class myframe : public CFrameWnd { CStatusBar st; unsigned int indicator[5]; public: myframe() { Create(0,"Status Bar Demo Window",WS_OVERLAPPEDWINDOW, CRect(20,20,600,600),0); } int OnCreate() { st.Create(this); indicator[0]=0; indicator[1]=ID_INDICATOR_CAPS; indicator[2]=ID_INDICATOR_NUM; indicator[3]=ID_INDICATOR_SCRL; st.SetIndicators(indicator,4); return 1; } DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(myframe,CFrameWnd) ON_WM_CREATE() END_MESSAGE_MAP() class Capp : public CWinApp { int InitInstance() { m_pMainWnd=new myframe; m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return 1; } }; CApp App; Draw pictures using mouse button #include<afxwin.h>

Upload: benjamin-franklin

Post on 18-Apr-2015

13 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Status Bar & Drawing

Status Bar#include<afxwin.h>#include<afxext.h>class myframe : public CFrameWnd{

CStatusBar st;unsigned int indicator[5];

public:myframe(){Create(0,"Status Bar Demo Window",WS_OVERLAPPEDWINDOW, CRect(20,20,600,600),0);}int OnCreate(){

st.Create(this);indicator[0]=0;indicator[1]=ID_INDICATOR_CAPS;indicator[2]=ID_INDICATOR_NUM;indicator[3]=ID_INDICATOR_SCRL;st.SetIndicators(indicator,4);return 1;

}DECLARE_MESSAGE_MAP()

};BEGIN_MESSAGE_MAP(myframe,CFrameWnd) ON_WM_CREATE()END_MESSAGE_MAP()class Capp : public CWinApp{

int InitInstance(){

m_pMainWnd=new myframe;m_pMainWnd->ShowWindow(m_nCmdShow);m_pMainWnd->UpdateWindow();return 1;

}};CApp App;

Draw pictures using mouse button#include<afxwin.h>int x,x1,y,y1;bool flag;class myframe : public CFrameWnd{public:

myframe(){

Create(NULL,"My Application");}

Page 2: Status Bar & Drawing

void OnLButtonUp(UINT nflag, CPoint point){

flag = 0;}void OnLButtonDown(UINT nflags, CPoint point){

if(flag == 0){

CClientDC dc(this);x = point.x;y = point.y;flag = 1;

}}void OnMouseMove(UINT nflags, CPoint point){

if(flag == 1){

CClientDC dc(this);CPen mypen;mypen.CreatePen(PS_SOLID,2,2);dc.MoveTo(x,y);x1 = point.x;y1 = point.y;dc.LineTo(x1,y1);x = x1;y = y1;

}}

DECLARE_MESSAGE_MAP()};BEGIN_MESSAGE_MAP(myframe, CFrameWnd)

ON_WM_LBUTTONDOWN()ON_WM_LBUTTONUP()ON_WM_MOUSEMOVE()

END_MESSAGE_MAP()class myapp : public CWinApp{public:

int InitInstance(){

myframe *p;p=new myframe;p->ShowWindow(3);m_pMainWnd=p;return 1;

}};myapp a;