screensvr.cpp

来自「"Visual C++.net实践与提高-深入Windows编程"的源代码」· C++ 代码 · 共 109 行

CPP
109
字号
// ScreenSvr.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "ScreenSvr.h"

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

/////////////////////////////////////////////////////////////////////////////
// CScreenSvrApp

BEGIN_MESSAGE_MAP(CScreenSvrApp, CWinApp)
	//{{AFX_MSG_MAP(CScreenSvrApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScreenSvrApp construction

CScreenSvrApp::CScreenSvrApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// CScreenSvrApp initialization

BOOL CScreenSvrApp::InitInstance()
{
	//	iState: 1:预览 ;0:显示;2:设置
	//
	//
	int iState = 2 ;		// 命令行中如何没有参数,则打开设置窗口
	HWND hwnd = NULL ;
	TCHAR * pCmdLn = ::GetCommandLine() ;
	CString str ;
	str += pCmdLn ;
	str.MakeUpper() ;
#ifdef _DEBUG
	AfxMessageBox(str) ;
#endif
	int i = str.Find('/' , 0 ) ;
	if( i == -1 ){
		i = str.Find('-' , 0 ) ;
	}
	if( i > 0 )
	{
		switch(str[i+1])
		{
		case 'S':
			iState = 0 ;	// 显示
			break ;
		case 'P':
		case 'L':
			iState = 1 ;	// 预览
			if( str.GetLength() > i+3 ){
				str = str.Right(str.GetLength() - (i+3) ) ;
#ifdef _DEBUG
				AfxMessageBox("P or L :"+str) ; 
#endif
				hwnd = reinterpret_cast<HWND>(atoi(LPCTSTR(str)));
			}
			else{
				AfxMessageBox("程序进入错误区域!") ;
			}
			break ;
		case 'C':
			if( str.GetLength() > i+3 ){
				str = str.Right(str.GetLength() - (i+3) ) ;
#ifdef _DEBUG
				AfxMessageBox("C or Default:"+str) ;
#endif
				hwnd = reinterpret_cast<HWND>(atoi(LPCTSTR(str)));
			}
			break ;			// 设置窗口
		default:
			iState = 4 ;
			break ;
		}
	}
	switch(iState){
	case 0:
	case 1:
		return OpenScreenSvrWnd(hwnd) ;
	case 2:
		return OpenConfigWnd(hwnd) ;
	default:
		// Since the dialog has been closed, return FALSE so that we exit the
		//  application, rather than start the application's message pump.
		return FALSE ;
	}
}

BOOL CScreenSvrApp::OpenConfigWnd(HWND hParentWnd)
{
	return FALSE ;			// Exit Appliction: FALSE; True: enter messages Processing
}

BOOL CScreenSvrApp::OpenScreenSvrWnd(HWND hParentWnd)
{
	return FALSE ;			// Exit Appliction: FALSE; True: enter messages Processing
}

⌨️ 快捷键说明

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