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

📄 fax_event_vcdlg.cpp

📁 VC6.0
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// Fax_Event_VCDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Fax_Event_VC.h"
#include "Fax_Event_VCDlg.h"

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

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

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

// 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)
	virtual BOOL OnInitDialog();
	//}}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)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFax_Event_VCDlg dialog

CFax_Event_VCDlg::CFax_Event_VCDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFax_Event_VCDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFax_Event_VCDlg)
	m_strAppendFile = _T("");
	m_nAutoOrNot = -1;
	m_nFaxSpeed = 1;
	m_bRecord = FALSE;
	m_strSetId = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

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


CFax_Event_VCDlg::~CFax_Event_VCDlg()
{
	int nCheck;
	if(m_LogFile != NULL)
		fclose(m_LogFile);
	for(int i = 0; i < m_nTotalCh; i++)
	{
		nCheck = SsmGetChType(i);
		if(nCheck == -1)
			WriteLog("Fail to call SsmGetChType");
		else if(nCheck == FAX_CH || nCheck == SOFTFAX_CH)
			GlobalFree(m_FaxCh[i].pffSCT);
	}
}


void CFax_Event_VCDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFax_Event_VCDlg)
	DDX_Control(pDX, IDC_COMBO_FAX_CH, m_cmbFaxCh);
	DDX_Control(pDX, IDC_TAB, m_TabCtrl);
	DDX_Control(pDX, IDC_LIST_TRUNK, m_TrkChList);
	DDX_Control(pDX, IDC_LIST_FAX, m_FaxChList);
	DDX_Control(pDX, IDC_COMBO_TRKCH, m_cmbTrkChNo);
	DDX_Control(pDX, IDC_COMBO_TRK_CH, m_cmbTrkCh);
	DDX_Control(pDX, IDC_COMBO_FAXCH, m_cmbFaxChNo);
	DDX_Text(pDX, IDC_EDIT_APPEND_FILE, m_strAppendFile);
	DDX_Radio(pDX, IDC_RADIO_AUTO, m_nAutoOrNot);
	DDX_Radio(pDX, IDC_RADIO_SPEED4800, m_nFaxSpeed);
	DDX_Check(pDX, IDC_CHECK_RECORD, m_bRecord);
	DDX_Text(pDX, IDC_EDIT_SET_ID, m_strSetId);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFax_Event_VCDlg, CDialog)
	//{{AFX_MSG_MAP(CFax_Event_VCDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RADIO_SPEED4800, OnRadioSpeed4800)
	ON_BN_CLICKED(IDC_RADIO_SPEED9600, OnRadioSpeed9600)
	ON_BN_CLICKED(IDC_RADIO_SPEED14400, OnRadioSpeed14400)
	ON_BN_CLICKED(IDC_BUTTON_APPEND_FILE, OnButtonAppendFile)
	ON_BN_CLICKED(IDC_BUTTON_APPEND_SEND, OnButtonAppendSend)
	ON_BN_CLICKED(IDC_BUTTON_FAX_STOP, OnButtonFaxStop)
	ON_BN_CLICKED(IDC_RADIO_AUTO, OnRadioAuto)
	ON_BN_CLICKED(IDC_RADIO_MANUAL, OnRadioManual)
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
	ON_WM_SHOWWINDOW()
	ON_CBN_SELCHANGE(IDC_COMBO_TRK_CH, OnSelchangeComboTrkCh)
	ON_BN_CLICKED(IDC_CHECK_RECORD, OnCheckRecord)
	ON_CBN_SELCHANGE(IDC_COMBO_TRKCH, OnSelchangeComboTrkch)
	ON_BN_CLICKED(IDC_BUTTON_SET_ID, OnButtonSetId)
	ON_EN_CHANGE(IDC_EDIT_SET_ID, OnChangeEditSetId)
	ON_WM_DESTROY()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFax_Event_VCDlg message handlers

BOOL CFax_Event_VCDlg::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
	// set up a vacant queue

	g_dwLanguageConversion = GetThreadLocale();
	InitLab();
	if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)	
	{
		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);
		tci.pszText = "截掉页眉";
		m_TabCtrl.InsertItem(3, &tci);
	}
	else
	{
		TC_ITEM	tci;
		tci.mask = TCIF_TEXT;
		tci.pszText = "Receive Fax";
		m_TabCtrl.InsertItem(0, &tci);
		tci.pszText = "Send Fax";
		m_TabCtrl.InsertItem(1, &tci);
		tci.pszText = "Add Header";
		m_TabCtrl.InsertItem(2, &tci);
		tci.pszText = "Cut off Header";
		m_TabCtrl.InsertItem(3, &tci);
	}

	m_FirstDlg.Create(IDD_FIRST_DLG, m_TabCtrl.GetActiveWindow());
	m_SecondDlg.Create(IDD_SECOND_DLG, m_TabCtrl.GetActiveWindow());
	m_SecondDlg.m_pParent = this;
	m_ThirdDlg.Create(IDD_THIRD_DLG, m_TabCtrl.GetActiveWindow());
	m_FourthDlg.Create(IDD_FOURTH_DLG, m_TabCtrl.GetActiveWindow());

	if(!InitCtiBoard())
	{
		PostQuitMessage(0);
		return FALSE;	
	}
	
	InitFaxChListCtrl();	//initialize fax channel list
	UpdateFaxChListCtrl();	//update fax channel list
	InitTrunkChListCtrl();	//initialize trunk channel list
	UpdateTrunkChListCtrl();//update trunk channel list
	//creat log file	
	char szLogFile[MAX_PATH];
	sprintf(szLogFile , "%s\\Fax.Log", m_szCurPath);

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

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

	// set event_message programming mode 	
	EVENT_SET_INFO EventSet;		
	EventSet.dwWorkMode = EVENT_MESSAGE;	
	EventSet.lpHandlerParam = this->GetSafeHwnd();	
	SsmSetEvent(-1, -1, TRUE, &EventSet);

	SetTimer(1, 200, NULL);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}


