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

📄 clientconnectionfullscreen.cpp

📁 teamviewer source code vc++
💻 CPP
字号:
//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
//
//  This file is part of TeamViewer.
//
//  TeamViewer is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
//  USA.
//
//  If the source code for TeamViewer is not available from the place 
//  whence you received this file, check http://www.teamviewer.com or 
// contact  for information on obtaining it.
//
// Many thanks to Greg Hewgill <greg@hewgill.com> for providing the basis for 
// the full-screen mode.

#include "stdhdrs.h"
#include "ClientConnection.h"
//#include "FullScreenTitleBar.h" //Added by: Lars Werner (http://lars.werner.no)

// Parameters for scrolling in full screen mode
#define BUMPSCROLLBORDER 8
#define BUMPSCROLLAMOUNTX 32
#define BUMPSCROLLAMOUNTY 8
extern char sz_J1[128];
extern char sz_J2[64];

bool ClientConnection::InFullScreenMode() 
{
	return m_opts.m_FullScreen; 
};

// Toggle FullScreen on/off
void ClientConnection::ToggleFullScreen()
{
	if(InFullScreenMode())
		SetFullScreenMode(false);
	else
	{
		int workwidth =  GetSystemMetrics(SM_CXSCREEN);
		int workheight = GetSystemMetrics(SM_CYSCREEN);

		// remote screen at least as big as local screen?
		if( (m_opts.AutoScaling() && m_si.framebufferWidth >= workwidth && m_si.framebufferHeight >= workheight) 
		  ||(!m_opts.AutoScaling() &&	
			 m_si.framebufferWidth*m_opts.m_scale_num/m_opts.m_scale_den >= workwidth && 
		     m_si.framebufferHeight*m_opts.m_scale_num/m_opts.m_scale_den >= workheight))
		// then use fullscreen
			SetFullScreenMode(true);
		else
		{
			if(m_opts.AutoScaling() && m_opts.m_scale_num < m_opts.m_scale_den)	// else set window size to remote size
			{
				m_opts.m_scale_num = 1;						
				m_opts.m_scale_den = 1;
				m_sizing = false;
			}
			SizeWindow();
			InvalidateRect(m_hwndMain, NULL, FALSE);
			CenterMainWindow();
		}
	}
}

// You can explicitly change mode by calling this
void ClientConnection::SetFullScreenMode(bool enable)
{
	if(enable == m_opts.m_FullScreen)							// choosen mode = current mode: nothing to do
		RealiseFullScreenMode();
	else
	{
		m_opts.m_FullScreen = enable;
		if(enable)												// switch to fullscreen
		{
			GetWindowRect(m_hwndMain,&m_last_autoscale);		// save current window size
			if(m_opts.AutoScaling())							// autoscaling: set display scaling 1:1
			{
				m_opts.m_scale_num = 1;
				m_opts.m_scale_den = 1;
			}
			SizeWindow();
			InvalidateRect(m_hwndMain, NULL, FALSE);
			RealiseFullScreenMode();
		}
		else													// leave fullscreen
		{
			RealiseFullScreenMode();
			ShowWindow(m_hwndMain, SW_NORMAL);
			MoveWindow(m_hwndMain, m_last_autoscale.left, m_last_autoscale.top,		// reset window size
				m_last_autoscale.right-m_last_autoscale.left,
				m_last_autoscale.bottom-m_last_autoscale.top, TRUE);
			if(m_opts.AutoScaling())
				AutoScale();
			SizeWindow();
		}
	}
	// Modif sf@2002 - v1.1.0 - In case of server scaling
	// Clear the Window (in black)
    if (m_opts.m_nServerScale > 1)
	{
		RECT winrect;
		GetWindowRect(m_hwndMain, &winrect);
		int winwidth = winrect.right - winrect.left;
		int winheight = winrect.bottom - winrect.top;
		ObjectSelector b(m_hBitmapDC, m_hBitmap);
		PaletteSelector p(m_hBitmapDC, m_hPalette);
		RECT rect;
		SetRect(&rect, 0,0, winwidth, winheight);
		COLORREF bgcol = RGB(0x0, 0x0, 0x0);
		FillSolidRect(&rect, bgcol);
		// Update the whole screen 
		SendFullFramebufferUpdateRequest();
	}
}

// If the options have been changed other than by calling 
// SetFullScreenMode, you need to call this to make it happen.
void ClientConnection::RealiseFullScreenMode()
{
	LONG style = GetWindowLong(m_hwndMain, GWL_STYLE);
	if (m_opts.m_FullScreen) {

		ShowWindow(m_hwndMain, SW_MAXIMIZE);

		style = GetWindowLong(m_hwndMain, GWL_STYLE);
		style &= ~(WS_DLGFRAME | WS_THICKFRAME);
		SetWindowLong(m_hwndMain, GWL_STYLE, style);

		int cx = GetSystemMetrics(SM_CXSCREEN);
		int cy = GetSystemMetrics(SM_CYSCREEN);
		SetWindowPos(m_hwndMain, HWND_TOPMOST, -1, -1, cx+3, cy+3, SWP_FRAMECHANGED);
		CheckMenuItem(GetSystemMenu(m_hwndMain, FALSE), ID_FULLSCREEN, MF_BYCOMMAND|MF_CHECKED);
		MoveWindow(m_hwnd, 0, 0, cx+3, cy+3, TRUE);
		m_sizing = true;
		SizeWindow();
		// scroll screen down to show task bar
		ScrollScreen(0, m_si.framebufferHeight - cy);
	} else {
		style = GetWindowLong(m_hwndMain, GWL_STYLE);
		style |= WS_DLGFRAME | WS_THICKFRAME;
		SetWindowLong(m_hwndMain, GWL_STYLE, style);
		SetWindowPos(m_hwndMain, HWND_NOTOPMOST, 0,0,100,100, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); //Modified by: Lars Werner (http://lars.werner.no) - Reason: Bugfix, The framework got invisible after moving, so a NCCALCSIZE needed to be called!
		CheckMenuItem(GetSystemMenu(m_hwndMain, FALSE), ID_FULLSCREEN, MF_BYCOMMAND|MF_UNCHECKED);

		//TitleBar.DisplayWindow(FALSE, TRUE); //Added by: Lars Werner (http://lars.werner.no)
	}
	AdjustScrollbars();
}

bool ClientConnection::BumpScroll(int x, int y)
{
	int dx = 0;
	int dy = 0;
	int rightborder = GetSystemMetrics(SM_CXSCREEN)-BUMPSCROLLBORDER;
	int bottomborder = GetSystemMetrics(SM_CYSCREEN)-BUMPSCROLLBORDER;
	if (x < BUMPSCROLLBORDER)
		dx = -BUMPSCROLLAMOUNTX * m_opts.m_scale_num / m_opts.m_scale_den;
	if (x >= rightborder)
		dx = +BUMPSCROLLAMOUNTX * m_opts.m_scale_num / m_opts.m_scale_den;;
	if (y < BUMPSCROLLBORDER)
		dy = -BUMPSCROLLAMOUNTY * m_opts.m_scale_num / m_opts.m_scale_den;;
	if (y >= bottomborder)
		dy = +BUMPSCROLLAMOUNTY * m_opts.m_scale_num / m_opts.m_scale_den;;
	if (dx || dy) {
		if (ScrollScreen(dx,dy)) {
			// If we haven't physically moved the cursor, artificially
			// generate another mouse event so we keep scrolling.
			POINT p;
			GetCursorPos(&p);
			if (p.x == x && p.y == y)
				SetCursorPos(x,y);
			return true;
		} 
	}
	return false;
}

⌨️ 快捷键说明

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