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

📄 picturelist.cpp

📁 无线图象监控系统(用VC++编程)用数据库ACCESS存储图象
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// PictureList.cpp : implementation file
//

#include "stdafx.h"
#include "MoinorCentre.h"
#include "PictureList.h"
#include"Jpeg.h"
#include"DateTime.h"
#include"DataBaseUI.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPictureList dialog


CPictureList::CPictureList(CWnd* pParent /*=NULL*/)
	: CDialog(CPictureList::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPictureList)
	m_picnum = _T("");
	m_note = _T("");
	//}}AFX_DATA_INIT
}


void CPictureList::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPictureList)
	DDX_Control(pDX, IDC_LASTPAGE, m_last);
	DDX_Control(pDX, IDC_NEXTPAGE, m_next);
	DDX_Text(pDX, IDC_PICNUM, m_picnum);
	DDX_Text(pDX, IDC_NOTE, m_note);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPictureList, CDialog)
	//{{AFX_MSG_MAP(CPictureList)
	ON_WM_VSCROLL()
	ON_WM_PAINT()
	ON_WM_SIZE()
	ON_WM_CLOSE()
	ON_WM_SHOWWINDOW()
	ON_WM_MOVE()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_FIRST, OnFirst)
	ON_BN_CLICKED(IDC_NEXTPAGE, OnNextpage)
	ON_BN_CLICKED(IDC_LASTPAGE, OnLastpage)
	ON_BN_CLICKED(IDC_END, OnEnd)
	ON_BN_CLICKED(IDC_PIC1, OnPic1)
	ON_BN_CLICKED(IDC_PIC2, OnPic2)
	ON_BN_CLICKED(IDC_PIC3, OnPic3)
	ON_BN_CLICKED(IDC_PIC4, OnPic4)
	ON_BN_CLICKED(IDC_PIC5, OnPic5)
	ON_BN_CLICKED(IDC_PIC6, OnPic6)
	ON_BN_CLICKED(IDC_PIC7, OnPic7)
	ON_BN_CLICKED(IDC_PIC8, OnPic8)
	ON_BN_CLICKED(IDC_PIC9, OnPic9)
	ON_BN_CLICKED(IDC_PIC10, OnPic10)
	ON_BN_CLICKED(IDC_PIC11, OnPic11)
	ON_BN_CLICKED(IDC_PIC12, OnPic12)
	ON_BN_CLICKED(IDC_PIC13, OnPic13)
	ON_BN_CLICKED(IDC_PIC14, OnPic14)
	ON_BN_CLICKED(IDC_PIC15, OnPic15)
	ON_BN_CLICKED(IDC_PIC16, OnPic16)
	ON_BN_CLICKED(IDC_DATETIME, OnDatetime)
	ON_BN_CLICKED(IDC_PLAY, OnPlay)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
	ON_WM_CTLCOLOR()
	ON_WM_MOUSEMOVE()
ON_MESSAGE(WM_DRAWPIC,OnDrawPic)
	ON_WM_SETCURSOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPictureList message handlers

BOOL CPictureList::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
	// TODO: Add your specialized code here and/or call the base class

	return CDialog::OnNotify(wParam, lParam, pResult);
}

void CPictureList::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	/*if(nSBCode==SB_THUMBPOSITION)
	{
	CString ss;
	
	CClientDC ssd(this);
  UINT kgg;
  kgg=SetScrollPos(SB_VERT,nPos);
   ss.Format("prePos=%x",kgg);
   ssd.TextOut(54,333,ss);
	}*/

}

