📄 fingerappdlg.cpp
字号:
// FingerAppDlg.cpp : implementation file
//
#include "stdafx.h"
#include "FingerApp.h"
#include "FingerAppDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFingerAppDlg dialog
CFingerAppDlg::CFingerAppDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFingerAppDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFingerAppDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
Width = 280;
Height = 350;
pImage = new unsigned char [280*350];
a = 0;
}
void CFingerAppDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFingerAppDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFingerAppDlg, CDialog)
//{{AFX_MSG_MAP(CFingerAppDlg)
ON_BN_CLICKED(IDC_FIG_OPEN, OnFigOpen)
ON_BN_CLICKED(IDC_FIG_READ, OnFigRead)
ON_BN_CLICKED(IDC_FIG_SHOE, OnFigShoe)
ON_BN_CLICKED(IDC_FIG_EXIT, OnFigExit)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFingerAppDlg message handlers
BOOL CFingerAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
int nWidth = GetSystemMetrics(SM_CXSCREEN);
int nHeight = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(NULL,0,0,nWidth,nHeight,SWP_NOZORDER);
HWND lpClassName;
lpClassName = ::FindWindow(TEXT("HHTaskBar"), NULL);
::ShowWindow(lpClassName, SW_HIDE);
InitFont();
return TRUE; // return TRUE unless you set the focus to a control
}
void CFingerAppDlg::OnFigOpen()
{
m_hDev = CreateFile(_T("FIG1:"),GENERIC_READ | GENERIC_WRITE,NULL,NULL,OPEN_EXISTING,NULL,NULL);
}
void CFingerAppDlg::OnFigRead()
{
WriteFile(m_hDev,pImage,sizeof(unsigned char),&(m_dwReadedBytes),NULL);
}
void CFingerAppDlg::OnFigShoe()
{
ReadFile(m_hDev,(unsigned char *)pImage,sizeof(unsigned char),&(m_dwReadedBytes),NULL);
a = 1;
Invalidate();
}
void CFingerAppDlg::OnFigExit()
{
HWND lpClassName;
lpClassName = ::FindWindow(TEXT("HHTaskBar"), NULL);
::ShowWindow(lpClassName, SW_SHOW);
CloseHandle(m_hDev);
delete [] pImage;
OnOK();
}
void CFingerAppDlg::OnPaint()
{
CPaintDC dc(this);
if(a == 1)
{
int i,j;
unsigned char *p;
unsigned int c;
unsigned int LcdWidth = 480;
unsigned int LcdHeight = 272;
unsigned int imStartX = 0;
unsigned int imstartY =0;
unsigned int LcdStartX = 0;
unsigned int LcdstartY =0;
unsigned int ImageFactor = 1;
p = pImage;
for(i = imstartY; i < Height/ImageFactor; i++)
{
for(j = imStartX; j < Width/ImageFactor; j++)
{
c = *(p + i*ImageFactor*Width + j*ImageFactor);
c = ((c & 0x0007)<<21) | ((c & 0x0007)<<13) | ((c & 0x0007)<<5);
if (((j+LcdStartX)<LcdHeight) && ((i+LcdstartY)<LcdWidth))
{
dc.SetPixel(i,LcdHeight-j,c);
}
}
}
}
}
void CFingerAppDlg::InitFont()
{
CStatic* pSt = NULL;
if(m_nTitleFont.CreateFont(
30, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial"))) // lpszFacename
{
pSt = (CStatic*)GetDlgItem(IDC_FIG_TITLE);
if(pSt!=NULL) pSt->SetFont(&m_nTitleFont);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -