该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
vc下的代码,老师说这是用c语言写的,我怎么看怎么不象。
晕了晕了。有些是两个冒号连用的。可是我记得两个冒号明明是c++里的语法。
高手帮忙看一下,这是不是用c写的代码?
// StudentPhotoDoc.cpp : implementation of the CStudentPhotoDoc class
//
#include "stdafx.h"
#include "StudentPhoto.h"
#include "StudentPhotoDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CStudentPhotoDoc
IMPLEMENT_DYNCREATE(CStudentPhotoDoc, CDocument)
BEGIN_MESSAGE_MAP(CStudentPhotoDoc, CDocument)
//{{AFX_MSG_MAP(CStudentPhotoDoc)
ON_COMMAND(IDR_WXSJDQ, OnWxsjdq)
ON_COMMAND(ID_WRITE_BMP_EXAMPLE, OnWriteBmpExample)
ON_COMMAND(ID_SHI_LI, OnShiLi)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CStudentPhotoDoc construction/destruction
CStudentPhotoDoc::CStudentPhotoDoc()
{
m_hDIB = NULL;
m_palDIB = NULL;
m_sizeDoc = CSize(1,1);
}
CStudentPhotoDoc::~CStudentPhotoDoc()
{
if (m_hDIB != NULL)
{
// 清除DIB对象
::GlobalFree((HGLOBAL) m_hDIB);
}
// 判断调色板是否存在
if (m_palDIB != NULL)
{
// 清除调色板
delete m_palDIB;
}
}
BOOL CStudentPhotoDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/
// CStudentPhotoDoc serialization
void CStudentPhotoDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/
// CStudentPhotoDoc diagnostics
#ifdef _DEBUG
void CStudentPhotoDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CStudentPhotoDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/
// CStudentPhotoDoc commands
void CStudentPhotoDoc::ReplaceHDIB(HDIB hDIB)
{
// 替换DIB,在功能粘贴中用到该函数
// 判断DIB是否为空
if (m_hDIB != NULL)
{
// 非空,则清除
::GlobalFree((HGLOBAL) m_hDIB);
}
// 替换成新的DIB对象
m_hDIB = hDIB;
}
void CStudentPhotoDoc::InitDIBData()
{
// 初始化DIB对象
// 判断调色板是否为空
if (m_palDIB != NULL)
{
// 删除调色板对象
delete m_palDIB;
// 重置调色板为空
m_palDIB = NULL;
}
// 如果DIB对象为空,直接返回
if (m_hDIB == NULL)
{
// 返回
return;
}
LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) m_hDIB);
// 判断图像是否过大
if (::DIBWidth(lpDIB) > INT_MAX ||::DIBHeight(lpDIB) > INT_MAX)
{
::GlobalUnlock((HGLOBAL) m_hDIB);
// 释放DIB对象
::GlobalFree((HGLOBAL) m_hDIB);
// 设置DIB为空
m_hDIB = NULL;
CString strMsg;
strMsg = "BMP图像太大!";