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

📄 crtt_ce.cpp

📁 《Windows CE 应用程序设计》 书上的第七章第六节实例——火车时刻表查询工具——EVC开发的
💻 CPP
字号:
// Crtt_CE.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "Crtt_CE.h"

#include "MainFrm.h"
#include "Crtt_CEDoc.h"
#include "Crtt_CEView.h"


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

/////////////////////////////////////////////////////////////////////////////
// CCrtt_CEApp

BEGIN_MESSAGE_MAP(CCrtt_CEApp, CWinApp)
	//{{AFX_MSG_MAP(CCrtt_CEApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_APP_EXIT, OnAppExit)
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCrtt_CEApp construction

CCrtt_CEApp::CCrtt_CEApp(LPCTSTR lpszAppName)
	: CWinApp(lpszAppName)
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CCrtt_CEApp object

// WCE MFC apps require the application name to be specified in the CWinApp 
// constructor. A help contents filename may also be specified.

CCrtt_CEApp theApp(_T("Crtt_CE"));

/////////////////////////////////////////////////////////////////////////////
// CCrtt_CEApp initialization
BOOL CheckOEMInfo()
{
	wchar_t  oemInfo[80];
	char     modelName[80];

	SystemParametersInfo(SPI_GETOEMINFO, 80, oemInfo, 0);
//	AfxMessageBox(oemInfo);
	WideCharToMultiByte(936, NULL, oemInfo, -1, modelName, 80, NULL, NULL);
	if ((strncmp(modelName, "PB10", 4) == NULL) ||
	    (strncmp(modelName, "PP510", 5) == NULL) ||
	    (strncmp(modelName, "PP520", 5) == NULL) ||
	    (strncmp(modelName, "PP530", 5) == NULL))    // HTC
		return TRUE;
	else
		return FALSE;
}



BOOL CCrtt_CEApp::InitInstance()
{
/*if( CheckOEMInfo()==FALSE)
	{
	::MessageBox(NULL,_T("请使用PB10,PP510,PP520,PP530型机器"),_T("列车时刻表 1.0 版"),MB_OK );
	return FALSE;
	}
*/
	HWND hwnd=FindWindow(NULL,_T("列车时刻表"));
	if(hwnd!=NULL)
	{
	//::MessageBox(hwnd,_T("列车时刻表1.0已经运行!"),_T("列车时刻表1.0"),MB_OK );
	SetActiveWindow(hwnd);
	BringWindowToTop(hwnd);
	return FALSE;
	}

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.

	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CCrtt_CEDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CCrtt_CEView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}

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

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

// 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
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();		// Added for WCE apps
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//}}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)
	ON_WM_LBUTTONDBLCLK()
	ON_WM_TIMER()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CCrtt_CEApp::OnAppAbout()
{
//	((CMainFrame*)AfxGetMainWnd())->UpdateCommandBar();

	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CCrtt_CEApp commands
// Added for WCE apps

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CenterWindow();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CAboutDlg::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class
		cs.style &= ~WS_HSCROLL;
//cs.style &= ~(WS_HSCROLL|ES_AUTOHSCROLL);

	return CDialog::PreCreateWindow(cs);
}

int CCrtt_CEApp::ExitInstance() 
{
	// TODO: Add your specialized code here and/or call the base class
	return CWinApp::ExitInstance();
}


void CCrtt_CEApp::OnAppExit() 
{
 CWinApp::OnAppExit() ;
	
}

void CAboutDlg::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
CString str;
	str.LoadString(IDS_AUTHORNAME);

//	if(nFlags==(MK_CONTROL | MK_SHIFT))
//	{
//		SetTimer(1,4000,NULL);
		GetDlgItem(IDL_AUTHORNAME)->SetWindowText(str);
		
	CDialog::OnLButtonDblClk(nFlags, point);
}

void CAboutDlg::OnTimer(UINT nIDEvent) 
{
//	GetDlgItem(IDL_AUTHORNAME)->SetWindowText(_T(""));
//	KillTimer(1);
		
	CDialog::OnTimer(nIDEvent);
}

void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
CString str;
	str.LoadString(IDS_AUTHORNAME);

//	if(nFlags==(MK_CONTROL | MK_SHIFT))
//	{
//		SetTimer(1,4000,NULL);
		GetDlgItem(IDL_AUTHORNAME)->SetWindowText(str);
		
	
//	CDialog::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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