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

📄 customsettings.cpp

📁 teamviewer source code vc++
💻 CPP
字号:
//  Copyright (C) 2006 TeamViewer GmbH. All Rights Reserved.
//
//  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.
//

#include "stdhdrs.h"
#include "CustomSettings.h"
#include "vncviewer.h"
#include "../winvnc/winvnc/localization.h"

CustomSettings::CustomSettings()
{

}

CustomSettings::~CustomSettings()
{
}

int CustomSettings::DoDialog(HWND parent)
{
	return DialogBoxParam(pApp->m_instance, DIALOG_MAKEINTRESOURCE(IDD_CUSTOM_SETTINGS), 
						  parent, (DLGPROC) DlgProc, (LONG) this);
}

void CustomSettings::InitDialog(HWND hwnd)
{
	HWND hEncoding = GetDlgItem(hwnd, IDC_CUSTOM_ENCODING);

	SendMessage(hEncoding, CB_ADDSTRING, 0, (LPARAM)sz_IDS_ENC_MAXCOMPRESSION);
	SendMessage(hEncoding, CB_ADDSTRING, 0, (LPARAM)sz_IDS_ENC_HIGHCOMPRESSION);
	SendMessage(hEncoding, CB_ADDSTRING, 0, (LPARAM)sz_IDS_ENC_MEDCOMPRESSION);
	SendMessage(hEncoding, CB_ADDSTRING, 0, (LPARAM)sz_IDS_ENC_LOWCOMPRESSION);
	SendMessage(hEncoding, CB_ADDSTRING, 0, (LPARAM)sz_IDS_ENC_NOCOMPRESSION);
	SendMessage(hEncoding, CB_SETCURSEL, m_Compression, 0);
	
	HWND hColors = GetDlgItem(hwnd, IDC_CUSTOM_COLORS);
	SendMessage(hColors, TBM_SETRANGE, FALSE, MAKELONG(0,3));
	SendMessage(hColors, TBM_SETPOS, TRUE, 3 - m_ColorDepth);

	CheckDlgButton(hwnd, IDC_CUSTOM_WALLPAPER, m_RemoveWallpaper);
}

void CustomSettings::ApplySettings(HWND hwnd)
{
	m_Compression = SendMessage(GetDlgItem(hwnd, IDC_CUSTOM_ENCODING), CB_GETCURSEL, 0, 0);
	m_ColorDepth = 3 - (CARD8)SendMessage(GetDlgItem(hwnd, IDC_CUSTOM_COLORS), TBM_GETPOS, 0, 0);
	m_RemoveWallpaper = IsDlgButtonChecked(hwnd, IDC_CUSTOM_WALLPAPER);
}

BOOL CALLBACK CustomSettings::DlgProc( HWND hwnd,  UINT uMsg, 
                                       WPARAM wParam, LPARAM lParam ) 
{
	// This is a static method, so we don't know which instantiation we're 
	// dealing with. But we can get a pseudo-this from the parameter to 
	// WM_INITDIALOG, which we therafter store with the window and retrieve
	// as follows:
	CustomSettings *_this = (CustomSettings *) GetWindowLong(hwnd, GWL_USERDATA);

	switch (uMsg) 
	{	
		case WM_INITDIALOG:
		{
			SetWindowLong(hwnd, GWL_USERDATA, lParam);
			_this = (CustomSettings *) lParam;
			_this->InitDialog(hwnd);
			CentreWindow(hwnd);
			ShowWindow(hwnd, SW_SHOW);
			return TRUE;
		}
		case WM_COMMAND:
		{
			switch (LOWORD(wParam))
			{
				case IDOK: 
				{
					_this->ApplySettings(hwnd);
					EndDialog(hwnd, TRUE);
					return TRUE;
				}
				case IDCANCEL:
				{
					EndDialog(hwnd, FALSE);
					return TRUE;
				}
			}
			break;
		}
		case WM_ERASEBKGND:
			return EraseBkgnd(hwnd, wParam);
		case WM_CTLCOLORBTN:
			return CtlColorBtn(wParam);
		case WM_CTLCOLORSTATIC:
			return CtlColorStatic(hwnd, wParam, lParam);
		case WM_DESTROY:
			EndDialog(hwnd, FALSE);
			return TRUE;
	}
	return 0;
}

void CustomSettings::Compression2Encoding(int compression, int *enc, int *jpeg, int *tight)
{
	switch(compression)
	{
		case 0:												// max compression
			*enc = rfbEncodingTight;
			*jpeg = MAX_JPEGLEVEL;
			*tight = MAX_COMPRESSLEVEL;
			break;
		case 1:
			*enc = rfbEncodingTight;
			*jpeg = DEFAULT_JPEGLEVEL;
			*tight = DEFAULT_COMPRESSLEVEL;
			break;
		case 2:
			*enc = rfbEncodingZRLE;
			break;
		case 3:
			*enc = rfbEncodingHextile;
			break;
		case 4:
			*enc = rfbEncodingRaw;
			break;
		default:
			vnclog.Print(LL_INTERR, VNCLOG("Compression2Encoding(): wrong param compression=%d"), compression);
	}
}

⌨️ 快捷键说明

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