CorpSms/FFaxDF.cpp
lujiang e17c4ce7ed 重新对窗口布局进行优化,解决缺字的情况。
对图标显示进行了优化,使用gdi+按DPI进行缩放。
2025-04-14 17:24:47 +08:00

418 lines
11 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// FFaxDF.cpp : implementation file
//
#include "stdafx.h"
#include "CorpSms.h"
#include "FFaxDF.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFFaxDF dialog
#include "MainFrm.h"
#include "ProcessSocket.h"
#include "DLG_Find_SmsBox.h"
#include "DLG_SmsList_Export.h"
CFFaxDF::CFFaxDF(CWnd* pParent /*=NULL*/)
: CDialog(CFFaxDF::IDD, pParent)
{
//{{AFX_DATA_INIT(CFFaxDF)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bInit = false;
m_bRefresh = false;
}
void CFFaxDF::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFFaxDF)
DDX_Control(pDX, IDC_FAXDF_LIST, m_wndList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFFaxDF, CDialog)
//{{AFX_MSG_MAP(CFFaxDF)
ON_WM_SIZE()
ON_NOTIFY(NM_RCLICK, IDC_FAXDF_LIST, OnRclickSmsdfList)
ON_NOTIFY(NM_DBLCLK, IDC_FAXDF_LIST, OnDblclkSmsdfList)
ON_NOTIFY(LVN_KEYDOWN, IDC_FAXDF_LIST, OnKeydownSmsdfList)
//}}AFX_MSG_MAP
ON_COMMAND( MENU_DF_ADD , On_User_Add )
ON_COMMAND( MENU_DF_MODIFY , On_User_Modify )
ON_COMMAND( MENU_DF_RESEND , On_User_ReSend )
ON_COMMAND( MENU_DF_DEL , On_User_Del )
ON_COMMAND( MENU_DF_REFRESH , On_User_Refresh )
ON_COMMAND( MENU_DF_FIND , On_User_Find )
ON_COMMAND( MENU_DF_EXPORT , On_User_Export )
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFFaxDF message handlers
BOOL CFFaxDF::OnInitDialog()
{
CDialog::OnInitDialog();
//È¡µÃ¹²ÓòÎÊý
//CMainFrame * pFrame = static_cast <CMainFrame *>((CMainFrame *)AfxGetMainWnd());
this->GetParent()->GetParentFrame();
m_pMainFrame = (CMainFrame *)this->GetParent()->GetParentFrame();
m_pSocket = &m_pMainFrame->m_Socket;
m_AdoRS.SetAdoConnection( &m_pMainFrame->m_adoConnection );
m_AdoRS2.SetAdoConnection( &m_pMainFrame->m_adoConnection );
//³õʼ»¯List
m_Image.Create(16,16,ILC_COLOR32|ILC_MASK,5,5);
m_Image.Add(AfxGetApp()->LoadIcon(IDI_L_SMSDF) );
m_Image.Add(AfxGetApp()->LoadIcon(IDI_L_LOCK) );
m_wndList.SubClassWindow2();
m_wndList.SetHeadings(_T("ÐòºÅ,50; ׫дʱ¼ä,135;ºÅÂëÊý,60; ´«Õæ±êÌâ,200; ¸½¼þ1,120; ¸½¼þ2,120; ¸½¼þ3,120; ¸½¼þ4,120; ¸½¼þ5,120;"));
m_wndList.SetGridLines(true);
m_wndList.SetImageList(&m_Image,LVSIL_SMALL);
//m_wndList.SetBkColor( RGB(237,191,175) );
//m_wndList.SetTextBkColor( RGB(237,191,175) );
m_bInit = true;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CFFaxDF::ReHide()
{
ShowWindow( SW_HIDE );
return true;
}
BOOL CFFaxDF::ReShow(BOOL bRefresh)
{
ShowWindow( SW_SHOW );
if ( bRefresh || !m_bRefresh )
{
RefreshInfo();
}
return true;
}
BOOL CFFaxDF::RefreshInfo()
{
m_wndList.ShowWindow( SW_HIDE ); //ΪÁ˼ӿìÏÔʾËÙ¶È
m_bRefresh = true;
m_wndList.DeleteAllItems();
CString str;
str.Format(_T("select * from faxbox where BoxType='0' %s order by CreateTime"),m_strFindAdd ); //²éѯ´ý·¢¶ÌÐÅ
BOOL b = m_AdoRS.Open( str );
CAdoRecordSet AdoRS;
AdoRS.SetAdoConnection( &m_pMainFrame->m_adoConnection );
long lCount = 0;
COleDateTime ot;
SYSTEMTIME t={0};
TCHAR szTemp[64]={0};
CString strTitle;
CString strAttach1,strAttach2,strAttach3,strAttach4,strAttach5;
long lBoxID=0;
long lSMSCount=0;
CString strID;
CString strCreateTime;
CString strUserCount;
if ( b && m_AdoRS.GetRecordCount() )
{
m_AdoRS.MoveFirst();
while( !m_AdoRS.IsEOF() )
{
m_AdoRS.GetCollect( _T("BoxID") , lBoxID );
m_AdoRS.GetCollect( _T("CreateTime") , ot ); ot.GetAsSystemTime(t);
m_AdoRS.GetCollect( _T("Title") , strTitle );
m_AdoRS.GetCollect( _T("FileName1") , strAttach1 );
m_AdoRS.GetCollect( _T("FileName2") , strAttach2 );
m_AdoRS.GetCollect( _T("FileName3") , strAttach3 );
m_AdoRS.GetCollect( _T("FileName4") , strAttach4 );
m_AdoRS.GetCollect( _T("FileName5") , strAttach5 );
strAttach1=ExPath(strAttach1);
strAttach2=ExPath(strAttach2);
strAttach3=ExPath(strAttach3);
strAttach4=ExPath(strAttach4);
strAttach5=ExPath(strAttach5);
//È¡¼Ç¼×ÜÊý
lSMSCount = 0;
_stprintf( szTemp , _T("select Count(*) from faxitem where BoxID=%d") , lBoxID );
BOOL b2 = AdoRS.Open(szTemp);
if ( b2 && AdoRS.GetRecordCount() )
{
AdoRS.MoveFirst();
long lIndex = 0;
AdoRS.GetCollect( lIndex , lSMSCount );
}
strID.Format( _T("%d") , lCount+1 );
strCreateTime.Format(_T("%04d.%02d.%02d %02d:%02d") , t.wYear,t.wMonth,t.wDay,t.wHour,t.wMinute);
strUserCount.Format(_T("%d"),lSMSCount);
m_wndList.InsertItemAndCol(0,strID,strCreateTime,strUserCount,strTitle,strAttach1,strAttach2,strAttach3,strAttach4,strAttach5);
m_wndList.SetItemData(0,lBoxID);
/*
//ÏÔʾ¼Ç¼×ÜÊý
m_wndList.SetItemText( 0 , 2 , _itot(lSMSCount , szTemp , 10 ) );
*/
lCount++;
m_AdoRS.MoveNext();
}
}
m_wndList.ShowWindow( SW_SHOW ); //ΪÁ˼ӿìÏÔʾËÙ¶È
return true;
}
void CFFaxDF::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if ( m_bInit )
{
m_wndList.MoveWindow( 0 , 0 , cx,cy);
}
}
void CFFaxDF::OnRclickSmsdfList(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
ShowRMenu();
}
void CFFaxDF::ShowRMenu()
{
// if (!m_pMainFrame->GetUserPurview(PURVIEW_GADDRESS_SEE,false)) //ûÓв鿴ȨÏÞ
// return ;
CMenu menu;
menu.CreatePopupMenu();
BOOL bLock = false;
long lItem = this->GetCurrentSelected();
menu.AppendMenu(MF_STRING , MENU_DF_ADD, _T(" н¨Áбí ") );
if ( lItem >= 0 )
{
menu.AppendMenu(MF_STRING , MENU_DF_MODIFY, _T(" ¼ÌÐø·¢ËÍ ") );
menu.AppendMenu(MF_STRING , MENU_DF_RESEND, _T(" ÖØÐ·¢ËÍ ") );
menu.AppendMenu(MF_STRING , MENU_DF_DEL, _T(" ɾ ³ý ") );
}
else
{
menu.AppendMenu(MF_STRING|MF_DISABLED|MF_GRAYED , MENU_DF_MODIFY, _T(" ¼ÌÐø·¢ËÍ ") );
menu.AppendMenu(MF_STRING|MF_DISABLED|MF_GRAYED , MENU_DF_RESEND, _T(" ÖØÐ·¢ËÍ ") );
menu.AppendMenu(MF_STRING|MF_DISABLED|MF_GRAYED , MENU_DF_DEL, _T(" ɾ ³ý ") );
}
menu.AppendMenu(MF_SEPARATOR );
//Ë¢ÐÂ
menu.AppendMenu(MF_STRING , MENU_DF_EXPORT, _T(" µ¼³ö... ") );
menu.AppendMenu(MF_STRING , MENU_DF_FIND , _T(" ²éÕÒ... ") );
menu.AppendMenu(MF_SEPARATOR );
//Ë¢ÐÂ
menu.AppendMenu(MF_STRING , MENU_DF_REFRESH, _T(" ˢ Р") );
//ÏÔʾ²Ëµ¥
POINT pt ;
::GetCursorPos( &pt );
//this->ClientToScreen( &pt);
menu.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RIGHTBUTTON,pt.x,pt.y, this, NULL);
menu.DestroyMenu();
}
long CFFaxDF::GetCurrentSelected()
{
POSITION pos = m_wndList.GetFirstSelectedItemPosition();
if ( pos )
{
return m_wndList.GetNextSelectedItem(pos);
}
return -1;
}
void CFFaxDF::On_User_Add()
{
m_pMainFrame->m_pFuncView->On_User_List_Add_Fax();
}
void CFFaxDF::On_User_Modify()
{
long lItem = GetCurrentSelected();
if ( lItem < 0 )
return ;
CString strTemp = _T("ÄãÑ¡ÔñµÄÊÇ\"¼ÌÐø·¢ËÍ\"£¬±¾ÈÎÎñÖÐËùÓÐδ·¢µÄ´«Õ潫±»¼ÌÐø·¢ËÍ£¡\r\n") \
_T("ÊÇ·ñ¼ÌÐø£¿");
int iRet = MessageBox( strTemp,_T("ÌáÎÊ") , MB_ICONQUESTION|MB_YESNO );
if ( iRet != IDYES )
return ;
long lBoxID = m_wndList.GetItemData( lItem );
if ( lBoxID <= 0 )
return ;
m_pMainFrame->m_pFuncView->On_User_List_Read_Fax( lBoxID );
}
void CFFaxDF::On_User_ReSend()
{
long lItem = GetCurrentSelected();
if ( lItem < 0 )
return ;
CString strTemp = _T("ÄãÑ¡ÔñµÄÊÇ\"ÖØÐ·¢ËÍ\"£¬±¾ÈÎÎñÖÐËùÓд«Õ潫»á±»ÔÙ´ÎÖØÐ·¢ËÍ£¡\r\n") \
_T("ÊÇ·ñ¼ÌÐø£¿");
int iRet = MessageBox( strTemp,_T("ÌáÎÊ") , MB_ICONQUESTION|MB_YESNO );
if ( iRet != IDYES )
return ;
long lBoxID = m_wndList.GetItemData( lItem );
if ( lBoxID <= 0 )
return ;
m_pMainFrame->m_pFuncView->On_User_List_ReSend_Fax( lBoxID );
}
void CFFaxDF::On_User_Del()
{
long lCount = m_wndList.GetSelectedCount();
long *lDel = new long[lCount+2];
POSITION pos = m_wndList.GetFirstSelectedItemPosition();
long i = 0;
while(pos)
{
lDel[i]= m_wndList.GetNextSelectedItem(pos);
i ++;
}
//µ¹×ªÉ¾³ý
m_wndList.ShowWindow( SW_HIDE ); //¼Ó¿ìÏÔʾµÄËÙ¶È
for ( i = lCount ; i>0 ; i-- )
{
long lBoxID = m_wndList.GetItemData( lDel[i-1] );
if ( lBoxID <= 0 )
continue ;
if ( m_pMainFrame->m_pFuncView->m_DLGSendFax.GetBoxID() == lBoxID )
{
long lRet = MessageBox( _T("Ҫɾ³ýµÄÁбíÕýÖб༭£¬ÊÇ·ñȷʵɾ³ý£¿") , _T("ÌáÎÊ") , MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
if ( lRet != IDYES )
continue ;
if ( !m_pMainFrame->m_pFuncView->m_DLGSendFax.List_Save() )
continue;
if ( !m_pMainFrame->m_pFuncView->m_DLGSendFax.List_New() )
continue;
}
TCHAR szSelect[128]={0};
_stprintf( szSelect , _T("delete from faxbox where BoxID=%d") , lBoxID ); //ÏÈɾ³ýsmsBox
BOOL b = m_AdoRS.Open( szSelect );
_stprintf( szSelect , _T("delete from faxitem where BoxID=%d") , lBoxID );//ÔÙɾ³ýBoxItem
b = m_AdoRS.Open( szSelect );
m_wndList.DeleteItem( lDel[i-1] ); //ɾ³ýListÖеÄItem
}
m_wndList.ShowWindow( SW_SHOW ); //¼Ó¿ìÏÔʾµÄËÙ¶È
delete lDel;
}
void CFFaxDF::On_User_Refresh()
{
RefreshInfo();
}
void CFFaxDF::On_User_Find()
{
CString strTemp;
DLG_Find_SmsBox dlg(this);
dlg.SetType(2);//fax
if ( dlg.DoModal() == IDOK )
{
strTemp.Format( _T(" AND CreateTime>=#%04d-%02d-%02d# AND CreateTime<=#%04d-%02d-%02d 23:59:59#"),dlg.m_TBegin.GetYear(),dlg.m_TBegin.GetMonth(),dlg.m_TBegin.GetDay(),dlg.m_TEnd.GetYear(),dlg.m_TEnd.GetMonth(),dlg.m_TEnd.GetDay());
m_strFindAdd = strTemp;
if ( dlg.m_strMsg.GetLength()>0 )
{
strTemp.Format( _T(" AND Title like '%%%s%%'"),dlg.m_strMsg );
m_strFindAdd += strTemp;
}
On_User_Refresh();
m_strFindAdd = _T(""); //ˢк󣬲éѯ½áÊø
}
}
void CFFaxDF::On_User_Export()
{
DLG_SmsList_Export dlg(this);
dlg.SetParam(&m_AdoRS2,&m_wndList,2);
dlg.DoModal();
}
void CFFaxDF::OnDblclkSmsdfList(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
On_User_Modify();
}
void CFFaxDF::OnKeydownSmsdfList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
*pResult = 0;
if ( pLVKeyDow->wVKey == VK_DELETE )
{
On_User_Del();
}
if ( pLVKeyDow->wVKey == VK_INSERT)
{
On_User_Add();
}
if ( pLVKeyDow->wVKey == VK_SPACE)
{
On_User_Modify();
}
if ( pLVKeyDow->wVKey == 'S' || pLVKeyDow->wVKey == 's')
{
On_User_ReSend();
}
if ( pLVKeyDow->wVKey == 'R' || pLVKeyDow->wVKey == 'r')
{
On_User_Refresh();
}
if ( pLVKeyDow->wVKey == 'F' || pLVKeyDow->wVKey == 'f')
{
On_User_Find();
}
if ( pLVKeyDow->wVKey == 'A' || pLVKeyDow->wVKey == 'a')
{
m_wndList.SelectAllItems();
}
}
void CFFaxDF::OnOK()
{
//CDialog::OnOK();
}
void CFFaxDF::OnCancel()
{
//CDialog::OnCancel();
}
CString CFFaxDF::ExPath(CString strFileName)
{
CString strRet=strFileName;
long lLen=strFileName.GetLength();
for ( int i=lLen-1;i>=0 ; i-- )
{
CString str = strFileName.Mid(i,1);
if ( str==CString(_T("\\")) ||str==CString(_T("/")) )
{
strRet = strFileName.Right(lLen-i-1);
break;
}
}
return strRet;
}