📄 rotationdlg.cpp
字号:
// rotationDlg.cpp : implementation file
//
#include "stdafx.h"
#include "rotation.h"
#include "rotationDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRotationDlg dialog
CRotationDlg::CRotationDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRotationDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRotationDlg)
// 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 CRotationDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRotationDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRotationDlg, CDialog)
//{{AFX_MSG_MAP(CRotationDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRotationDlg message handlers
BOOL CRotationDlg::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
return TRUE; // return TRUE unless you set the focus to a control
}
void CRotationDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HKEY hRegKey;
DWORD status;
DWORD ValType;
DWORD ValLen;
DWORD Rotation = 0;
DEVMODE devmode = {0};
devmode.dmSize = sizeof(DEVMODE);
devmode.dmFields = DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx(NULL, &devmode, 0, CDS_TEST, NULL);
switch(devmode.dmDisplayOrientation)
{
case DMDO_0:
devmode.dmDisplayOrientation = DMDO_90; //ˮƽģʽ
Rotation = 90;
break;
case DMDO_90:
devmode.dmDisplayOrientation = DMDO_180;
Rotation = 180;
break;
case DMDO_180:
devmode.dmDisplayOrientation = DMDO_270;
Rotation = 270;
break;
case DMDO_270:
devmode.dmDisplayOrientation = DMDO_0;
Rotation = 0;
break;
default :
devmode.dmDisplayOrientation = DMDO_0;
Rotation = 0;
}
devmode.dmFields = DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx(NULL, &devmode, NULL, 0, NULL);
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("System\\GDI\\Rotation"),
0, 0, &hRegKey);
if (ERROR_SUCCESS == status)
{
ValLen = sizeof(DWORD);
if (ERROR_SUCCESS == RegSetValueEx (hRegKey, TEXT("Angle"), NULL, REG_DWORD, (PBYTE)&Rotation, ValLen))
RegCloseKey(hRegKey);
}
RegFlushKey(HKEY_LOCAL_MACHINE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -