VC++程序源代码 贾长建.docx

上传人:b****5 文档编号:29307061 上传时间:2023-07-22 格式:DOCX 页数:13 大小:17KB
下载 相关 举报
VC++程序源代码 贾长建.docx_第1页
第1页 / 共13页
VC++程序源代码 贾长建.docx_第2页
第2页 / 共13页
VC++程序源代码 贾长建.docx_第3页
第3页 / 共13页
VC++程序源代码 贾长建.docx_第4页
第4页 / 共13页
VC++程序源代码 贾长建.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

VC++程序源代码 贾长建.docx

《VC++程序源代码 贾长建.docx》由会员分享,可在线阅读,更多相关《VC++程序源代码 贾长建.docx(13页珍藏版)》请在冰豆网上搜索。

VC++程序源代码 贾长建.docx

VC++程序源代码贾长建

JCJView.cpp

//JCJView.cpp:

implementationoftheCJCJViewclass

//

#include"stdafx.h"

#include"JCJ.h"

#include"JCJDoc.h"

#include"JCJView.h"

#include"MainFrm.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

//CJCJView

IMPLEMENT_DYNCREATE(CJCJView,CView)

BEGIN_MESSAGE_MAP(CJCJView,CView)

//{{AFX_MSG_MAP(CJCJView)

ON_COMMAND(ID_MENUITEM32771,OnMenuitem32771)

ON_COMMAND(ID_MENUITEM32772,OnMenuitem32772)

ON_COMMAND(ID_MENUITEM32773,OnMenuitem32773)

ON_COMMAND(ID_MENUITEM32774,OnMenuitem32774)

ON_WM_MOUSEMOVE()

ON_WM_TIMER()

ON_COMMAND(ID_MENU_bitmap,OnMENUbitmap)

ON_COMMAND(ID_MENU_textout,OnMENUtextout)

ON_COMMAND(ID_MENU_draw,OnMENUdraw)

//}}AFX_MSG_MAP

//Standardprintingcommands

ON_COMMAND(ID_FILE_PRINT,CView:

:

OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_DIRECT,CView:

:

OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_PREVIEW,CView:

:

OnFilePrintPreview)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CJCJViewconstruction/destruction

CJCJView:

:

CJCJView()

{x_b=0;flag=0;

caidanID=32772,m=1;

}

CJCJView:

:

~CJCJView()

{

}

BOOLCJCJView:

:

PreCreateWindow(CREATESTRUCT&cs)

{

//TODO:

ModifytheWindowclassorstylesherebymodifying

//theCREATESTRUCTcs

returnCView:

:

PreCreateWindow(cs);

}

/////////////////////////////////////////////////////////////////////////////

//CJCJViewdrawing

voidCJCJView:

:

OnDraw(CDC*pDC)

{text(pDC,200,300,200,"黑体",RGB(0,0,255),"1232222222222");

CJCJDoc*pDoc=GetDocument();

ASSERT_VALID(pDoc);

//TODO:

adddrawcodefornativedatahere

}

/////////////////////////////////////////////////////////////////////////////

//CJCJViewprinting

BOOLCJCJView:

:

OnPreparePrinting(CPrintInfo*pInfo)

{

//defaultpreparation

returnDoPreparePrinting(pInfo);

}

voidCJCJView:

:

OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)

{

//TODO:

addextrainitializationbeforeprinting

}

voidCJCJView:

:

OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)

{

//TODO:

addcleanupafterprinting

}

/////////////////////////////////////////////////////////////////////////////

//CJCJViewdiagnostics

#ifdef_DEBUG

voidCJCJView:

:

AssertValid()const

{

CView:

:

AssertValid();

}

voidCJCJView:

:

Dump(CDumpContext&dc)const

{

CView:

:

Dump(dc);

}

CJCJDoc*CJCJView:

:

GetDocument()//non-debugversionisinline

{

ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJCJDoc)));

return(CJCJDoc*)m_pDocument;

}

#endif//_DEBUG

