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

📄 mainfrm.cpp

📁 wince下交警执法程序源码,使用evc编写
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "TrafficExecLaw.h"

#include "MainFrm.h"

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

const DWORD dwAdornmentFlags = 0; // exit button

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_SETFOCUS()
	ON_COMMAND(ID_Law_Book, OnLawBook)
	ON_COMMAND(ID_Diary, OnDiary)
	ON_COMMAND(ID_Exec_Traffic_Law, OnExecTrafficLaw)
	ON_COMMAND(ID_Search_Car, OnSearchCar)
	ON_COMMAND(ID_Phone, OnPhone)
	ON_COMMAND(ID_Map, OnMap)
	ON_COMMAND(ID_Tools, OnTools)
	ON_COMMAND(ID_LOGON, OnLogon)
	ON_UPDATE_COMMAND_UI(ID_Diary, OnUpdateDiary)
	ON_UPDATE_COMMAND_UI(ID_Exec_Traffic_Law, OnUpdateExecTrafficLaw)
	ON_UPDATE_COMMAND_UI(ID_Law_Book, OnUpdateLawBook)
	ON_UPDATE_COMMAND_UI(ID_Map, OnUpdateMap)
	ON_UPDATE_COMMAND_UI(ID_Phone, OnUpdatePhone)
	ON_UPDATE_COMMAND_UI(ID_Search_Car, OnUpdateSearchCar)
	ON_UPDATE_COMMAND_UI(ID_Tools, OnUpdateTools)
	ON_COMMAND(ID_LOGOFF, OnLogoff)
	ON_UPDATE_COMMAND_UI(ID_LOGOFF, OnUpdateLogoff)
	ON_UPDATE_COMMAND_UI(ID_LOGON, OnUpdateLogon)
	ON_COMMAND(ID_Messages, OnMessages)
	ON_UPDATE_COMMAND_UI(ID_Messages, OnUpdateMessages)
	ON_WM_DESTROY()
	ON_COMMAND(ID_ENA_DISA_PHONE_SYS, OnEnaDisaPhoneSys)
	ON_UPDATE_COMMAND_UI(ID_ENA_DISA_PHONE_SYS, OnUpdateEnaDisaPhoneSys)
	ON_COMMAND(ID_SET_DATABASE_SERVER, OnSetDatabaseServer)
	ON_UPDATE_COMMAND_UI(ID_SET_DATABASE_SERVER, OnUpdateSetDatabaseServer)
	ON_COMMAND(ID_INIT_ICC, OnInitIcc)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
extern CTrafficExecLawApp theApp;

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}




int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	// create a view to occupy the client area of the frame
	if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
		CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
	{
		TRACE0("Failed to create view window\n");
		return -1;
	}
	
#if defined(_WIN32_WCE_PSPC) // MFC for Palm-Size PC
	if(!m_wndCommandBar.Create(this) ||
	   !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
	   !m_wndCommandBar.AddAdornments(dwAdornmentFlags) ||
	   !m_wndCommandBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create CommandBar\n");
		return -1;      // fail to create
	}
#else // MFC for Windows CE 2.1 or later
	if(!m_wndCommandBar.Create(this) ||
	   !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
	   !m_wndCommandBar.InsertSeparator(6) ||
	   //!m_wndCommandBar.LoadToolBar(IDR_MAINFRAME) ||
	   !m_wndCommandBar.AddAdornments(dwAdornmentFlags))
	{
		TRACE0("Failed to create CommandBar\n");
		return -1;      // fail to create
	}
#endif

	m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create

		
	}
	else {
 	
		m_wndStatusBar.SetPaneInfo (1,ID_INDICATOR_CAPS,SBPS_NORMAL,100);
	    
	}


	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

    cs.lpszClass = AfxRegisterWndClass(0);
	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
	// forward focus to the view window
	m_wndView.SetFocus();
}

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
	// let the view have first crack at the command
	if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
		return TRUE;

	// otherwise, do default handling
	return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

void CMainFrame::OnLawBook() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (0);
}

void CMainFrame::OnDiary() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (1);
}

void CMainFrame::OnExecTrafficLaw() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (2);

}

void CMainFrame::OnSearchCar() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (3);

}

void CMainFrame::OnMessages() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (4);
}

void CMainFrame::OnPhone() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (5);

}



void CMainFrame::OnMap() 
{
	// TODO: Add your command handler code here
		this->m_wndView.m_FuncList.DoOneFunction (6);

}

void CMainFrame::OnTools() 
{
	// TODO: Add your command handler code here
	this->m_wndView.m_FuncList.DoOneFunction (7);
}


#include "Logon_Dlg.h"

void CMainFrame::OnLogon() 
{
	// TODO: Add your command handler code here
    CLogon_Dlg  c_ld;

    if(c_ld.DoModal ()==IDOK)
 	{
		theApp.fLogonSuccess =TRUE;
		this->m_wndView.m_FuncList.EnableWindow (TRUE); 
 	}

}

void CMainFrame::OnUpdateLogon(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess==FALSE);
}


void CMainFrame::OnUpdateMessages(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
}

void CMainFrame::OnUpdateDiary(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnUpdateExecTrafficLaw(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnUpdateLawBook(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnUpdateMap(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnUpdatePhone(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnUpdateSearchCar(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnUpdateTools(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess);
	
}

void CMainFrame::OnLogoff() 
{
	// TODO: Add your command handler code here
	theApp.fLogonSuccess=FALSE;
	this->m_wndView.m_FuncList.EnableWindow (FALSE);  

}

void CMainFrame::OnUpdateLogoff(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess==TRUE);

}




void CMainFrame::OnDestroy() 
{
	CFrameWnd::OnDestroy();
	
	::AfxSocketTerm ();
}

void CMainFrame::OnEnaDisaPhoneSys() 
{
	// TODO: Add your command handler code here
	theApp.phonePort.fUsePhoneSys =!theApp.phonePort.fUsePhoneSys;
	CMenu *pm=m_wndCommandBar.GetMenuBar (0);
    pm=pm->GetSubMenu (1);
	pm->CheckMenuItem (ID_ENA_DISA_PHONE_SYS,	
		(MF_CHECKED*theApp.phonePort.fUsePhoneSys+
		MF_UNCHECKED*(theApp.phonePort.fUsePhoneSys==FALSE)) |MF_BYCOMMAND);



	if(theApp.phonePort.fUsePhoneSys==TRUE)
		theApp.phonePort.InitPhoneSys ();
	else
		theApp.phonePort.ClosePhoneSys ();

}

void CMainFrame::OnUpdateEnaDisaPhoneSys(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess==TRUE);

}

#include "InputBox.h"
void CMainFrame::OnSetDatabaseServer() 
{
	CInputBox  c_inb(L"数据库服务器设置",L"IP地址:",theApp.databaseSrvIP);

	if(c_inb.DoModal ()==IDOK)
	{
		CString sIP;
		c_inb.GetInputText (sIP);
		wcscpy(theApp.databaseSrvIP,sIP);
	}
}

void CMainFrame::OnUpdateSetDatabaseServer(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable (theApp.fLogonSuccess==TRUE);

}

void CMainFrame::OnInitIcc() 
{
	// TODO: Add your command handler code here
	Drive_Certi_Info dci;
	unsigned char* p = (unsigned char*)&dci;
	int i;
	
	wcscpy(dci.m_address,L"湖北省武汉市洪山区狮子山街");
    wcscpy(dci.m_born_date,L"1977-06-13");
	wcscpy(dci.m_car_permission,L"C1");
	wcscpy(dci.m_cer_mumber,L"42011177061XXXX");
    wcscpy(dci.m_country,L"中国");
    dci.m_curr_points=12;
    dci.m_deducted_points=0;

    wcscpy(dci.m_date_get_cer_date,L"2005-09-30");
    wcscpy(dci.m_name,L"陈XX");
    wcscpy(dci.m_sex ,L"男");
	wcscpy(dci.m_start_date,L"2005-09-30");
    dci.m_valid_date=6;


	WriteICC(32, p, sizeof(dci));

	MessageBox(L"OK");

}

⌨️ 快捷键说明

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