BOOL CPictureList::OnInitDialog() 
{ CDialog::OnInitDialog();

	CJpeg jpg;
    i=0;
  picrs.MoveFirst();
  picrs.MoveLast();
  picrs.MoveFirst();
	// TODO: Add extra initialization here
	while (!picrs.IsEOF() && i<16)
	{if(jpg.Load(picrs.m_picturepath))
	   {//AfxMessageBox("开始显示");
		dib[i].Destroy();
		HDIB hDIB=CopyHandle(jpg.GetDib()->GetHandle());
		datetime[i]=picrs.m_DateAndTime.Format("%Y-%m-%d %H:%M:%S");
	      dib[i].Attach(hDIB);
		i++;
		  }
	  picrs.MoveNext();
	}
	m_note.Format("下面显示的是%d-%d条图像记录的缩略图",1,i);

	m_picnum.Format("%d张",picrs.GetRecordCount());
	UpdateData(FALSE);
CDib beijing;
	 beijing.Load(".//res//dd.bmp");
	 CRect ff;
GetWindowRect(ff);
beijing.ChangeImageSize(ff.Width(),ff.Height());
  m_brush.CreateDIBPatternBrush(beijing.m_hDib,DIB_PAL_COLORS);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPictureList::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	// TODO: Add your message handler code here
	PostMessage(WM_DRAWPIC);
	// Do not call CDialog::OnPaint() for painting messages
}

//DEL void CPictureList::OnButton1() 
//DEL {
//DEL 
//DEL 		// TODO: Add your control notification handler code here
//DEL 	
//DEL }

void CPictureList::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);

  
	// TODO: Add your message handler code here
	
}
 LRESULT CPictureList::OnDrawPic(WPARAM wParam,LPARAM lParam)
{		 int IDPIC[16]={IDC_PIC1,IDC_PIC2,IDC_PIC3,IDC_PIC4,IDC_PIC5,IDC_PIC6,IDC_PIC7,IDC_PIC8,
IDC_PIC9,IDC_PIC10,IDC_PIC11,IDC_PIC12,IDC_PIC13,IDC_PIC14,IDC_PIC15,IDC_PIC16};
 //int IDDATE[16]={IDC_DATE1,IDC_DATE2,IDC_DATE3,IDC_DATE4,IDC_DATE5,IDC_DATE6,IDC_DATE7,IDC_DATE8,
	 //IDC_DATE9,IDC_DATE10,IDC_DATE11,IDC_DATE12,IDC_DATE13,IDC_DATE14,IDC_DATE15,IDC_DATE16};

	int i=0;
    CDC* pdc=GetDC();

	while (i<16)
	{
			  //CRect dibsrc(0,0,dib[i].GetWidth(),dib[i].GetHeight());
		      CRect crec;
			  CRect daterec;
			  GetDlgItem(IDPIC[i])->GetWindowRect(&daterec);
			  //GetDlgItem(IDDATE[i])->ShowWindow(SW_HIDE);
              GetDlgItem(IDPIC[i])->GetClientRect(&crec);
          			  	ScreenToClient(&daterec);
          int ratio=((double)dib[i].GetHeight()/(double)dib[i].GetWidth())*crec.Width();
		  CDib  dis;
			  HDIB hdib=CopyHandle(dib[i].GetHandle());
		  dis.Attach(hdib);
		  dis.ChangeImageSize(crec.Width(),crec.Height());
		  dis.Display(GetDlgItem(IDPIC[i])->GetDC(),crec.TopLeft().x,crec.TopLeft().y);
		//dib[i].Display(GetDlgItem(IDPIC[i])->GetDC(),crec.TopLeft().x,crec.TopLeft().y,160,120,0,0,dib[i].GetWidth(),dib[i].GetHeight());
		  dis.Destroy();
		 pdc->TextOut(daterec.TopLeft().x,daterec.TopLeft().y-15,datetime[i]);
		  i++;

	}
	return 0;
}

void CPictureList::OnOK() 
{
	// TODO: Add extra validation here
	picrs.Close();
	DestroyWindow();

}

void CPictureList::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	picrs.Close();
	DestroyWindow();
}

void CPictureList::OnClose() 
{m_brush.DeleteObject();
	picrs.Close();
	DestroyWindow();

}

void CPictureList::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	//CDialog::OnShowWindow(bShow, nStatus);
	//PostMessage(WM_DRAWPIC);
	// TODO: Add your message handler code here
	
}

void CPictureList::OnMove(int x, int y) 
{
	CDialog::OnMove(x, y);
	//PostMessage(WM_DRAWPIC);
	// TODO: Add your message handler code here
	
}

void CPictureList::OnButton1() 
{
	// TODO: Add your control notification handler code here
	
}

void CPictureList::OnFirst() 
{
	CJpeg jpg;
   i=0;
  picrs.MoveFirst();
	// TODO: Add extra initialization here
	while (!picrs.IsEOF() && i<16)
	{if(jpg.Load(picrs.m_picturepath))
	   {//AfxMessageBox("开始显示");
		dib[i].Destroy();
		HDIB hDIB=CopyHandle(jpg.GetDib()->GetHandle());
	      dib[i].Attach(hDIB);
		 datetime[i]=picrs.m_DateAndTime.Format("%Y-%m-%d %H:%M:%S");
		  i++;
		  }
	  picrs.MoveNext();
	}
m_next.EnableWindow();
m_last.EnableWindow(FALSE);
	m_note.Format("下面显示的是%d-%d条图像记录的缩略图",1,i);
UpdateData(FALSE);
	m_picnum.Format("%d张",picrs.GetRecordCount());
PostMessage(WM_DRAWPIC);	
}

void CPictureList::OnNextpage() 
{
	CJpeg jpg;
   
   if(picrs.IsBOF())
   {
	picrs.Move(17);
   }
i=0;
int pk=picrs.GetAbsolutePosition()+1;
	// TODO: Add extra initialization here
	while (!picrs.IsEOF() && i<16)
	{if(jpg.Load(picrs.m_picturepath))
	   {//AfxMessageBox("开始显示");
		dib[i].Destroy();
		HDIB hDIB=CopyHandle(jpg.GetDib()->GetHandle());
	      dib[i].Attach(hDIB);
	  datetime[i]=picrs.m_DateAndTime.Format("%Y-%m-%d %H:%M:%S");
		  i++;
		  }
	  picrs.MoveNext();
	}
	for(int j=i;j<16;j++)
	{      dib[j].Destroy();
		dib[j].Load("nopic.bmp");
       datetime[j]="                                           ";
	}
	if(picrs.IsEOF())
	{
	m_next.EnableWindow(FALSE);
	m_last.EnableWindow();
	}
m_note.Format("下面显示的是%d-%d条图像记录的缩略图",pk,pk+i-1);
	UpdateData(FALSE);
	PostMessage(WM_DRAWPIC);
}

void CPictureList::OnLastpage() 
{
	CJpeg jpg;
	
   
	if(picrs.IsEOF())
	{
	picrs.Move(-1-i);
	}
int pk=picrs.GetAbsolutePosition()+1;
 i=16;
	// TODO: Add extra initialization here
	while (!picrs.IsBOF() && i>0)
	{if(jpg.Load(picrs.m_picturepath))
	   {//AfxMessageBox("开始显示");
		dib[i-1].Destroy();
		HDIB hDIB=CopyHandle(jpg.GetDib()->GetHandle());
	      dib[i-1].Attach(hDIB);
	datetime[i-1]=picrs.m_DateAndTime.Format("%Y-%m-%d %H:%M:%S");
		  i--;
	 		  }
	  picrs.MovePrev();
	}
	for(int j=0;j<i;j++)
	{     datetime[j]="                                              ";
     dib[j].Destroy();
		dib[j].Load("nopic.bmp");
	}
	if(picrs.IsBOF())
	{
	m_next.EnableWindow();
	m_last.EnableWindow(FALSE);
	}
m_note.Format("下面显示的是%d-%d条图像记录的缩略图",picrs.GetAbsolutePosition()+2,pk);
	UpdateData(FALSE);
	PostMessage(WM_DRAWPIC);
	
}

void CPictureList::OnEnd() 
{
	CJpeg jpg;
   i=0;
   int k=picrs.GetRecordCount()-picrs.GetRecordCount()%16;
  picrs.SetAbsolutePosition(k);

	// TODO: Add extra initialization here
	while (!picrs.IsEOF() && i<16)
	{if(jpg.Load(picrs.m_picturepath))
	   {//AfxMessageBox("开始显示");
		dib[i].Destroy();
		HDIB hDIB=CopyHandle(jpg.GetDib()->GetHandle());
	      dib[i].Attach(hDIB);
		 datetime[i]=picrs.m_DateAndTime.Format("%Y-%m-%d %H:%M:%S");

⌨️ 快捷键说明

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