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

📄 atrkfaxdlg.cpp

📁 这是一个Demo程序
💻 CPP
📖 第 1 页 / 共 4 页
字号:
// AtrkFaxDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AtrkFax.h"
#include "AtrkFaxDlg.h"

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


//int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData);
/////////////////////////////////////////////////////////////////////////////
// CAtrkFaxDlg dialog

CAtrkFaxDlg::CAtrkFaxDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAtrkFaxDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAtrkFaxDlg)
	m_AutoFaxMode = 0;
	m_MaxFaxSpeed = 1;
	m_strRecordFile = _T("recordFile.wav");
	m_strAppendSendFile = _T("");
	m_bMultiFax = FALSE;
	m_bSetMixer = FALSE;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	m_LogFile = NULL;
	m_bLog	   = FALSE;
	m_nTabShow = 0;
}

CAtrkFaxDlg::~CAtrkFaxDlg()
{
	if(m_LogFile != NULL)
		fclose(m_LogFile);
}

void CAtrkFaxDlg::DoDataExchange(CDataExchange* pDX)
{
	int m_OldMaxFaxSpeed = m_MaxFaxSpeed;
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAtrkFaxDlg)
	DDX_Control(pDX, IDC_COMBO_CurFaxCh, m_cmbFaxCh);
	DDX_Control(pDX, IDC_COMBO_CurCh, m_cmbCurCh);
	DDX_Control(pDX, IDC_TAB1, m_TabCtrl);
	DDX_Control(pDX, IDC_HANGUP, m_flaghangup);
	DDX_Control(pDX, IDC_TRK_CH_LIST, m_TrkChList);
	DDX_Control(pDX, IDC_LIST_CH_INFO, m_FaxChList);
	DDX_Radio(pDX, IDC_RADIO_AUTO_MODE1, m_AutoFaxMode);
	DDX_Radio(pDX, IDC_RADIO_MAX_SPEED1, m_MaxFaxSpeed);
	DDX_Text(pDX, IDC_EDIT_RecordFile, m_strRecordFile);
	DDX_Text(pDX, IDC_EDIT_AppendSendFile, m_strAppendSendFile);
	DDX_Check(pDX, IDC_CHECK_Multi_Ch_Rec, m_bMultiFax);
	DDX_Check(pDX, IDC_CHECK_SetRexMixer, m_bSetMixer);
	//}}AFX_DATA_MAP

	if( m_OldMaxFaxSpeed != m_MaxFaxSpeed )
	{
		if(m_MaxFaxSpeed == 0)      SsmFaxSetMaxSpeed(4800);
		else if(m_MaxFaxSpeed == 1) SsmFaxSetMaxSpeed(9600);
		else if(m_MaxFaxSpeed == 2) SsmFaxSetMaxSpeed(14400);
	}
}

BEGIN_MESSAGE_MAP(CAtrkFaxDlg, CDialog)
	//{{AFX_MSG_MAP(CAtrkFaxDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RADIO_AUTO_MODE1, OnRadioAutoMode1)
	ON_BN_CLICKED(IDC_RADIO_MAX_SPEED2, OnRadioMaxSpeed2)
	ON_BN_CLICKED(IDC_RADIO_MAX_SPEED3, OnRadioMaxSpeed3)
	ON_BN_CLICKED(IDC_RADIO_AUTO_MODE2, OnRadioAutoMode2)
	ON_BN_CLICKED(IDC_RADIO_MAX_SPEED1, OnRadioMaxSpeed1)
	ON_WM_DESTROY()
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_HANGUP, OnHangup)
	ON_BN_CLICKED(IDC_NOHANGUP, OnNohangup)
	ON_BN_CLICKED(IDC_APPEND, OnAppend)
	ON_BN_CLICKED(IDC_SELFN, OnSelfn)
	ON_BN_CLICKED(IDC_BUTTON_STOP_FAX, OnButtonStopFax)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_VIEWMANSENDFAXFILE, OnViewmansendfaxfile)
	ON_BN_CLICKED(IDC_AUTOCALL, OnAutocall)
	ON_WM_SHOWWINDOW()
	ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnSelchangingTab1)
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
	ON_MESSAGE(AUTOSENDFAX, AutoSendFax)
	ON_BN_CLICKED(IDC_BUTTON_AppendSend, OnBUTTONAppendSend)
	ON_BN_CLICKED(IDC_BUTTON_APPEND, OnButtonAppend)
	ON_BN_CLICKED(IDC_CHECK_Multi_Ch_Rec, OnCHECKMultiChRec)
	ON_BN_CLICKED(IDC_CHECK_SetRexMixer, OnCHECKSetRexMixer)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAtrkFaxDlg message handlers

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

	// 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

	//+++start+++added by xxh for tab, 2003.12.10
	TC_ITEM	tci;
	tci.mask = TCIF_TEXT;
	tci.pszText = "传真收发";
	m_TabCtrl.InsertItem(0, &tci);
	tci.pszText = "自动呼出";
	m_TabCtrl.InsertItem(1, &tci);
	tci.pszText = "自动接收";
	m_TabCtrl.InsertItem(2, &tci);


	m_firstDlg.Create(IDD_FIRST_DLG, m_TabCtrl.GetActiveWindow());
	m_secondDlg.Create(IDD_SECOND_DLG, m_TabCtrl.GetActiveWindow());
	m_thirdDlg.Create(IDD_THIRD_DLG, m_TabCtrl.GetActiveWindow());
	
	//m_secondDlg.GetCurrentPath(m_szCurPath);
	//m_thirdDlg.GetCurrentPath(m_szCurPath);
	//+++end+++added by xxh for tab, 2003.12.10

	m_flaghangup.SetCheck(1); //add by mjb 2001.11.15

	if( !myInitFaxBoard() )
	{
		PostQuitMessage(0);
		return FALSE;	
	}
	
	m_firstDlg.GetCurrentPath(m_szCurPath);
	m_secondDlg.GetCurrentPath(m_szCurPath);
	//m_szSendFaxFile[0] = '\0';
	//m_szManSendFaxFile[0] = '\0';
	InitATrunkListCtrl();
	InitChInfoList();

	char szLogFile[MAX_PATH];
	sprintf(szLogFile , "%s\\Fax.Log" , m_szCurPath);

	m_LogFile = fopen(szLogFile , "a+");

	if(m_LogFile == NULL)
	{
		AfxMessageBox(_T("创建log文件时候出错"));
		m_bLog = FALSE;
	}
	else
		m_bLog = TRUE;

	SetTimer(1,100,NULL);
	//text