/////////////////////////////////////////////////////////////////////////////

//CJCJViewmessagehandlers

voidCJCJView:

:

OnMenuitem32771()

{

CWnd*pParent=GetParent();//得到主框窗口

CMenu*pMenu=pParent->GetMenu();//得到所有菜单

CMenu*SubMenu1=pMenu->GetSubMenu(4);//第5列菜单

CMenumenu;

menu.CreatePopupMenu();

switch(m)

{

case1:

SubMenu1->AppendMenu(MF_STRING,caidanID,"menu1");caidanID++;m++;break;

case2:

SubMenu1->AppendMenu(MF_STRING,caidanID,"menu2");caidanID++;m++;break;

case3:

SubMenu1->AppendMenu(MF_STRING,caidanID,"menu3");caidanID++;m++;break;

default:

MessageBox("添加完!

");

}

menu.Detach();

GetParent()->DrawMenuBar();

}

voidCJCJView:

:

OnMenuitem32772()

{

CDC*pDC;

pDC=GetDC();

CRectrect(100,100,300,300);//画一个长100,宽100的矩形

pDC->Rectangle(&rect);

}

voidCJCJView:

:

OnMenuitem32773()

{

//MessageBox("车辆22222222");

CDC*pDC;

pDC=GetDC();

CPointpoly[4];//画一个平行四边形

poly[0]=CPoint(0,0);

poly[1]=CPoint(50,50);

poly[2]=CPoint(50,100);

poly[3]=CPoint(0,50);

pDC->Polygon(poly,4);

}

voidCJCJView:

:

OnMenuitem32774()

{

MessageBox("车辆33333333");

}

voidCJCJView:

:

OnMouseMove(UINTnFlags,CPointpoint)

{

CMainFrame*pm=(CMainFrame*)AfxGetMainWnd();

CStatusBar*psb=&pm->m_wndStatusBar;

CStringstr;

if(psb)

{

str.Format("x=%d,y=%d",point.x,point.y);

psb->SetPaneText(0,str);

//psb->SetPaneText(psb->CommandToIndex(ID_SEPARATOR),str);

}

CView:

:

OnMouseMove(nFlags,point);

}

voidCJCJView:

:

OnTimer(UINTnIDEvent)

{

if(x_b==1000||x_b==0)

flag=!

flag;

if(flag==1)

{x_b=x_b+1;}

else

{x_b=x_b-1;}

UpdateData(true);

CBitmapbitmap1,*pOldbitmap;

bitmap1.LoadBitmap(IDB_BITMAP1);

CDCmemDC1,*pDC;

pDC=GetDC();

memDC1.CreateCompatibleDC(pDC);

pOldbitmap=memDC1.SelectObject(&bitmap1);

pDC->BitBlt(x_b,0,600,600,&memDC1,0,0,SRCCOPY);

if(flag==1)

{pDC->FillSolidRect(0,0,x_b,600,RGB(255,255,255));}

else

{pDC->FillSolidRect(x_b+300,0,1200,600,RGB(255,255,255));}

memDC1.SelectObject(pOldbitmap);

CView:

:

OnTimer(nIDEvent);

}

voidCJCJView:

:

OnMENUbitmap()

{

SetTimer(0,10,NULL);

}

voidCJCJView:

:

text(CDC*pDC,intx_zuobiao,inty_zuobiao,intDa_ziti,LPCTSTRziti,COLORREFr_color,CStringstr

{

CFontfn;

CFont*pfn;

fn.CreatePointFont(Da_ziti,ziti,pDC);

pfn=pDC->SelectObject(&fn);

pDC->SetTextColor(r_color);

pDC->TextOut(x_zuobiao,y_zuobiao,str);

pDC->SelectObject(pfn);

}

voidCJCJView:

:

OnMENUtextout()

{CDC*pDC;

pDC=GetDC();

CFontfn1;

CFont*pfn1;

fn1.CreatePointFont(200,"Arial",pDC);

pfn1=pDC->SelectObject(&fn1);

pDC->SetTextColor(RGB(0,125,0));

pDC->TextOut(20,300,"1234567890");

pDC->SelectObject(pfn1);

}

voidCJCJView:

:

OnMENUdraw()

{

CDC*pDC;

pDC=GetDC();

CPointpoly[4];//画一个平行四边形

poly[0]=CPoint(0,0);

poly[1]=CPoint(50,50);

poly[2]=CPoint(50,100);

poly[3]=CPoint(0,50);

pDC->Polygon(poly,4);

CRectrect(100,100,300,300);//画一个长100,宽100的矩形

pDC->Rectangle(&rect);

}

MainFrm.cpp

//MainFrm.cpp:

implementationoftheCMainFrameclass

//

#include"stdafx.h"

#include"JCJ.h"

#include"MainFrm.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

//CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame,CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame,CFrameWnd)

//{{AFX_MSG_MAP(CMainFrame)

ON_WM_CREATE()

ON_WM_TIMER()

ON_WM_CLOSE()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

staticUINTindicators[]=

{

ID_SEPARATOR,//statuslineindicator

ID_INDICATOR_CAPS,

ID_INDICATOR_NUM,

ID_INDICATOR_SCRL,

ID_INDICATOR_TIMER,

};

/////////////////////////////////////////////////////////////////////////////

//CMainFrameconstruction/destruction

CMainFrame:

:

CMainFrame()

{

//TODO:

addmemberinitializationcodehere

}

CMainFrame:

:

~CMainFrame()

{

}

intCMainFrame:

:

OnCreate(LPCREATESTRUCTlpCreateStruct)

{

if(CFrameWnd:

:

OnCreate(lpCreateStruct)==-1)

return-1;

if(!

m_wndToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_TOP

|CBRS_GRIPPER|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)||

!

m_wndToolBar.LoadToolBar(IDR_MAINFRAME))

{

TRACE0("Failedtocreatetoolbar\n");

return-1;//failtocreate

}

if(!

m_wndStatusBar.Create(this)||

!

m_wndStatusBar.SetIndicators(indicators,

sizeof(indicators)/sizeof(UINT)))

{

TRACE0("Failedtocreatestatusbar\n");

return-1;//failtocreate

}

//TODO:

Deletethesethreelinesifyoudon'twantthetoolbarto

//bedockable

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_wndToolBar);

SetTimer(1,1000,NULL);//安装一个计时器

return0;

}

