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

📄 peccancydlg.cpp

📁 对列表中的图片的浏览,可以进行上下翻页,可以装载jpg的图片
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// PeccancyDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Peccancy.h"
#include "PeccancyDlg.h"
#include"QueryDlg.h"
#include"ImageData.h"

#include "comdef.h"
 //引用接口
#include "myMQCom.h"
#include "myMQCom_i.c"
 

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

//申明接口返回和接口类型
HRESULT hr;
ImyMQ *pmaCom = NULL;
int comflag=0;

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPeccancyDlg dialog

CPeccancyDlg::CPeccancyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPeccancyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPeccancyDlg)
	m_Car = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CPeccancyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPeccancyDlg)
	DDX_Control(pDX, IDC_PICTURE, m_CPicture);
	DDX_Control(pDX, IDC_LIST_QUERY, m_ListQuery);
	DDX_Text(pDX, IDC_CAR, m_Car);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPeccancyDlg, CDialog)
	//{{AFX_MSG_MAP(CPeccancyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_QUERY, OnQuery)
	ON_BN_CLICKED(IDC_CANCLE, OnCancle)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	ON_NOTIFY(NM_CLICK, IDC_LIST_QUERY, OnClickListQuery)
	ON_BN_CLICKED(IDC_EXPLAIN, OnExplain)
	ON_BN_CLICKED(IDC_SEND, OnSend)
	ON_BN_CLICKED(IDC_FIRST, OnFirst)
	ON_BN_CLICKED(IDC_LAST, OnLast)
	ON_BN_CLICKED(IDC_PREV, OnPrev)
	ON_BN_CLICKED(IDC_NEXT, OnNext)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPeccancyDlg message handlers

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

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	flag=0;
	m_ImageID=0;

	//int scrx = GetSystemMetrics(SM_CXSCREEN);
    //int scry = GetSystemMetrics(SM_CYSCREEN);

	//this->MoveWindow( -4, -4, scrx+8, scry+8, true );

	m_ListQuery.SetTextColor(RGB (0, 0, 0));
	m_ListQuery.SetTextBkColor(RGB (140, 180, 220));
	m_ListQuery.SetBkColor(RGB (140, 180, 220));
	m_ListQuery.InsertColumn(0,"违章车速",LVCFMT_LEFT,80,-1);
	m_ListQuery.InsertColumn(1,"违章车号",LVCFMT_LEFT,100,-1);
    m_ListQuery.InsertColumn(2,"违章日期",LVCFMT_LEFT,100,-1);
	m_ListQuery.InsertColumn(3,"违章时间",LVCFMT_LEFT,100,-1);
	m_ListQuery.InsertColumn(4,"操作人员",LVCFMT_LEFT,100,-1);
	m_ListQuery.InsertColumn(5,"ID",LVCFMT_LEFT,10,-1);
//	(void)m_ListQuery.SetExtendedStyle( LVS_EX_FULLROWSELECT );

	m_ListQuery.SetExtendedStyle(LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT);

	 // 初始化COM
	hr = CoInitialize(0);
	// 使用SUCCEEDED 宏并检查我们是否能得到一个接口指针 

	if (SUCCEEDED(hr))
	{
		hr = CoCreateInstance( CLSID_myMQ, NULL, CLSCTX_LOCAL_SERVER,
			IID_ImyMQ, (void**) &pmaCom);//生成接口调用类场
	}
    comflag++;
