📄 testdlg.cpp
字号:
// testDlg.cpp : implementation file
//
#include "stdafx.h"
#include "test.h"
#include "testDlg.h"
#include "shellapi.h"
//#include "Pwinuser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern BOOL WINAPI TouchCalibrate(void);
/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
// 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);
}
void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_BN_CLICKED(IDC_Bshell, OnBshell)
ON_BN_CLICKED(IDC_Bplayer, OnBplayer)
ON_BN_CLICKED(IDC_Bgprs, OnBgprs)
ON_BN_CLICKED(IDC_Bcali, OnBcali)
ON_BN_CLICKED(IDC_Brotate, OnBrotate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers
BOOL CTestDlg::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
// TODO: Add extra initialization here
// Check the Node & create it if it doesn't exist
HKEY hKEY;
LPCTSTR data_Set=_T("System\\GDI\\ROTATION");
long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_ALL_ACCESS, &hKEY);
if(ret0!=ERROR_SUCCESS)
{
DWORD dwDisposition;
::RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("System\\GDI\\ROTATION"),
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS
, NULL, &hKEY, &dwDisposition) ;
}
// Read Value
int angle=0;
DWORD value=0;
DWORD dwAidSize=4;
DWORD type=REG_DWORD;
long ret1=::RegQueryValueEx(hKEY,_T("Angle"),NULL,&type,(LPBYTE)&value,&dwAidSize);
if(ret1!=ERROR_SUCCESS)
{
//MessageBox(_T("Error when reading reg"));
DWORD rvalue=90; //init value
::RegSetValueEx(hKEY,_T("Angle"),0,REG_DWORD_LITTLE_ENDIAN,(LPBYTE)&rvalue,sizeof(rvalue));
::RegQueryValueEx(hKEY,_T("Angle"),NULL,&type,(LPBYTE)&value,&dwAidSize);
}
/*
char *tmp=new char[5];
_itoa(value,tmp,10);
AfxMessageBox((LPCTSTR)tmp);
*/
::RegCloseKey(hKEY);
//== Rotate the LCD ==//
DEVMODE devMode;
switch(angle)
{
case 0:
devMode.dmDisplayOrientation=DMDO_0;
break;
case 90:
devMode.dmDisplayOrientation=DMDO_90;
break;
case 180:
devMode.dmDisplayOrientation=DMDO_180;
break;
case 270:
devMode.dmDisplayOrientation=DMDO_270;
break;
default:
devMode.dmDisplayOrientation=DMDO_0;
}
devMode.dmFields=DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx(NULL,&devMode,NULL,CDS_RESET,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::OnBshell()
{
// TODO: Add your control notification handler code here
SHELLEXECUTEINFO shelli;
ZeroMemory(&shelli, sizeof(SHELLEXECUTEINFO));
shelli.cbSize = sizeof(SHELLEXECUTEINFO);
shelli.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
shelli.hwnd = NULL;
shelli.lpVerb = _T("open");
shelli.lpFile = _T("explorer.exe");
shelli.lpParameters = NULL;
shelli.lpDirectory = NULL;
shelli.nShow = SW_SHOW;
ShellExecuteEx(&shelli);
}
void CTestDlg::OnBplayer()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
SHELLEXECUTEINFO shelli;
ZeroMemory(&shelli, sizeof(SHELLEXECUTEINFO));
shelli.cbSize = sizeof(SHELLEXECUTEINFO);
shelli.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
shelli.hwnd = NULL;
shelli.lpVerb = _T("open");
shelli.lpFile = _T("\\ResidentFlash\\BetaPlayer\\player.exe");
shelli.lpParameters = NULL;
shelli.lpDirectory = NULL;
shelli.nShow = SW_SHOW;
ShellExecuteEx(&shelli);
}
void CTestDlg::OnBgprs()
{
// TODO: Add your control notification handler code here
MessageBox(_T("GPRS not installed"));
}
void CTestDlg::OnBcali()
{
// TODO: Add your control notification handler code here
// if(TouchCalibrate()!=TRUE)
// {
// MessageBox(_T("Error when Touch Calibrate"));
// };
}
// Reg Save
void RegSaveRotate(DWORD value)
{
DWORD rvalue=0;
// set tmp value
switch(value)
{
// CE store the short type data low-high upside down
case DMDO_0:
rvalue=0;
break;
case DMDO_90:
rvalue=0x5A; // 5A
break;
case DMDO_180:
rvalue=0xB4; // B4
break;
case DMDO_270:
rvalue=0x010E; // 010E
break;
default:
rvalue=0;
break;
}
// set value
HKEY hKEY;
LPCTSTR data_Set=_T("System\\GDI\\ROTATION");
long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_ALL_ACCESS, &hKEY);
if(ret0!=ERROR_SUCCESS)
{
DWORD dwDisposition;
::RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("System\\GDI\\ROTATION"),
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS
, NULL, &hKEY, &dwDisposition) ;
}
//BYTE lm=0;
long ret1=::RegSetValueEx(hKEY,_T("Angle"),0,REG_DWORD_LITTLE_ENDIAN,(LPBYTE)&rvalue,sizeof(rvalue));
//ret1=::RegSetValueEx(hKEY,_T("LandscapeMode"),0,REG_BINARY,(LPBYTE)&lm,sizeof(lm));
long ret2=::RegCloseKey(hKEY);
}
void CTestDlg::OnBrotate()
{
// TODO: Add your control notification handler code here
// Return Current Direction
DEVMODE devMode;
memset(&devMode,0x00,sizeof(devMode));
devMode.dmSize=sizeof(devMode);
devMode.dmFields=DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx(NULL,&devMode,NULL,CDS_TEST,NULL);
// Calculate New Angle
switch(devMode.dmDisplayOrientation)
{
case DMDO_0:
devMode.dmDisplayOrientation=DMDO_90;
RegSaveRotate(DMDO_90);
break;
case DMDO_90:
devMode.dmDisplayOrientation=DMDO_180;
RegSaveRotate(DMDO_180);
break;
case DMDO_180:
devMode.dmDisplayOrientation=DMDO_270;
RegSaveRotate(DMDO_270);
break;
case DMDO_270:
devMode.dmDisplayOrientation=DMDO_0;
RegSaveRotate(DMDO_0);
break;
default:
devMode.dmDisplayOrientation=DMDO_0;
RegSaveRotate(DMDO_0);
break;
}
// Set new Direction
// ChangeDisplaySettingsEx(NULL,&devMode,NULL,CDS_RESET,NULL);
// devMode.dmFields=DM_DISPLAYORIENTATION;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -