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

📄 screeninfodlg.cpp

📁 VIPSHELL2007客户端代码
💻 CPP
字号:
// ScreenInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "VipShellClient.h"
#include "ScreenInfoDlg.h"
#include ".\screeninfodlg.h"
#include "VipShellClientDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CScreenInfoDlg dialog
HBITMAP CopyBitmap( HBITMAP hbm)
{
    HDC hdcSrc = CreateCompatibleDC(NULL);
    HDC hdcDst = CreateCompatibleDC(NULL);
    HBITMAP hbmOld, hbmOld2, hbmNew;
    BITMAP bm;

    GetObject(hbm, sizeof(bm), &bm);

    hbmOld = (HBITMAP)SelectObject(hdcSrc, hbm);

    hbmNew = CreateBitmap( bm.bmWidth, bm.bmHeight, bm.bmPlanes, bm.bmBitsPixel,
            NULL);

    hbmOld2 = (HBITMAP)SelectObject(hdcDst, hbmNew);

    BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY);

    SelectObject(hdcSrc, hbmOld);
    DeleteDC(hdcSrc);
    DeleteDC(hdcDst);

    return hbmNew;
}

CScreenInfoDlg::CScreenInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CScreenInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CScreenInfoDlg)
	m_nCount = -1;
	m_nArea = -1;
	//}}AFX_DATA_INIT
	m_nSideLen = 0;
	m_isControl = false;
	m_isGetScreen = false;
}

BOOL CScreenInfoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();


	m_wndPic.Create(NULL, NULL, WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL, CRect(0, 0, 200, 200), this, 0);
	m_wndPic.ModifyStyle(NULL, WS_HSCROLL | WS_VSCROLL);

	m_nSideLen = 16;

//	virtual bool start(uint32 nx, uint32 ny, uint32 ncount) = 0;
//	virtual bool setscreencount(uint32 ncount) = 0;
//	virtual bool setscreenarea(uint32 nx, uint32 ny) = 0;
//	virtual hbitmap getscreen() = 0;
//	virtual bool close() = 0;

	
//	m_spVipShellClientScreenHandle->SetScreenCount(8);

	m_nArea = 2;
	m_nCount = 2;

	m_spVipShellClientScreenHandle->Start( 10, 10, 8);



	HBITMAP hBitmap = (HBITMAP)	LoadImage(AfxGetInstanceHandle(), L"C:\\test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
//	CBitmap hBitmap;
//	hBitmap.Attach( );
	m_wndPic.SetBitmap(hBitmap);

	
	Layout();

	UpdateData(false);
	SetTimer(0x1, 100, NULL);
	SetTimer(0x2, 1000, NULL);
	
	return TRUE; 
}
void CScreenInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CScreenInfoDlg)
	DDX_CBIndex(pDX, IDC_COMBO_COLORCOUNT, m_nCount);
	DDX_Radio(pDX, IDC_RADIO1, m_nArea);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CScreenInfoDlg, CDialog)
	//{{AFX_MSG_MAP(CScreenInfoDlg)
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_CHECK_CONTROL, OnCheckControl)
	ON_BN_CLICKED(IDC_CHECK_GETSCREEN, OnCheckGetscreen)
	ON_CBN_SELCHANGE(IDC_COMBO_COLORCOUNT, OnSelchangeComboColorcount)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio1)
	//}}AFX_MSG_MAP
	ON_WM_TIMER()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScreenInfoDlg message handlers

void CScreenInfoDlg::Layout()
{
	if( m_wndPic.GetSafeHwnd() == NULL)
		return ;
	CRect rc;
	GetClientRect(&rc);


	CRect rcPic(m_nSideLen, m_nSideLen, rc.Width() - m_nSideLen, rc.Height() - m_nSideLen);
//	rcPic.top += 50; 
	m_wndPic.MoveWindow(&rcPic);
}

void CScreenInfoDlg::OnSize(UINT nType, int cx, int cy) 
{
	Layout();

	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here

}