/*	CString str1,str2;
	int bb,dd;
	str1.Format("d.tif");
	str1.TrimRight();
	str2 = str1.Right(5);
	dd = str2.GetLength();
	bb = str2.Find('.');
	str2.Format("%d",3);
	bb = str1.GetLength() - dd + bb;
	str1.Insert(bb,str2[0]);
*/	//


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

// 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 CAtrkFaxDlg::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();
	}
}

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

void CAtrkFaxDlg::OnRadioAutoMode1() 
{
	UpdateData(TRUE);
}

void CAtrkFaxDlg::OnRadioMaxSpeed2() 
{
	UpdateData(TRUE);
}

void CAtrkFaxDlg::OnRadioMaxSpeed3() 
{
	UpdateData(TRUE);
}

void CAtrkFaxDlg::OnRadioAutoMode2() 
{
	UpdateData(TRUE);
}

void CAtrkFaxDlg::OnRadioMaxSpeed1() 
{
	UpdateData(TRUE);
}

void CAtrkFaxDlg::OnAutoRcvPathButton() 
{

}

//DEL void CAtrkFaxDlg::OnSrcFaxButton() 
//DEL {
//DEL 	CFileDialog cf(1,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"fax file(*.fax)|*.fax|",NULL);
//DEL 	char path[200];
//DEL 	strcpy(path,m_szCurPath);
//DEL 	strcat(path,"\\FaxFile");
//DEL 	cf.m_ofn .lpstrInitialDir = path;
//DEL 	if(cf.DoModal() == IDOK)	
//DEL 	{
//DEL 		strcpy(m_SrcFile.GetBuffer(250), cf.GetPathName());
//DEL 		UpdateData(FALSE);
//DEL 	}	
//DEL }

//DEL void CAtrkFaxDlg::OnBmpFileButton() 
//DEL {
//DEL 	CFileDialog cf(0,".bmp",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Bmp file(*.bmp)|*.bmp|",NULL);
//DEL 	cf.m_ofn.lpstrTitle = "转换到文件";
//DEL 	char path[200];
//DEL 	strcpy(path,m_szCurPath);
//DEL 	strcat(path,"\\FaxFile");
//DEL 	cf.m_ofn.lpstrInitialDir = path;
//DEL 	if(cf.DoModal() == IDOK)	
//DEL 	{
//DEL 		strcpy(m_BmpFile.GetBuffer(250), cf.GetPathName());
//DEL 		UpdateData(FALSE);
//DEL 	}	
//DEL }

//DEL void CAtrkFaxDlg::OnMakeFaxFile() 
//DEL {
//DEL 	CFileDialog cf(0,".fax",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Fax file(*.fax)|*.fax|",NULL);
//DEL 	char path[200];
//DEL 	strcpy(path,m_szCurPath);
//DEL 	strcat(path,"\\FaxFile");
//DEL 	cf.m_ofn.lpstrInitialDir = path;
//DEL 	if(cf.DoModal() == IDOK)	
//DEL 	{
//DEL 		char fnfax[250];
//DEL 		strcpy(fnfax, cf.GetPathName());
//DEL 		CFileFind cff;
//DEL 		if( cff.FindFile(fnfax,0) )
//DEL 			CFile::Remove(fnfax);
//DEL 
//DEL 		char fnbmp[250];
//DEL 		strcpy(fnbmp,m_szCurPath);
//DEL 		strcat(fnbmp,"\\FaxFile\\Contract.bmp");
//DEL 		myMakeFaxFile(fnbmp, fnfax);
//DEL 	}	
//DEL }

