⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 panelrounddlg.cpp

📁 WINCE5。0下屏幕旋转程序,2440上通过
💻 CPP
字号:
// panelroundDlg.cpp : implementation file
//

#include "stdafx.h"
#include "panelround.h"
#include "panelroundDlg.h"
#include "Shellapi.h"
#include "windows.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

DWORD gAngle;
static TCHAR gszBaseInstance[256] = _T("System\\GDI\\Rotation");

NOTIFYICONDATA m_tnid;
CCeCommandBar	m_wndCommandBar;
#define MYWM_NOTIFYICON WM_USER+1
DWORD dwAdornmentFlags;

/////////////////////////////////////////////////////////////////////////////
// CPanelroundDlg dialog
CPanelroundDlg::CPanelroundDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPanelroundDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPanelroundDlg)
		// 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 CPanelroundDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPanelroundDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPanelroundDlg, CDialog)
	//{{AFX_MSG_MAP(CPanelroundDlg)
	ON_WM_TIMER()
	ON_WM_CANCELMODE()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPanelroundDlg message handlers

BOOL CPanelroundDlg::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
    //this->SetWindowPos(&CWnd::wndBottom,0,0,320,240,SWP_SHOWWINDOW);
	//this->SetWindowPos(&CWnd::wndBottom,0,0,0,0,SWP_HIDEWINDOW);
	//this->SetWindowText(L"rout");
	// TODO: Add extra initialization here
	if(!m_wndCommandBar.Create(this) ||
	   !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
	   !m_wndCommandBar.AddAdornments(dwAdornmentFlags))
	{
		TRACE0("Failed to create CommandBar\n");
		return -1;      // fail to create
	}

	m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

/**************/
	m_tnid.cbSize = sizeof(NOTIFYICONDATA);
	m_tnid.hWnd = this->m_hWnd;
	m_tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP; 
	m_tnid.uCallbackMessage=MYWM_NOTIFYICON; 
//用户定义的回调消息 
	CString szToolTip; 
	szToolTip=_T("NOTIFY");
	_tcscpy(m_tnid.szTip, szToolTip); 
	m_tnid.uID=IDR_MAINFRAME;
	HICON hIcon; 
	hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
	m_tnid.hIcon=hIcon; 
	::Shell_NotifyIcon(NIM_ADD,&m_tnid); 
	if(hIcon)::DestroyIcon(hIcon); 
	//CRect rcWorkArea(0,0,480,234);
	CRect rcWorkArea(0,0,0,0);
	SystemParametersInfo(SPI_SETWORKAREA,0,(void*)&rcWorkArea,SPIF_SENDCHANGE);

	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CPanelroundDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnTimer(nIDEvent);
}

void CPanelroundDlg::OnCancelMode() 
{
	CDialog::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

BOOL CPanelroundDlg::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	::Shell_NotifyIcon(NIM_DELETE,&m_tnid); 
	return CDialog::DestroyWindow();
}

LRESULT CPanelroundDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	switch(message)
	{
	case MYWM_NOTIFYICON://如果是用户定义的消息
			if(lParam==WM_LBUTTONDBLCLK)
			{//双击鼠标时主窗口出现
				//AfxMessageBox(L"adfa");
				HKEY hkDisplay = NULL;
				DWORD dwStatus, dwType, dwSize;
				BYTE bKeyValue;

				dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, gszBaseInstance, 0, 0, &hkDisplay);
				dwType = REG_DWORD;
				if(gAngle!=DMDO_0&&gAngle!=DMDO_90&&gAngle!=DMDO_180&&gAngle!=DMDO_270)
				{
					bKeyValue=DMDO_0;
					RegSetValueEx(hkDisplay,L"Rotval",0,REG_DWORD,&bKeyValue,1);
				}

				if(dwStatus == ERROR_SUCCESS && dwType == REG_DWORD) 
				{
					dwSize = sizeof(DWORD);
					dwStatus = RegQueryValueEx(hkDisplay, _T("Rotval"), NULL, &dwType, 
						(LPBYTE) &gAngle, &dwSize);
				}
				DEVMODE devmode={0};
				devmode.dmSize=sizeof(DEVMODE);
				if(gAngle==DMDO_0)
				{
				devmode.dmDisplayOrientation=DMDO_90;
				bKeyValue=DMDO_90;
				RegSetValueEx(hkDisplay,L"Rotval",0,REG_DWORD,&bKeyValue,1);
				}
				if(gAngle==DMDO_90)
				{
				devmode.dmDisplayOrientation=DMDO_180;
				bKeyValue=DMDO_180;
				RegSetValueEx(hkDisplay,L"Rotval",0,REG_DWORD,&bKeyValue,1);
				}
				if(gAngle==DMDO_180)
				{
				devmode.dmDisplayOrientation=DMDO_270;
				bKeyValue=DMDO_270;
				RegSetValueEx(hkDisplay,L"Rotval",0,REG_DWORD,&bKeyValue,1);
				}
				if(gAngle==DMDO_270)
				{
				devmode.dmDisplayOrientation=DMDO_0;
				bKeyValue=DMDO_0;
				RegSetValueEx(hkDisplay,L"Rotval",0,REG_DWORD,&bKeyValue,1);
				}
				devmode.dmFields=DM_DISPLAYORIENTATION;
				ChangeDisplaySettingsEx(NULL,&devmode,NULL,0,NULL);
						
			}
			else if(lParam==WM_RBUTTONDOWN)
			{
				DestroyWindow();
				/*
				//鼠标右键单击弹出选单
				CMenu menu;
				menu.LoadMenu(IDR_MAINFRAME);//载入事先定义的选单IDR_RIGHT_MENU
				CMenu* pMenu=menu.GetSubMenu(0);
				CPoint pos;
				GetCursorPos(&pos);
				pMenu->TrackPopupMenu(TPM_LEFTALIGN,pos.x,pos.y,AfxGetMainWnd());
				*/
			}
		break;
	case WM_SYSCOMMAND:
		//接收到最小化消息时主窗口隐藏
		if(wParam==SW_MINIMIZE)
		{
		AfxGetApp()->m_pMainWnd->ShowWindow(SW_HIDE);
		return 0;
		}
		break;
	}
	return CDialog::DefWindowProc(message, wParam, lParam);
}

void CPanelroundDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
    static int i=2;
	if(i>0)
	{
		i--;
		ShowWindow(SW_HIDE);
	}
	else
	{
		CDialog::OnPaint();
	}
	// TODO: Add your message handler code here
	
	// Do not call CDialog::OnPaint() for painting messages
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -