// PictureShowView.cpp : implementation of the CPictureShowView class
//
#include "stdafx.h"
#include "PictureShow.h"
#include "PictureShowDoc.h"
#include "PictureShowView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "MainFrm.h"
/////////////////////////////////////////////////////////////////////////////
// CPictureShowView
IMPLEMENT_DYNCREATE(CPictureShowView, CScrollView)
BEGIN_MESSAGE_MAP(CPictureShowView, CScrollView)
//{{AFX_MSG_MAP(CPictureShowView)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_COMMAND(ID_LAST, OnLast)
ON_COMMAND(ID_NEXT, OnNext)
ON_UPDATE_COMMAND_UI(ID_NEXT, OnUpdateNext)
ON_UPDATE_COMMAND_UI(ID_LAST, OnUpdateLast)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPictureShowView construction/destruction
CPictureShowView::CPictureShowView()
{
// TODO: add construction code here
// m_vScroll=0;
m_clientOrg=0;
m_client=0;
m_indexSel=-1;
m_indexOrg=-1;
m_pics.RemoveAll();
m_strFiles.RemoveAll();
m_dcDraw=m_memDraw=false;
openFileCount=0;
IDS_PICTURE=400;
}
CPictureShowView::~CPictureShowView()
{
}
BOOL CPictureShowView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CPictureShowView drawing
void CPictureShowView::OnDraw(CDC* pDC)
{
CPictureShowDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//this->m_dcCompatibleDraw.SetViewportOrg(-m_sizeViewport.cx,-m_sizeViewport.cy);
/* this->GetClientRect(&m_client);
CSize sizeTotal;
sizeTotal=this->GetTotalSize();
if(m_dcCompatibleDraw.m_hDC)
m_dcCompatibleDraw.DeleteDC();
m_dcCompatibleDraw.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pDC,sizeTotal.cx,sizeTotal.cy);
m_dcCompatibleDraw.SelectObject(&bitmap);
CBrush *pBrush;
pBrush=CBrush::FromHandle((HBRUSH)(GetStockObject(WHITE_BRUSH)));
m_dcCompatibleDraw.FillRect(CRect(0,0,sizeTotal.cx,sizeTotal.cy),pBrush);
if(m_pics.GetSize())
{
this->ShowSmallPic(&m_dcCompatibleDraw);
}
if(m_indexSel!=-1)
{
this->ShowBigPic(&m_dcCompatibleDraw,m_indexSel);
}
pDC->BitBlt(0,0,sizeTotal.cx,sizeTotal.cy,&m_dcCompatibleDraw,0,0,SRCCOPY); */
/* this->GetClientRect(&m_client);
if(m_pics.GetSize())
{
this->ShowSmallPic(pDC);
}
if(m_indexSel!=-1)
{
this->ShowBigPic(pDC,m_indexSel);
}*/
CClientDC dc(this);
m_clientOrg=m_client;
this->GetClientRect(&m_client);
if(m_indexSel!=m_indexOrg)
{
this->DoIndexChanged(pDC,&m_dcSmall,&m_dcBig,m_indexSel,m_indexOrg);
}
if(m_memDraw==true)
{
this->memdcShowSmallPic(pDC);
this->memdcShowBigPic(pDC);
m_memDraw=false;
m_dcDraw=true;
}
if(m_dcDraw==true)
{
if(m_client!=m_clientOrg)
{
this->memdcShowBigPic(pDC);
//this->memdcShowSmallPic(pDC);
}
CSize size;
if(m_client.Width()>m_pics.GetSize()*100)
{
size.cx=m_client.Width();
size.cy=100;
pDC->BitBlt(0,m_client.Height()-100,size.cx*2,m_client.Height(),&m_dcSmall,0,0,SRCCOPY);
}
else
{
size.cx=m_pics.GetSize()*100;
size.cy=100;
pDC->BitBlt(0,m_client.Height()-100,m_pics.GetSize()*100,m_client.Height(),&m_dcSmall,0,0,SRCCOPY);
}
dc.BitBlt(0,0,m_client.Width(),m_client.Height()-100,&m_dcBig,0,0,SRCCOPY);
}
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CPictureShowView diagnostics
#ifdef _DEBUG
void CPictureShowView::AssertValid() const
{
CScrollView::AssertValid();
}
void CPictureShowView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CPictureShowDoc* CPictureShowView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPictureShowDoc)));
return (CPictureShowDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPictureShowView message handlers
void CPictureShowView::OnFileOpen()
{
// TODO: Add your command handler code here
//this->ResetAllDate();
CString strPath; GetCurrentDirectory(MAX_PATH,strPath.GetBuffer(MAX_PATH)); strPath.ReleaseBuffer();
CFileDialog dlg(true);
dlg.m_ofn.lpstrTitle="打开图片";
dlg.m_ofn.lpstrDefExt="jpg";
dlg.m_ofn.lpstrFilter="jpg image\0*.jpg\0Bitmap image\0*.bmp\0gif image\0*.gif\0all file\0*.*\0\0";
dlg.m_ofn.lpstrInitialDir=strPath;//对话框初始选择的路径;
dlg.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
dlg.m_ofn.nMaxFile = 4000; //这必不可少 要不然打开过多文件 会报错
char* pc = new char[4000];
dlg.m_ofn.lpstrFile = pc;
dlg.m_ofn.lpstrFile[0] = NULL;
if(IDOK==dlg.DoModal())
{
openFileCount++;
if(openFileCount!=1)
{
MessageBox("再次打开待改进功能 程序即将退出");
PostQuitMessage(0);
}
int count=0;
POSITION pos=dlg.GetStartPosition();
while(pos!=NULL)
{
CString *pstr=new CString(dlg.GetNextPathName(pos));
m_strFiles.Add(pstr);
count++;
}
if(count!=0 && count!=-1)
{
m_indexSel=0;
m_indexOrg=0;
}
this->LoadPicsFormStr();
this->CreateStatic();
m_memDraw=true;
this->SetPicInfoOnPane();
this->Invalidate();
}
}
BOOL CPictureShowView::LoadPicsFormStr()
{
for(int i=0;i<m_strFiles.GetSize();i++)
{
CStaticPicture *p=new CStaticPicture;
p->Load(*((CString *)m_strFiles.GetAt(i)));
m_pics.Add(p);
}
return m_pics.GetSize() ? true : false;
}
void CPictureShowView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
this->SetScrollSizes(MM_TEXT,CSize(600,100));
// TODO: Add your specialized code here and/or call the base class
}
void CPictureShowView::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)
{
// TODO: Add your specialized code here and/or call the base class
CScrollView::CalcWindowRect(lpClientRect, nAdjustType);
}
void CPictureShowView::ShowSmallPic(CDC *pDC)
{
int width=0;
for(int i=0;i<m_pics.GetSize();i++)
{
CRect rect;
/* width=i*100;
rect.left=width;
rect.top=m_client.bottom-100;
rect.right=width+100;
rect.bottom=m_client.bottom;*/
width=i*100;
rect.left=width;
rect.top=0;
rect.right=width+100;
rect.bottom=100;
/* if(!((CStaticPicture *)(m_pics.GetAt(i)))->m_hWnd)
//((CStaticPicture *)(m_pics.GetAt(i)))->Detach();
((CStaticPicture *)(m_pics.GetAt(i)))->Create("STATIC","",WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_BITMAP,rect,this,IDS_PICTURE+i);
*/
rect.DeflateRect(10,10);
((CStaticPicture *)(m_pics.GetAt(i)))->Render(pDC,rect);
}
if(width>m_client.right)
{
this->SetScrollSizes(MM_TEXT,CSize(m_pics.GetSize()*100,100));
}
if(m_indexSel!=-1)
{
this->DrawBorder(pDC,m_indexSel);
}
}
void CPictureShowView::ShowBigPic(CDC *pDC,int index)
{
CRect rectClientBig;
CRect rectDraw;
CSize sizePic;
sizePic=((CStaticPicture *)(m_pics.GetAt(index)))->GetImageSize();
rectClientBig=m_client;
rectClientBig.bottom=m_client.bottom-100;
CPoint point=rectClientBig.CenterPoint();
rectDraw.left=point.x-sizePic.cx/2;
rectDraw.right=point.x+sizePic.cx/2;
rectDraw.top=point.y-sizePic.cy/2;
rectDraw.bottom=point.y+sizePic.cy/2;
while(rectDraw.Width()>rectClientBig.Width() ||
rectDraw.Height()>rectClientBig.Height())
{
rectDraw.DeflateRect(sizePic.cx/50,sizePic.cy/50);
}
// ((CStaticPicture *)(m_pics.GetAt(index)))->Create("STATIC","",WS_CHILD | WS_VISIBLE | SS_NOTIFY |
cao2008liang
- 粉丝: 1
- 资源: 6
最新资源
- 数据分析实验ALL(1).zip
- 由GPT4生成的完整版工具调用指令微调数据集
- 基于java+spring+springMVC的影院管理系统开题报告.doc
- 一个简单易用的 go 库 , 一个简单的Arduino的Go语言封装库.zip
- ssm511资产管理信息系统vue.zip
- 069-java精品项目-基于ssm的预约挂号系统.zip
- springboot459客户管理系统--论文pf.zip
- 由GPT4生成的相似度0.9版工具调用指令微调数据集
- 基于java+spring+springMVC的自助医疗服务系统开题报告.docx
- 后端使用 SpringCloud Alibaba 开发移动端使用 React Native 构建管理后台使用 Arc.zip
- ssm680基于SSM的旅游论坛设计与实现vue.zip
- TouchFreeze(触摸板智能开关)
- ssm幼儿园管理系统程序.zip
- 由GPT4生成的相似度0.8版工具调用指令微调数据集
- 机电公司管理信息系统小程序--论文pf.zip
- 一个简单易用的C语言日志库 简单易用的C语言日志库.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页