void CFax_Event_VCDlg::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 CFax_Event_VCDlg::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 CFax_Event_VCDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


void CFax_Event_VCDlg::OnRadioSpeed4800() 
{
	if (m_nOldSpeed!=4800)
	{
		m_nOldSpeed=4800;
		SsmFaxSetMaxSpeed(4800);
	}
}


void CFax_Event_VCDlg::OnRadioSpeed9600() 
{
	if (m_nOldSpeed!=9600)
	{
		m_nOldSpeed=9600;
		SsmFaxSetMaxSpeed(9600);
	}
}


void CFax_Event_VCDlg::OnRadioSpeed14400() 
{
	if (m_nOldSpeed!=14400)
	{
		m_nOldSpeed=14400;
		SsmFaxSetMaxSpeed(14400);
	}
}


void CFax_Event_VCDlg::OnButtonAppendFile()			
{
	// TODO: Add your control notification handler code here
	CFileDialog cf(1, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Fax File(*.tif)|*.tif|Tif File(*.fax)|*.fax|Tiff File(*.tiff)|*.tiff|All File(*.*)|*.*|",NULL);
	char szPath[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, m_szCurPath);
	strcpy(szPath, m_szCurPath);
	cf.m_ofn.lpstrInitialDir = szPath;

	if(cf.DoModal() == IDOK)
	{
		strcpy(m_strAppendFile.GetBuffer(MAX_PATH), cf.GetFileName());
		m_strAppendFile.ReleaseBuffer();
		UpdateData(FALSE);
	}
}


// Append:Send
void CFax_Event_VCDlg::OnButtonAppendSend()			
{
	// TODO: Add your control notification handler code here
	char sz[50];
	m_cmbFaxChNo.GetLBText(m_cmbFaxChNo.GetCurSel(), sz);
	int n = atoi(sz);
	if(SsmFaxAppendSend(n, m_strAppendFile) == -1)
		WriteLog("Fail to call SsmFaxAppendSend");
}

// stop faxing
void CFax_Event_VCDlg::OnButtonFaxStop()			
{
	// TODO: Add your control notification handler code here
	char sz[50];
	m_cmbFaxChNo.GetLBText(m_cmbFaxChNo.GetCurSel(), sz);
	int n = atoi(sz);
	if(SsmFaxStop(n) == -1)
		WriteLog("Fail to call SsmFaxStop");
}


// receive/send fax automatically
void CFax_Event_VCDlg::OnRadioAuto()		
{
	// TODO: Add your control notification handler code here
	char sz[50];
	UpdateData(TRUE);
	m_cmbTrkChNo.GetLBText(m_cmbTrkChNo.GetCurSel(), sz);
	int n = atoi(sz);
	m_TrkCh[n].nAutoOrNot = m_nAutoOrNot;
}


// receive/send fax according to the voice
void CFax_Event_VCDlg::OnRadioManual()		
{
	// TODO: Add your control notification handler code here
	char sz[50];
	UpdateData(TRUE);
	m_cmbTrkChNo.GetLBText(m_cmbTrkChNo.GetCurSel(), sz);
	int n = atoi(sz);
	m_TrkCh[n].nAutoOrNot = m_nAutoOrNot;
}


// initialize board
BOOL CFax_Event_VCDlg::InitCtiBoard()	
{
	char szShIndex[MAX_PATH];	// path to ShIndex.ini
	char szShConfig[MAX_PATH];	// path to ShConfig.ini
	CString str;
	int nCheck;
	int nChk;

	GetCurrentDirectory(MAX_PATH, m_szCurPath);
	strcpy(szShIndex, m_szCurPath);
	strcpy(szShConfig, m_szCurPath);
	strcat(szShIndex, "\\ShIndex.ini");
	strcat(szShConfig, "\\ShConfig.ini");

	// load configuration file and initialize system
	if (SsmStartCti(szShConfig, szShIndex) == -1)
	{
		// get initialization error message
		SsmGetLastErrMsg(m_szErrMsg);	
		AfxMessageBox(m_szErrMsg, MB_OK);
		return FALSE;
	}

	// Judge if the number of initialized boards is the same as
	//		   that of boards specified in the configuration file
	
	if(SsmGetMaxUsableBoard() != SsmGetMaxCfgBoard())
	{
		SsmGetLastErrMsg(m_szErrMsg);	
		AfxMessageBox(m_szErrMsg, MB_OK);
		return FALSE;

⌨️ 快捷键说明

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