vncviewer.cpp
来自「teamviewer source code vc++」· C++ 代码 · 共 116 行
CPP
116 行
// Copyright (C) 2006 Teamviewer GmbH. All Rights Reserved.
// Copyright (C) 2002 Ultr@VNC Team Members. All Rights Reserved.
// 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
// for information on obtaining it.
#include "stdhdrs.h"
#include "vncviewer.h"
#include "..\..\Winvnc\Winvnc\Localization.h"
// All logging is done via the log object
//Log vnclog;
bool command_line=true;
bool g_passwordfailed=true;
// Accelerator Keys
AccelKeys TheAccelKeys;
// Move the given window to the centre of the screen
// and bring it to the top.
void CentreWindow(HWND hwnd)
{
RECT winrect, workrect;
// Find how large the desktop work area is
SystemParametersInfo(SPI_GETWORKAREA, 0, &workrect, 0);
int workwidth = workrect.right - workrect.left;
int workheight = workrect.bottom - workrect.top;
// And how big the window is
GetWindowRect(hwnd, &winrect);
int winwidth = winrect.right - winrect.left;
int winheight = winrect.bottom - winrect.top;
// Make sure it's not bigger than the work area
winwidth = min(winwidth, workwidth);
winheight = min(winheight, workheight);
int posX = workrect.left + (workwidth-winwidth) / 2;
int posY = workrect.top + (workheight-winheight) / 2;
// Now centre it
SetWindowPos(hwnd,
HWND_TOP,
posX,
posY,
winwidth, winheight,
SWP_SHOWWINDOW);
SetForegroundWindow(hwnd);
}
// sf@2002 - TightVNC method - RealVNC method
// Convert "host:display" or "host::port" or "host:port" if port > 100, into host and port
// Returns true if valid format, false if not.
// Takes initial string, addresses of results and size of host buffer in wchars.
// If the display info passed in is longer than the size of the host buffer, it
// is assumed to be invalid, so false is returned.
bool ParseDisplay(LPTSTR display, LPTSTR phost, int hostlen, int *pport)
{
if (hostlen < (int)_tcslen(display))
return false;
int tmp_port;
TCHAR *colonpos = _tcschr(display, L':');
if (colonpos == NULL)
{
// No colon -- use default port number
tmp_port = RFB_PORT_OFFSET;
_tcsncpy(phost, display, MAX_HOST_NAME_LEN);
}
else
{
_tcsncpy(phost, display, colonpos - display);
phost[colonpos - display] = L'\0';
if (colonpos[1] == L':') {
// Two colons -- interpret as a port number
if (_stscanf(colonpos + 2, TEXT("%d"), &tmp_port) != 1)
return false;
}
else
{
// One colon -- interpret as a display number or port number
if (_stscanf(colonpos + 1, TEXT("%d"), &tmp_port) != 1)
return false;
// RealVNC method - If port < 100 interpret as display number else as Port number
if (tmp_port < 100)
tmp_port += RFB_PORT_OFFSET;
}
}
*pport = tmp_port;
return true;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?