//	pmaCom->Connect();

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CPeccancyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CPeccancyDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
   	
	if(!m_Image.IsEmpty())
	{
        CDC* pDC = m_CPicture.GetDC();
		m_pic.LoadPictureFromFile(m_Image); 
		CSize sz = m_pic.GetSize();
		m_pic.Draw(pDC, 0,0,sz.cx,sz.cy,0,0,sz.cx,sz.cy);
		CDialog::OnPaint();	
	}
	
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPeccancyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CPeccancyDlg::OnQuery() 
{
	CQueryDlg  m_QueryDlg;
    if (m_QueryDlg.DoModal() == IDOK)
	{
		CString strpath = "d:\\image\\";
		CString sfrom1,sto1;
		
		UpdateData(true);
		CTime time = CTime::GetCurrentTime();
		if(m_QueryDlg.m_FromMonth.GetLength() == 1)
		{
			if (m_QueryDlg.m_FromDay.GetLength() == 1)
			{
				sfrom1 = m_QueryDlg.m_FromYear + "0" + m_QueryDlg.m_FromMonth + "0"+m_QueryDlg.m_FromDay;
			}
			else
			{
				sfrom1 = m_QueryDlg.m_FromYear + "0" + m_QueryDlg.m_FromMonth + m_QueryDlg.m_FromDay;
			}
		}
		else
		{
			if (m_QueryDlg.m_FromDay.GetLength() == 1)
			{
				sfrom1 = m_QueryDlg.m_FromYear + m_QueryDlg.m_FromMonth + "0" + m_QueryDlg.m_FromDay;
			}
			else
			{
				sfrom1 = m_QueryDlg.m_FromYear + m_QueryDlg.m_FromMonth + m_QueryDlg.m_FromDay;
			}
		}
		
		if (m_QueryDlg.m_ToMonth.GetLength() == 1)
		{
			if (m_QueryDlg.m_ToDay.GetLength() == 1)
			{
				sto1 = m_QueryDlg.m_ToYear + "0" + m_QueryDlg.m_ToMonth + "0" + m_QueryDlg.m_ToDay;
			}
			else
			{
				sto1 = m_QueryDlg.m_ToYear + "0" + m_QueryDlg.m_ToMonth + m_QueryDlg.m_ToDay;
			}
		}
		else
		{
			if (m_QueryDlg.m_ToDay.GetLength() == 1)
			{
				sto1 = m_QueryDlg.m_ToYear + m_QueryDlg.m_ToMonth + "0" + m_QueryDlg.m_ToDay;
			}
			else
			{
				sto1 = m_QueryDlg.m_ToYear + m_QueryDlg.m_ToMonth + m_QueryDlg.m_ToDay;
			}
		}
		
		CString sfrom2,sto2;
		char str5[20];
		itoa(m_QueryDlg.m_FromHour,str5,10);
		
		char str6[20];
		itoa(m_QueryDlg.m_FromMinute,str6,10);
		
		char str7[20];
		itoa(m_QueryDlg.m_FromSecond,str7,10);
		
		char str8[20];
		itoa(m_QueryDlg.m_ToHour,str8,10);
		
		char str9[20];
		itoa(m_QueryDlg.m_ToMinute,str9,10);
		
		char str10[20];
		itoa(m_QueryDlg.m_ToSecond,str10,10);
		
		CString strfromhour="";
		CString strfromminute="";
		CString strfromsecond="";
		CString strtohour="";
		CString strtoministe="";
		CString strtosecond="";
		CString str0="0";
		if (m_QueryDlg.m_FromHour<10)
		{
			strfromhour += str0 + str5; 
		}
		else
		{
			strfromhour += str5;
		}
		
		if (m_QueryDlg.m_FromMinute<10)
		{
			strfromminute += str0 + str6;
		}
		else
		{
			strfromminute += str6;
		}
		
		if (m_QueryDlg.m_FromSecond < 10)
		{
			strfromsecond += str0 + str7;
		}
		else
		{
			strfromsecond += str7;
		}
		
		if (m_QueryDlg.m_ToHour<10)
		{
			strtohour += str0 + str8;
		}
		else
		{
			strtohour += str8;
		}
		
		if (m_QueryDlg.m_ToMinute < 10)
		{
			strtoministe += str0 + str9;
		}
		else
		{
			strtoministe += str9;
		}
		
		if (m_QueryDlg.m_ToSecond < 10)
		{
			strtosecond += str0 + str10;
		}
		else
		{
			strtosecond += str10;
		}
		
		sfrom2 = sfrom1 + strfromhour + strfromminute + strfromsecond;
		sto2 = sto1+strtohour + strtoministe + strtosecond;
		
		if (m_QueryDlg.m_CheckTime) 
		{
			if ( m_QueryDlg.m_FromYear == "" || m_QueryDlg.m_FromMonth == "" || m_QueryDlg.m_FromDay == "" 
				|| m_QueryDlg.m_FromHour < 0 || m_QueryDlg.m_FromSecond < 0 || m_QueryDlg.m_FromMinute < 0 
				|| m_QueryDlg.m_ToYear == "" || m_QueryDlg.m_ToMonth == "" || m_QueryDlg.m_ToDay == "" 
				|| m_QueryDlg.m_ToHour < 0 || m_QueryDlg.m_ToSecond < 0 || m_QueryDlg.m_ToMinute < 0) 
			{
				AfxMessageBox("输入时间不完整!", MB_ICONEXCLAMATION);
				return;
			}
			else
			{
				p_query.Format("select * from Image where PeccancyDate+PeccancyTime>='%s' AND PeccancyDate+PeccancyTime<='%s'",sfrom2,sto2);
			}
			
		} 
		
		if ( m_QueryDlg.m_CheckCar) 
		{
			
			if (m_QueryDlg.m_ComRow == "" ||  m_QueryDlg.m_Content == "" ) 
			{
				AfxMessageBox("输入数据不完整!", MB_ICONEXCLAMATION);
				return;
			}
			else
			{
				if(m_QueryDlg.m_ComRow=="车速")
				{
					p_query.Format("select * from Image where  PeccancySpeed >=%d",atoi(m_QueryDlg.m_Content));
				}	
				else
				{ 
					CString str = "select * from Image where PeccancyNumber like '%" + m_QueryDlg.m_Content + "%'";
					p_query = str;
				}
			}
			
		}
		
		if (m_QueryDlg.m_CheckTime && m_QueryDlg.m_CheckCar) 
		{
			if ( m_QueryDlg.m_FromYear == "" || m_QueryDlg.m_FromMonth == "" || m_QueryDlg.m_FromDay == "" 
				|| m_QueryDlg.m_FromHour < 0 || m_QueryDlg.m_FromSecond < 0 || m_QueryDlg.m_FromMinute < 0 
				|| m_QueryDlg.m_ToYear == "" || m_QueryDlg.m_ToMonth == "" || m_QueryDlg.m_ToDay == "" 
				|| m_QueryDlg.m_ToHour < 0 || m_QueryDlg.m_ToSecond < 0 || m_QueryDlg.m_ToMinute < 0
				|| m_QueryDlg.m_ComRow== "" || m_QueryDlg.m_Content== "" ) 
			{
				AfxMessageBox("输入数据不完整!", MB_ICONEXCLAMATION);
				return;
			}
			else
			{
				if(m_QueryDlg.m_ComRow == "车速")
				{
					p_query.Format("select * from Image where  PeccancySpeed >=%d AND PeccancyDate+PeccancyTime >= '%s' AND PeccancyDate+PeccancyTime <= '%s'",m_QueryDlg.m_Content,sfrom2,sto2);
				}	
				else
				{ 
					CString str1,str2;
                    str1="select * from Image where PeccancyNumber like '%"+m_QueryDlg.m_Content + "%' ";

⌨️ 快捷键说明

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