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

📄 hfcxdlg.cpp

📁 170话费查询系统
💻 CPP
字号:
// hfcxDlg.cpp : implementation file
//

#include "stdafx.h"
#include "hfcx.h"
#include "hfcxDlg.h"
#include "mybase.h"
#include "myvc.h"
#include "d300.h"


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

/////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
// CHfcxDlg dialog
CHfcxDlg::CHfcxDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHfcxDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHfcxDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CHfcxDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHfcxDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CHfcxDlg, CDialog)
	//{{AFX_MSG_MAP(CHfcxDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDexit, Onexit)
	ON_BN_CLICKED(IDOpenDev, OnOpenDev)
	ON_MESSAGE(WM_QueryDone, OnMessageQueryDone)
	ON_MESSAGE(WM_ResetVoiceDone, OnMessageResetDone)
	ON_MESSAGE(WM_StopWork, OnMessageStopWork)
	ON_MESSAGE(WM_ShowMyWin, OnMessageShowMyWin)
	ON_MESSAGE(WM_HideMyWin, OnMessageHideMyWin)
	ON_MESSAGE(WM_DataOperate, OnMessageDataOperate)
	ON_MESSAGE(WM_UpdateMonth, OnMessageUpdateMonth) 
	ON_MESSAGE(WM_UpdateQfTable,OnMessageUpdateQfTable)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHfcxDlg message handlers

BOOL CHfcxDlg::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
	
	//标志主控程序是否运行
	ControlExist = false;
	// TODO: Add extra initialization here
	
	//程序自动启动服务
	set_system_info();
	OnOpenDev();

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


//启动程序
void CHfcxDlg::OnOpenDev() 
{
	HWND hWnd;

	
	if (RegisterGCA()==false)
	{
		AfxMessageBox("错误:请先运行主控程序!");
		return;
	}
	ControlExist = true;  //这是CHfcxDlg一个成员变量,用于标志主控程序是否运行
	init_prog();	
	start_time_trigger();
	start_sys_event_dispatcher();	
	SysPrintf("System Event Dispatcher 启动.");
	SysPrintf("YYSL is ready.");
	SysPrintf(" ");
	//返回消息给主控程序,告之“服务启动”
	hWnd = GetScreenShowWindow();
	if (hWnd == NULL || hWnd ==0 ){
	  //WinPrintf("主控程序没有启动!");
      return;
	}
	
	::PostMessage(hWnd, WM_MyAppStarted, (WPARAM )TheAppID, (LPARAM )0);

	//自己给自己发消息,隐藏窗口
	::PostMessage(m_hWnd, WM_HideMyWin, (WPARAM )0, (LPARAM )0);
	    
}

//停止运行消息
void CHfcxDlg::OnMessageStopWork(WPARAM wParam, LPARAM lParam) 
{ 
	Onexit();
	return; 
} 

//显示程序窗口
void CHfcxDlg::OnMessageShowMyWin(WPARAM wParam, LPARAM lParam) 
{ 
	ShowWindow(SW_SHOW);
	return; 
}

//隐藏程序窗口
void CHfcxDlg::OnMessageHideMyWin(WPARAM wParam, LPARAM lParam) 
{ 
	ShowWindow(SW_HIDE);
	return; 
}

//更新月份消息
void CHfcxDlg::OnMessageUpdateMonth(WPARAM wParam, LPARAM lParam) 
{ 
	int mstart, mend;

	mstart = (int) wParam;
	mend   = (int) lParam;

	update_month(mstart, mend);
    //SysPrintf("yysl: month update! start=%d, end = %d", mstart, mend);
	return; 
} 

//欠费表切换
void CHfcxDlg::OnMessageUpdateQfTable(WPARAM wParam, LPARAM lParam) 
{ 
	int new_table;

	new_table = (int) wParam;
	
	update_qf_table(new_table);
    //SysPrintf("yysl: qftable update! newtable=%d", new_table);
	return; 
} 

//接受语音数据
void CHfcxDlg::OnMessageDataOperate(WPARAM wParam, LPARAM lParam) 
{
	int		cn;
	long	win_msg;
    PCOPYDATASTRUCT  p;
    char    l_voice_chain[2048];

	cn  = (int)wParam;
	p	= (PCOPYDATASTRUCT)lParam;

	
	win_msg = p->dwData;
	strcpy(l_voice_chain, (const char *)p->lpData);

	//将voice_chain转换到 cvca中
    voice_to_cvca(cn, l_voice_chain);

	if (win_msg == WM_QueryDone ) {
   		SysPrintf("WM_QueryDone accepted from (%d)",cn);
		put_event_to_board(cn,qry_ok);
		return;		
	}
	if (win_msg == WM_VoiceChainProduct ) {
		SysPrintf("WM_VoiceChainProduct accepted from (%d)  !", cn);
		put_event_to_board(cn,mply_chkdata);
		return;		
	}
	if (win_msg == WM_ResetVoiceDone ) {
		SysPrintf("WM_ResetVoiceDone  accepted from (%d)  !", cn);
		//put_event_to_board(cn,voc_resetok);
		put_event_to_board(cn,mply_start);
		return; 		
	}
	
	return;
}

//数据查询完毕
void CHfcxDlg::OnMessageQueryDone(WPARAM wParam, LPARAM lParam) 
{ 
	int cn;
	cn  = (int)wParam;

	SysPrintf("WM_QueryDone accepted from (%d)  !", cn);
	put_event_to_board(cn,qry_ok);
	return; 
} 

//语音链Reset完毕
void CHfcxDlg::OnMessageResetDone(WPARAM wParam, LPARAM lParam) 
{ 
	int cn;
	cn  = (int)wParam;

	SysPrintf("WM_ResetVoiceDone  accepted from (%d)  !", cn);
	put_event_to_board(cn,voc_resetok);
	return; 
} 

/************************************************************************************************
*	FUNCTION: RegiterGCA(void)
*   参数:无
*	说明:向全局通讯区注册程序主窗口名。
************************************************************************************************/
bool	RegisterGCA(void)
{

	HWND hWnd, control_handle, server_handle;
	char WinTitle[128];

	//判断主控程序是否存在
	control_handle = GetScreenShowWindow();
	if (control_handle == NULL) {
		return false;	
	}

	//向GCA注册主窗口名
    hWnd=AfxGetMainWnd()->m_hWnd;
    ::GetWindowText(hWnd,WinTitle, 128); 	


    if (SetGCA("DBClientAppName",WinTitle)==0)
	{   
		//SysPrintf("窗口名[%s]注册失败!", WinTitle);
		return false;
	}
	else
	{
		if (DEBUG) {
			//SysPrintf("窗口名[%s]注册成功!", WinTitle);
		}
	}

    if (DEBUG){
		control_handle = GetScreenShowWindow();
		::GetWindowText(control_handle,WinTitle, 128); 
		//SysPrintf("主控程序窗口名是[%s]", WinTitle);
 
		server_handle  = GetDataServerWindow();
		::GetWindowText(server_handle,WinTitle, 128); 
		//SysPrintf("数据服务程序窗口名是[%s]", WinTitle);
	}

    return true;
}

//退出受理程序
void CHfcxDlg::Onexit() 
{
	HWND hWnd;

	
	if (ControlExist){
		end_prog();
	}

	//返回消息给主控程序,告之“程序退出”
	hWnd = GetScreenShowWindow();
	if (hWnd == NULL || hWnd ==0 ){
	  //主控程序已经退出
	}
	else
	{
		::PostMessage(hWnd, WM_MyAppClosed, (WPARAM )TheAppID, (LPARAM )0);
	}
	DestroyWindow();
}



⌨️ 快捷键说明

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