//DEL void CAtrkFaxDlg::OnConvertButton() 
//DEL {
//DEL 	if( !strlen(m_SrcFile) )
//DEL 	{
//DEL 		AfxMessageBox("请先输入源FAX文件名!",MB_OK);
//DEL 		return;
//DEL 	}
//DEL 	else if( !strlen(m_BmpFile) )
//DEL 	{
//DEL 		AfxMessageBox("请先输入目标BMP文件名!",MB_OK);
//DEL 		return;
//DEL 	}
//DEL 
//DEL 	fBmp_ConvertFaxToBmp(m_SrcFile.GetBuffer(250), m_BmpFile.GetBuffer(250));	
//DEL }

void CAtrkFaxDlg::InitChInfoList()
{
	static int ColumnWidth[10] = {25, 36, 250, 36, 60, 100, 140, 100};
	LV_COLUMN lvc;
	lvc.mask =  LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	
	lvc.iSubItem = 0;
	lvc.pszText = "ch" ;
	lvc.cx = ColumnWidth[0];
	m_FaxChList.InsertColumn(0,&lvc);

	lvc.iSubItem = 1;
	lvc.pszText = "模式";
	lvc.cx = ColumnWidth[1];
	m_FaxChList.InsertColumn(1,&lvc);

	lvc.iSubItem = 2;
	lvc.pszText = "通道状态";
	lvc.cx = ColumnWidth[2];
	m_FaxChList.InsertColumn(2,&lvc);

	lvc.iSubItem = 3;
	lvc.pszText = "页数";
	lvc.cx = ColumnWidth[3];
	m_FaxChList.InsertColumn(3,&lvc);

	lvc.iSubItem = 4;
	lvc.pszText = "GetID";
	lvc.cx = ColumnWidth[4];
	m_FaxChList.InsertColumn(4,&lvc);

	lvc.iSubItem = 5;
	lvc.pszText = "当前文件名";
	lvc.cx = ColumnWidth[5];
	m_FaxChList.InsertColumn(5,&lvc);

	lvc.iSubItem = 6;
	lvc.pszText = "错误信息";
	lvc.cx = ColumnWidth[6];
	m_FaxChList.InsertColumn(6,&lvc);

	lvc.iSubItem = 7;
	lvc.pszText = "SsmCheckEnd";
	lvc.cx = ColumnWidth[7];
	m_FaxChList.InsertColumn(7,&lvc);

	char dig[3];
	for(int i=0; i < m_nTotalCh; i++)	
	{
		if( SsmGetChType(i) == FAX_CH
			|| SsmGetChType(i) == SOFTFAX_CH)
		{
			itoa( i, dig, 10 );
			m_FaxChList.InsertItem(i,dig);
		}
	}
}

void CAtrkFaxDlg::InitATrunkListCtrl()
{
	static int ColumnWidth[10] = {40, 100, 100, 150, 250};
	LV_COLUMN lvc;
	lvc.mask =  LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	
	lvc.iSubItem = 0;
	lvc.pszText = "ch" ;
	lvc.cx = ColumnWidth[0];
	m_TrkChList.InsertColumn(0,&lvc);

	lvc.iSubItem = 1;
	lvc.pszText = "通道状态";
	lvc.cx = ColumnWidth[1];
	m_TrkChList.InsertColumn(1,&lvc);

	lvc.iSubItem = 2;
	lvc.pszText = "传真过程状态";
	lvc.cx = ColumnWidth[2];
	m_TrkChList.InsertColumn(2,&lvc);

	lvc.iSubItem = 3;
	lvc.pszText = "DTMF按键";
	lvc.cx = ColumnWidth[3];
	m_TrkChList.InsertColumn(3,&lvc);

	lvc.iSubItem = 4;
	lvc.pszText = "出错信息";
	lvc.cx = ColumnWidth[4];
	m_TrkChList.InsertColumn(4,&lvc);

	char dig[3];
	for(int i = 0; i < m_nTotalCh; i++)
	{
		if( m_ATrkCh[i].EnCalled )
			m_TrkChList.InsertItem(i,_itoa(i, dig, 10));
	}
}

void CAtrkFaxDlg::myDrawSelect(int x, int y, Img_Block *pImg)
{
	int x1=x+5, y1=y+5;

	fBmp_PutLine(x1, y1, x1+7, y1+7, pImg);
	fBmp_PutLine(x1+7, y1+7, x1+14, y1-5,pImg);

	fBmp_PutLine(x1-1, y1, x1+7, y1+8, pImg);
	fBmp_PutLine(x1+7, y1+8, x1+15, y1-5,pImg);
}

int CAtrkFaxDlg::myFindAnIdleCh()
{
	CString str;
	//int i;
	switch(m_nTabShow)
	{
	case 0:
		m_firstDlg.m_cmbFaxCh.GetWindowText(str);
		if(!str.IsEmpty())
		{
			return atoi(str);
		}

⌨️ 快捷键说明

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