BOOLCMainFrame:

:

PreCreateWindow(CREATESTRUCT&cs)

{

if(!

CFrameWnd:

:

PreCreateWindow(cs))

returnFALSE;

//TODO:

ModifytheWindowclassorstylesherebymodifying

//theCREATESTRUCTcs

returnTRUE;

}

/////////////////////////////////////////////////////////////////////////////

//CMainFramediagnostics

#ifdef_DEBUG

voidCMainFrame:

:

AssertValid()const

{

CFrameWnd:

:

AssertValid();

}

voidCMainFrame:

:

Dump(CDumpContext&dc)const

{

CFrameWnd:

:

Dump(dc);

}

#endif//_DEBUG

/////////////////////////////////////////////////////////////////////////////

//CMainFramemessagehandlers

voidCMainFrame:

:

OnTimer(UINTnIDEvent)

{

//TODO:

Addyourmessagehandlercodehereand/orcalldefault

CTimetime;//构建了一个CTime对象

time=CTime:

:

GetCurrentTime();//获得当前时间

CStringstr_time=time.Format("%H:

%M:

%S");

//设置时间格式为hh:

mm:

ss

m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(

ID_INDICATOR_TIMER),str_time);

//更新时间窗格显示的正文

CFrameWnd:

:

OnTimer(nIDEvent);

}

voidCMainFrame:

:

OnClose()

{

KillTimer

(1);//撤销主框架窗口时应关闭计时器

CFrameWnd:

:

OnClose();

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 材料科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1