📄 capture.cpp
字号:
// Capture.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Capture.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "USkin.h"
/////////////////////////////////////////////////////////////////////////////
// CCaptureApp
BEGIN_MESSAGE_MAP(CCaptureApp, CWinApp)
//{{AFX_MSG_MAP(CCaptureApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCaptureApp construction
CCaptureApp::CCaptureApp()
{
//AfxMessageBox("sss");
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCaptureApp object
CCaptureApp theApp;
CDataManage dataManage;
/////////////////////////////////////////////////////////////////////////////
// CCaptureApp initialization
BOOL CCaptureApp::InitInstance()
{
InitCommonControls();
CWinApp::InitInstance();
AfxEnableControlContainer();
InitCommonControls();
// 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
AfxOleInit();
AfxInitRichEdit(); //初始化RichEdit
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
USkinInit(NULL,NULL,_T("media.u3"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CCaptureDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CCaptureView));
AddDocTemplate(pDocTemplate);
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
char c_str[MAX_PATH]; //获取当前文件名
GetModuleFileName(NULL,c_str,MAX_PATH);
if (dataManage.InitADO()==false)
AfxMessageBox("数据库初始化失败.",64,0);
CString c_currentdir = c_str;
h_module = LoadLibrary("./FunctionDll.dll");
if (h_module != NULL)
{
ExtractFilePath = (CExtractFilePath*)GetProcAddress(h_module,"ExtractFilePath");
c_currentdir = ExtractFilePath(c_str);
}
else
{
AfxMessageBox("加载动态库出错.",64,0);
}
GetPrivateProfileString("Database", "Databasename", "", c_database, sizeof(c_database), c_currentdir+"/Data.ini");
GetPrivateProfileString("Database","UserName","",c_user,sizeof(c_user),c_currentdir+"/Data.ini");
GetPrivateProfileString("Database","Password","",c_password,sizeof(c_password),c_currentdir+"/Data.ini");
c_connectionstr.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb","","",adModeUnknown);
// c_connectionstr.Format("driver={SQL Server};SERVER=.;UID = %s;PWD=%s;DATABASE=%s",c_user,c_password,c_database);
if (dataManage.ConnectionDatabase(c_connectionstr.GetBuffer(c_connectionstr.GetLength()))==false)
{
AfxMessageBox("连接数据库失败.",64,0);
}
CLogin* m_pLogin = new CLogin();
int result = m_pLogin->DoModal();
delete m_pLogin;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
if (result==1)
PostMessage(AfxGetMainWnd()->m_hWnd,WM_CLOSE,0,0);
else
{
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
void OnCancel();
void OnOK();
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
afx_msg UINT OnNcHitTest(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_NCHITTEST()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CCaptureApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CCaptureApp message handlers
int CCaptureApp::ExitInstance()
{
::FreeLibrary(h_module);
return CWinApp::ExitInstance();
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg)
{
// if (pMsg->hwnd==m_hWnd)
// if (pMsg->message == WM_NCHITTEST)
// pMsg->wParam ==
return CDialog::PreTranslateMessage(pMsg);
}
UINT CAboutDlg::OnNcHitTest(CPoint point)
{
// return HTCAPTION|HTMENU;
return CDialog::OnNcHitTest(point);
}
void CAboutDlg::OnOK()
{
CDialog::OnOK();
}
void CAboutDlg::OnCancel()
{
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -