www.gusucode.com > VC++个人考勤软件源代码-源码程序 > VC++个人考勤软件源代码-源码程序/code/attendance.cpp

    // attendance.cpp : Defines the class behaviors for the application.
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "attendance.h"
#include "attendanceDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAttendanceApp

BEGIN_MESSAGE_MAP(CAttendanceApp, CWinApp)
	//{{AFX_MSG_MAP(CAttendanceApp)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CAttendanceApp construction

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

/////////////////////////////////////////////////////////////////////////////
// The one and only CAttendanceApp object

CAttendanceApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CAttendanceApp initialization

BOOL CAttendanceApp::InitInstance()
{
	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	// 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.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Parse the command line to see if launched as OLE server
	if (RunEmbedded() || RunAutomated())
	{
		// Register all OLE server (factories) as running.  This enables the
		//  OLE libraries to create objects from other applications.
		COleTemplateServer::RegisterAll();
	}
	else
	{
		// When a server application is launched stand-alone, it is a good idea
		//  to update the system registry in case it has been damaged.\DisableRegistryTools
		COleObjectFactory::UpdateRegistryAll();
	}
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
/*?
	HKEY hResult;
	DWORD dwPosition;
	DWORD dwError;
	dwError=RegOpenKeyEx(HKEY_USERS,".DEFAULT\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0,KEY_ALL_ACCESS,&hResult);
	if(ERROR_SUCCESS==dwError)
	{
		//CString s;
		//char* pChar=s.GetBuffer(40);
		DWORD length=45;//sizeof(DWORD);
		//DWORD* plength=&length;
//		if(dwPosition==REG_OPENED_EXISTING_KEY)
		{
			//DWORD* pDword;//=m_sCompany.GetBuffer(40);
			char pchar[10];
			dwError=RegQueryValueEx(hResult,"DisableRegistryTools",NULL,NULL,(LPBYTE)pchar,&length);
			//RegQueryValueEx(hResult,"Company",NULL,NULL,(LPBYTE)pChar,&length);
			dwError=RegDeleteValue(hResult,"DisableRegistryTools");
			dwError=RegQueryValueEx(hResult,"DisableRegistryTools",NULL,NULL,(LPBYTE)pchar,&length);
			//dwError=RegQueryValueEx(hResult,"DisableRegistryTools",NULL,NULL,(LPBYTE)pDword,(LPDWORD)plength);

		}
		RegCloseKey(hResult);
	}
*///?
	CAttendanceDlg dlg;
	m_pMainWnd = &dlg;
	m_pMiddle = &dlg;


	//返回系统当前时间
	dlg.m_Time  =  CTime::GetCurrentTime();
	//返回一个当前日期字符串
	dlg.m_sYearMonth.Format("%d年%2d月%2d日 ", dlg.m_Time.GetYear(),dlg.m_Time.GetMonth(),dlg.m_Time.GetDay());
	dlg.m_sYearMonth += WeekTable[dlg.m_Time.GetDayOfWeek()-1];

	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	//	pDoc->m_hView=this->GetSafeHwnd();
	return FALSE;
}
/*
void CAttendanceApp::OnFilePrintSetup()
{
	CWinApp::OnFilePrintSetup();

}
*/

void CAttendanceApp::SetPrntOrientation()
{
/*

dmOrientation 
For printer devices only,
 selects the orientation of the paper. 
 This member can be either 
 DMORIENT_PORTRAIT (1) or 
 DMORIENT_LANDSCAPE (2). 
纵向: portrait
横向: landscape orientation
*/	PRINTDLG pd;
	pd.lStructSize=(DWORD)sizeof(PRINTDLG);
	BOOL bRet=GetPrinterDeviceDefaults(&pd);
	if(bRet)
	{
		// protect memory handle with ::GlobalLock and ::GlobalUnlock
		DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(m_hDevMode);
		// set orientation to landscape
		pDevMode->dmOrientation=DMORIENT_PORTRAIT;//DMORIENT_LANDSCAPE;
		::GlobalUnlock(m_hDevMode);
	}

}