📄 rotationscreendlg.cpp
字号:
// RotationScreenDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RotationScreen.h"
#include "RotationScreenDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const TCHAR szregRootKey[] = TEXT("System\\GDI\\Rotation");
const TCHAR szregAngle[] = TEXT("Angle");
/////////////////////////////////////////////////////////////////////////////
// CRotationScreenDlg dialog
CRotationScreenDlg::CRotationScreenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRotationScreenDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRotationScreenDlg)
// 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 CRotationScreenDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRotationScreenDlg)
DDX_Control(pDX, IDC_RADIO_ROTATE90, m_radio_rotate_90);
DDX_Control(pDX, IDC_RADIO_ROTATE0, m_radio_rotate_0);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRotationScreenDlg, CDialog)
//{{AFX_MSG_MAP(CRotationScreenDlg)
ON_BN_CLICKED(IDC_RADIO_ROTATE90, OnRadioRotate90)
ON_BN_CLICKED(IDC_RADIO_ROTATE0, OnRadioRotate0)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRotationScreenDlg message handlers
BOOL CRotationScreenDlg::OnInitDialog()
{
HKEY hKey;
LONG lResult;
DWORD dwType;
DWORD dwVal;
DWORD dwLen;
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
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szregRootKey, 0, KEY_ALL_ACCESS, &hKey);
if(ERROR_SUCCESS == lResult)
{
dwType = REG_DWORD;
dwLen = sizeof(DWORD);
lResult = RegQueryValueEx(hKey, szregAngle, NULL, &dwType,
(LPBYTE)&dwVal, &dwLen);
if(ERROR_SUCCESS == lResult)
{
if(dwVal == 90)
{
m_radio_rotate_90.SetCheck(TRUE);
m_radio_rotate_0.SetCheck(FALSE);
m_RotateState = TRUE;
}
else if(dwVal == 180)
{
m_radio_rotate_90.SetCheck(FALSE);
m_radio_rotate_0.SetCheck(TRUE);
m_RotateState = FALSE;
}
else
{
RegCloseKey(hKey);
return FALSE;
}
}
else
{
RegCloseKey(hKey);
return FALSE;
}
}
else
{
RegCloseKey(hKey);
return FALSE;
}
RegCloseKey(hKey);
return TRUE; // return TRUE unless you set the focus to a control
}
void CRotationScreenDlg::OnRadioRotate90()
{
// TODO: Add your control notification handler code here
m_radio_rotate_90.SetCheck(TRUE);
m_radio_rotate_0.SetCheck(FALSE);
m_RotateState = TRUE;
}
void CRotationScreenDlg::OnRadioRotate0()
{
// TODO: Add your control notification handler code here
m_radio_rotate_90.SetCheck(FALSE);
m_radio_rotate_0.SetCheck(TRUE);
m_RotateState = FALSE;
}
void CRotationScreenDlg::OnOK()
{
DEVMODE mode;
HKEY hKey;
LONG lResult;
DWORD dwVal;
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szregRootKey, 0, KEY_ALL_ACCESS, &hKey);
if(ERROR_SUCCESS != lResult)
{
RegCloseKey(hKey);
return;
}
mode.dmSize = sizeof(DEVMODE);
mode.dmFields = DM_DISPLAYORIENTATION;
// TODO: Add extra validation here
if(m_RotateState)
{
mode.dmDisplayOrientation = DMDO_90;
dwVal = 90;
}
else
{
mode.dmDisplayOrientation = DMDO_180;
dwVal = 180;
}
RegSetValueEx (hKey, szregAngle, 0, REG_DWORD, (BYTE *)&dwVal, sizeof(DWORD));
RegCloseKey(hKey);
ChangeDisplaySettingsEx( NULL, &mode, NULL, 0, NULL );
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -