⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 knc_misview.cpp

📁 基于SQLSERVER2000的机械工艺数据库系统
💻 CPP
字号:
// KNC_MISView.cpp : implementation of the CKNC_MISView class
//

#include "stdafx.h"
#include "KNC_MIS.h"

#include "KNC_MISDoc.h"
#include "KNC_MISView.h"
#include "CODEDLG.h"
#include "RULEDLG.h"
#include "WORKPIECE.h"
#include "TOOLDRILL.h"
#include "TOOLENDMILL.h"
#include "TOOLTURN.h"
#include "TOOLOTHER.h"
#include "PARAPLANE.h"
#include "PARATURN.h"
#include "PARADRILL.h"
#include "PARAMILL.h"
#include "INFORMATION.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CKNC_MISView

IMPLEMENT_DYNCREATE(CKNC_MISView, CView)

BEGIN_MESSAGE_MAP(CKNC_MISView, CView)
	//{{AFX_MSG_MAP(CKNC_MISView)
	ON_COMMAND(ID_CODE, OnCode)
	ON_COMMAND(ID_RULE, OnRule)
	ON_COMMAND(ID_WORKPIECE, OnWorkpiece)
	ON_COMMAND(ID_TOOL_DRILLING, OnToolDrilling)
	ON_COMMAND(ID_TOOL_MILLING, OnToolMilling)
	ON_COMMAND(ID_TOOL_TURNING, OnToolTurning)
	ON_COMMAND(ID_TOOL_OTHER, OnToolOther)
	ON_COMMAND(ID_PARAMETER_MILLPLANE, OnParameterMillplane)
	ON_COMMAND(ID_PARAMETER_TURN, OnParameterTurn)
	ON_COMMAND(ID_PARAMETER_DRILL, OnParameterDrill)
	ON_COMMAND(ID_PARAMETER_TURNMILL, OnParameterTurnmill)
	ON_COMMAND(ID_ABOUT_MESSAGE, OnAboutMessage)
	ON_COMMAND(ID_ABOUT_HELP, OnAboutHelp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CKNC_MISView construction/destruction

CKNC_MISView::CKNC_MISView()
{
	// TODO: add construction code here

}

CKNC_MISView::~CKNC_MISView()
{
}

BOOL CKNC_MISView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CKNC_MISView drawing

void CKNC_MISView::OnDraw(CDC* pDC)
{ //改变背景颜色
	CBrush Brush(RGB(136,193,255));
// Select the brush into the device context . 
    CBrush* pOldBrush = pDC->SelectObject (&Brush); 
// Get the area that needs to be erased . 
    CRect rcClip ; 
    pDC->GetClipBox (&rcClip); 
//Paint the area. 
    pDC->PatBlt(rcClip.left,rcClip.top,rcClip.Width(),rcClip.Height(),PATCOPY); 
//Unselect brush out of device context . 
    pDC->SelectObject (pOldBrush );
//加背景图
    IPicture *pPic;
    IStream *pStm;
	CClientDC dc(this);
    CFileStatus fstatus;
    CFile file;
    LONG cb;
	char path[MAX_PATH] = {'\0'};
	CString m_strExePath;
	GetModuleFileName(NULL,path,MAX_PATH);
	m_strExePath.Format("%s", path);
	int iPosition;
	iPosition = m_strExePath.ReverseFind('\\');
	m_strExePath = m_strExePath.Left(iPosition + 1);
    m_strExePath+="leilei.jpg";
	if (file.Open(m_strExePath,CFile::modeRead)&&file.GetStatus(m_strExePath,fstatus)&&((cb =fstatus.m_size) != -1))
    {
       HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);
       LPVOID pvData = NULL;
       if (hGlobal != NULL)
	   {
          if ((pvData = GlobalLock(hGlobal)) != NULL)
		  {
              file.ReadHuge(pvData, cb);
              GlobalUnlock(hGlobal);
              CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
              if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic)))
			  {
                   OLE_XSIZE_HIMETRIC hmWidth;
                   OLE_YSIZE_HIMETRIC hmHeight;    
                   pPic->get_Width(&hmWidth);
                   pPic->get_Height(&hmHeight);
				   CRect rect;
				   GetWindowRect(&rect);
                   double fX,fY;
                   fX=(double)dc.GetDeviceCaps(HORZRES)*(double)hmWidth/((double)dc.GetDeviceCaps(HORZSIZE)*100.0);
                   fY=(double)dc.GetDeviceCaps(VERTRES)*(double)hmHeight/((double)dc.GetDeviceCaps(VERTSIZE)*100.0);
                   if(FAILED(pPic->Render(dc,(rect.Width()-(DWORD)fX)/2,(rect.Height()-(DWORD)fY)/2,(DWORD)fX,(DWORD)fY,0,hmHeight,hmWidth,-hmHeight,NULL)))
                     AfxMessageBox("Failed To Render The picture!");
                   pPic->Release();
			  }
              else
                   AfxMessageBox("Error Loading Picture From Stream!");
		  }
	   }
	}
    else
       AfxMessageBox("Can't Open Image File!");
	CKNC_MISDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CKNC_MISView diagnostics

#ifdef _DEBUG
void CKNC_MISView::AssertValid() const
{
	CView::AssertValid();
}

void CKNC_MISView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CKNC_MISDoc* CKNC_MISView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CKNC_MISDoc)));
	return (CKNC_MISDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CKNC_MISView message handlers

void CKNC_MISView::OnCode() 
{
	// TODO: Add your command handler code here
	CCODEDLG dlg;
	dlg.DoModal();	
}

void CKNC_MISView::OnRule() 
{
	// TODO: Add your command handler code here
	CRULEDLG dlg;
	dlg.DoModal();	
}



void CKNC_MISView::OnWorkpiece() 
{
	// TODO: Add your command handler code here
	CWORKPIECE dlg;
	dlg.DoModal();	
}

void CKNC_MISView::OnToolDrilling() 
{
	// TODO: Add your command handler code here
	CTOOLDRILL dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnToolMilling() 
{
	// TODO: Add your command handler code here
	CTOOLENDMILL dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnToolTurning() 
{
	// TODO: Add your command handler code here
	CTOOLTURN dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnToolOther() 
{
	// TODO: Add your command handler code here
	CTOOLOTHER dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnParameterMillplane() 
{
	// TODO: Add your command handler code here
	CPARAPLANE dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnParameterTurn() 
{
	// TODO: Add your command handler code here
	CPARATURN dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnParameterDrill() 
{
	// TODO: Add your command handler code here
	CPARADRILL dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnParameterTurnmill() 
{
	// TODO: Add your command handler code here
	CPARAMILL dlg;
	dlg.DoModal();
}

void CKNC_MISView::OnAboutMessage() 
{
	// TODO: Add your command handler code here
	CINFORMATION dlg;
	dlg.DoModal();
}


void CKNC_MISView::OnAboutHelp() 
{
	// TODO: Add your command handler code here
	// 得到可CHM文件的路径
char exeFullPath[MAX_PATH];
CString strPath;
GetModuleFileName(NULL, exeFullPath, MAX_PATH);
strPath = CString(exeFullPath);
strPath = strPath.Left(strPath.ReverseFind('\\'));
strPath += "\\KNC.chm";
// 设置显示的初始页面
//strPath += "::软件使用说明书.htm";
char cCommandLine[MAX_PATH];
::strcpy(cCommandLine, strPath);
// 显示CHM帮助文件
HtmlHelp(GetSafeHwnd(), cCommandLine, HH_DISPLAY_TOPIC, 0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -