// testDlg.cpp : 实现文件 // #include "stdafx.h" #include "test.h" #include "testDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialog { public: CAboutDlg(); // 对话框数据 enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // CtestDlg 对话框 CtestDlg::CtestDlg(CWnd* pParent /*=NULL*/) : CDialog(CtestDlg::IDD, pParent) , m_nImgtype(1) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_pImgkernel = NULL; #if USE_ThumbNail m_hEvent = NULL; m_hThread = NULL; #endif } void CtestDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST1, m_list); DDX_Radio(pDX, IDC_RADIO1, m_nImgtype); DDX_Control(pDX, IDC_LIST2, m_listThumbNail); } BEGIN_MESSAGE_MAP(CtestDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON1, &CtestDlg::OnBnClickedButton1) ON_BN_CLICKED(IDC_BUTTON2, &CtestDlg::OnBnClickedButton2) ON_BN_CLICKED(IDC_BUTTON3, &CtestDlg::OnBnClickedButton3) ON_BN_CLICKED(IDC_RADIO1, &CtestDlg::OnBnClickedRadio1) ON_BN_CLICKED(IDC_RADIO2, &CtestDlg::OnBnClickedRadio2) ON_BN_CLICKED(IDC_RADIO3, &CtestDlg::OnBnClickedRadio3) ON_BN_CLICKED(IDC_RADIO4, &CtestDlg::OnBnClickedRadio4) END_MESSAGE_MAP() // CtestDlg 消息处理程序 BOOL CtestDlg::OnInitDialog() { CDialog::OnInitDialog(); // 将“关于...”菜单项添加到系统菜单中。 // IDM_ABOUTBOX 必须在系统命令范围内。 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 INT nFieldCount = 0; vector vtRSet; INT nRet = g_AdoImpl->GetTbl_NetShareInfoRecordSet(_T("NetShareInfo"), NULL, SELECT_NetShareInfo, nFieldCount, vtRSet); if ( nRet == -1 ) { OutputDebugString(_T("获取表记录失败")); return FALSE; } else if ( nRet == 0 ) { CString strInsert = _T(""); // 原片; strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\客户原片(管理软件)$"), 5, 35, 1, 255); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\客户原片(管理软件)1$"), 5, 35, 1, 254); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\客户原片(管理软件)2$"), 5, 35, 1, 253); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\客户原片(管理软件)3$"), 5, 35, 1, 252); g_AdoImpl->Execute(strInsert); // 初修片; strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\修好的片(管理软件)$"), 5, 35, 2, 255); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\修好的片(管理软件)1$"), 5, 35, 2, 254); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\修好的片(管理软件)2$"), 5, 35, 2, 253); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\修好的片(管理软件)3$"), 5, 35, 2, 252); g_AdoImpl->Execute(strInsert); // 精修片; strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\精修好的片(管理软件)$"), 5, 35, 3, 255); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\精修好的片(管理软件)1$"), 5, 35, 3, 254); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\精修好的片(管理软件)2$"), 5, 35, 3, 253); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\精修好的片(管理软件)3$"), 5, 35, 3, 252); g_AdoImpl->Execute(strInsert); // 设计片; strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\设计好的片(管理软件)$"), 5, 35, 4, 255); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\设计好的片(管理软件)1$"), 5, 35, 4, 254); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\设计好的片(管理软件)2$"), 5, 35, 4, 253); g_AdoImpl->Execute(strInsert); strInsert.Format(INSERT_NetShareInfo, 1, g_szEncryS1,_T("\\\\lyfz-server\\设计好的片(管理软件)3$"), 5, 35, 4, 252); g_AdoImpl->Execute(strInsert); } else { for ( vector::iterator it = vtRSet.begin(); it != vtRSet.end(); it++ ) { ImgShareInfo *pImgInfo = new ImgShareInfo; pImgInfo->bEnable = it->_enable; pImgInfo->byImgType = it->_phototype; pImgInfo->byMaxCapacity = it->_maxcapacity; pImgInfo->byMinCapacity = it->_mincapacity; pImgInfo->byPriority = it->_priority; _stprintf_s(pImgInfo->szBranchId, MAX_PATH, _T("%s"), it->_branchid.c_str()); _stprintf_s(pImgInfo->szShareDirectory, MAX_PATH, _T("%s"), it->_sharepath.c_str()); m_ImgShareInfo.push_back(pImgInfo); } } m_pImgkernel = new ImgOfOriginal(); m_pImgkernel->InitializeEnvironment(g_szEncryS1, &m_ImgShareInfo); InitCtrlList(); Inputdata(); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } void CtestDlg::InitCtrlList() { INT nIndex = 0; m_list.InsertColumn(nIndex,_T("订单号")); m_list.SetColumnWidth(nIndex,120); nIndex++; m_list.InsertColumn(nIndex,_T("名称1")); m_list.SetColumnWidth(nIndex,70); nIndex++; m_list.InsertColumn(nIndex,_T("名称2")); m_list.SetColumnWidth(nIndex,70); nIndex++; m_list.InsertColumn(nIndex,_T("套系名称")); m_list.SetColumnWidth(nIndex,80); nIndex++; m_list.InsertColumn(nIndex,_T("套系价格")); m_list.SetColumnWidth(nIndex,60); nIndex++; m_list.InsertColumn(nIndex,_T("相片编号")); m_list.SetColumnWidth(nIndex,60); nIndex++; m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); } void CtestDlg::Inputdata() { // 清除之前的数据; m_list.DeleteAllItems(); INT nFieldCount = 0; vector vtRSet; INT nRet = g_AdoImpl->GetTbl_dindanRecordSet(_T("dindan"), NULL, SELECT_dindan, nFieldCount, vtRSet); if ( nRet == -1 ) { OutputDebugString(_T("获取表记录失败")); return ; } INT nItemIndex = 0; for ( vector::iterator it = vtRSet.begin(); it != vtRSet.end(); it++ ) { nItemIndex = m_list.InsertItem(0,it->_id.c_str()); m_list.SetItemText(nItemIndex,1,it->_name1.c_str()); m_list.SetItemText(nItemIndex,2,it->_name2.c_str()); m_list.SetItemText(nItemIndex,3,it->_taoxiname.c_str()); m_list.SetItemText(nItemIndex,4,it->_taoxijiage.c_str()); m_list.SetItemText(nItemIndex,4,it->_curno.c_str()); } } void CtestDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // 如果向对话框添加最小化按钮,则需要下面的代码 // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。 void CtestDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); // 使图标在工作区矩形中居中 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; // 绘制图标 dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } //当用户拖动最小化窗口时系统调用此函数取得光标 //显示。 HCURSOR CtestDlg::OnQueryDragIcon() { return static_cast(m_hIcon); } void CtestDlg::OnBnClickedButton1() // 导入相片; { // 获取选中行; CString strOrder; CString strName1; CString strName2; CString strTaoxi; CString strTXJG; CString strImgNo; POSITION pos; pos = m_list.GetFirstSelectedItemPosition(); if ( pos == NULL ) { AfxMessageBox(_T("未选中任何行!")); return; } int nItem = m_list.GetNextSelectedItem(pos); strOrder = m_list.GetItemText(nItem,0); strName1 = m_list.GetItemText(nItem,1); strName2 = m_list.GetItemText(nItem,2); strTaoxi = m_list.GetItemText(nItem,3); strTXJG = m_list.GetItemText(nItem,4); strImgNo = m_list.GetItemText(nItem,5); // TODO: 在此添加控件通知处理程序代码 switch (m_nImgtype) { case OImgtype: { STR_VEC vtfiles; LPCTSTR lpExt = _T("*.jpg|*.jpeg"); underlyingapi::OpenFloder(vtfiles); if ( vtfiles.size() == 0 ) return; TCHAR szEnablefolder[MAX_PATH] = {0}; if ( !m_pImgkernel ) return; if ( !m_pImgkernel->GetEnableShareDirectory(OImgtype, g_szEncryS1, strOrder, szEnablefolder, MAX_PATH) ) { AfxMessageBox(_T("无可用共享目录")); return; } LPCTSTR lpWithExt = _T("*.nef|*.cr2"); INT nCount = m_pImgkernel->CopyImg2Specifiedpath(vtfiles, szEnablefolder, lpWithExt, SET_PIX(100,100), FALSE, NULL, 0); if ( nCount == 0 ) { OutputDebugString(_T("复制失败~")); } else { AfxMessageBox(_T("导入成功~")); } } break; case EImgtype: break; case FImgtype: break; case DImgtype: break; default: break; } OutputDebugString(_T("导入按钮\n")); } void CtestDlg::OnBnClickedButton2() // 导出相片; { // TODO: 在此添加控件通知处理程序代码 } void CtestDlg::OnBnClickedButton3() // 查看相片; { // TODO: 在此添加控件通知处理程序代码 } void CtestDlg::OnBnClickedRadio1() // 原片; { m_nImgtype = 1; } void CtestDlg::OnBnClickedRadio2() // 修片; { m_nImgtype = 2; } void CtestDlg::OnBnClickedRadio3() // 精修; { m_nImgtype = 3; } void CtestDlg::OnBnClickedRadio4() // 设计; { m_nImgtype = 4; } #if USE_ThumbNail int CtestDlg::StartThread() { m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); // 无信号事件; if (m_hEvent == NULL){ return -1; } m_hThread = CreateThread(NULL, 0, ThreadThumbNail, this, 0, NULL); if ( m_hThread ) { CloseHandle(m_hThread); m_hThread = NULL; } return 0; } DWORD CtestDlg::ThreadThumbNail(LPVOID lpParameter) { CtestDlg *pInstance = (CtestDlg*)lpParameter; // 初始化参数; CListCtrl *pListCtrl =&pInstance->m_listThumbNail; CImageList *pImgList = &pInstance->m_ImageList; STR_VEC *pvtfiles = &pInstance->m_vtfiles; // 清除列表; for ( int i = 0; i < pImgList->GetImageCount(); i++ ) { pImgList->Remove(i); } pListCtrl->DeleteAllItems(); if ( pvtfiles->size() == 0 ) { OutputDebugString(_T("无文件\n")); return 0; } // 重新设置数量; pImgList->SetImageCount(pvtfiles->size()); // 设置列表不可重绘,直到添加元素完毕; INT nIndex = 0; TString strname; pListCtrl->SetRedraw(FALSE); for ( STR_VEC::iterator it = pvtfiles->begin(); it != pvtfiles->end(); it++ ) { strname = filehelpImpl::getfilename(*it); pListCtrl->InsertItem(nIndex, strname.c_str(), nIndex); } pListCtrl->SetRedraw(); pListCtrl->Invalidate(); return 0L; } int CtestDlg::EndofThread() { if (m_hEvent){ SetEvent(m_hEvent); } if (m_hThread){ if (WaitForSingleObject(m_hThread, INFINITE) != WAIT_TIMEOUT) { CloseHandle(m_hThread); m_hThread = NULL; } } if (m_hEvent){ CloseHandle(m_hEvent); } m_hEvent = NULL; return 0; } #endif BOOL CtestDlg::DestroyWindow() { // TODO: 在此添加专用代码和/或调用基类 if ( m_pImgkernel ) { delete m_pImgkernel; } ImgShareInfo *pImg = NULL; for ( IMGSHARE_VEC::iterator it = m_ImgShareInfo.begin(); it != m_ImgShareInfo.end(); ) { pImg = *it; delete pImg; pImg = NULL; it = m_ImgShareInfo.erase(it); } if ( g_AdoImpl ) { delete g_AdoImpl; g_AdoImpl = NULL; } return CDialog::DestroyWindow(); }