onfilesaveas.txt
来自「这是机械工业张德丰《MATLAB与外部程序接口编程》随书源码」· 文本 代码 · 共 47 行
TXT
47 行
void CDipDoc::OnfileSaveAs()
{
//TODO::Add your command handler code here
static int nIndex=1;
CFileDialog DialogSaveAs(FALSE,NULL,m_pDibObject->GetImageName(),OFN_HIDEREADONLY,szFilter);
DialogSaveAs.m_ofn.nFilterIndex=(DWORD)nIndex;
if(DialogSaveAs.DoModal()==IDOK)
{
CMainFram*pMainFram=(CMainFrame*)AfxGetMainWnd();
CChildFrame*pChildFrame=(CChildFrame*)pMainFrame->MDIGetActive();
CDipView*pDipView=(CDipView*)pChildFrame->GetActiveFrame();
nIndex=(int)DialogSaveAs.m_ofn.nFilterIndex;
if(nIndex==5)
{
if(m_pDibObject->GetNumBits()!=24)
{
AfxMessageBox("必须是24位真彩色图像才能存为JPEG格式!");
return;
}
}
if(m_pDibObject!=NULL)
{
CString strPathName=DialogSaveAs.GetPathName();
int nFindIndex=strPathName.Find(".");
if(nFindIndex!=-1)
strPathName=strPathName.Left(nFindIndex);
strPathName+=CDibObject::szExtensions[nIndex-1];
//m_pDibObject->ProcessImageHeader();
//m_pDibObject->ProcessPalette();
m_pDibObject->Save(strPathName);
CString strFileName=DialogSaveAs.GetFileName();
nFindIndex=strFileName.Find(".");
if(nFindIndex!=-1)
strFileName=strFileName.Left(nFindIndex);
strFileName+=CDibObject::szExtensions[nIndex-1];
pChildFrame->SetWindowText(strFileName);
SetPathName(strPathName);
if(nIndex==5)
{
m_pDibObject->Load(strPathName);
pDipView->InvalidateRect(NULL,FALSE);
pDipView->UpdateWindow();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?