void CScreenInfoDlg::OnTimer(UINT nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值


	HBITMAP hBitmap = m_spVipShellClientScreenHandle->GetScreen();
	if( hBitmap )
		m_wndPic.SetBitmap( CopyBitmap(hBitmap) );
	
	if( 0x2 == nIDEvent && m_isGetScreen)
		m_spVipShellClientScreenHandle->UpDateScreen();
	CDialog::OnTimer(nIDEvent);
}

void CScreenInfoDlg::OnCheckControl()	
{
	// TODO: Add your control notification handler code here
	CButton* pButton =(CButton*)GetDlgItem(IDC_CHECK_CONTROL);
	if( pButton->GetCheck() )
	{
		if( m_spVipShellClientScreenHandle->GetVipShellClientHandleId() == -1 )
		{
			MessageBox(L"目前还不能控制请稍后...");
		}
		else
		{
			if( m_spVipShellClientInputHandle == NULL )
			{
				m_spVipShellClientInputHandle = ((CVipShellClientDlg*)theApp.m_pMainWnd)->GetVipShellClientHandleById(m_spVipShellClientScreenHandle->GetVipShellClientHandleId())->GetVipShellClientInputHandle();
			}
			m_isControl = true;
		}
	}
	else
		m_isControl = false;
}
void CScreenInfoDlg::OnCheckGetscreen() 
{
	// TODO: Add your control notification handler code here
	CButton* pButton =(CButton*)GetDlgItem(IDC_CHECK_GETSCREEN);
	if( pButton->GetCheck() )
		m_isGetScreen = true;
	else
		m_isGetScreen = false;
	
	
}
BOOL CScreenInfoDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( m_isControl && pMsg->hwnd == m_wndPic.GetSafeHwnd() )
	{
		if(pMsg->message == WM_KEYDOWN)
			m_spVipShellClientInputHandle->SendKeyDown(pMsg->wParam);
		if(pMsg->message == WM_KEYUP)
			m_spVipShellClientInputHandle->SendKeyUp(pMsg->wParam);
		if(pMsg->message == WM_MOUSEMOVE)
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendMouseMove(&pt);
		}
		if(pMsg->message == WM_LBUTTONDOWN )
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendLButtonDown(&pt);
		}
		if(pMsg->message == WM_LBUTTONUP )
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendLButtonUp(&pt);
		}
		if(pMsg->message == WM_LBUTTONDBLCLK )
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendLButtonDblclk(&pt);
		}
		if(pMsg->message == WM_RBUTTONDOWN )
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendRButtonDown(&pt);
		}
		if(pMsg->message == WM_RBUTTONUP )
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendRButtonUp(&pt);
		}
		if(pMsg->message == WM_RBUTTONDBLCLK )
		{
			POINT ptIn, pt;
			ptIn.x = LOWORD(pMsg->lParam);
			ptIn.y = HIWORD(pMsg->lParam);
			bool f = m_wndPic.GetPicPoint(ptIn, &pt);
			if(f)
				m_spVipShellClientInputHandle->SendRButtonDblclk(&pt);
		}
			
	}
	return CDialog::PreTranslateMessage(pMsg);
}



void CScreenInfoDlg::OnSelchangeComboColorcount() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	UINT32 nCount = 1;

	if( m_nCount == 0)
		nCount = 1;
	if( m_nCount == 1)
		nCount = 4;
	if( m_nCount == 2)
		nCount = 8;
	if( m_nCount == 3)
		nCount = 16;
	if( m_nCount == 4)
		nCount = 24;
	if( m_nCount == 5)
		nCount = 32;
	m_spVipShellClientScreenHandle->SetScreenCount(nCount);
	m_spVipShellClientScreenHandle->UpDateScreen();

}

void CScreenInfoDlg::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	UINT32 nArea = 10;
	if( m_nArea == 0 )
 		nArea = 1;
	if( m_nArea == 1 )
		nArea = 5;
	if( m_nArea == 2 )
		nArea = 10;
	if( m_nArea == 3 )
		nArea = 20;
	m_spVipShellClientScreenHandle->SetScreenArea(nArea, nArea);
	m_spVipShellClientScreenHandle->UpDateScreen();


}

⌨️ 快捷键说明

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