diff -urN win/logmessages/logmessages.vcproj win.new/logmessages/logmessages.vcproj
--- win/logmessages/logmessages.vcproj	1970-01-01 01:00:00.000000000 +0100
+++ win.new/logmessages/logmessages.vcproj	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,527 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="logmessages"
+	ProjectGUID="{D059D343-6D24-4087-AF5E-4DA340030009}"
+	TargetFrameworkVersion="0"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug Unicode|Win32"
+			OutputDirectory=".\..\Debug_Unicode"
+			IntermediateDirectory=".\..\Debug_Unicode\logmessages"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+				CommandLine="mc messages.mc&#x0D;&#x0A;rc -r -fo messages.res messages.rc&#x0D;&#x0A;link -dll -noentry -out:..\Debug_Unicode\logmessages.dll messages.res&#x0D;&#x0A;"
+				Outputs="messages.res;messages.rc;messages.h;..\Debug_Unicode\logmessages.dll"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug_Unicode/logmessages.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="_WINDOWS;_USRDLL;LOGMESSAGES_EXPORTS;_DEBUG;WIN32;UNICODE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\logmessages/logmessages.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\logmessages/"
+				ObjectFile=".\..\Debug_Unicode\logmessages/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\logmessages/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				IgnoreImportLibrary="true"
+				AdditionalDependencies="odbc32.lib odbccp32.lib"
+				OutputFile="messages.mc"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				IgnoreAllDefaultLibraries="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug_Unicode/messages.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\..\Debug_Unicode/messages.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug_Unicode/logmessages.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\..\Release"
+			IntermediateDirectory=".\..\Release\logmessages"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+				CommandLine="mc messages.mc&#x0D;&#x0A;rc -r -fo messages.res messages.rc&#x0D;&#x0A;link -dll -noentry -out:..\Release\logmessages.dll messages.res&#x0D;&#x0A;"
+				Outputs="messages.res;messages.rc;messages.h;..\Release\logmessages.dll"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Release/logmessages.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;LOGMESSAGES_EXPORTS;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\logmessages/logmessages.pch"
+				AssemblerListingLocation=".\..\Release\logmessages/"
+				ObjectFile=".\..\Release\logmessages/"
+				ProgramDataBaseFileName=".\..\Release\logmessages/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="odbc32.lib odbccp32.lib"
+				OutputFile="messages.mc"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/messages.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\..\Release/messages.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/logmessages.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\../Debug"
+			IntermediateDirectory=".\..\Debug\logmessages"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+				CommandLine="mc messages.mc&#x0D;&#x0A;rc -r -fo messages.res messages.rc&#x0D;&#x0A;link -dll -noentry -out:..\Debug\logmessages.dll messages.res&#x0D;&#x0A;"
+				Outputs="messages.res;messages.rc;messages.h;..\Debug\logmessages.dll"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\../Debug/logmessages.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;LOGMESSAGES_EXPORTS;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug\logmessages/logmessages.pch"
+				AssemblerListingLocation=".\..\Debug\logmessages/"
+				ObjectFile=".\..\Debug\logmessages/"
+				ProgramDataBaseFileName=".\..\Debug\logmessages/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				IgnoreImportLibrary="true"
+				AdditionalDependencies="odbc32.lib odbccp32.lib"
+				OutputFile="messages.mc"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				IgnoreAllDefaultLibraries="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\../Debug/messages.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\../Debug/messages.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\../Debug/logmessages.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Released Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+				CommandLine="mc messages.mc&#x0D;&#x0A;rc -r -fo messages.res messages.rc&#x0D;&#x0A;link -dll -noentry -out:..\Debug_Unicode\logmessages.dll messages.res&#x0D;&#x0A;"
+				Outputs="messages.res;messages.rc;messages.h;..\Debug_Unicode\logmessages.dll"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug_Unicode/logmessages.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="_WINDOWS;_USRDLL;LOGMESSAGES_EXPORTS;_DEBUG;WIN32;UNICODE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\logmessages/logmessages.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\logmessages/"
+				ObjectFile=".\..\Debug_Unicode\logmessages/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\logmessages/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				IgnoreImportLibrary="true"
+				AdditionalDependencies="odbc32.lib odbccp32.lib"
+				OutputFile="messages.mc"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				IgnoreAllDefaultLibraries="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug_Unicode/messages.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\..\Debug_Unicode/messages.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release_Unicode/logmessages.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+				CommandLine="mc messages.mc&#x0D;&#x0A;rc -r -fo messages.res messages.rc&#x0D;&#x0A;link -dll -noentry -out:..\Release\logmessages.dll messages.res&#x0D;&#x0A;"
+				Outputs="messages.res;messages.rc;messages.h;..\Release\logmessages.dll"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Release/logmessages.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;LOGMESSAGES_EXPORTS;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\logmessages/logmessages.pch"
+				AssemblerListingLocation=".\..\Release\logmessages/"
+				ObjectFile=".\..\Release\logmessages/"
+				ProgramDataBaseFileName=".\..\Release\logmessages/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="odbc32.lib odbccp32.lib"
+				OutputFile="messages.mc"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/messages.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\..\Release/messages.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/logmessages.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+			>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl"
+			>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+			>
+		</Filter>
+		<File
+			RelativePath="messages.mc"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff -urN win/logmessages/messages.h win.new/logmessages/messages.h
--- win/logmessages/messages.h	2009-11-26 16:51:51.000000000 +0100
+++ win.new/logmessages/messages.h	2009-11-26 15:19:23.000000000 +0100
@@ -1,47 +1,47 @@
-//
-//  Values are 32 bit values layed out as follows:
-//
-//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-//  +---+-+-+-----------------------+-------------------------------+
-//  |Sev|C|R|     Facility          |               Code            |
-//  +---+-+-+-----------------------+-------------------------------+
-//
-//  where
-//
-//      Sev - is the severity code
-//
-//          00 - Success
-//          01 - Informational
-//          10 - Warning
-//          11 - Error
-//
-//      C - is the Customer code flag
-//
-//      R - is a reserved bit
-//
-//      Facility - is the facility code
-//
-//      Code - is the facility's status code
-//
-//
-// Define the facility codes
-//
-
-
-//
-// Define the severity codes
-//
-
-
-//
-// MessageId: VNC4LogMessage
-//
-// MessageText:
-//
-//  %1: %2
-//  
-//  
-//
-#define VNC4LogMessage                   0x00000001L
-
+//
+//  Values are 32 bit values laid out as follows:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//  +---+-+-+-----------------------+-------------------------------+
+//  |Sev|C|R|     Facility          |               Code            |
+//  +---+-+-+-----------------------+-------------------------------+
+//
+//  where
+//
+//      Sev - is the severity code
+//
+//          00 - Success
+//          01 - Informational
+//          10 - Warning
+//          11 - Error
+//
+//      C - is the Customer code flag
+//
+//      R - is a reserved bit
+//
+//      Facility - is the facility code
+//
+//      Code - is the facility's status code
+//
+//
+// Define the facility codes
+//
+
+
+//
+// Define the severity codes
+//
+
+
+//
+// MessageId: VNC4LogMessage
+//
+// MessageText:
+//
+// %1: %2
+// 
+// 
+//
+#define VNC4LogMessage                   0x00000001L
+
diff -urN win/logmessages/messages.h.backup win.new/logmessages/messages.h.backup
--- win/logmessages/messages.h.backup	1970-01-01 01:00:00.000000000 +0100
+++ win.new/logmessages/messages.h.backup	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,47 @@
+//
+//  Values are 32 bit values laid out as follows:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//  +---+-+-+-----------------------+-------------------------------+
+//  |Sev|C|R|     Facility          |               Code            |
+//  +---+-+-+-----------------------+-------------------------------+
+//
+//  where
+//
+//      Sev - is the severity code
+//
+//          00 - Success
+//          01 - Informational
+//          10 - Warning
+//          11 - Error
+//
+//      C - is the Customer code flag
+//
+//      R - is a reserved bit
+//
+//      Facility - is the facility code
+//
+//      Code - is the facility's status code
+//
+//
+// Define the facility codes
+//
+
+
+//
+// Define the severity codes
+//
+
+
+//
+// MessageId: VNC4LogMessage
+//
+// MessageText:
+//
+// %1: %2
+// 
+// 
+//
+#define VNC4LogMessage                   0x00000001L
+
diff -urN win/logmessages/messages.rc win.new/logmessages/messages.rc
--- win/logmessages/messages.rc	2009-11-26 16:51:51.000000000 +0100
+++ win.new/logmessages/messages.rc	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-LANGUAGE 0x9,0x1
-1 11 MSG00001.bin
diff -urN win/rfb_win32/CKeyboard.cxx win.new/rfb_win32/CKeyboard.cxx
--- win/rfb_win32/CKeyboard.cxx	2009-11-26 16:51:42.000000000 +0100
+++ win.new/rfb_win32/CKeyboard.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -64,7 +64,7 @@
     // be a comma and a DECIMAL to be a dot. 
     if (extendedVkey == VK_DECIMAL || extendedVkey == VK_SEPARATOR) {
       char buf[4];
-      if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buf, sizeof(buf))) {
+      if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, LPWSTR(buf), sizeof(buf))) {
 	vlog.debug("failed to retrieve LOCALE_SDECIMAL");
       } else {
 	switch (buf[0]) {
diff -urN win/rfb_win32/Clipboard.cxx win.new/rfb_win32/Clipboard.cxx
--- win/rfb_win32/Clipboard.cxx	2009-11-26 16:51:32.000000000 +0100
+++ win.new/rfb_win32/Clipboard.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -127,7 +127,7 @@
               } else {
                 CharArray unix_text;
                 unix_text.buf = dos2unix(clipdata);
-                removeNonISOLatin1Chars(unix_text.buf);
+//                removeNonISOLatin1Chars(unix_text.buf);
                 notifier->notifyClipboardChanged(unix_text.buf, strlen(unix_text.buf));
               }
             } else {
@@ -163,7 +163,7 @@
     // - Pre-process the supplied clipboard text into DOS format
     CharArray dos_text;
     dos_text.buf = unix2dos(text);
-    removeNonISOLatin1Chars(dos_text.buf);
+//    removeNonISOLatin1Chars(dos_text.buf);
     int dos_text_len = strlen(dos_text.buf);
 
     // - Allocate global memory for the data
diff -urN win/rfb_win32/rfb_win32.vcproj win.new/rfb_win32/rfb_win32.vcproj
--- win/rfb_win32/rfb_win32.vcproj	1970-01-01 01:00:00.000000000 +0100
+++ win.new/rfb_win32/rfb_win32.vcproj	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,2792 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="rfb_win32"
+	ProjectGUID="{19ACBA32-084D-4EFA-9923-8662039A53B5}"
+	TargetFrameworkVersion="0"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\..\Release"
+			IntermediateDirectory=".\..\Release\rfb_win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_LIB;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\rfb_win32/rfb_win32.pch"
+				AssemblerListingLocation=".\..\Release\rfb_win32/"
+				ObjectFile=".\..\Release\rfb_win32/"
+				ProgramDataBaseFileName=".\..\Release\rfb_win32/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile=".\..\Release\rfb_win32.lib"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/rfb_win32.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\..\Debug"
+			IntermediateDirectory=".\..\Debug\rfb_win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_DEBUG;_LIB;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug\rfb_win32/rfb_win32.pch"
+				AssemblerListingLocation=".\..\Debug\rfb_win32/"
+				ObjectFile=".\..\Debug\rfb_win32/"
+				ProgramDataBaseFileName=".\..\Debug\rfb_win32/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile=".\..\Debug\rfb_win32.lib"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug/rfb_win32.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug Unicode|Win32"
+			OutputDirectory=".\..\Debug_Unicode"
+			IntermediateDirectory=".\..\Debug_Unicode\rfb_win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/D &quot;HAVE_GNUTLS&quot;"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_DEBUG;UNICODE;_LIB;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\rfb_win32/rfb_win32.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\rfb_win32/"
+				ObjectFile=".\..\Debug_Unicode\rfb_win32/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\rfb_win32/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				AdditionalOptions="&quot;..\..\gnutls\w32gnutls.lib&quot; &quot;..\..\gnutls\w32gcrypt.lib&quot; &quot;..\..\gnutls\w32gpgerror.lib&quot;"
+				OutputFile=".\..\Debug_Unicode\rfb_win32.lib"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug_Unicode/rfb_win32.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Released Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/D &quot;HAVE_GNUTLS&quot;"
+				Optimization="2"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_NDEBUG;UNICODE;_LIB;WIN32"
+				StringPooling="true"
+				MinimalRebuild="false"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release_Unicode\rfb_win32/rfb_win32.pch"
+				AssemblerListingLocation=".\..\Release_Unicode\rfb_win32/"
+				ObjectFile=".\..\Release_Unicode\rfb_win32/"
+				ProgramDataBaseFileName=".\..\Release_Unicode\rfb_win32/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="0"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				AdditionalOptions="&quot;..\..\gnutls\w32gnutls.lib&quot; &quot;..\..\gnutls\w32gcrypt.lib&quot; &quot;..\..\gnutls\w32gpgerror.lib&quot;"
+				OutputFile=".\..\Release_Unicode\rfb_win32.lib"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release_Unicode/rfb_win32.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_LIB;WIN32;UNICODE;HAVE_GNUTLS"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\rfb_win32/rfb_win32.pch"
+				AssemblerListingLocation=".\..\Release\rfb_win32/"
+				ObjectFile=".\..\Release\rfb_win32/"
+				ProgramDataBaseFileName=".\..\Release\rfb_win32/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile=".\..\Release\rfb_win32.lib"
+				SuppressStartupBanner="true"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/rfb_win32.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+			>
+			<File
+				RelativePath="AboutDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CKeyboard.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CleanDesktop.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Clipboard.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CPointer.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CurrentUser.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="DeviceContext.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="DeviceFrameBuffer.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Dialog.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="DIBSectionBuffer.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="DynamicFn.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="EventManager.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="LaunchProcess.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ListViewControl.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="LowLevelKeyEvents.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="MonitorInfo.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="MsgWindow.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="OSVersion.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ProgressControl.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="RegConfig.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Registry.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ScaledDIBSectionBuffer.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="SDisplay.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="SDisplayCorePolling.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="SDisplayCoreWMHooks.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Security.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Service.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="SInput.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="SocketManager.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="TCharArray.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Threading.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ToolBar.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="TsSessions.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Win32Util.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="WMCursor.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="WMHooks.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="WMNotifier.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="WMPoller.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="WMShatter.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="WMWindowCopyRect.cxx"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl"
+			>
+			<File
+				RelativePath="AboutDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="BitmapInfo.h"
+				>
+			</File>
+			<File
+				RelativePath="CKeyboard.h"
+				>
+			</File>
+			<File
+				RelativePath="CleanDesktop.h"
+				>
+			</File>
+			<File
+				RelativePath="Clipboard.h"
+				>
+			</File>
+			<File
+				RelativePath="CompatibleBitmap.h"
+				>
+			</File>
+			<File
+				RelativePath="ComputerName.h"
+				>
+			</File>
+			<File
+				RelativePath="CPointer.h"
+				>
+			</File>
+			<File
+				RelativePath="CurrentUser.h"
+				>
+			</File>
+			<File
+				RelativePath="DeviceContext.h"
+				>
+			</File>
+			<File
+				RelativePath="DeviceFrameBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="Dialog.h"
+				>
+			</File>
+			<File
+				RelativePath="DIBSectionBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="DynamicFn.h"
+				>
+			</File>
+			<File
+				RelativePath="EventManager.h"
+				>
+			</File>
+			<File
+				RelativePath="Handle.h"
+				>
+			</File>
+			<File
+				RelativePath="IconInfo.h"
+				>
+			</File>
+			<File
+				RelativePath="IntervalTimer.h"
+				>
+			</File>
+			<File
+				RelativePath="keymap.h"
+				>
+			</File>
+			<File
+				RelativePath="LaunchProcess.h"
+				>
+			</File>
+			<File
+				RelativePath="ListViewControl.h"
+				>
+			</File>
+			<File
+				RelativePath="LocalMem.h"
+				>
+			</File>
+			<File
+				RelativePath="LogicalPalette.h"
+				>
+			</File>
+			<File
+				RelativePath="LowLevelKeyEvents.h"
+				>
+			</File>
+			<File
+				RelativePath="ModuleFileName.h"
+				>
+			</File>
+			<File
+				RelativePath="MonitorInfo.h"
+				>
+			</File>
+			<File
+				RelativePath="MsgBox.h"
+				>
+			</File>
+			<File
+				RelativePath="MsgWindow.h"
+				>
+			</File>
+			<File
+				RelativePath="OSVersion.h"
+				>
+			</File>
+			<File
+				RelativePath="ProgressControl.h"
+				>
+			</File>
+			<File
+				RelativePath="RegConfig.h"
+				>
+			</File>
+			<File
+				RelativePath="Registry.h"
+				>
+			</File>
+			<File
+				RelativePath="ScaledDIBSectionBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="SDisplay.h"
+				>
+			</File>
+			<File
+				RelativePath="SDisplayCoreDriver.h"
+				>
+			</File>
+			<File
+				RelativePath="SDisplayCorePolling.h"
+				>
+			</File>
+			<File
+				RelativePath="SDisplayCoreWMHooks.h"
+				>
+			</File>
+			<File
+				RelativePath="Security.h"
+				>
+			</File>
+			<File
+				RelativePath="Service.h"
+				>
+			</File>
+			<File
+				RelativePath="SInput.h"
+				>
+			</File>
+			<File
+				RelativePath="SocketManager.h"
+				>
+			</File>
+			<File
+				RelativePath="TCharArray.h"
+				>
+			</File>
+			<File
+				RelativePath="Threading.h"
+				>
+			</File>
+			<File
+				RelativePath="ToolBar.h"
+				>
+			</File>
+			<File
+				RelativePath="TrayIcon.h"
+				>
+			</File>
+			<File
+				RelativePath="TsSessions.h"
+				>
+			</File>
+			<File
+				RelativePath="Win32Util.h"
+				>
+			</File>
+			<File
+				RelativePath="WMCursor.h"
+				>
+			</File>
+			<File
+				RelativePath="WMHooks.h"
+				>
+			</File>
+			<File
+				RelativePath="WMNotifier.h"
+				>
+			</File>
+			<File
+				RelativePath="WMPoller.h"
+				>
+			</File>
+			<File
+				RelativePath="WMShatter.h"
+				>
+			</File>
+			<File
+				RelativePath="WMWindowCopyRect.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff -urN win/vncconfig/vncconfig.vcproj win.new/vncconfig/vncconfig.vcproj
--- win/vncconfig/vncconfig.vcproj	1970-01-01 01:00:00.000000000 +0100
+++ win.new/vncconfig/vncconfig.vcproj	2009-11-26 15:19:24.000000000 +0100
@@ -0,0 +1,776 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="vncconfig"
+	ProjectGUID="{92081715-84D3-43EB-B556-1479F100035E}"
+	TargetFrameworkVersion="0"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\..\Debug"
+			IntermediateDirectory=".\..\Debug\vncconfig"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug/vncconfig.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_DEBUG;_WINDOWS;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug\vncconfig/vncconfig.pch"
+				AssemblerListingLocation=".\..\Debug\vncconfig/"
+				ObjectFile=".\..\Debug\vncconfig/"
+				ProgramDataBaseFileName=".\..\Debug\vncconfig/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="4"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="version.lib comctl32.lib ws2_32.lib"
+				OutputFile=".\..\Debug/vncconfig.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug/vncconfig.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug/vncconfig.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\..\Release"
+			IntermediateDirectory=".\..\Release\vncconfig"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Release/vncconfig.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\vncconfig/vncconfig.pch"
+				AssemblerListingLocation=".\..\Release\vncconfig/"
+				ObjectFile=".\..\Release\vncconfig/"
+				ProgramDataBaseFileName=".\..\Release\vncconfig/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="version.lib comctl32.lib ws2_32.lib"
+				OutputFile=".\..\Release/vncconfig.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/vncconfig.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/vncconfig.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug Unicode|Win32"
+			OutputDirectory=".\..\Debug_Unicode"
+			IntermediateDirectory=".\..\Debug_Unicode\vncconfig"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug_Unicode/vncconfig.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_WINDOWS;_DEBUG;WIN32;UNICODE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\vncconfig/vncconfig.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\vncconfig/"
+				ObjectFile=".\..\Debug_Unicode\vncconfig/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\vncconfig/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="4"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="version.lib comctl32.lib ws2_32.lib"
+				OutputFile=".\..\Debug_Unicode/vncconfig.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug_Unicode/vncconfig.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug_Unicode/vncconfig.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Released Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug_Unicode/vncconfig.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_WINDOWS;_NDEBUG;WIN32;UNICODE"
+				StringPooling="true"
+				MinimalRebuild="false"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release_Unicode\vncconfig/vncconfig.pch"
+				AssemblerListingLocation=".\..\Release_Unicode\vncconfig/"
+				ObjectFile=".\..\Release_Unicode\vncconfig/"
+				ProgramDataBaseFileName=".\..\Release_Unicode\vncconfig/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="0"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_NDEBUG"
+				Culture="2057"
+				AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="version.lib comctl32.lib ws2_32.lib"
+				OutputFile=".\..\Release_Unicode/vncconfig.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="false"
+				ProgramDatabaseFile=".\..\Release_Unicode/vncconfig.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release_Unicode/vncconfig.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Release/vncconfig.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;WIN32;UNICODE"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\vncconfig/vncconfig.pch"
+				AssemblerListingLocation=".\..\Release\vncconfig/"
+				ObjectFile=".\..\Release\vncconfig/"
+				ProgramDataBaseFileName=".\..\Release\vncconfig/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="version.lib comctl32.lib ws2_32.lib"
+				OutputFile=".\..\Release/vncconfig.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/vncconfig.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/vncconfig.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+			>
+			<File
+				RelativePath="Legacy.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="PasswordDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="vncconfig.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl"
+			>
+			<File
+				RelativePath="Authentication.h"
+				>
+			</File>
+			<File
+				RelativePath="Connections.h"
+				>
+			</File>
+			<File
+				RelativePath="Desktop.h"
+				>
+			</File>
+			<File
+				RelativePath="Hooking.h"
+				>
+			</File>
+			<File
+				RelativePath="Inputs.h"
+				>
+			</File>
+			<File
+				RelativePath="Legacy.h"
+				>
+			</File>
+			<File
+				RelativePath="PasswordDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="resource.h"
+				>
+			</File>
+			<File
+				RelativePath="Sharing.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+			>
+			<File
+				RelativePath="connected.ico"
+				>
+			</File>
+			<File
+				RelativePath="vncconfig.ico"
+				>
+			</File>
+			<File
+				RelativePath="vncconfig.rc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+						AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+						AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<File
+			RelativePath="vncconfig.exe.manifest"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Binary files win/vnc.ncb and win.new/vnc.ncb differ
diff -urN win/vnc.sln win.new/vnc.sln
--- win/vnc.sln	1970-01-01 01:00:00.000000000 +0100
+++ win.new/vnc.sln	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,165 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Xregion", "..\common\Xregion\Xregion.vcproj", "{E6D27A83-B5A1-491E-872E-81C2FAE43D83}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logmessages", "logmessages\logmessages.vcproj", "{D059D343-6D24-4087-AF5E-4DA340030009}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "..\common\network\network.vcproj", "{3BE44946-BCE4-4B02-9B3A-43FF66953674}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdr", "..\common\rdr\rdr.vcproj", "{0B1C0461-89E3-4D82-8B48-39E075B57D27}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rfb", "..\common\rfb\rfb.vcproj", "{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}"
+	ProjectSection(ProjectDependencies) = postProject
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27} = {0B1C0461-89E3-4D82-8B48-39E075B57D27}
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83} = {E6D27A83-B5A1-491E-872E-81C2FAE43D83}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rfb_win32", "rfb_win32\rfb_win32.vcproj", "{19ACBA32-084D-4EFA-9923-8662039A53B5}"
+	ProjectSection(ProjectDependencies) = postProject
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2} = {D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vncconfig", "vncconfig\vncconfig.vcproj", "{92081715-84D3-43EB-B556-1479F100035E}"
+	ProjectSection(ProjectDependencies) = postProject
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2} = {D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}
+		{19ACBA32-084D-4EFA-9923-8662039A53B5} = {19ACBA32-084D-4EFA-9923-8662039A53B5}
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674} = {3BE44946-BCE4-4B02-9B3A-43FF66953674}
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83} = {E6D27A83-B5A1-491E-872E-81C2FAE43D83}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vncviewer", "vncviewer\vncviewer.vcproj", "{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}"
+	ProjectSection(ProjectDependencies) = postProject
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2} = {D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}
+		{BCEAC881-6508-470B-959B-72859119DD2E} = {BCEAC881-6508-470B-959B-72859119DD2E}
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009} = {3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}
+		{19ACBA32-084D-4EFA-9923-8662039A53B5} = {19ACBA32-084D-4EFA-9923-8662039A53B5}
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674} = {3BE44946-BCE4-4B02-9B3A-43FF66953674}
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27} = {0B1C0461-89E3-4D82-8B48-39E075B57D27}
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83} = {E6D27A83-B5A1-491E-872E-81C2FAE43D83}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winvnc", "winvnc\winvnc.vcproj", "{37376EA9-D030-4B38-9795-7202F265DE2A}"
+	ProjectSection(ProjectDependencies) = postProject
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674} = {3BE44946-BCE4-4B02-9B3A-43FF66953674}
+		{19ACBA32-084D-4EFA-9923-8662039A53B5} = {19ACBA32-084D-4EFA-9923-8662039A53B5}
+		{BCEAC881-6508-470B-959B-72859119DD2E} = {BCEAC881-6508-470B-959B-72859119DD2E}
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009} = {3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83} = {E6D27A83-B5A1-491E-872E-81C2FAE43D83}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wm_hooks", "wm_hooks\wm_hooks.vcproj", "{B0A5671B-4337-454D-BAD3-0FE8C555A532}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\common\zlib\zlib.vcproj", "{BCEAC881-6508-470B-959B-72859119DD2E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg", "..\common\jpeg\jpeg.vcproj", "{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug Unicode|Win32 = Debug Unicode|Win32
+		Debug|Win32 = Debug|Win32
+		Release Unicode|Win32 = Release Unicode|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Debug|Win32.ActiveCfg = Debug|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Debug|Win32.Build.0 = Debug|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Release|Win32.ActiveCfg = Release|Win32
+		{E6D27A83-B5A1-491E-872E-81C2FAE43D83}.Release|Win32.Build.0 = Release|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Debug|Win32.ActiveCfg = Debug|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Debug|Win32.Build.0 = Debug|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Release|Win32.ActiveCfg = Release|Win32
+		{D059D343-6D24-4087-AF5E-4DA340030009}.Release|Win32.Build.0 = Release|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Debug|Win32.Build.0 = Debug|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Release|Win32.ActiveCfg = Release|Win32
+		{3BE44946-BCE4-4B02-9B3A-43FF66953674}.Release|Win32.Build.0 = Release|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Debug|Win32.ActiveCfg = Debug|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Debug|Win32.Build.0 = Debug|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Release|Win32.ActiveCfg = Release|Win32
+		{0B1C0461-89E3-4D82-8B48-39E075B57D27}.Release|Win32.Build.0 = Release|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Debug|Win32.ActiveCfg = Debug|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Debug|Win32.Build.0 = Debug|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Release|Win32.ActiveCfg = Release|Win32
+		{D3C81000-23AB-4B6B-BA54-9D4FC70EB6C2}.Release|Win32.Build.0 = Release|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Debug|Win32.ActiveCfg = Debug|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Debug|Win32.Build.0 = Debug|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Release|Win32.ActiveCfg = Release|Win32
+		{19ACBA32-084D-4EFA-9923-8662039A53B5}.Release|Win32.Build.0 = Release|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Debug|Win32.ActiveCfg = Debug|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Debug|Win32.Build.0 = Debug|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Release|Win32.ActiveCfg = Release|Win32
+		{92081715-84D3-43EB-B556-1479F100035E}.Release|Win32.Build.0 = Release|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Debug|Win32.ActiveCfg = Debug|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Debug|Win32.Build.0 = Debug|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Release|Win32.ActiveCfg = Release|Win32
+		{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}.Release|Win32.Build.0 = Release|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Debug|Win32.ActiveCfg = Debug|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Debug|Win32.Build.0 = Debug|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Release|Win32.ActiveCfg = Release|Win32
+		{37376EA9-D030-4B38-9795-7202F265DE2A}.Release|Win32.Build.0 = Release|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Debug|Win32.ActiveCfg = Debug|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Debug|Win32.Build.0 = Debug|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Release|Win32.ActiveCfg = Release|Win32
+		{B0A5671B-4337-454D-BAD3-0FE8C555A532}.Release|Win32.Build.0 = Release|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Debug|Win32.ActiveCfg = Debug|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Debug|Win32.Build.0 = Debug|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Release|Win32.ActiveCfg = Release|Win32
+		{BCEAC881-6508-470B-959B-72859119DD2E}.Release|Win32.Build.0 = Release|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Debug Unicode|Win32.ActiveCfg = Debug|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Debug Unicode|Win32.Build.0 = Debug|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Debug|Win32.Build.0 = Debug|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Release|Win32.ActiveCfg = Release|Win32
+		{3EA93C03-7D6D-41B1-9C2C-4AF5C2449009}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Binary files win/vnc.suo and win.new/vnc.suo differ
diff -urN win/vncviewer/CConn.cxx win.new/vncviewer/CConn.cxx
--- win/vncviewer/CConn.cxx	2009-11-26 16:51:06.000000000 +0100
+++ win.new/vncviewer/CConn.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -1,826 +1,884 @@
-/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * 
- * This 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 software 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 software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-#include <windows.h>
-#include <winsock2.h>
-#include <vncviewer/UserPasswdDialog.h>
-#include <vncviewer/CConn.h>
-#include <vncviewer/CConnThread.h>
-#include <vncviewer/resource.h>
-#include <rfb/encodings.h>
-#include <rfb/secTypes.h>
-#include <rfb/CSecurityNone.h>
-#include <rfb/CSecurityVncAuth.h>
-#include <rfb/CMsgWriter.h>
-#include <rfb/Configuration.h>
-#include <rfb/LogWriter.h>
-#include <rfb_win32/AboutDialog.h>
-
-using namespace rfb;
-using namespace rfb::win32;
-using namespace rdr;
-
-// - Statics & consts
-
-static LogWriter vlog("CConn");
-
-
-const int IDM_FULLSCREEN = ID_FULLSCREEN;
-const int IDM_SEND_MENU_KEY = ID_SEND_MENU_KEY;
-const int IDM_SEND_CAD = ID_SEND_CAD;
-const int IDM_SEND_CTLESC = ID_SEND_CTLESC;
-const int IDM_ABOUT = ID_ABOUT;
-const int IDM_OPTIONS = ID_OPTIONS;
-const int IDM_INFO = ID_INFO;
-const int IDM_NEWCONN = ID_NEW_CONNECTION;
-const int IDM_REQUEST_REFRESH = ID_REQUEST_REFRESH;
-const int IDM_CTRL_KEY = ID_CTRL_KEY;
-const int IDM_ALT_KEY = ID_ALT_KEY;
-const int IDM_CONN_SAVE_AS = ID_CONN_SAVE_AS;
-const int IDM_ZOOM_IN = ID_ZOOM_IN;
-const int IDM_ZOOM_OUT = ID_ZOOM_OUT;
-const int IDM_ACTUAL_SIZE = ID_ACTUAL_SIZE;
-const int IDM_AUTO_SIZE = ID_AUTO_SIZE;
-
-
-static IntParameter debugDelay("DebugDelay","Milliseconds to display inverted "
-                               "pixel data - a debugging feature", 0);
-
-const int scaleValues[9] = {10, 25, 50, 75, 90, 100, 125, 150, 200};
-const int scaleCount = 9;
-
-
-//
-// -=- CConn implementation
-//
-
-RegKey            CConn::userConfigKey;
-
-
-CConn::CConn() 
-  : window(0), sameMachine(false), encodingChange(false), formatChange(false), 
-    lastUsedEncoding_(encodingRaw), sock(0), sockEvent(CreateEvent(0, TRUE, FALSE, 0)), 
-    reverseConnection(false), requestUpdate(false), firstUpdate(true),
-    isClosed_(false) {
-}
-
-CConn::~CConn() {
-  delete window;
-}
-
-bool CConn::initialise(network::Socket* s, bool reverse) {
-  // Set the server's name for MRU purposes
-  CharArray endpoint(s->getPeerEndpoint());
-  setServerName(endpoint.buf);
-  if (!options.host.buf)
-    options.setHost(endpoint.buf);
-
-  // Initialise the underlying CConnection
-  setStreams(&s->inStream(), &s->outStream());
-
-  // Enable processing of window messages while blocked on I/O
-  s->inStream().setBlockCallback(this);
-
-  // Initialise the viewer options
-  applyOptions(options);
-
-  // - Set which auth schemes we support, in order of preference
-  addSecType(secTypeVncAuth);
-  addSecType(secTypeNone);
-
-  // Start the RFB protocol
-  sock = s;
-  reverseConnection = reverse;
-  initialiseProtocol();
-
-  return true;
-}
-
-
-void
-CConn::applyOptions(CConnOptions& opt) {
-  // - If any encoding-related settings have changed then we must
-  //   notify the server of the new settings
-  encodingChange |= ((options.useLocalCursor != opt.useLocalCursor) ||
-                     (options.useDesktopResize != opt.useDesktopResize) ||
-                     (options.customCompressLevel != opt.customCompressLevel) ||
-                     (options.compressLevel != opt.compressLevel) ||
-                     (options.noJpeg != opt.noJpeg) ||
-                     (options.qualityLevel != opt.qualityLevel) ||
-                     (options.preferredEncoding != opt.preferredEncoding));
-
-  // - If the preferred pixel format has changed then notify the server
-  formatChange |= (options.fullColour != opt.fullColour);
-  if (!opt.fullColour)
-    formatChange |= (options.lowColourLevel != opt.lowColourLevel);
-
-  // - Save the new set of options
-  options = opt;
-
-  // - Set optional features in ConnParams
-  cp.supportsLocalCursor = options.useLocalCursor;
-  cp.supportsDesktopResize = options.useDesktopResize;
-  cp.supportsExtendedDesktopSize = options.useDesktopResize;
-  cp.supportsDesktopRename = true;
-  cp.customCompressLevel = options.customCompressLevel;
-  cp.compressLevel = options.compressLevel;
-  cp.noJpeg = options.noJpeg;
-  cp.qualityLevel = options.qualityLevel;
-
-  // - Configure connection sharing on/off
-  setShared(options.shared);
-
-  // - Whether to use protocol 3.3 for legacy compatibility
-  setProtocol3_3(options.protocol3_3);
-
-  // - Apply settings that affect the window, if it is visible
-  if (window) {
-    window->setMonitor(options.monitor.buf);
-    window->setFullscreen(options.fullScreen);
-    window->setEmulate3(options.emulate3);
-    window->setPointerEventInterval(options.pointerEventInterval);
-    window->setMenuKey(options.menuKey);
-    window->setDisableWinKeys(options.disableWinKeys);
-    window->setShowToolbar(options.showToolbar);
-    window->printScale();
-    if (options.autoScaling) {
-      window->setAutoScaling(true);
-    } else {
-      window->setAutoScaling(false);
-      window->setDesktopScale(options.scale);
-    }
-    if (!options.useLocalCursor)
-      window->setCursor(0, 0, Point(), 0, 0);
-  }
-}
-
-
-void
-CConn::displayChanged() {
-  // Display format has changed - recalculate the full-colour pixel format
-  calculateFullColourPF();
-}
-
-void
-CConn::paintCompleted() {
-  // A repaint message has just completed - request next update if necessary
-  requestNewUpdate();
-}
-
-bool
-CConn::sysCommand(WPARAM wParam, LPARAM lParam) {
-  // - If it's one of our (F8 Menu) messages
-  switch (wParam) {
-  case IDM_FULLSCREEN:
-    options.fullScreen = !window->isFullscreen();
-    window->setFullscreen(options.fullScreen);
-    return true;
-  case IDM_ZOOM_IN:
-  case IDM_ZOOM_OUT:
-    {
-      if (options.autoScaling) {
-        options.scale = window->getDesktopScale();
-        options.autoScaling = false;
-        window->setAutoScaling(false);
-      }
-      if (wParam == IDM_ZOOM_IN) {
-        for (int i = 0; i < scaleCount; i++)
-          if (options.scale < scaleValues[i]) { 
-            options.scale = scaleValues[i];
-            break;
-          }
-      } else {
-        for (int i = scaleCount-1; i >= 0; i--)
-          if (options.scale > scaleValues[i]) { 
-            options.scale = scaleValues[i];
-            break;
-          }
-      }
-      if (options.scale != window->getDesktopScale()) 
-        window->setDesktopScale(options.scale);
-    }
-    return true;
-  case IDM_ACTUAL_SIZE:
-    if (options.autoScaling) {
-      options.autoScaling = false;
-      window->setAutoScaling(false);
-    }
-    options.scale = 100;
-    window->setDesktopScale(100);
-    return true;
-  case IDM_AUTO_SIZE:
-    options.autoScaling = !options.autoScaling;
-    window->setAutoScaling(options.autoScaling);
-    if (!options.autoScaling) options.scale = window->getDesktopScale();
-    return true;
-  case IDM_SHOW_TOOLBAR:
-    options.showToolbar = !window->isToolbarEnabled();
-    window->setShowToolbar(options.showToolbar);
-    return true;
-  case IDM_CTRL_KEY:
-    window->kbd.keyEvent(this, VK_CONTROL, 0, !window->kbd.keyPressed(VK_CONTROL));
-    return true;
-  case IDM_ALT_KEY:
-    window->kbd.keyEvent(this, VK_MENU, 0, !window->kbd.keyPressed(VK_MENU));
-    return true;
-  case IDM_SEND_MENU_KEY:
-    window->kbd.keyEvent(this, options.menuKey, 0, true);
-    window->kbd.keyEvent(this, options.menuKey, 0, false);
-    return true;
-  case IDM_SEND_CAD:
-    window->kbd.keyEvent(this, VK_CONTROL, 0, true);
-    window->kbd.keyEvent(this, VK_MENU, 0, true);
-    window->kbd.keyEvent(this, VK_DELETE, 0x1000000, true);
-    window->kbd.keyEvent(this, VK_DELETE, 0x1000000, false);
-    window->kbd.keyEvent(this, VK_MENU, 0, false);
-    window->kbd.keyEvent(this, VK_CONTROL, 0, false);
-    return true;
-  case IDM_SEND_CTLESC:
-    window->kbd.keyEvent(this, VK_CONTROL, 0, true);
-    window->kbd.keyEvent(this, VK_ESCAPE, 0, true);
-    window->kbd.keyEvent(this, VK_ESCAPE, 0, false);
-    window->kbd.keyEvent(this, VK_CONTROL, 0, false);
-    return true;
-  case IDM_REQUEST_REFRESH:
-    try {
-      writer()->writeFramebufferUpdateRequest(Rect(0,0,cp.width,cp.height), false);
-      requestUpdate = false;
-    } catch (rdr::Exception& e) {
-      close(e.str());
-    }
-    return true;
-  case IDM_NEWCONN:
-    {
-      Thread* newThread = new CConnThread;
-    }
-    return true;
-  case IDM_OPTIONS:
-    // Update the monitor device name in the CConnOptions instance
-    options.monitor.replaceBuf(window->getMonitor());
-    showOptionsDialog();
-    return true;
-  case IDM_INFO:
-    infoDialog.showDialog(this);
-    return true;
-  case IDM_ABOUT:
-    AboutDialog::instance.showDialog();
-    return true;
-  case IDM_CONN_SAVE_AS:
-    return true;
-  };
-  return false;
-}
-
-
-void
-CConn::closeWindow() {
-  vlog.info("window closed");
-  close();
-}
-
-
-void
-CConn::refreshMenu(bool enableSysItems) {
-  HMENU menu = GetSystemMenu(window->getHandle(), FALSE);
-
-  if (!enableSysItems) {
-    // Gray out menu items that might cause a World Of Pain
-    EnableMenuItem(menu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);
-    EnableMenuItem(menu, SC_MOVE, MF_BYCOMMAND | MF_GRAYED);
-    EnableMenuItem(menu, SC_RESTORE, MF_BYCOMMAND | MF_ENABLED);
-    EnableMenuItem(menu, SC_MINIMIZE, MF_BYCOMMAND | MF_ENABLED);
-    EnableMenuItem(menu, SC_MAXIMIZE, MF_BYCOMMAND | MF_ENABLED);
-  }
-
-  // Update the modifier key menu items
-  UINT ctrlCheckFlags = window->kbd.keyPressed(VK_CONTROL) ? MF_CHECKED : MF_UNCHECKED;
-  UINT altCheckFlags = window->kbd.keyPressed(VK_MENU) ? MF_CHECKED : MF_UNCHECKED;
-  CheckMenuItem(menu, IDM_CTRL_KEY, MF_BYCOMMAND | ctrlCheckFlags);
-  CheckMenuItem(menu, IDM_ALT_KEY, MF_BYCOMMAND | altCheckFlags);
-
-  // Ensure that the Send <MenuKey> menu item has the correct text
-  if (options.menuKey) {
-    TCharArray menuKeyStr(options.menuKeyName());
-    TCharArray tmp(_tcslen(menuKeyStr.buf) + 6);
-    _stprintf(tmp.buf, _T("Send %s"), menuKeyStr.buf);
-    if (!ModifyMenu(menu, IDM_SEND_MENU_KEY, MF_BYCOMMAND | MF_STRING, IDM_SEND_MENU_KEY, tmp.buf))
-      InsertMenu(menu, IDM_SEND_CAD, MF_BYCOMMAND | MF_STRING, IDM_SEND_MENU_KEY, tmp.buf);
-  } else {
-    RemoveMenu(menu, IDM_SEND_MENU_KEY, MF_BYCOMMAND);
-  }
-
-  // Set the menu fullscreen option tick
-  CheckMenuItem(menu, IDM_FULLSCREEN, (window->isFullscreen() ? MF_CHECKED : 0) | MF_BYCOMMAND);
-
-  // Set the menu toolbar option tick
-  int toolbarFlags = window->isToolbarEnabled() ? MF_CHECKED : 0;
-  CheckMenuItem(menu, IDM_SHOW_TOOLBAR, MF_BYCOMMAND | toolbarFlags);
-
-  // In the full-screen mode, "Show toolbar" should be grayed.
-  toolbarFlags = window->isFullscreen() ? MF_GRAYED : MF_ENABLED;
-  EnableMenuItem(menu, IDM_SHOW_TOOLBAR, MF_BYCOMMAND | toolbarFlags);
-}
-
-
-void
-CConn::blockCallback() {
-  // - An InStream has blocked on I/O while processing an RFB message
-  //   We re-enable socket event notifications, so we'll know when more
-  //   data is available, then we sit and dispatch window events until
-  //   the notification arrives.
-  if (!isClosed()) {
-    if (WSAEventSelect(sock->getFd(), sockEvent, FD_READ | FD_CLOSE) == SOCKET_ERROR)
-      throw rdr::SystemException("Unable to wait for sokcet data", WSAGetLastError());
-  }
-  while (true) {
-    // If we have closed then we can't block waiting for data
-    if (isClosed())
-      throw rdr::EndOfStream();
-
-    // Wait for socket data, or a message to process
-    DWORD result = MsgWaitForMultipleObjects(1, &sockEvent.h, FALSE, INFINITE, QS_ALLINPUT);
-    if (result == WAIT_OBJECT_0) {
-      // - Network event notification.  Return control to I/O routine.
-      break;
-    } else if (result == WAIT_FAILED) {
-      // - The wait operation failed - raise an exception
-      throw rdr::SystemException("blockCallback wait error", GetLastError());
-    }
-
-    // - There should be a message in the message queue
-    MSG msg;
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
-      // IMPORTANT: We mustn't call TranslateMessage() here, because instead we
-      // call ToAscii() in CKeyboard::keyEvent().  ToAscii() stores dead key
-      // state from one call to the next, which would be messed up by calls to
-      // TranslateMessage() (actually it looks like TranslateMessage() calls
-      // ToAscii() internally).
-      DispatchMessage(&msg);
-    }
-  }
-
-  // Before we return control to the InStream, reset the network event
-  WSAEventSelect(sock->getFd(), sockEvent, 0);
-  ResetEvent(sockEvent);
-}
-
-
-void CConn::keyEvent(rdr::U32 key, bool down) {
-  if (!options.sendKeyEvents) return;
-  try {
-    writer()->keyEvent(key, down);
-  } catch (rdr::Exception& e) {
-    close(e.str());
-  }
-}
-void CConn::pointerEvent(const Point& pos, int buttonMask) {
-  if (!options.sendPtrEvents) return;
-  try {
-    writer()->pointerEvent(pos, buttonMask);
-  } catch (rdr::Exception& e) {
-    close(e.str());
-  }
-}
-void CConn::clientCutText(const char* str, int len) {
-  if (!options.clientCutText) return;
-  if (state() != RFBSTATE_NORMAL) return;
-  try {
-    writer()->clientCutText(str, len);
-  } catch (rdr::Exception& e) {
-    close(e.str());
-  }
-}
-
-
-CSecurity* CConn::getCSecurity(int secType)
-{
-  switch (secType) {
-  case secTypeNone:
-    return new CSecurityNone();
-  case secTypeVncAuth:
-    return new CSecurityVncAuth(this);
-  default:
-    throw Exception("Unsupported secType?");
-  }
-}
-
-
-void
-CConn::setColourMapEntries(int first, int count, U16* rgbs) {
-  vlog.debug("setColourMapEntries: first=%d, count=%d", first, count);
-  int i;
-  for (i=0;i<count;i++)
-    window->setColour(i+first, rgbs[i*3], rgbs[i*3+1], rgbs[i*3+2]);
-  // *** change to 0, 256?
-  window->refreshWindowPalette(first, count);
-}
-
-void
-CConn::bell() {
-  if (options.acceptBell)
-    MessageBeep((UINT)-1);
-}
-
-
-void
-CConn::setDesktopSize(int w, int h) {
-  vlog.debug("setDesktopSize %dx%d", w, h);
-
-  // Resize the window's buffer
-  if (window)
-    window->setSize(w, h);
-
-  // Tell the underlying CConnection
-  CConnection::setDesktopSize(w, h);
-}
-
-
-void
-CConn::setExtendedDesktopSize(int reason, int result, int w, int h,
-                              const rfb::ScreenSet& layout) {
-  if ((reason == reasonClient) && (result != resultSuccess)) {
-    vlog.error("SetDesktopSize failed: %d", result);
-    return;
-  }
-
-  // Resize the window's buffer
-  if (window)
-    window->setSize(w, h);
-
-  // Tell the underlying CConnection
-  CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
-}
-
-
-void
-CConn::setCursor(int w, int h, const Point& hotspot, void* data, void* mask) {
-  if (!options.useLocalCursor) return;
-
-  // Set the window to use the new cursor
-  window->setCursor(w, h, hotspot, data, mask);
-}
-
-
-void
-CConn::close(const char* reason) {
-  // If already closed then ignore this
-  if (isClosed())
-    return;
-
-  // Hide the window, if it exists
-  if (window)
-    ShowWindow(window->getHandle(), SW_HIDE);
-
-  // Save the reason & flag that we're closed & shutdown the socket
-  isClosed_ = true;
-  closeReason_.replaceBuf(strDup(reason));
-  sock->shutdown();
-}
-
-
-void
-CConn::showOptionsDialog() {
-  optionsDialog.showDialog(this);
-}
-
-
-void
-CConn::framebufferUpdateEnd() {
-  if (debugDelay != 0) {
-    vlog.debug("debug delay %d",(int)debugDelay);
-    UpdateWindow(window->getHandle());
-    Sleep(debugDelay);
-    std::list<rfb::Rect>::iterator i;
-    for (i = debugRects.begin(); i != debugRects.end(); i++) {
-      window->invertRect(*i);
-    }
-    debugRects.clear();
-  }
-  window->framebufferUpdateEnd();
-
-  if (firstUpdate) {
-    int width, height;
-
-    if (cp.supportsSetDesktopSize &&
-        sscanf(options.desktopSize.buf, "%dx%d", &width, &height) == 2) {
-      ScreenSet layout;
-
-      layout = cp.screenLayout;
-
-      if (layout.num_screens() == 0)
-        layout.add_screen(rfb::Screen());
-      else if (layout.num_screens() != 1) {
-        ScreenSet::iterator iter;
-
-        while (true) {
-          iter = layout.begin();
-          ++iter;
-
-          if (iter == layout.end())
-            break;
-
-          layout.remove_screen(iter->id);
-        }
-      }
-
-      layout.begin()->dimensions.tl.x = 0;
-      layout.begin()->dimensions.tl.y = 0;
-      layout.begin()->dimensions.br.x = width;
-      layout.begin()->dimensions.br.y = height;
-
-      writer()->writeSetDesktopSize(width, height, layout);
-    }
-
-    firstUpdate = false;
-  }
-
-  if (options.autoSelect)
-    autoSelectFormatAndEncoding();
-
-  // Always request the next update
-  requestUpdate = true;
-
-  // Check that at least part of the window has changed
-  if (!GetUpdateRect(window->getHandle(), 0, FALSE)) {
-    if (!(GetWindowLong(window->getHandle(), GWL_STYLE) & WS_MINIMIZE))
-      requestNewUpdate();
-  }
-
-  // Make sure the local cursor is shown
-  window->showCursor();
-}
-
-
-// Note: The method below is duplicated in win/vncviewer/CConn.cxx!
-
-// autoSelectFormatAndEncoding() chooses the format and encoding appropriate
-// to the connection speed:
-//
-//   First we wait for at least one second of bandwidth measurement.
-//
-//   Above 16Mbps (i.e. LAN), we choose the second highest JPEG quality,
-//   which should be perceptually lossless.
-//
-//   If the bandwidth is below that, we choose a more lossy JPEG quality.
-//
-//   If the bandwidth drops below 256 Kbps, we switch to palette mode.
-//
-//   Note: The system here is fairly arbitrary and should be replaced
-//         with something more intelligent at the server end.
-//
-void CConn::autoSelectFormatAndEncoding()
-{
-  int kbitsPerSecond = sock->inStream().kbitsPerSecond();
-  unsigned int timeWaited = sock->inStream().timeWaited();
-  bool newFullColour = options.fullColour;
-  int newQualityLevel = options.qualityLevel;
-
-  // Always use Tight
-  options.preferredEncoding = encodingTight;
-
-  // Check that we have a decent bandwidth measurement
-  if ((kbitsPerSecond == 0) || (timeWaited < 10000))
-    return;
-
-  // Select appropriate quality level
-  if (!options.noJpeg) {
-    if (kbitsPerSecond > 16000)
-      newQualityLevel = 8;
-    else
-      newQualityLevel = 6;
-
-    if (newQualityLevel != options.qualityLevel) {
-      vlog.info("Throughput %d kbit/s - changing to quality %d ",
-                kbitsPerSecond, newQualityLevel);
-      cp.qualityLevel = newQualityLevel;
-      options.qualityLevel = newQualityLevel;
-      encodingChange = true;
-    }
-  }
-
-  if (cp.beforeVersion(3, 8)) {
-    // Xvnc from TightVNC 1.2.9 sends out FramebufferUpdates with
-    // cursors "asynchronously". If this happens in the middle of a
-    // pixel format change, the server will encode the cursor with
-    // the old format, but the client will try to decode it
-    // according to the new format. This will lead to a
-    // crash. Therefore, we do not allow automatic format change for
-    // old servers.
-    return;
-  }
-  
-  // Select best color level
-  newFullColour = (kbitsPerSecond > 256);
-  if (newFullColour != options.fullColour) {
-    vlog.info("Throughput %d kbit/s - full color is now %s", 
-	      kbitsPerSecond,
-	      newFullColour ? "enabled" : "disabled");
-    options.fullColour = newFullColour;
-    formatChange = true;
-  } 
-}
-
-void
-CConn::requestNewUpdate() {
-  if (!requestUpdate) return;
-
-  if (formatChange) {
-    // Select the required pixel format
-    if (options.fullColour) {
-      window->setPF(fullColourPF);
-    } else {
-      switch (options.lowColourLevel) {
-      case 0:
-        window->setPF(PixelFormat(8,3,0,1,1,1,1,2,1,0));
-        break;
-      case 1:
-        window->setPF(PixelFormat(8,6,0,1,3,3,3,4,2,0));
-        break;
-      case 2:
-        window->setPF(PixelFormat(8,8,0,0,0,0,0,0,0,0));
-        break;
-      }
-    }
-
-    // Print the current pixel format
-    char str[256];
-    window->getPF().print(str, 256);
-    vlog.info("Using pixel format %s",str);
-
-    // Save the connection pixel format and tell server to use it
-    cp.setPF(window->getPF());
-    writer()->writeSetPixelFormat(cp.pf());
-
-    // Correct the local window's palette
-    if (!window->getNativePF().trueColour)
-      window->refreshWindowPalette(0, 1 << cp.pf().depth);
-  }
-
-  if (encodingChange) {
-    vlog.info("Using %s encoding",encodingName(options.preferredEncoding));
-    writer()->writeSetEncodings(options.preferredEncoding, true);
-  }
-
-  writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height),
-                                          !formatChange);
-
-  encodingChange = formatChange = requestUpdate = false;
-}
-
-
-void
-CConn::calculateFullColourPF() {
-  // If the server is palette based then use palette locally
-  // Also, don't bother doing bgr222
-  if (!serverDefaultPF.trueColour || (serverDefaultPF.depth < 6)) {
-    fullColourPF = serverDefaultPF;
-    options.fullColour = true;
-  } else {
-    // If server is trueColour, use lowest depth PF
-    PixelFormat native = window->getNativePF();
-    if ((serverDefaultPF.bpp < native.bpp) ||
-        ((serverDefaultPF.bpp == native.bpp) &&
-        (serverDefaultPF.depth < native.depth)))
-      fullColourPF = serverDefaultPF;
-    else
-      fullColourPF = window->getNativePF();
-  }
-  formatChange = true;
-}
-
-
-void
-CConn::setName(const char* name) {
-  if (window)
-    window->setName(name);
-  CConnection::setName(name);
-}
-
-
-void CConn::serverInit() {
-  CConnection::serverInit();
-
-  // If using AutoSelect with old servers, start in FullColor
-  // mode. See comment in autoSelectFormatAndEncoding. 
-  if (cp.beforeVersion(3, 8) && options.autoSelect) {
-    options.fullColour = true;
-  }
-
-  // Show the window
-  window = new DesktopWindow(this);
-
-  // Update the window menu
-  HMENU wndmenu = GetSystemMenu(window->getHandle(), FALSE);
-  int toolbarChecked = options.showToolbar ? MF_CHECKED : 0;
-
-  AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
-  AppendMenu(wndmenu, MF_STRING, IDM_FULLSCREEN, _T("&Full screen"));
-  AppendMenu(wndmenu, MF_STRING | toolbarChecked, IDM_SHOW_TOOLBAR,
-             _T("Show tool&bar"));
-  AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
-  AppendMenu(wndmenu, MF_STRING, IDM_CTRL_KEY, _T("Ctr&l"));
-  AppendMenu(wndmenu, MF_STRING, IDM_ALT_KEY, _T("Al&t"));
-  AppendMenu(wndmenu, MF_STRING, IDM_SEND_CAD, _T("Send Ctrl-Alt-&Del"));
-  AppendMenu(wndmenu, MF_STRING, IDM_SEND_CTLESC, _T("Send Ctrl-&Esc"));
-  AppendMenu(wndmenu, MF_STRING, IDM_REQUEST_REFRESH, _T("Refres&h Screen"));
-  AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
-  AppendMenu(wndmenu, MF_STRING, IDM_NEWCONN, _T("Ne&w Connection..."));
-  AppendMenu(wndmenu, MF_STRING, IDM_OPTIONS, _T("&Options..."));
-  AppendMenu(wndmenu, MF_STRING, IDM_INFO, _T("Connection &Info..."));
-  AppendMenu(wndmenu, MF_STRING, IDM_ABOUT, _T("&About..."));
-
-  // Set window attributes
-  window->setName(cp.name());
-  window->setShowToolbar(options.showToolbar);
-  window->setSize(cp.width, cp.height);
-  applyOptions(options);
-
-  // Save the server's current format
-  serverDefaultPF = cp.pf();
-
-  // Calculate the full-colour format to use
-  calculateFullColourPF();
-
-  // Request the initial update
-  vlog.info("requesting initial update");
-  formatChange = encodingChange = requestUpdate = true;
-  requestNewUpdate();
-}
-
-void
-CConn::serverCutText(const char* str, rdr::U32 len) {
-  if (!options.serverCutText) return;
-  window->serverCutText(str, len);
-}
-
-
-void CConn::beginRect(const Rect& r, unsigned int encoding) {
-  sock->inStream().startTiming();
-}
-
-void CConn::endRect(const Rect& r, unsigned int encoding) {
-  sock->inStream().stopTiming();
-  lastUsedEncoding_ = encoding;
-  if (debugDelay != 0) {
-    window->invertRect(r);
-    debugRects.push_back(r);
-  }
-}
-
-void CConn::fillRect(const Rect& r, Pixel pix) {
-  window->fillRect(r, pix);
-}
-void CConn::imageRect(const Rect& r, void* pixels) {
-  window->imageRect(r, pixels);
-}
-void CConn::copyRect(const Rect& r, int srcX, int srcY) {
-  window->copyRect(r, srcX, srcY);
-}
-
-void CConn::getUserPasswd(char** user, char** password) {
-  if (!user && options.passwordFile.buf[0]) {
-    FILE* fp = fopen(options.passwordFile.buf, "rb");
-    if (fp) {
-      char data[256];
-      int datalen = fread(data, 1, 256, fp);
-      fclose(fp);
-      if (datalen == 8) {
-	ObfuscatedPasswd obfPwd;
-	obfPwd.buf = data;
-	obfPwd.length  = datalen; 
-	PlainPasswd passwd(obfPwd);
-	obfPwd.takeBuf();
-	*password = strDup(passwd.buf);
-	memset(data, 0, sizeof(data));
-      }
-    }
-  }
-  if (user && options.userName.buf)
-    *user = strDup(options.userName.buf);
-  if (password && options.password.buf)
-    *password = strDup(options.password.buf);
-  if ((user && !*user) || (password && !*password)) {
-    // Missing username or password - prompt the user
-    UserPasswdDialog userPasswdDialog;
-    userPasswdDialog.setCSecurity(getCurrentCSecurity());
-    userPasswdDialog.getUserPasswd(user, password);
-  }
-  if (user) options.setUserName(*user);
-  if (password) options.setPassword(*password);
-}
-
+/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * 
+ * This 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 software 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 software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#include <windows.h>
+#include <winsock2.h>
+#include <vncviewer/UserPasswdDialog.h>
+#include <vncviewer/CConn.h>
+#include <vncviewer/CConnThread.h>
+#include <vncviewer/resource.h>
+#include <rfb/encodings.h>
+#include <rfb/secTypes.h>
+#include <rfb/CSecurityNone.h>
+#include <rfb/CSecurityVncAuth.h>
+#include <rfb/CSecurityTLS.h>
+#include <rfb/CSecurityX509.h>
+#include <rfb/CSecurityStack.h>
+#include <rfb/CSecurityPlain.h>
+#include <rfb/CMsgWriter.h>
+#include <rfb/Configuration.h>
+#include <rfb/LogWriter.h>
+#include <rfb_win32/AboutDialog.h>
+
+using namespace rfb;
+using namespace rfb::win32;
+using namespace rdr;
+
+// - Statics & consts
+
+static LogWriter vlog("CConn");
+
+#ifdef HAVE_GNUTLS
+StringParameter X509_CA("x509ca", "X509 CA certificate", "");
+StringParameter X509_CRL("x509crl", "X509 CRL file", "");
+#endif
+
+
+const int IDM_FULLSCREEN = ID_FULLSCREEN;
+const int IDM_SEND_MENU_KEY = ID_SEND_MENU_KEY;
+const int IDM_SEND_CAD = ID_SEND_CAD;
+const int IDM_SEND_CTLESC = ID_SEND_CTLESC;
+const int IDM_ABOUT = ID_ABOUT;
+const int IDM_OPTIONS = ID_OPTIONS;
+const int IDM_INFO = ID_INFO;
+const int IDM_NEWCONN = ID_NEW_CONNECTION;
+const int IDM_REQUEST_REFRESH = ID_REQUEST_REFRESH;
+const int IDM_CTRL_KEY = ID_CTRL_KEY;
+const int IDM_ALT_KEY = ID_ALT_KEY;
+const int IDM_CONN_SAVE_AS = ID_CONN_SAVE_AS;
+const int IDM_ZOOM_IN = ID_ZOOM_IN;
+const int IDM_ZOOM_OUT = ID_ZOOM_OUT;
+const int IDM_ACTUAL_SIZE = ID_ACTUAL_SIZE;
+const int IDM_AUTO_SIZE = ID_AUTO_SIZE;
+
+
+static IntParameter debugDelay("DebugDelay","Milliseconds to display inverted "
+                               "pixel data - a debugging feature", 0);
+
+const int scaleValues[9] = {10, 25, 50, 75, 90, 100, 125, 150, 200};
+const int scaleCount = 9;
+
+
+//
+// -=- CConn implementation
+//
+
+RegKey            CConn::userConfigKey;
+
+
+CConn::CConn() 
+  : window(0), sameMachine(false), encodingChange(false), formatChange(false), 
+    lastUsedEncoding_(encodingRaw), sock(0), sockEvent(CreateEvent(0, TRUE, FALSE, 0)), 
+    reverseConnection(false), requestUpdate(false), firstUpdate(true),
+    isClosed_(false) {
+}
+
+CConn::~CConn() {
+  delete window;
+}
+
+bool CConn::initialise(network::Socket* s, bool reverse) {
+  // Set the server's name for MRU purposes
+  CharArray endpoint(s->getPeerEndpoint());
+  setServerName(endpoint.buf);
+  if (!options.host.buf)
+    options.setHost(endpoint.buf);
+
+  // Initialise the underlying CConnection
+  setStreams(&s->inStream(), &s->outStream());
+
+  // Enable processing of window messages while blocked on I/O
+  s->inStream().setBlockCallback(this);
+
+  // Initialise the viewer options
+  applyOptions(options);
+
+  // - Set which auth schemes we support, in order of preference
+  addSecType(secTypeVncAuth);
+  addSecType(secTypeNone);
+#ifdef HAVE_GNUTLS
+  addSecType(secTypeX509None);
+  addSecType(secTypeX509Vnc);
+  addSecType(secTypeX509Plain);
+  addSecType(secTypeTLSNone);
+  addSecType(secTypeTLSVnc);
+  addSecType(secTypeTLSPlain);
+#endif
+
+  // Start the RFB protocol
+  sock = s;
+  reverseConnection = reverse;
+  initialiseProtocol();
+
+  return true;
+}
+
+
+void
+CConn::applyOptions(CConnOptions& opt) {
+  // - If any encoding-related settings have changed then we must
+  //   notify the server of the new settings
+  encodingChange |= ((options.useLocalCursor != opt.useLocalCursor) ||
+                     (options.useDesktopResize != opt.useDesktopResize) ||
+                     (options.customCompressLevel != opt.customCompressLevel) ||
+                     (options.compressLevel != opt.compressLevel) ||
+                     (options.noJpeg != opt.noJpeg) ||
+                     (options.qualityLevel != opt.qualityLevel) ||
+                     (options.preferredEncoding != opt.preferredEncoding));
+
+  // - If the preferred pixel format has changed then notify the server
+  formatChange |= (options.fullColour != opt.fullColour);
+  if (!opt.fullColour)
+    formatChange |= (options.lowColourLevel != opt.lowColourLevel);
+
+  // - Save the new set of options
+  options = opt;
+
+  // - Set optional features in ConnParams
+  cp.supportsLocalCursor = options.useLocalCursor;
+  cp.supportsDesktopResize = options.useDesktopResize;
+  cp.supportsExtendedDesktopSize = options.useDesktopResize;
+  cp.supportsDesktopRename = true;
+  cp.customCompressLevel = options.customCompressLevel;
+  cp.compressLevel = options.compressLevel;
+  cp.noJpeg = options.noJpeg;
+  cp.qualityLevel = options.qualityLevel;
+  cp.allowClose = options.allowClose;
+
+  // - Configure connection sharing on/off
+  setShared(options.shared);
+
+  // - Whether to use protocol 3.3 for legacy compatibility
+  setProtocol3_3(options.protocol3_3);
+
+  // - Apply settings that affect the window, if it is visible
+  if (window) {
+    window->setMonitor(options.monitor.buf);
+    window->setFullscreen(options.fullScreen);
+    window->setEmulate3(options.emulate3);
+    window->setPointerEventInterval(options.pointerEventInterval);
+    window->setMenuKey(options.menuKey);
+    window->setDisableWinKeys(options.disableWinKeys);
+    window->setShowToolbar(options.showToolbar);
+    window->printScale();
+	if (options.allowClose) {
+		window->setAllowClose(true);
+	} else {
+		window->setAllowClose(false);
+	}
+    if (options.autoScaling) {
+      window->setAutoScaling(true);
+    } else {
+      window->setAutoScaling(false);
+      window->setDesktopScale(options.scale);
+    }
+    if (!options.useLocalCursor)
+      window->setCursor(0, 0, Point(), 0, 0);
+  }
+}
+
+
+void
+CConn::displayChanged() {
+  // Display format has changed - recalculate the full-colour pixel format
+  calculateFullColourPF();
+}
+
+void
+CConn::paintCompleted() {
+  // A repaint message has just completed - request next update if necessary
+  requestNewUpdate();
+}
+
+bool
+CConn::sysCommand(WPARAM wParam, LPARAM lParam) {
+  // - If it's one of our (F8 Menu) messages
+  switch (wParam) {
+  case IDM_FULLSCREEN:
+    options.fullScreen = !window->isFullscreen();
+    window->setFullscreen(options.fullScreen);
+    return true;
+  case IDM_ZOOM_IN:
+  case IDM_ZOOM_OUT:
+    {
+      if (options.autoScaling) {
+        options.scale = window->getDesktopScale();
+        options.autoScaling = false;
+        window->setAutoScaling(false);
+      }
+      if (wParam == IDM_ZOOM_IN) {
+        for (int i = 0; i < scaleCount; i++)
+          if (options.scale < scaleValues[i]) { 
+            options.scale = scaleValues[i];
+            break;
+          }
+      } else {
+        for (int i = scaleCount-1; i >= 0; i--)
+          if (options.scale > scaleValues[i]) { 
+            options.scale = scaleValues[i];
+            break;
+          }
+      }
+      if (options.scale != window->getDesktopScale()) 
+        window->setDesktopScale(options.scale);
+    }
+    return true;
+  case IDM_ACTUAL_SIZE:
+    if (options.autoScaling) {
+      options.autoScaling = false;
+      window->setAutoScaling(false);
+    }
+    options.scale = 100;
+    window->setDesktopScale(100);
+    return true;
+  case IDM_AUTO_SIZE:
+    options.autoScaling = !options.autoScaling;
+    window->setAutoScaling(options.autoScaling);
+    if (!options.autoScaling) options.scale = window->getDesktopScale();
+    return true;
+  case IDM_SHOW_TOOLBAR:
+    options.showToolbar = !window->isToolbarEnabled();
+    window->setShowToolbar(options.showToolbar);
+    return true;
+  case IDM_CTRL_KEY:
+    window->kbd.keyEvent(this, VK_CONTROL, 0, !window->kbd.keyPressed(VK_CONTROL));
+    return true;
+  case IDM_ALT_KEY:
+    window->kbd.keyEvent(this, VK_MENU, 0, !window->kbd.keyPressed(VK_MENU));
+    return true;
+  case IDM_SEND_MENU_KEY:
+    window->kbd.keyEvent(this, options.menuKey, 0, true);
+    window->kbd.keyEvent(this, options.menuKey, 0, false);
+    return true;
+  case IDM_SEND_CAD:
+    window->kbd.keyEvent(this, VK_CONTROL, 0, true);
+    window->kbd.keyEvent(this, VK_MENU, 0, true);
+    window->kbd.keyEvent(this, VK_DELETE, 0x1000000, true);
+    window->kbd.keyEvent(this, VK_DELETE, 0x1000000, false);
+    window->kbd.keyEvent(this, VK_MENU, 0, false);
+    window->kbd.keyEvent(this, VK_CONTROL, 0, false);
+    return true;
+  case IDM_SEND_CTLESC:
+    window->kbd.keyEvent(this, VK_CONTROL, 0, true);
+    window->kbd.keyEvent(this, VK_ESCAPE, 0, true);
+    window->kbd.keyEvent(this, VK_ESCAPE, 0, false);
+    window->kbd.keyEvent(this, VK_CONTROL, 0, false);
+    return true;
+  case IDM_REQUEST_REFRESH:
+    try {
+      writer()->writeFramebufferUpdateRequest(Rect(0,0,cp.width,cp.height), false);
+      requestUpdate = false;
+    } catch (rdr::Exception& e) {
+      close(e.str());
+    }
+    return true;
+  case IDM_NEWCONN:
+    {
+      Thread* newThread = new CConnThread;
+    }
+    return true;
+  case IDM_OPTIONS:
+    // Update the monitor device name in the CConnOptions instance
+    options.monitor.replaceBuf(window->getMonitor());
+    showOptionsDialog();
+    return true;
+  case IDM_INFO:
+    infoDialog.showDialog(this);
+    return true;
+  case IDM_ABOUT:
+    AboutDialog::instance.showDialog();
+    return true;
+  case IDM_CONN_SAVE_AS:
+    return true;
+  };
+  return false;
+}
+
+
+void
+CConn::closeWindow() {
+  vlog.info("window closed");
+  close();
+}
+
+
+void
+CConn::refreshMenu(bool enableSysItems) {
+  HMENU menu = GetSystemMenu(window->getHandle(), FALSE);
+
+  if (!enableSysItems) {
+    // Gray out menu items that might cause a World Of Pain
+    EnableMenuItem(menu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);
+    EnableMenuItem(menu, SC_MOVE, MF_BYCOMMAND | MF_GRAYED);
+    EnableMenuItem(menu, SC_RESTORE, MF_BYCOMMAND | MF_ENABLED);
+    EnableMenuItem(menu, SC_MINIMIZE, MF_BYCOMMAND | MF_ENABLED);
+    EnableMenuItem(menu, SC_MAXIMIZE, MF_BYCOMMAND | MF_ENABLED);
+  }
+
+  // Update the modifier key menu items
+  UINT ctrlCheckFlags = window->kbd.keyPressed(VK_CONTROL) ? MF_CHECKED : MF_UNCHECKED;
+  UINT altCheckFlags = window->kbd.keyPressed(VK_MENU) ? MF_CHECKED : MF_UNCHECKED;
+  CheckMenuItem(menu, IDM_CTRL_KEY, MF_BYCOMMAND | ctrlCheckFlags);
+  CheckMenuItem(menu, IDM_ALT_KEY, MF_BYCOMMAND | altCheckFlags);
+
+  // Ensure that the Send <MenuKey> menu item has the correct text
+  if (options.menuKey) {
+    TCharArray menuKeyStr(options.menuKeyName());
+    TCharArray tmp(_tcslen(menuKeyStr.buf) + 6);
+    _stprintf(tmp.buf, _T("Send %s"), menuKeyStr.buf);
+    if (!ModifyMenu(menu, IDM_SEND_MENU_KEY, MF_BYCOMMAND | MF_STRING, IDM_SEND_MENU_KEY, tmp.buf))
+      InsertMenu(menu, IDM_SEND_CAD, MF_BYCOMMAND | MF_STRING, IDM_SEND_MENU_KEY, tmp.buf);
+  } else {
+    RemoveMenu(menu, IDM_SEND_MENU_KEY, MF_BYCOMMAND);
+  }
+
+  // Set the menu fullscreen option tick
+  CheckMenuItem(menu, IDM_FULLSCREEN, (window->isFullscreen() ? MF_CHECKED : 0) | MF_BYCOMMAND);
+
+  // Set the menu toolbar option tick
+  int toolbarFlags = window->isToolbarEnabled() ? MF_CHECKED : 0;
+  CheckMenuItem(menu, IDM_SHOW_TOOLBAR, MF_BYCOMMAND | toolbarFlags);
+
+  // In the full-screen mode, "Show toolbar" should be grayed.
+  toolbarFlags = window->isFullscreen() ? MF_GRAYED : MF_ENABLED;
+  EnableMenuItem(menu, IDM_SHOW_TOOLBAR, MF_BYCOMMAND | toolbarFlags);
+}
+
+
+void
+CConn::blockCallback() {
+  // - An InStream has blocked on I/O while processing an RFB message
+  //   We re-enable socket event notifications, so we'll know when more
+  //   data is available, then we sit and dispatch window events until
+  //   the notification arrives.
+  if (!isClosed()) {
+    if (WSAEventSelect(sock->getFd(), sockEvent, FD_READ | FD_CLOSE) == SOCKET_ERROR)
+      throw rdr::SystemException("Unable to wait for sokcet data", WSAGetLastError());
+  }
+  while (true) {
+    // If we have closed then we can't block waiting for data
+    if (isClosed())
+      throw rdr::EndOfStream();
+
+    // Wait for socket data, or a message to process
+    DWORD result = MsgWaitForMultipleObjects(1, &sockEvent.h, FALSE, INFINITE, QS_ALLINPUT);
+    if (result == WAIT_OBJECT_0) {
+      // - Network event notification.  Return control to I/O routine.
+      break;
+    } else if (result == WAIT_FAILED) {
+      // - The wait operation failed - raise an exception
+      throw rdr::SystemException("blockCallback wait error", GetLastError());
+    }
+
+    // - There should be a message in the message queue
+    MSG msg;
+    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+      // IMPORTANT: We mustn't call TranslateMessage() here, because instead we
+      // call ToAscii() in CKeyboard::keyEvent().  ToAscii() stores dead key
+      // state from one call to the next, which would be messed up by calls to
+      // TranslateMessage() (actually it looks like TranslateMessage() calls
+      // ToAscii() internally).
+      DispatchMessage(&msg);
+    }
+  }
+
+  // Before we return control to the InStream, reset the network event
+  WSAEventSelect(sock->getFd(), sockEvent, 0);
+  ResetEvent(sockEvent);
+}
+
+
+void CConn::keyEvent(rdr::U32 key, bool down) {
+  if (!options.sendKeyEvents) return;
+  try {
+    writer()->keyEvent(key, down);
+  } catch (rdr::Exception& e) {
+    close(e.str());
+  }
+}
+void CConn::pointerEvent(const Point& pos, int buttonMask) {
+  if (!options.sendPtrEvents) return;
+  try {
+    writer()->pointerEvent(pos, buttonMask);
+  } catch (rdr::Exception& e) {
+    close(e.str());
+  }
+}
+void CConn::clientCutText(const char* str, int len) {
+  if (!options.clientCutText) return;
+  if (state() != RFBSTATE_NORMAL) return;
+  try {
+    writer()->clientCutText(str, len);
+  } catch (rdr::Exception& e) {
+    close(e.str());
+  }
+}
+
+
+CSecurity* CConn::getCSecurity(int secType)
+{
+  switch (secType) {
+  case secTypeNone:
+    return new CSecurityNone();
+  case secTypeVncAuth:
+    return new CSecurityVncAuth(this);
+#ifdef HAVE_GNUTLS
+  case secTypePlain:
+    return new CSecurityPlain(this);
+  case secTypeTLSNone:
+    return new CSecurityTLS();
+  case secTypeTLSVnc:
+    return new CSecurityStack(secTypeTLSVnc,"TLS with VNCAuth",getCSecurity(secTypeTLSNone), getCSecurity(secTypeVncAuth));
+  case secTypeTLSPlain:
+    return new CSecurityStack(secTypeTLSVnc,"TLS with Plain",getCSecurity(secTypeTLSNone), getCSecurity(secTypePlain));
+  case secTypeX509None:
+    return new CSecurityX509(this,X509_CA.getData(),X509_CRL.getData());
+  case secTypeX509Vnc:
+    return new CSecurityStack(secTypeX509Vnc,"X509 with VNCAuth",getCSecurity(secTypeX509None), getCSecurity(secTypeVncAuth));
+  case secTypeX509Plain:
+    return new CSecurityStack(secTypeX509Vnc,"X509 with Plain",getCSecurity(secTypeX509None), getCSecurity(secTypePlain));
+#endif
+  default:
+    throw Exception("Unsupported secType?");
+  }
+}
+
+
+void
+CConn::setColourMapEntries(int first, int count, U16* rgbs) {
+  vlog.debug("setColourMapEntries: first=%d, count=%d", first, count);
+  int i;
+  for (i=0;i<count;i++)
+    window->setColour(i+first, rgbs[i*3], rgbs[i*3+1], rgbs[i*3+2]);
+  // *** change to 0, 256?
+  window->refreshWindowPalette(first, count);
+}
+
+void
+CConn::bell() {
+  if (options.acceptBell)
+    MessageBeep((UINT)-1);
+}
+
+
+void
+CConn::setDesktopSize(int w, int h) {
+  vlog.debug("setDesktopSize %dx%d", w, h);
+
+  // Resize the window's buffer
+  if (window)
+    window->setSize(w, h);
+
+  // Tell the underlying CConnection
+  CConnection::setDesktopSize(w, h);
+}
+
+
+void
+CConn::setExtendedDesktopSize(int reason, int result, int w, int h,
+                              const rfb::ScreenSet& layout) {
+  if ((reason == reasonClient) && (result != resultSuccess)) {
+    vlog.error("SetDesktopSize failed: %d", result);
+    return;
+  }
+
+  // Resize the window's buffer
+  if (window)
+    window->setSize(w, h);
+
+  // Tell the underlying CConnection
+  CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
+}
+
+
+void
+CConn::setCursor(int w, int h, const Point& hotspot, void* data, void* mask) {
+  if (!options.useLocalCursor) return;
+
+  // Set the window to use the new cursor
+  window->setCursor(w, h, hotspot, data, mask);
+}
+
+
+void
+CConn::close(const char* reason) {
+  // If already closed then ignore this
+  if (isClosed())
+    return;
+
+  // Hide the window, if it exists
+  if (window)
+    ShowWindow(window->getHandle(), SW_HIDE);
+
+  // Save the reason & flag that we're closed & shutdown the socket
+  isClosed_ = true;
+  closeReason_.replaceBuf(strDup(reason));
+  sock->shutdown();
+}
+
+
+void
+CConn::showOptionsDialog() {
+  optionsDialog.showDialog(this);
+}
+
+
+void
+CConn::framebufferUpdateEnd() {
+  if (debugDelay != 0) {
+    vlog.debug("debug delay %d",(int)debugDelay);
+    UpdateWindow(window->getHandle());
+    Sleep(debugDelay);
+    std::list<rfb::Rect>::iterator i;
+    for (i = debugRects.begin(); i != debugRects.end(); i++) {
+      window->invertRect(*i);
+    }
+    debugRects.clear();
+  }
+  window->framebufferUpdateEnd();
+
+  if (firstUpdate) {
+    int width, height;
+
+    if (cp.supportsSetDesktopSize &&
+        sscanf(options.desktopSize.buf, "%dx%d", &width, &height) == 2) {
+      ScreenSet layout;
+
+      layout = cp.screenLayout;
+
+      if (layout.num_screens() == 0)
+        layout.add_screen(rfb::Screen());
+      else if (layout.num_screens() != 1) {
+        ScreenSet::iterator iter;
+
+        while (true) {
+          iter = layout.begin();
+          ++iter;
+
+          if (iter == layout.end())
+            break;
+
+          layout.remove_screen(iter->id);
+        }
+      }
+
+      layout.begin()->dimensions.tl.x = 0;
+      layout.begin()->dimensions.tl.y = 0;
+      layout.begin()->dimensions.br.x = width;
+      layout.begin()->dimensions.br.y = height;
+
+      writer()->writeSetDesktopSize(width, height, layout);
+    }
+
+    firstUpdate = false;
+  }
+
+  if (options.autoSelect)
+    autoSelectFormatAndEncoding();
+
+  // Always request the next update
+  requestUpdate = true;
+
+  // Check that at least part of the window has changed
+  if (!GetUpdateRect(window->getHandle(), 0, FALSE)) {
+    if (!(GetWindowLong(window->getHandle(), GWL_STYLE) & WS_MINIMIZE))
+      requestNewUpdate();
+  }
+
+  // Make sure the local cursor is shown
+  window->showCursor();
+}
+
+
+// Note: The method below is duplicated in win/vncviewer/CConn.cxx!
+
+// autoSelectFormatAndEncoding() chooses the format and encoding appropriate
+// to the connection speed:
+//
+//   First we wait for at least one second of bandwidth measurement.
+//
+//   Above 16Mbps (i.e. LAN), we choose the second highest JPEG quality,
+//   which should be perceptually lossless.
+//
+//   If the bandwidth is below that, we choose a more lossy JPEG quality.
+//
+//   If the bandwidth drops below 256 Kbps, we switch to palette mode.
+//
+//   Note: The system here is fairly arbitrary and should be replaced
+//         with something more intelligent at the server end.
+//
+void CConn::autoSelectFormatAndEncoding()
+{
+  int kbitsPerSecond = sock->inStream().kbitsPerSecond();
+  unsigned int timeWaited = sock->inStream().timeWaited();
+  bool newFullColour = options.fullColour;
+  int newQualityLevel = options.qualityLevel;
+
+  // Always use Tight
+  options.preferredEncoding = encodingTight;
+
+  // Check that we have a decent bandwidth measurement
+  if ((kbitsPerSecond == 0) || (timeWaited < 10000))
+    return;
+
+  // Select appropriate quality level
+  if (!options.noJpeg) {
+    if (kbitsPerSecond > 18000)
+	  newQualityLevel = 9;
+    else if (kbitsPerSecond > 16000)
+      newQualityLevel = 8;
+    else
+      newQualityLevel = 6;
+
+    if (newQualityLevel != options.qualityLevel) {
+      vlog.info("Throughput %d kbit/s - changing to quality %d ",
+                kbitsPerSecond, newQualityLevel);
+      cp.qualityLevel = newQualityLevel;
+      options.qualityLevel = newQualityLevel;
+      encodingChange = true;
+    }
+  }
+
+  if (cp.beforeVersion(3, 8)) {
+    // Xvnc from TightVNC 1.2.9 sends out FramebufferUpdates with
+    // cursors "asynchronously". If this happens in the middle of a
+    // pixel format change, the server will encode the cursor with
+    // the old format, but the client will try to decode it
+    // according to the new format. This will lead to a
+    // crash. Therefore, we do not allow automatic format change for
+    // old servers.
+    return;
+  }
+  
+  // Select best color level
+  newFullColour = (kbitsPerSecond > 256);
+  if (newFullColour != options.fullColour) {
+    vlog.info("Throughput %d kbit/s - full color is now %s", 
+	      kbitsPerSecond,
+	      newFullColour ? "enabled" : "disabled");
+    options.fullColour = newFullColour;
+    formatChange = true;
+  } 
+}
+
+void
+CConn::requestNewUpdate() {
+  if (!requestUpdate) return;
+
+  if (formatChange) {
+    // Select the required pixel format
+    if (options.fullColour) {
+      window->setPF(fullColourPF);
+    } else {
+      switch (options.lowColourLevel) {
+      case 0:
+        window->setPF(PixelFormat(8,3,0,1,1,1,1,2,1,0));
+        break;
+      case 1:
+        window->setPF(PixelFormat(8,6,0,1,3,3,3,4,2,0));
+        break;
+      case 2:
+        window->setPF(PixelFormat(8,8,0,0,0,0,0,0,0,0));
+        break;
+      }
+    }
+
+    // Print the current pixel format
+    char str[256];
+    window->getPF().print(str, 256);
+    vlog.info("Using pixel format %s",str);
+
+    // Save the connection pixel format and tell server to use it
+    cp.setPF(window->getPF());
+    writer()->writeSetPixelFormat(cp.pf());
+
+    // Correct the local window's palette
+    if (!window->getNativePF().trueColour)
+      window->refreshWindowPalette(0, 1 << cp.pf().depth);
+  }
+
+  if (encodingChange) {
+    vlog.info("Using %s encoding",encodingName(options.preferredEncoding));
+    writer()->writeSetEncodings(options.preferredEncoding, true);
+  }
+
+  writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height),
+                                          !formatChange);
+
+  encodingChange = formatChange = requestUpdate = false;
+}
+
+
+void
+CConn::calculateFullColourPF() {
+  // If the server is palette based then use palette locally
+  // Also, don't bother doing bgr222
+  if (!serverDefaultPF.trueColour || (serverDefaultPF.depth < 6)) {
+    fullColourPF = serverDefaultPF;
+    options.fullColour = true;
+  } else {
+    // If server is trueColour, use lowest depth PF
+    PixelFormat native = window->getNativePF();
+    if ((serverDefaultPF.bpp < native.bpp) ||
+        ((serverDefaultPF.bpp == native.bpp) &&
+        (serverDefaultPF.depth < native.depth)))
+      fullColourPF = serverDefaultPF;
+    else
+      fullColourPF = window->getNativePF();
+  }
+  formatChange = true;
+}
+
+
+void
+CConn::setName(const char* name) {
+  if (window)
+    window->setName(name);
+  CConnection::setName(name);
+}
+
+
+void CConn::serverInit() {
+  CConnection::serverInit();
+
+  // If using AutoSelect with old servers, start in FullColor
+  // mode. See comment in autoSelectFormatAndEncoding. 
+  if (cp.beforeVersion(3, 8) && options.autoSelect) {
+    options.fullColour = true;
+  }
+
+  // Show the window
+  window = new DesktopWindow(this);
+
+  // Update the window menu
+  HMENU wndmenu = GetSystemMenu(window->getHandle(), FALSE);
+  int toolbarChecked = options.showToolbar ? MF_CHECKED : 0;
+
+  AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
+  AppendMenu(wndmenu, MF_STRING, IDM_FULLSCREEN, _T("&Full screen"));
+  AppendMenu(wndmenu, MF_STRING | toolbarChecked, IDM_SHOW_TOOLBAR,
+             _T("Show tool&bar"));
+  AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
+  AppendMenu(wndmenu, MF_STRING, IDM_CTRL_KEY, _T("Ctr&l"));
+  AppendMenu(wndmenu, MF_STRING, IDM_ALT_KEY, _T("Al&t"));
+  AppendMenu(wndmenu, MF_STRING, IDM_SEND_CAD, _T("Send Ctrl-Alt-&Del"));
+  AppendMenu(wndmenu, MF_STRING, IDM_SEND_CTLESC, _T("Send Ctrl-&Esc"));
+  AppendMenu(wndmenu, MF_STRING, IDM_REQUEST_REFRESH, _T("Refres&h Screen"));
+  AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
+  AppendMenu(wndmenu, MF_STRING, IDM_NEWCONN, _T("Ne&w Connection..."));
+  AppendMenu(wndmenu, MF_STRING, IDM_OPTIONS, _T("&Options..."));
+  AppendMenu(wndmenu, MF_STRING, IDM_INFO, _T("Connection &Info..."));
+  AppendMenu(wndmenu, MF_STRING, IDM_ABOUT, _T("&About..."));
+
+  // Set window attributes
+  window->setName(cp.name());
+  window->setShowToolbar(options.showToolbar);
+  window->setSize(cp.width, cp.height);
+  applyOptions(options);
+
+  // Save the server's current format
+  serverDefaultPF = cp.pf();
+
+  // Calculate the full-colour format to use
+  calculateFullColourPF();
+
+  // Request the initial update
+  vlog.info("requesting initial update");
+  formatChange = encodingChange = requestUpdate = true;
+  requestNewUpdate();
+}
+
+void
+CConn::serverCutText(const char* str, rdr::U32 len) {
+  if (!options.serverCutText) return;
+  window->serverCutText(str, len);
+}
+
+
+void CConn::beginRect(const Rect& r, unsigned int encoding) {
+  sock->inStream().startTiming();
+}
+
+void CConn::endRect(const Rect& r, unsigned int encoding) {
+  sock->inStream().stopTiming();
+  lastUsedEncoding_ = encoding;
+  if (debugDelay != 0) {
+    window->invertRect(r);
+    debugRects.push_back(r);
+  }
+}
+
+void CConn::fillRect(const Rect& r, Pixel pix) {
+  window->fillRect(r, pix);
+}
+void CConn::imageRect(const Rect& r, void* pixels) {
+  window->imageRect(r, pixels);
+}
+void CConn::copyRect(const Rect& r, int srcX, int srcY) {
+  window->copyRect(r, srcX, srcY);
+}
+
+void CConn::getUserPasswd(char** user, char** password) {
+  if (!user && options.passwordFile.buf[0]) {
+    FILE* fp = fopen(options.passwordFile.buf, "rb");
+    if (fp) {
+      char data[256];
+      int datalen = fread(data, 1, 256, fp);
+      fclose(fp);
+      if (datalen == 8) {
+	ObfuscatedPasswd obfPwd;
+	obfPwd.buf = data;
+	obfPwd.length  = datalen; 
+	PlainPasswd passwd(obfPwd);
+	obfPwd.takeBuf();
+	*password = strDup(passwd.buf);
+	memset(data, 0, sizeof(data));
+      }
+    }
+  }
+  if (user && options.userName.buf)
+    *user = strDup(options.userName.buf);
+  if (password && options.password.buf)
+    *password = strDup(options.password.buf);
+  if ((user && !*user) || (password && !*password)) {
+    // Missing username or password - prompt the user
+    UserPasswdDialog userPasswdDialog;
+    userPasswdDialog.setCSecurity(getCurrentCSecurity());
+    userPasswdDialog.getUserPasswd(user, password);
+  }
+  if (user) options.setUserName(*user);
+  if (password) options.setPassword(*password);
+}
+
+bool CConn::showMsgBox(int flags,const char* text)
+{
+  int res;
+  const char* secType = secTypeName(getCurrentCSecurity()->getType());
+  const char* titlePrefix = "VNC Authentication";
+  CharArray title(strlen(titlePrefix) + strlen(secType) + 4);
+  sprintf(title.buf, "%s [%s]", titlePrefix, secType);
+
+  res=MessageBox(0, LPCWSTR(text), LPCWSTR(title.buf), flags);
+
+  if(res == IDOK)
+    return 1;
+  if(res == IDYES)
+    return 1;
+  return 0;
+}
+
diff -urN win/vncviewer/CConn.h win.new/vncviewer/CConn.h
--- win/vncviewer/CConn.h	2009-11-26 16:51:00.000000000 +0100
+++ win.new/vncviewer/CConn.h	2009-11-26 15:19:23.000000000 +0100
@@ -1,163 +1,167 @@
-/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * 
- * This 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 software 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 software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-// -=- CConn.h
-
-// Windows-specific implementation of CConnection
-
-#ifndef __RFB_WIN32_CCONN_H__
-#define __RFB_WIN32_CCONN_H__
-
-#include <network/Socket.h>
-#include <rfb/CConnection.h>
-#include <rfb/Cursor.h>
-#include <rfb/UserPasswdGetter.h>
-#include <rfb_win32/Registry.h>
-#include <rfb_win32/Handle.h>
-#include <vncviewer/InfoDialog.h>
-#include <vncviewer/OptionsDialog.h>
-#include <vncviewer/CConnOptions.h>
-#include <vncviewer/DesktopWindow.h>
-#include <list>
-
-
-namespace rfb {
-
-  namespace win32 {
-
-    class CConn : public CConnection,
-                  UserPasswdGetter,
-                  DesktopWindow::Callback,
-                  rdr::FdInStreamBlockCallback
-    {
-    public:
-      CConn();
-      ~CConn();
-
-      // - Start the VNC session on the supplied socket
-      //   The socket must already be connected to a host
-      bool initialise(network::Socket* s, bool reverse=false);
-
-      // - Set/get the session options
-      void applyOptions(CConnOptions& opt);
-      const CConnOptions& getOptions() const { return options; };
-
-      // - Show the options dialog for the connection
-      void showOptionsDialog();
-
-      // - Close the socket & set the reason for closure
-      void close(const char* reason=0);
-      bool isClosed() const { return isClosed_; }
-      const char* closeReason() const { return closeReason_.buf; }
-
-      // - Last received encoding, for the Info dialog
-      int lastUsedEncoding() const { return lastUsedEncoding_; }
-
-      // - Get at the DesktopWindow, if any
-      DesktopWindow* getWindow() { return window; }
-
-      // - Get at the underlying Socket
-      network::Socket* getSocket() { return sock; }
-
-      // - Get the server's preferred format
-      const PixelFormat& getServerDefaultPF() const { return serverDefaultPF; }
-
-      // Global user-config registry key
-      static RegKey userConfigKey;
-
-    protected:
-      // InputHandler interface (via DesktopWindow::Callback)
-      void keyEvent(rdr::U32 key, bool down);
-      void pointerEvent(const Point& pos, int buttonMask);
-      void clientCutText(const char* str, int len);
-
-      // DesktopWindow::Callback interface
-      void displayChanged();
-      void paintCompleted();
-      bool sysCommand(WPARAM wParam, LPARAM lParam);
-      void closeWindow();
-      void refreshMenu(bool enableSysCommands);
-
-      // CConnection interface
-      CSecurity* getCSecurity(int secType);
-      void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
-      void bell();
-      void framebufferUpdateEnd();
-      void setDesktopSize(int w, int h);
-      void setExtendedDesktopSize(int reason, int result, int w, int h,
-                                  const rfb::ScreenSet& layout);
-      void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);
-      void setName(const char* name);
-      void serverInit();
-      void serverCutText(const char* str, rdr::U32 len);
-      void beginRect(const Rect& r, unsigned int encoding);
-      void endRect(const Rect& r, unsigned int encoding);
-      void fillRect(const Rect& r, Pixel pix);
-      void imageRect(const Rect& r, void* pixels);
-      void copyRect(const Rect& r, int srcX, int srcY);
-
-      // rdr::FdInStreamBlockCallback interface
-      void blockCallback();
-
-      // UserPasswdGetter interface
-      // (overridden to allow a pre-supplied username & password)
-      void getUserPasswd(char** user, char** password);
-
-      // CConn-specific internal interface
-      void autoSelectFormatAndEncoding();
-      void requestNewUpdate();
-      void calculateFullColourPF();
-
-      // The desktop window
-      DesktopWindow* window;
-
-      // Info and Options dialogs
-      OptionsDialog optionsDialog;
-      InfoDialog infoDialog;
-
-      // VNC Viewer options
-      CConnOptions options;
-
-      // Pixel format and encoding
-      PixelFormat serverDefaultPF;
-      PixelFormat fullColourPF;
-      bool sameMachine;
-      bool encodingChange;
-      bool formatChange;
-      int lastUsedEncoding_;
-
-      // Networking and RFB protocol
-      network::Socket* sock;
-      Handle sockEvent;
-      bool reverseConnection;
-      bool requestUpdate;
-      bool firstUpdate;
-
-      // Debugging/logging
-      std::list<Rect> debugRects;
-      CharArray closeReason_;
-      bool isClosed_;
-    };
-
-  };
-
-};
-
-#endif
-
-
+/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * 
+ * This 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 software 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 software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+// -=- CConn.h
+
+// Windows-specific implementation of CConnection
+
+#ifndef __RFB_WIN32_CCONN_H__
+#define __RFB_WIN32_CCONN_H__
+
+#include <network/Socket.h>
+#include <rfb/CConnection.h>
+#include <rfb/Cursor.h>
+#include <rfb/UserMsgBox.h>
+#include <rfb/UserPasswdGetter.h>
+#include <rfb_win32/Registry.h>
+#include <rfb_win32/Handle.h>
+#include <vncviewer/InfoDialog.h>
+#include <vncviewer/OptionsDialog.h>
+#include <vncviewer/CConnOptions.h>
+#include <vncviewer/DesktopWindow.h>
+#include <list>
+
+
+namespace rfb {
+
+  namespace win32 {
+
+    class CConn : public CConnection,
+                  UserPasswdGetter,
+                  DesktopWindow::Callback,
+				  rdr::FdInStreamBlockCallback, public rfb::UserMsgBox
+    {
+    public:
+      CConn();
+      ~CConn();
+
+      // - Start the VNC session on the supplied socket
+      //   The socket must already be connected to a host
+      bool initialise(network::Socket* s, bool reverse=false);
+
+      // - Set/get the session options
+      void applyOptions(CConnOptions& opt);
+      const CConnOptions& getOptions() const { return options; };
+
+      // - Show the options dialog for the connection
+      void showOptionsDialog();
+
+      // - Close the socket & set the reason for closure
+      void close(const char* reason=0);
+      bool isClosed() const { return isClosed_; }
+      const char* closeReason() const { return closeReason_.buf; }
+
+      // - Last received encoding, for the Info dialog
+      int lastUsedEncoding() const { return lastUsedEncoding_; }
+
+      // - Get at the DesktopWindow, if any
+      DesktopWindow* getWindow() { return window; }
+
+      // - Get at the underlying Socket
+      network::Socket* getSocket() { return sock; }
+
+      // - Get the server's preferred format
+      const PixelFormat& getServerDefaultPF() const { return serverDefaultPF; }
+
+      // Global user-config registry key
+      static RegKey userConfigKey;
+
+    protected:
+      // InputHandler interface (via DesktopWindow::Callback)
+      void keyEvent(rdr::U32 key, bool down);
+      void pointerEvent(const Point& pos, int buttonMask);
+      void clientCutText(const char* str, int len);
+
+      // DesktopWindow::Callback interface
+      void displayChanged();
+      void paintCompleted();
+      bool sysCommand(WPARAM wParam, LPARAM lParam);
+      void closeWindow();
+      void refreshMenu(bool enableSysCommands);
+
+      // CConnection interface
+      CSecurity* getCSecurity(int secType);
+      void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
+      void bell();
+      void framebufferUpdateEnd();
+      void setDesktopSize(int w, int h);
+      void setExtendedDesktopSize(int reason, int result, int w, int h,
+                                  const rfb::ScreenSet& layout);
+      void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);
+      void setName(const char* name);
+      void serverInit();
+      void serverCutText(const char* str, rdr::U32 len);
+      void beginRect(const Rect& r, unsigned int encoding);
+      void endRect(const Rect& r, unsigned int encoding);
+      void fillRect(const Rect& r, Pixel pix);
+      void imageRect(const Rect& r, void* pixels);
+      void copyRect(const Rect& r, int srcX, int srcY);
+
+      // rdr::FdInStreamBlockCallback interface
+      void blockCallback();
+
+      // UserPasswdGetter interface
+      // (overridden to allow a pre-supplied username & password)
+      void getUserPasswd(char** user, char** password);
+
+	  // UserMsgBox methods
+	  virtual bool showMsgBox(int flags,const char* text);
+
+      // CConn-specific internal interface
+      void autoSelectFormatAndEncoding();
+      void requestNewUpdate();
+      void calculateFullColourPF();
+
+      // The desktop window
+      DesktopWindow* window;
+
+      // Info and Options dialogs
+      OptionsDialog optionsDialog;
+      InfoDialog infoDialog;
+
+      // VNC Viewer options
+      CConnOptions options;
+
+      // Pixel format and encoding
+      PixelFormat serverDefaultPF;
+      PixelFormat fullColourPF;
+      bool sameMachine;
+      bool encodingChange;
+      bool formatChange;
+      int lastUsedEncoding_;
+
+      // Networking and RFB protocol
+      network::Socket* sock;
+      Handle sockEvent;
+      bool reverseConnection;
+      bool requestUpdate;
+      bool firstUpdate;
+
+      // Debugging/logging
+      std::list<Rect> debugRects;
+      CharArray closeReason_;
+      bool isClosed_;
+    };
+
+  };
+
+};
+
+#endif
+
+
diff -urN win/vncviewer/CConnOptions.cxx win.new/vncviewer/CConnOptions.cxx
--- win/vncviewer/CConnOptions.cxx	2009-11-26 16:50:59.000000000 +0100
+++ win.new/vncviewer/CConnOptions.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -1,490 +1,504 @@
-/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * 
- * This 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 software 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 software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-#include <vncviewer/CConnOptions.h>
-#include <rfb/Configuration.h>
-#include <rfb/encodings.h>
-#include <rfb/LogWriter.h>
-#include <rfb/ScaleFilters.h>
-#include <rfb_win32/MsgBox.h>
-#include <rfb_win32/Registry.h>
-#include <rdr/HexInStream.h>
-#include <rdr/HexOutStream.h>
-#include <stdlib.h>
-
-using namespace rfb;
-using namespace rfb::win32;
-
-static StringParameter passwordFile("PasswordFile",
-				    "Password file for VNC authentication", "");
-
-// - Settings stored in the registry & in .vnc files, by Save Defaults and
-//   Save Configuration respectively.
-
-static BoolParameter useLocalCursor("UseLocalCursor", "Render the mouse cursor locally", true);
-static BoolParameter useDesktopResize("UseDesktopResize", "Support dynamic desktop resizing", true);
-
-static BoolParameter fullColour("FullColor",
-				"Use full color", true);
-static AliasParameter fullColourAlias("FullColour", "Alias for FullColor", &fullColour);
-
-static IntParameter lowColourLevel("LowColorLevel",
-                         "Color level to use on slow connections. "
-                         "0 = Very Low (8 colors), 1 = Low (64 colors), 2 = Medium (256 colors)",
-                         2);
-static AliasParameter lowColourLevelAlias("LowColourLevel", "Alias for LowColorLevel", &lowColourLevel);
-
-static BoolParameter fullScreen("FullScreen",
-                         "Use the whole display to show the remote desktop."
-                         "(Press F8 to access the viewer menu)",
-                         false);
-static StringParameter preferredEncoding("PreferredEncoding",
-					 "Preferred encoding to use (Tight, ZRLE, Hextile or"
-					 " Raw)", "Tight");
-static BoolParameter autoSelect("AutoSelect", 
-				"Auto select pixel format and encoding. "
-				"Default if PreferredEncoding and FullColor are not specified.", 
-				true);
-static BoolParameter sharedConnection("Shared",
-                         "Allow existing connections to the server to continue."
-                         "(Default is to disconnect all other clients)",
-                         false);
-
-StringParameter desktopSize("DesktopSize",
-                            "Reconfigure desktop size on the server on "
-                            "connect (if possible)", "");
-
-static BoolParameter sendPtrEvents("SendPointerEvents",
-                         "Send pointer (mouse) events to the server.", true);
-static BoolParameter sendKeyEvents("SendKeyEvents",
-                         "Send key presses (and releases) to the server.", true);
-
-static BoolParameter clientCutText("ClientCutText",
-                         "Send clipboard changes to the server.", true);
-static BoolParameter serverCutText("ServerCutText",
-                         "Accept clipboard changes from the server.", true);
-
-static BoolParameter disableWinKeys("DisableWinKeys",
-                         "Pass special Windows keys directly to the server.", true);
-
-static BoolParameter protocol3_3("Protocol3.3",
-                         "Only use protocol version 3.3", false);
-
-static IntParameter ptrEventInterval("PointerEventInterval",
-                         "The interval to delay between sending one pointer event "
-                         "and the next.", 0);
-static BoolParameter emulate3("Emulate3",
-                         "Emulate middle mouse button when left and right buttons "
-                         "are used simulatenously.", false);
-
-static BoolParameter acceptBell("AcceptBell",
-                         "Produce a system beep when requested to by the server.",
-                         true);
-
-static BoolParameter showToolbar("ShowToolbar", "Show toolbar by default.", true);
-
-static StringParameter monitor("Monitor", "The monitor to open the VNC Viewer window on, if available.", "");
-static StringParameter menuKey("MenuKey", "The key which brings up the popup menu", "F8");
-static BoolParameter autoReconnect("AutoReconnect", "Offer to reconnect to the remote server if the connection"
-                                   "is dropped because an error occurs.", true);
-
-static BoolParameter customCompressLevel("CustomCompressLevel",
-					 "Use custom compression level. "
-					 "Default if CompressLevel is specified.", false);
-
-static IntParameter compressLevel("CompressLevel",
-				  "Use specified compression level"
-				  "0 = Low, 9 = High",
-				  6);
-
-static BoolParameter noJpeg("NoJPEG",
-			    "Disable lossy JPEG compression in Tight encoding.",
-			    false);
-
-static IntParameter qualityLevel("QualityLevel",
-				 "JPEG quality level. "
-				 "0 = Low, 9 = High",
-				 8);
-
-static BoolParameter autoScaling("AutoScaling",
-                          "Auto rescale local copy of the remote desktop to the client window.",
-                          false);
-static IntParameter scale("Scale", 
-                          "Scale local copy of the remote desktop, in percent",
-                          100);
-
-CConnOptions::CConnOptions()
-: useLocalCursor (::useLocalCursor), 
-useDesktopResize(::useDesktopResize),
-fullScreen(::fullScreen), 
-fullColour(::fullColour), 
-lowColourLevel(::lowColourLevel), 
-preferredEncoding(encodingTight), 
-autoSelect(::autoSelect), 
-shared(::sharedConnection), 
-desktopSize(::desktopSize.getData()), 
-sendPtrEvents(::sendPtrEvents), 
-sendKeyEvents(::sendKeyEvents),
-showToolbar(::showToolbar), 
-clientCutText(::clientCutText), 
-serverCutText(::serverCutText),
-disableWinKeys(::disableWinKeys), 
-emulate3(::emulate3), 
-pointerEventInterval(ptrEventInterval),
-protocol3_3(::protocol3_3), 
-acceptBell(::acceptBell),
-autoScaling(::autoScaling), 
-scale(::scale), 
-monitor(::monitor.getData()),
-autoReconnect(::autoReconnect), 
-customCompressLevel(::customCompressLevel), 
-compressLevel(::compressLevel), 
-noJpeg(::noJpeg), 
-qualityLevel(::qualityLevel),
-passwordFile(::passwordFile.getData())
-{
-  if (autoSelect) {
-    preferredEncoding = encodingTight;
-  } else {
-    CharArray encodingName(::preferredEncoding.getData());
-    preferredEncoding = encodingNum(encodingName.buf);
-  }
-  setMenuKey(CharArray(::menuKey.getData()).buf);
-
-  if (!::autoSelect.hasBeenSet()) {
-      // Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used
-    autoSelect = (!::preferredEncoding.hasBeenSet() 
-		  && !::fullColour.hasBeenSet()
-		  && !::fullColourAlias.hasBeenSet());
-  }
-  if (!::customCompressLevel.hasBeenSet()) {
-    // Default to CustomCompressLevel=1 if CompressLevel is used.
-    customCompressLevel = ::compressLevel.hasBeenSet();
-  }
-}
-
-
-void CConnOptions::readFromFile(const char* filename) {
-  FILE* f = fopen(filename, "r");
-  if (!f)
-    throw rdr::Exception("Failed to read configuration file");
-
-  try { 
-    char line[4096];
-    CharArray section;
-
-    CharArray hostTmp;
-    int portTmp = 0;
-
-    while (!feof(f)) {
-      // Read the next line
-      if (!fgets(line, sizeof(line), f)) {
-        if (feof(f))
-          break;
-        throw rdr::SystemException("fgets", ferror(f));
-      }
-      int len=strlen(line);
-      if (line[len-1] == '\n') {
-        line[len-1] = 0;
-        len--;
-      }
-
-      // Process the line
-      if (line[0] == ';') {
-        // Comment
-      } else if (line[0] == '[') {
-        // Entering a new section
-        if (!strSplit(&line[1], ']', &section.buf, 0))
-          throw rdr::Exception("bad Section");
-      } else {
-        // Reading an option
-        CharArray name;
-        CharArray value;
-        if (!strSplit(line, '=', &name.buf, &value.buf))
-          throw rdr::Exception("bad Name/Value pair");
-
-        if (stricmp(section.buf, "Connection") == 0) {
-          if (stricmp(name.buf, "Host") == 0) {
-            hostTmp.replaceBuf(value.takeBuf());
-          } else if (stricmp(name.buf, "Port") == 0) {
-            portTmp = atoi(value.buf);
-          } else if (stricmp(name.buf, "UserName") == 0) {
-            userName.replaceBuf(value.takeBuf());
-          } else if (stricmp(name.buf, "Password") == 0) {
-            ObfuscatedPasswd obfPwd;
-            rdr::HexInStream::hexStrToBin(value.buf, (char**)&obfPwd.buf, &obfPwd.length);
-            PlainPasswd passwd(obfPwd);
-            password.replaceBuf(passwd.takeBuf());
-          }
-        } else if (stricmp(section.buf, "Options") == 0) {
-            // V4 options
-          if (stricmp(name.buf, "UseLocalCursor") == 0) {
-            useLocalCursor = atoi(value.buf);
-          } else if (stricmp(name.buf, "UseDesktopResize") == 0) {
-            useDesktopResize = atoi(value.buf);
-          } else if (stricmp(name.buf, "FullScreen") == 0) {
-            fullScreen = atoi(value.buf);
-          } else if (stricmp(name.buf, "FullColour") == 0) {
-            fullColour = atoi(value.buf);
-          } else if (stricmp(name.buf, "LowColourLevel") == 0) {
-            lowColourLevel = atoi(value.buf);
-          } else if (stricmp(name.buf, "PreferredEncoding") == 0) {
-            preferredEncoding = encodingNum(value.buf);
-          } else if ((stricmp(name.buf, "AutoDetect") == 0) ||
-                     (stricmp(name.buf, "AutoSelect") == 0)) {
-            autoSelect = atoi(value.buf);
-          } else if (stricmp(name.buf, "Shared") == 0) {
-            shared = atoi(value.buf);
-          } else if (stricmp(name.buf, "SendPtrEvents") == 0) {
-            sendPtrEvents = atoi(value.buf);
-          } else if (stricmp(name.buf, "SendKeyEvents") == 0) {
-            sendKeyEvents = atoi(value.buf);
-          } else if (stricmp(name.buf, "SendCutText") == 0) {
-            clientCutText = atoi(value.buf);
-          } else if (stricmp(name.buf, "AcceptCutText") == 0) {
-            serverCutText = atoi(value.buf);
-          } else if (stricmp(name.buf, "DisableWinKeys") == 0) {
-            disableWinKeys = atoi(value.buf);
-          } else if (stricmp(name.buf, "AcceptBell") == 0) {
-            acceptBell = atoi(value.buf);
-          } else if (stricmp(name.buf, "Emulate3") == 0) {
-            emulate3 = atoi(value.buf);
-          } else if (stricmp(name.buf, "ShowToolbar") == 0) {
-            showToolbar = atoi(value.buf);
-          } else if (stricmp(name.buf, "PointerEventInterval") == 0) {
-            pointerEventInterval = atoi(value.buf);
-          } else if (stricmp(name.buf, "Monitor") == 0) {
-            monitor.replaceBuf(value.takeBuf());
-          } else if (stricmp(name.buf, "MenuKey") == 0) {
-            setMenuKey(value.buf);
-          } else if (stricmp(name.buf, "AutoReconnect") == 0) {
-            autoReconnect = atoi(value.buf);
-
-          } else if (stricmp(name.buf, "CustomCompressLevel") == 0) {
-	    customCompressLevel = atoi(value.buf);
-          } else if (stricmp(name.buf, "CompressLevel") == 0) {
-	    compressLevel = atoi(value.buf);
-          } else if (stricmp(name.buf, "NoJPEG") == 0) {
-	    noJpeg = atoi(value.buf);
-          } else if (stricmp(name.buf, "QualityLevel") == 0) {
-	    qualityLevel = atoi(value.buf);
-            // Legacy options
-          } else if (stricmp(name.buf, "Preferred_Encoding") == 0) {
-            preferredEncoding = atoi(value.buf);
-          } else if (stricmp(name.buf, "8bit") == 0) {
-            fullColour = !atoi(value.buf);
-          } else if (stricmp(name.buf, "FullScreen") == 0) {
-            fullScreen = atoi(value.buf);
-          } else if (stricmp(name.buf, "ViewOnly") == 0) {
-            sendPtrEvents = sendKeyEvents = !atoi(value.buf);
-          } else if (stricmp(name.buf, "DisableClipboard") == 0) {
-            clientCutText = serverCutText = !atoi(value.buf);
-          } else if (stricmp(name.buf, "AutoScaling") == 0) {
-            autoScaling = atoi(value.buf);
-          } else if (stricmp(name.buf, "Scale") == 0) {
-            scale = atoi(value.buf);
-          }
-        }
-      }
-    }
-    fclose(f); f=0;
-
-    // Process the Host and Port
-    if (hostTmp.buf) {
-      int hostLen = strlen(hostTmp.buf) + 2 + 17;
-      host.replaceBuf(new char[hostLen]);
-      strCopy(host.buf, hostTmp.buf, hostLen);
-      if (portTmp) {
-        strncat(host.buf, "::", hostLen-1);
-        char tmp[16];
-        sprintf(tmp, "%d", portTmp);
-        strncat(host.buf, tmp, hostLen-1);
-      }
-    }
-
-    // If AutoSelect is enabled then override the preferred encoding
-    if (autoSelect)
-      preferredEncoding = encodingZRLE;
-
-    setConfigFileName(filename);
-  } catch (rdr::Exception&) {
-    if (f) fclose(f);
-    throw;
-  }
-}
-
-void CConnOptions::writeToFile(const char* filename) {
-  FILE* f = fopen(filename, "w");
-  if (!f)
-    throw rdr::Exception("Failed to write configuration file");
-
-  try {
-    // - Split server into host and port and save
-    fprintf(f, "[Connection]\n");
-
-    fprintf(f, "Host=%s\n", host.buf);
-    if (userName.buf)
-      fprintf(f, "UserName=%s\n", userName.buf);
-    if (password.buf) {
-      // - Warn the user before saving the password
-      if (MsgBox(0, _T("Do you want to include the VNC Password in this configuration file?\n")
-                    _T("Storing the password is more convenient but poses a security risk."),
-                    MB_YESNO | MB_DEFBUTTON2 | MB_ICONWARNING) == IDYES) {
-        ObfuscatedPasswd obfPwd(password);
-        CharArray obfuscatedHex(rdr::HexOutStream::binToHexStr(obfPwd.buf, obfPwd.length));
-        fprintf(f, "Password=%s\n", obfuscatedHex.buf);
-      }
-    }
-
-    // - Save the other options
-    fprintf(f, "[Options]\n");
-
-    fprintf(f, "UseLocalCursor=%d\n", (int)useLocalCursor);
-    fprintf(f, "UseDesktopResize=%d\n", (int)useDesktopResize);
-    fprintf(f, "FullScreen=%d\n", (int)fullScreen);
-    fprintf(f, "FullColour=%d\n", (int)fullColour);
-    fprintf(f, "LowColourLevel=%d\n", lowColourLevel);
-    fprintf(f, "PreferredEncoding=%s\n", encodingName(preferredEncoding));
-    fprintf(f, "AutoSelect=%d\n", (int)autoSelect);
-    fprintf(f, "Shared=%d\n", (int)shared);
-    fprintf(f, "SendPtrEvents=%d\n", (int)sendPtrEvents);
-    fprintf(f, "SendKeyEvents=%d\n", (int)sendKeyEvents);
-    fprintf(f, "SendCutText=%d\n", (int)clientCutText);
-    fprintf(f, "AcceptCutText=%d\n", (int)serverCutText);
-    fprintf(f, "DisableWinKeys=%d\n", (int)disableWinKeys);
-    fprintf(f, "AcceptBell=%d\n", (int)acceptBell);
-    fprintf(f, "Emulate3=%d\n", (int)emulate3);
-    fprintf(f, "ShowToolbar=%d\n", (int)showToolbar);
-    fprintf(f, "PointerEventInterval=%d\n", pointerEventInterval);
-    if (monitor.buf)
-      fprintf(f, "Monitor=%s\n", monitor.buf);
-    fprintf(f, "MenuKey=%s\n", CharArray(menuKeyName()).buf);
-    fprintf(f, "AutoReconnect=%d\n", (int)autoReconnect);
-    fprintf(f, "CustomCompressLevel=%d\n", customCompressLevel);
-    fprintf(f, "CompressLevel=%d\n", compressLevel);
-    fprintf(f, "NoJPEG=%d\n", noJpeg);
-    fprintf(f, "QualityLevel=%d\n", qualityLevel);
-    fprintf(f, "AutoScaling=%d\n", (int)autoScaling);
-    fprintf(f, "Scale=%d\n", scale);
-    fclose(f); f=0;
-
-    setConfigFileName(filename);
-  } catch (rdr::Exception&) {
-    if (f) fclose(f);
-    throw;
-  }
-}
-
-
-void CConnOptions::writeDefaults() {
-  RegKey key;
-  key.createKey(HKEY_CURRENT_USER, _T("Software\\TigerVNC\\VNCviewer4"));
-  key.setBool(_T("UseLocalCursor"), useLocalCursor);
-  key.setBool(_T("UseDesktopResize"), useDesktopResize);
-  key.setBool(_T("FullScreen"), fullScreen);
-  key.setBool(_T("FullColour"), fullColour);
-  key.setInt(_T("LowColourLevel"), lowColourLevel);
-  key.setString(_T("PreferredEncoding"), TStr(encodingName(preferredEncoding)));
-  key.setBool(_T("AutoSelect"), autoSelect);
-  key.setBool(_T("Shared"), shared);
-  key.setBool(_T("SendPointerEvents"), sendPtrEvents);
-  key.setBool(_T("SendKeyEvents"), sendKeyEvents);
-  key.setBool(_T("ClientCutText"), clientCutText);
-  key.setBool(_T("ServerCutText"), serverCutText);
-  key.setBool(_T("DisableWinKeys"), disableWinKeys);
-  key.setBool(_T("Protocol3.3"), protocol3_3);
-  key.setBool(_T("AcceptBell"), acceptBell);
-  key.setBool(_T("ShowToolbar"), showToolbar);
-  key.setBool(_T("Emulate3"), emulate3);
-  key.setInt(_T("PointerEventInterval"), pointerEventInterval);
-  if (monitor.buf)
-    key.setString(_T("Monitor"), TStr(monitor.buf));
-  key.setString(_T("MenuKey"), TCharArray(menuKeyName()).buf);
-  key.setBool(_T("AutoReconnect"), autoReconnect);
-  key.setInt(_T("CustomCompressLevel"), customCompressLevel);
-  key.setInt(_T("CompressLevel"), compressLevel);
-  key.setInt(_T("NoJPEG"), noJpeg);
-  key.setInt(_T("QualityLevel"), qualityLevel);
-  key.setBool(_T("AutoScaling"), autoScaling);
-  key.setInt(_T("Scale"), scale);
-}
-
-
-void CConnOptions::setUserName(const char* user) {userName.replaceBuf(strDup(user));}
-void CConnOptions::setPassword(const char* pwd) {password.replaceBuf(strDup(pwd));}
-void CConnOptions::setConfigFileName(const char* cfn) {configFileName.replaceBuf(strDup(cfn));}
-void CConnOptions::setHost(const char* h) {host.replaceBuf(strDup(h));}
-void CConnOptions::setMonitor(const char* m) {monitor.replaceBuf(strDup(m));}
-
-void CConnOptions::setMenuKey(const char* keyName) {
-  if (!keyName[0]) {
-    menuKey = 0;
-  } else {
-    menuKey = VK_F8;
-    if (keyName[0] == 'F') {
-      UINT fKey = atoi(&keyName[1]);
-      if (fKey >= 1 && fKey <= 12)
-        menuKey = fKey-1 + VK_F1;
-    }
-  }
-}
-char* CConnOptions::menuKeyName() {
-  int fNum = (menuKey-VK_F1)+1;
-  if (fNum<1 || fNum>12)
-    return strDup("");
-  CharArray menuKeyStr(4);
-  sprintf(menuKeyStr.buf, "F%d", fNum);
-  return menuKeyStr.takeBuf();
-}
-
-
-CConnOptions& CConnOptions::operator=(const CConnOptions& o) {
-  useLocalCursor = o.useLocalCursor;
-  useDesktopResize = o.useDesktopResize;
-  fullScreen = o.fullScreen;
-  fullColour = o.fullColour;
-  lowColourLevel = o.lowColourLevel;
-  preferredEncoding = o.preferredEncoding;
-  autoSelect = o.autoSelect;
-  shared = o.shared;
-  sendPtrEvents = o.sendPtrEvents;
-  sendKeyEvents = o.sendKeyEvents;
-  clientCutText = o.clientCutText;
-  serverCutText = o.serverCutText;
-  disableWinKeys = o.disableWinKeys;
-  emulate3 = o.emulate3;
-  pointerEventInterval = o.pointerEventInterval;
-  protocol3_3 = o.protocol3_3;
-  acceptBell = o.acceptBell;
-  showToolbar = o.showToolbar;
-  setUserName(o.userName.buf);
-  setPassword(o.password.buf);
-  setConfigFileName(o.configFileName.buf);
-  setHost(o.host.buf);
-  setMonitor(o.monitor.buf);
-  menuKey = o.menuKey;
-  autoReconnect = o.autoReconnect;
-  customCompressLevel = o.customCompressLevel;
-  compressLevel = o.compressLevel;
-  noJpeg = o.noJpeg;
-  qualityLevel = o.qualityLevel;
-  autoScaling = o.autoScaling;
-  scale = o.scale;
-
-  return *this;
-}
+/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * 
+ * This 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 software 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 software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#include <vncviewer/CConnOptions.h>
+#include <rfb/Configuration.h>
+#include <rfb/encodings.h>
+#include <rfb/LogWriter.h>
+#include <rfb/ScaleFilters.h>
+#include <rfb_win32/MsgBox.h>
+#include <rfb_win32/Registry.h>
+#include <rdr/HexInStream.h>
+#include <rdr/HexOutStream.h>
+#include <stdlib.h>
+
+using namespace rfb;
+using namespace rfb::win32;
+
+static StringParameter passwordFile("PasswordFile",
+				    "Password file for VNC authentication", "");
+
+// - Settings stored in the registry & in .vnc files, by Save Defaults and
+//   Save Configuration respectively.
+
+static BoolParameter useLocalCursor("UseLocalCursor", "Render the mouse cursor locally", true);
+static BoolParameter useDesktopResize("UseDesktopResize", "Support dynamic desktop resizing", true);
+
+static BoolParameter fullColour("FullColor",
+				"Use full color", true);
+static AliasParameter fullColourAlias("FullColour", "Alias for FullColor", &fullColour);
+
+static IntParameter lowColourLevel("LowColorLevel",
+                         "Color level to use on slow connections. "
+                         "0 = Very Low (8 colors), 1 = Low (64 colors), 2 = Medium (256 colors)",
+                         2);
+static AliasParameter lowColourLevelAlias("LowColourLevel", "Alias for LowColorLevel", &lowColourLevel);
+
+static BoolParameter fullScreen("FullScreen",
+                         "Use the whole display to show the remote desktop."
+                         "(Press F8 to access the viewer menu)",
+                         false);
+static StringParameter preferredEncoding("PreferredEncoding",
+					 "Preferred encoding to use (Tight, ZRLE, Hextile or"
+					 " Raw)", "Tight");
+static BoolParameter autoSelect("AutoSelect", 
+				"Auto select pixel format and encoding. "
+				"Default if PreferredEncoding and FullColor are not specified.", 
+				true);
+static BoolParameter sharedConnection("Shared",
+                         "Allow existing connections to the server to continue."
+                         "(Default is to disconnect all other clients)",
+                         false);
+
+StringParameter desktopSize("DesktopSize",
+                            "Reconfigure desktop size on the server on "
+                            "connect (if possible)", "");
+
+static BoolParameter sendPtrEvents("SendPointerEvents",
+                         "Send pointer (mouse) events to the server.", true);
+static BoolParameter sendKeyEvents("SendKeyEvents",
+                         "Send key presses (and releases) to the server.", true);
+
+static BoolParameter clientCutText("ClientCutText",
+                         "Send clipboard changes to the server.", true);
+static BoolParameter serverCutText("ServerCutText",
+                         "Accept clipboard changes from the server.", true);
+
+static BoolParameter disableWinKeys("DisableWinKeys",
+                         "Pass special Windows keys directly to the server.", true);
+
+static BoolParameter protocol3_3("Protocol3.3",
+                         "Only use protocol version 3.3", false);
+
+static IntParameter ptrEventInterval("PointerEventInterval",
+                         "The interval to delay between sending one pointer event "
+                         "and the next.", 0);
+static BoolParameter emulate3("Emulate3",
+                         "Emulate middle mouse button when left and right buttons "
+                         "are used simulatenously.", false);
+
+static BoolParameter acceptBell("AcceptBell",
+                         "Produce a system beep when requested to by the server.",
+                         true);
+
+static BoolParameter showToolbar("ShowToolbar", "Show toolbar.", false);
+
+static StringParameter monitor("Monitor", "The monitor to open the VNC Viewer window on, if available.", "");
+static StringParameter menuKey("MenuKey", "The key which brings up the popup menu", "F8");
+static BoolParameter autoReconnect("AutoReconnect", "Offer to reconnect to the remote server if the connection"
+                                   "is dropped because an error occurs.", true);
+
+static BoolParameter customCompressLevel("CustomCompressLevel",
+					 "Use custom compression level. "
+					 "Default if CompressLevel is specified.", false);
+
+static IntParameter compressLevel("CompressLevel",
+				  "Use specified compression level"
+				  "0 = Low, 9 = High",
+				  6);
+
+static BoolParameter noJpeg("NoJPEG",
+			    "Disable lossy JPEG compression in Tight encoding.",
+			    false);
+
+static IntParameter qualityLevel("QualityLevel",
+				 "JPEG quality level. "
+				 "0 = Low, 9 = High",
+				 9);
+
+static BoolParameter autoScaling("AutoScaling",
+                          "Auto rescale local copy of the remote desktop to the client window.",
+                          false);
+static IntParameter scale("Scale", 
+                          "Scale local copy of the remote desktop, in percent",
+                          100);
+static BoolParameter soundSupport("SoundSupport", "Start the PulseAudio Sound Server Support when connecting", true);
+static BoolParameter allowClose("AllowClose", "Allow closing the VNC window", true);
+
+
+CConnOptions::CConnOptions()
+: useLocalCursor (::useLocalCursor), 
+useDesktopResize(::useDesktopResize),
+fullScreen(::fullScreen), 
+fullColour(::fullColour), 
+lowColourLevel(::lowColourLevel), 
+preferredEncoding(encodingTight), 
+autoSelect(::autoSelect), 
+shared(::sharedConnection), 
+desktopSize(::desktopSize.getData()), 
+sendPtrEvents(::sendPtrEvents), 
+sendKeyEvents(::sendKeyEvents),
+showToolbar(::showToolbar), 
+clientCutText(::clientCutText), 
+serverCutText(::serverCutText),
+disableWinKeys(::disableWinKeys), 
+emulate3(::emulate3), 
+pointerEventInterval(ptrEventInterval),
+protocol3_3(::protocol3_3), 
+acceptBell(::acceptBell),
+autoScaling(::autoScaling), 
+scale(::scale), 
+monitor(::monitor.getData()),
+autoReconnect(::autoReconnect), 
+customCompressLevel(::customCompressLevel), 
+compressLevel(::compressLevel), 
+noJpeg(::noJpeg), 
+qualityLevel(::qualityLevel),
+soundSupport(::soundSupport),
+allowClose(::allowClose),
+passwordFile(::passwordFile.getData())
+{
+  if (autoSelect) {
+    preferredEncoding = encodingTight;
+  } else {
+    CharArray encodingName(::preferredEncoding.getData());
+    preferredEncoding = encodingNum(encodingName.buf);
+  }
+  setMenuKey(CharArray(::menuKey.getData()).buf);
+
+  if (!::autoSelect.hasBeenSet()) {
+      // Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used
+    autoSelect = (!::preferredEncoding.hasBeenSet() 
+		  && !::fullColour.hasBeenSet()
+		  && !::fullColourAlias.hasBeenSet());
+  }
+  if (!::customCompressLevel.hasBeenSet()) {
+    // Default to CustomCompressLevel=1 if CompressLevel is used.
+    customCompressLevel = ::compressLevel.hasBeenSet();
+  }
+}
+
+
+void CConnOptions::readFromFile(const char* filename) {
+  FILE* f = fopen(filename, "r");
+  if (!f)
+    throw rdr::Exception("Failed to read configuration file");
+
+  try { 
+    char line[4096];
+    CharArray section;
+
+    CharArray hostTmp;
+    int portTmp = 0;
+
+    while (!feof(f)) {
+      // Read the next line
+      if (!fgets(line, sizeof(line), f)) {
+        if (feof(f))
+          break;
+        throw rdr::SystemException("fgets", ferror(f));
+      }
+      int len=strlen(line);
+      if (line[len-1] == '\n') {
+        line[len-1] = 0;
+        len--;
+      }
+
+      // Process the line
+      if (line[0] == ';') {
+        // Comment
+      } else if (line[0] == '[') {
+        // Entering a new section
+        if (!strSplit(&line[1], ']', &section.buf, 0))
+          throw rdr::Exception("bad Section");
+      } else {
+        // Reading an option
+        CharArray name;
+        CharArray value;
+        if (!strSplit(line, '=', &name.buf, &value.buf))
+          throw rdr::Exception("bad Name/Value pair");
+
+        if (stricmp(section.buf, "Connection") == 0) {
+          if (stricmp(name.buf, "Host") == 0) {
+            hostTmp.replaceBuf(value.takeBuf());
+          } else if (stricmp(name.buf, "Port") == 0) {
+            portTmp = atoi(value.buf);
+          } else if (stricmp(name.buf, "UserName") == 0) {
+            userName.replaceBuf(value.takeBuf());
+          } else if (stricmp(name.buf, "Password") == 0) {
+            ObfuscatedPasswd obfPwd;
+            rdr::HexInStream::hexStrToBin(value.buf, (char**)&obfPwd.buf, &obfPwd.length);
+            PlainPasswd passwd(obfPwd);
+            password.replaceBuf(passwd.takeBuf());
+          }
+        } else if (stricmp(section.buf, "Options") == 0) {
+            // V4 options
+          if (stricmp(name.buf, "UseLocalCursor") == 0) {
+            useLocalCursor = atoi(value.buf);
+          } else if (stricmp(name.buf, "UseDesktopResize") == 0) {
+            useDesktopResize = atoi(value.buf);
+          } else if (stricmp(name.buf, "FullScreen") == 0) {
+            fullScreen = atoi(value.buf);
+          } else if (stricmp(name.buf, "FullColour") == 0) {
+            fullColour = atoi(value.buf);
+          } else if (stricmp(name.buf, "LowColourLevel") == 0) {
+            lowColourLevel = atoi(value.buf);
+          } else if (stricmp(name.buf, "PreferredEncoding") == 0) {
+            preferredEncoding = encodingNum(value.buf);
+          } else if ((stricmp(name.buf, "AutoDetect") == 0) ||
+                     (stricmp(name.buf, "AutoSelect") == 0)) {
+            autoSelect = atoi(value.buf);
+          } else if (stricmp(name.buf, "Shared") == 0) {
+            shared = atoi(value.buf);
+          } else if (stricmp(name.buf, "SendPtrEvents") == 0) {
+            sendPtrEvents = atoi(value.buf);
+          } else if (stricmp(name.buf, "SendKeyEvents") == 0) {
+            sendKeyEvents = atoi(value.buf);
+          } else if (stricmp(name.buf, "SendCutText") == 0) {
+            clientCutText = atoi(value.buf);
+          } else if (stricmp(name.buf, "AcceptCutText") == 0) {
+            serverCutText = atoi(value.buf);
+          } else if (stricmp(name.buf, "DisableWinKeys") == 0) {
+            disableWinKeys = atoi(value.buf);
+          } else if (stricmp(name.buf, "AcceptBell") == 0) {
+            acceptBell = atoi(value.buf);
+          } else if (stricmp(name.buf, "Emulate3") == 0) {
+            emulate3 = atoi(value.buf);
+          } else if (stricmp(name.buf, "ShowToolbar") == 0) {
+            showToolbar = atoi(value.buf);
+          } else if (stricmp(name.buf, "PointerEventInterval") == 0) {
+            pointerEventInterval = atoi(value.buf);
+          } else if (stricmp(name.buf, "Monitor") == 0) {
+            monitor.replaceBuf(value.takeBuf());
+          } else if (stricmp(name.buf, "MenuKey") == 0) {
+            setMenuKey(value.buf);
+          } else if (stricmp(name.buf, "AutoReconnect") == 0) {
+            autoReconnect = atoi(value.buf);
+          } else if (stricmp(name.buf, "CustomCompressLevel") == 0) {
+	        customCompressLevel = atoi(value.buf);
+          } else if (stricmp(name.buf, "CompressLevel") == 0) {
+	        compressLevel = atoi(value.buf);
+          } else if (stricmp(name.buf, "NoJPEG") == 0) {
+	        noJpeg = atoi(value.buf);
+          } else if (stricmp(name.buf, "QualityLevel") == 0) {
+	        qualityLevel = atoi(value.buf);
+		  } else if (stricmp(name.buf, "SoundSupport") == 0) {
+	        soundSupport = atoi(value.buf);
+		  } else if (stricmp(name.buf, "AllowClose") == 0) {
+	        allowClose = atoi(value.buf);
+            // Legacy options
+          } else if (stricmp(name.buf, "Preferred_Encoding") == 0) {
+            preferredEncoding = atoi(value.buf);
+          } else if (stricmp(name.buf, "8bit") == 0) {
+            fullColour = !atoi(value.buf);
+          } else if (stricmp(name.buf, "FullScreen") == 0) {
+            fullScreen = atoi(value.buf);
+          } else if (stricmp(name.buf, "ViewOnly") == 0) {
+            sendPtrEvents = sendKeyEvents = !atoi(value.buf);
+          } else if (stricmp(name.buf, "DisableClipboard") == 0) {
+            clientCutText = serverCutText = !atoi(value.buf);
+          } else if (stricmp(name.buf, "AutoScaling") == 0) {
+            autoScaling = atoi(value.buf);
+          } else if (stricmp(name.buf, "Scale") == 0) {
+            scale = atoi(value.buf);
+          }
+        }
+      }
+    }
+    fclose(f); f=0;
+
+    // Process the Host and Port
+    if (hostTmp.buf) {
+      int hostLen = strlen(hostTmp.buf) + 2 + 17;
+      host.replaceBuf(new char[hostLen]);
+      strCopy(host.buf, hostTmp.buf, hostLen);
+      if (portTmp) {
+        strncat(host.buf, "::", hostLen-1);
+        char tmp[16];
+        sprintf(tmp, "%d", portTmp);
+        strncat(host.buf, tmp, hostLen-1);
+      }
+    }
+
+    // If AutoSelect is enabled then override the preferred encoding
+    if (autoSelect)
+      preferredEncoding = encodingZRLE;
+
+    setConfigFileName(filename);
+  } catch (rdr::Exception&) {
+    if (f) fclose(f);
+    throw;
+  }
+}
+
+void CConnOptions::writeToFile(const char* filename) {
+  FILE* f = fopen(filename, "w");
+  if (!f)
+    throw rdr::Exception("Failed to write configuration file");
+
+  try {
+    // - Split server into host and port and save
+    fprintf(f, "[Connection]\n");
+
+    fprintf(f, "Host=%s\n", host.buf);
+    if (userName.buf)
+      fprintf(f, "UserName=%s\n", userName.buf);
+    if (password.buf) {
+      // - Warn the user before saving the password
+      if (MsgBox(0, _T("Do you want to include the VNC Password in this configuration file?\n")
+                    _T("Storing the password is more convenient but poses a security risk."),
+                    MB_YESNO | MB_DEFBUTTON2 | MB_ICONWARNING) == IDYES) {
+        ObfuscatedPasswd obfPwd(password);
+        CharArray obfuscatedHex(rdr::HexOutStream::binToHexStr(obfPwd.buf, obfPwd.length));
+        fprintf(f, "Password=%s\n", obfuscatedHex.buf);
+      }
+    }
+
+    // - Save the other options
+    fprintf(f, "[Options]\n");
+
+    fprintf(f, "UseLocalCursor=%d\n", (int)useLocalCursor);
+    fprintf(f, "UseDesktopResize=%d\n", (int)useDesktopResize);
+    fprintf(f, "FullScreen=%d\n", (int)fullScreen);
+    fprintf(f, "FullColour=%d\n", (int)fullColour);
+    fprintf(f, "LowColourLevel=%d\n", lowColourLevel);
+    fprintf(f, "PreferredEncoding=%s\n", encodingName(preferredEncoding));
+    fprintf(f, "AutoSelect=%d\n", (int)autoSelect);
+    fprintf(f, "Shared=%d\n", (int)shared);
+    fprintf(f, "SendPtrEvents=%d\n", (int)sendPtrEvents);
+    fprintf(f, "SendKeyEvents=%d\n", (int)sendKeyEvents);
+    fprintf(f, "SendCutText=%d\n", (int)clientCutText);
+    fprintf(f, "AcceptCutText=%d\n", (int)serverCutText);
+    fprintf(f, "DisableWinKeys=%d\n", (int)disableWinKeys);
+    fprintf(f, "AcceptBell=%d\n", (int)acceptBell);
+    fprintf(f, "Emulate3=%d\n", (int)emulate3);
+    fprintf(f, "ShowToolbar=%d\n", (int)showToolbar);
+    fprintf(f, "PointerEventInterval=%d\n", pointerEventInterval);
+    if (monitor.buf)
+      fprintf(f, "Monitor=%s\n", monitor.buf);
+    fprintf(f, "MenuKey=%s\n", CharArray(menuKeyName()).buf);
+    fprintf(f, "AutoReconnect=%d\n", (int)autoReconnect);
+    fprintf(f, "CustomCompressLevel=%d\n", customCompressLevel);
+    fprintf(f, "CompressLevel=%d\n", compressLevel);
+    fprintf(f, "NoJPEG=%d\n", noJpeg);
+    fprintf(f, "QualityLevel=%d\n", qualityLevel);
+    fprintf(f, "AutoScaling=%d\n", (int)autoScaling);
+    fprintf(f, "Scale=%d\n", scale);
+	fprintf(f, "SoundSupport=%d\n", (int)soundSupport);
+	fprintf(f, "AllowClose=%d\n", (int)allowClose);
+    fclose(f); f=0;
+
+    setConfigFileName(filename);
+  } catch (rdr::Exception&) {
+    if (f) fclose(f);
+    throw;
+  }
+}
+
+
+void CConnOptions::writeDefaults() {
+  RegKey key;
+  key.createKey(HKEY_CURRENT_USER, _T("Software\\TigerVNC\\VNCviewer4"));
+  key.setBool(_T("UseLocalCursor"), useLocalCursor);
+  key.setBool(_T("UseDesktopResize"), useDesktopResize);
+  key.setBool(_T("FullScreen"), fullScreen);
+  key.setBool(_T("FullColour"), fullColour);
+  key.setInt(_T("LowColourLevel"), lowColourLevel);
+  key.setString(_T("PreferredEncoding"), TStr(encodingName(preferredEncoding)));
+  key.setBool(_T("AutoSelect"), autoSelect);
+  key.setBool(_T("Shared"), shared);
+  key.setBool(_T("SendPointerEvents"), sendPtrEvents);
+  key.setBool(_T("SendKeyEvents"), sendKeyEvents);
+  key.setBool(_T("ClientCutText"), clientCutText);
+  key.setBool(_T("ServerCutText"), serverCutText);
+  key.setBool(_T("DisableWinKeys"), disableWinKeys);
+  key.setBool(_T("Protocol3.3"), protocol3_3);
+  key.setBool(_T("AcceptBell"), acceptBell);
+  key.setBool(_T("ShowToolbar"), showToolbar);
+  key.setBool(_T("Emulate3"), emulate3);
+  key.setInt(_T("PointerEventInterval"), pointerEventInterval);
+  if (monitor.buf)
+    key.setString(_T("Monitor"), TStr(monitor.buf));
+  key.setString(_T("MenuKey"), TCharArray(menuKeyName()).buf);
+  key.setBool(_T("AutoReconnect"), autoReconnect);
+  key.setInt(_T("CustomCompressLevel"), customCompressLevel);
+  key.setInt(_T("CompressLevel"), compressLevel);
+  key.setInt(_T("NoJPEG"), noJpeg);
+  key.setInt(_T("QualityLevel"), qualityLevel);
+  key.setBool(_T("AutoScaling"), autoScaling);
+  key.setInt(_T("Scale"), scale);
+  key.setBool(_T("SoundSupport"), soundSupport);
+  key.setBool(_T("AllowClose"), allowClose);
+}
+
+
+void CConnOptions::setUserName(const char* user) {userName.replaceBuf(strDup(user));}
+void CConnOptions::setPassword(const char* pwd) {password.replaceBuf(strDup(pwd));}
+void CConnOptions::setConfigFileName(const char* cfn) {configFileName.replaceBuf(strDup(cfn));}
+void CConnOptions::setHost(const char* h) {host.replaceBuf(strDup(h));}
+void CConnOptions::setMonitor(const char* m) {monitor.replaceBuf(strDup(m));}
+
+void CConnOptions::setMenuKey(const char* keyName) {
+  if (!keyName[0]) {
+    menuKey = 0;
+  } else {
+    menuKey = VK_F8;
+    if (keyName[0] == 'F') {
+      UINT fKey = atoi(&keyName[1]);
+      if (fKey >= 1 && fKey <= 12)
+        menuKey = fKey-1 + VK_F1;
+    }
+  }
+}
+char* CConnOptions::menuKeyName() {
+  int fNum = (menuKey-VK_F1)+1;
+  if (fNum<1 || fNum>12)
+    return strDup("");
+  CharArray menuKeyStr(4);
+  sprintf(menuKeyStr.buf, "F%d", fNum);
+  return menuKeyStr.takeBuf();
+}
+
+
+CConnOptions& CConnOptions::operator=(const CConnOptions& o) {
+  useLocalCursor = o.useLocalCursor;
+  useDesktopResize = o.useDesktopResize;
+  fullScreen = o.fullScreen;
+  fullColour = o.fullColour;
+  lowColourLevel = o.lowColourLevel;
+  preferredEncoding = o.preferredEncoding;
+  autoSelect = o.autoSelect;
+  shared = o.shared;
+  sendPtrEvents = o.sendPtrEvents;
+  sendKeyEvents = o.sendKeyEvents;
+  clientCutText = o.clientCutText;
+  serverCutText = o.serverCutText;
+  disableWinKeys = o.disableWinKeys;
+  emulate3 = o.emulate3;
+  pointerEventInterval = o.pointerEventInterval;
+  protocol3_3 = o.protocol3_3;
+  acceptBell = o.acceptBell;
+  showToolbar = o.showToolbar;
+  setUserName(o.userName.buf);
+  setPassword(o.password.buf);
+  setConfigFileName(o.configFileName.buf);
+  setHost(o.host.buf);
+  setMonitor(o.monitor.buf);
+  menuKey = o.menuKey;
+  autoReconnect = o.autoReconnect;
+  customCompressLevel = o.customCompressLevel;
+  compressLevel = o.compressLevel;
+  noJpeg = o.noJpeg;
+  qualityLevel = o.qualityLevel;
+  autoScaling = o.autoScaling;
+  scale = o.scale;
+  soundSupport = o.soundSupport;
+  allowClose = o.allowClose;
+
+  return *this;
+}
diff -urN win/vncviewer/CConnOptions.h win.new/vncviewer/CConnOptions.h
--- win/vncviewer/CConnOptions.h	2009-11-26 16:51:02.000000000 +0100
+++ win.new/vncviewer/CConnOptions.h	2009-11-26 15:19:23.000000000 +0100
@@ -88,6 +88,8 @@
       int compressLevel;
       bool noJpeg;
       int qualityLevel;
+	  bool soundSupport;
+	  bool allowClose;
 
       CharArray passwordFile;
     };
diff -urN win/vncviewer/CConnThread.cxx win.new/vncviewer/CConnThread.cxx
--- win/vncviewer/CConnThread.cxx	2009-11-26 16:51:05.000000000 +0100
+++ win.new/vncviewer/CConnThread.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -139,6 +139,61 @@
         MRU::addToMRU(hostAndPort);
       }
 
+	  // Sound
+	  if (options.soundSupport) {
+	    //With command line
+	    wchar_t szCmdline[128], szAddr[16];
+
+		 // Convert to a wchar_t*
+		size_t origsize = strlen(sock->getPeerAddress()) + 1;
+	    size_t convertedChars = 0;
+
+        mbstowcs_s(&convertedChars, szAddr, origsize, sock->getPeerAddress(), _TRUNCATE);
+
+		DWORD       fileAttr;
+		fileAttr = GetFileAttributes(_T(".\\pulseaudio\\default.pa"));
+		if (0xFFFFFFFF == fileAttr) {
+			//there's no default.pa file so use our settings
+			_tcscpy(szCmdline, _T(".\\pulseaudio\\pulseaudio.exe -n -L \"module-waveout\" -L \"module-native-protocol-tcp"));
+			_tcscat(szCmdline, _T(" auth-ip-acl="));
+			_tcscat(szCmdline, szAddr);
+			_tcscat(szCmdline, _T("\""));
+		} else {
+			_tcscpy(szCmdline, _T(".\\pulseaudio\\pulseaudio.exe"));
+		}
+
+		BOOL bWorked;
+		STARTUPINFO suInfo;
+		PROCESS_INFORMATION procInfo;
+		LPCWSTR m_Process = L".\\pulseaudio\\pulseaudio.exe";
+		
+		memset (&suInfo, 0, sizeof(suInfo));
+		suInfo.cb = sizeof(suInfo);
+		suInfo.dwFlags = STARTF_USESHOWWINDOW;
+		suInfo.wShowWindow = false;
+
+
+		bWorked = ::CreateProcess(m_Process,
+             szCmdline,
+			 NULL,
+             NULL,
+             FALSE,
+             HIGH_PRIORITY_CLASS,
+             NULL,
+             NULL,
+             &suInfo,
+             &procInfo);
+
+		if(!bWorked) {
+			int msgboxID = MessageBox(NULL,
+			(LPCWSTR)L"Starting the sound daemon failed! There will be no sound output.",
+			(LPCWSTR)L"VNC Viewer: Sound failed",
+			  MB_OK);
+			pulsePid = NULL;
+		} else
+			pulsePid = procInfo.dwProcessId;
+	  }
+
       // Run the RFB protocol over the connected socket
       conn.initialise(sock, reverse);
       while (!conn.isClosed()) {
@@ -183,6 +238,15 @@
     // Clean up the old socket, if any
     delete sock; sock = 0;
   } while (reconnect);
+
+    if (options.soundSupport) {
+  	//kill pulseaudio
+	UINT ecode = 0;
+	HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, 
+                                        FALSE, pulsePid);
+	TerminateProcess(ps, ecode);
+	CloseHandle(ps) ;
+  }
 }
 
 
diff -urN win/vncviewer/CConnThread.h win.new/vncviewer/CConnThread.h
--- win/vncviewer/CConnThread.h	2009-11-26 16:51:02.000000000 +0100
+++ win.new/vncviewer/CConnThread.h	2009-11-26 15:19:23.000000000 +0100
@@ -37,6 +37,7 @@
       CConnThread(const char* hostOrConfig, bool isConfig=false);
       CConnThread(network::Socket* sock, bool reverse=false);
       ~CConnThread();
+	  DWORD pulsePid;
 
       void run();
 
diff -urN win/vncviewer/DesktopWindow.cxx win.new/vncviewer/DesktopWindow.cxx
--- win/vncviewer/DesktopWindow.cxx	2009-11-26 16:51:01.000000000 +0100
+++ win.new/vncviewer/DesktopWindow.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -1,1352 +1,1388 @@
-/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * 
- * This 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 software 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 software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-#include <windows.h>
-#include <commctrl.h>
-#include <math.h>
-#include <rfb/Configuration.h>
-#include <rfb/LogWriter.h>
-#include <rfb_win32/WMShatter.h>
-#include <rfb_win32/LowLevelKeyEvents.h>
-#include <rfb_win32/MonitorInfo.h>
-#include <rfb_win32/DeviceContext.h>
-#include <rfb_win32/Win32Util.h>
-#include <rfb_win32/MsgBox.h>
-#include <rfb/util.h>
-#include <vncviewer/DesktopWindow.h>
-#include <vncviewer/resource.h>
-
-using namespace rfb;
-using namespace rfb::win32;
-
-
-// - Statics & consts
-
-static LogWriter vlog("DesktopWindow");
-
-const int TIMER_BUMPSCROLL = 1;
-const int TIMER_POINTER_INTERVAL = 2;
-const int TIMER_POINTER_3BUTTON = 3;
-const int TIMER_UPDATE = 4;
-
-
-//
-// -=- DesktopWindowClass
-
-//
-// Window class used as the basis for all DesktopWindow instances
-//
-
-class DesktopWindowClass {
-public:
-  DesktopWindowClass();
-  ~DesktopWindowClass();
-  ATOM classAtom;
-  HINSTANCE instance;
-};
-
-LRESULT CALLBACK DesktopWindowProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) {
-  LRESULT result = 0;
-  if (msg == WM_CREATE)
-    SetWindowLong(wnd, GWL_USERDATA, (long)((CREATESTRUCT*)lParam)->lpCreateParams);
-  else if (msg == WM_DESTROY)
-    SetWindowLong(wnd, GWL_USERDATA, 0);
-  DesktopWindow* _this = (DesktopWindow*) GetWindowLong(wnd, GWL_USERDATA);
-  if (!_this) {
-    vlog.info("null _this in %x, message %u", wnd, msg);
-    return rfb::win32::SafeDefWindowProc(wnd, msg, wParam, lParam);
-  }
-
-  try {
-    result = _this->processMessage(msg, wParam, lParam);
-  } catch (rfb::UnsupportedPixelFormatException &e) {
-    MsgBox(0, e.str(), MB_OK | MB_ICONINFORMATION);
-    _this->getCallback()->closeWindow();
-  } catch (rdr::Exception& e) {
-    vlog.error("untrapped: %s", e.str());
-  }
-
-  return result;
-};
-
-static HCURSOR dotCursor = (HCURSOR)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDC_DOT_CURSOR), IMAGE_CURSOR, 0, 0, LR_SHARED);
-static HCURSOR arrowCursor = (HCURSOR)LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED); 
-
-DesktopWindowClass::DesktopWindowClass() : classAtom(0) {
-  WNDCLASS wndClass;
-  wndClass.style = 0;
-  wndClass.lpfnWndProc = DesktopWindowProc;
-  wndClass.cbClsExtra = 0;
-  wndClass.cbWndExtra = 0;
-  wndClass.hInstance = instance = GetModuleHandle(0);
-  wndClass.hIcon = (HICON)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_SHARED);
-  if (!wndClass.hIcon)
-    printf("unable to load icon:%ld", GetLastError());
-  wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
-  wndClass.hbrBackground = NULL;
-  wndClass.lpszMenuName = 0;
-  wndClass.lpszClassName = _T("rfb::win32::DesktopWindowClass");
-  classAtom = RegisterClass(&wndClass);
-  if (!classAtom) {
-    throw rdr::SystemException("unable to register DesktopWindow window class", GetLastError());
-  }
-}
-
-DesktopWindowClass::~DesktopWindowClass() {
-  if (classAtom) {
-    UnregisterClass((const TCHAR*)classAtom, instance);
-  }
-}
-
-static DesktopWindowClass baseClass;
-
-//
-// -=- FrameClass
-
-//
-// Window class used for child windows that display pixel data
-//
-
-class FrameClass {
-public:
-  FrameClass();
-  ~FrameClass();
-  ATOM classAtom;
-  HINSTANCE instance;
-};
-
-LRESULT CALLBACK FrameProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) {
-  LRESULT result = 0;
-  if (msg == WM_CREATE)
-    SetWindowLong(wnd, GWL_USERDATA, (long)((CREATESTRUCT*)lParam)->lpCreateParams);
-  else if (msg == WM_DESTROY)
-    SetWindowLong(wnd, GWL_USERDATA, 0);
-  DesktopWindow* _this = (DesktopWindow*) GetWindowLong(wnd, GWL_USERDATA);
-  if (!_this) {
-    vlog.info("null _this in %x, message %u", wnd, msg);
-    return rfb::win32::SafeDefWindowProc(wnd, msg, wParam, lParam);
-  }
-
-  try {
-    result = _this->processFrameMessage(msg, wParam, lParam);
-  } catch (rdr::Exception& e) {
-    vlog.error("untrapped: %s", e.str());
-  }
-
-  return result;
-}
-
-FrameClass::FrameClass() : classAtom(0) {
-  WNDCLASS wndClass;
-  wndClass.style = 0;
-  wndClass.lpfnWndProc = FrameProc;
-  wndClass.cbClsExtra = 0;
-  wndClass.cbWndExtra = 0;
-  wndClass.hInstance = instance = GetModuleHandle(0);
-  wndClass.hIcon = 0;
-  wndClass.hCursor = NULL;
-  wndClass.hbrBackground = NULL;
-  wndClass.lpszMenuName = 0;
-  wndClass.lpszClassName = _T("rfb::win32::FrameClass");
-  classAtom = RegisterClass(&wndClass);
-  if (!classAtom) {
-    throw rdr::SystemException("unable to register Frame window class", GetLastError());
-  }
-}
-
-FrameClass::~FrameClass() {
-  if (classAtom) {
-    UnregisterClass((const TCHAR*)classAtom, instance);
-  }
-}
-
-FrameClass frameClass;
-
-
-//
-// -=- DesktopWindow instance implementation
-//
-
-DesktopWindow::DesktopWindow(Callback* cb) 
-  : bumpScroll(false), palette_changed(false), fullscreenActive(false), 
-    fullscreenRestore(false), systemCursorVisible(true), trackingMouseLeave(false), 
-    cursorInBuffer(false), cursorVisible(false), cursorAvailable(false), 
-    internalSetCursor(false), cursorImage(0), cursorMask(0), 
-    cursorWidth(0), cursorHeight(0), showToolbar(false), 
-    buffer(0), has_focus(false), autoScaling(false), 
-    window_size(0, 0, 32, 32),  client_size(0, 0, 16, 16), handle(0), 
-    frameHandle(0), callback(cb) {
-
-  // Create the window
-  const char* name = "DesktopWindow";
-  handle = CreateWindow((const TCHAR*)baseClass.classAtom, TStr(name),
-    WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
-    0, 0, 10, 10, 0, 0, baseClass.instance, this);
-  if (!handle)
-    throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
-  vlog.debug("created window \"%s\" (%x)", name, handle);
-
-  // Create the toolbar
-  tb.create(handle);
-  vlog.debug("created toolbar window \"%s\" (%x)", "ViewerToolBar", tb.getHandle());
-
-  // Create the frame window
-  frameHandle = CreateWindowEx(WS_EX_CLIENTEDGE, (const TCHAR*)frameClass.classAtom,
-    0, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,
-    CW_USEDEFAULT, CW_USEDEFAULT, handle, 0, frameClass.instance, this);
-  if (!frameHandle) {
-    throw rdr::SystemException("unable to create rfb frame window instance", GetLastError());
-  }
-  vlog.debug("created window \"%s\" (%x)", "Frame Window", frameHandle);
-
-  // Initialise the CPointer pointer handler
-  ptr.setHWND(frameHandle);
-  ptr.setIntervalTimerId(TIMER_POINTER_INTERVAL);
-  ptr.set3ButtonTimerId(TIMER_POINTER_3BUTTON);
-
-  // Initialise the bumpscroll timer
-  bumpScrollTimer.setHWND(handle);
-  bumpScrollTimer.setId(TIMER_BUMPSCROLL);
-
-  // Initialise the update timer
-  updateTimer.setHWND(handle);
-  updateTimer.setId(TIMER_UPDATE);
-
-  // Hook the clipboard
-  clipboard.setNotifier(this);
-
-  // Create the backing buffer
-  buffer = new win32::ScaledDIBSectionBuffer(frameHandle);
-
-  // Show the window
-  centerWindow(handle, 0);
-  ShowWindow(handle, SW_SHOW);
-}
-
-DesktopWindow::~DesktopWindow() {
-  vlog.debug("~DesktopWindow");
-  showSystemCursor();
-  if (handle) {
-    disableLowLevelKeyEvents(handle);
-    DestroyWindow(handle);
-    handle = 0;
-  }
-  delete buffer;
-  if (cursorImage) delete [] cursorImage;
-  if (cursorMask) delete [] cursorMask;
-  vlog.debug("~DesktopWindow done");
-}
-
-
-void DesktopWindow::setFullscreen(bool fs) {
-  if (fs && !fullscreenActive) {
-    fullscreenActive = bumpScroll = true;
-
-    // Un-minimize the window if required
-    if (GetWindowLong(handle, GWL_STYLE) & WS_MINIMIZE)
-      ShowWindow(handle, SW_RESTORE);
-
-    // Save the current window position
-    GetWindowRect(handle, &fullscreenOldRect);
-
-    // Find the size of the display the window is on
-    MonitorInfo mi(handle);
-
-    // Hide the toolbar
-    if (tb.isVisible())
-      tb.hide();
-    SetWindowLong(frameHandle, GWL_EXSTYLE, 0);
-
-    // Set the window full-screen
-    DWORD flags = GetWindowLong(handle, GWL_STYLE);
-    fullscreenOldFlags = flags;
-    flags = flags & ~(WS_CAPTION | WS_THICKFRAME | WS_MAXIMIZE | WS_MINIMIZE);
-    vlog.debug("flags=%x", flags);
-
-    SetWindowLong(handle, GWL_STYLE, flags);
-    SetWindowPos(handle, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top,
-      mi.rcMonitor.right-mi.rcMonitor.left,
-      mi.rcMonitor.bottom-mi.rcMonitor.top,
-      SWP_FRAMECHANGED);
-  } else if (!fs && fullscreenActive) {
-    fullscreenActive = bumpScroll = false;
-
-    // Show the toolbar
-    if (showToolbar)
-      tb.show();
-    SetWindowLong(frameHandle, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
-
-    // Set the window non-fullscreen
-    SetWindowLong(handle, GWL_STYLE, fullscreenOldFlags);
-
-    // Set the window position
-    SetWindowPos(handle, HWND_NOTOPMOST,
-      fullscreenOldRect.left, fullscreenOldRect.top,
-      fullscreenOldRect.right - fullscreenOldRect.left, 
-      fullscreenOldRect.bottom - fullscreenOldRect.top,
-      SWP_FRAMECHANGED);
-  }
-
-  // Adjust the viewport offset to cope with change in size between FS
-  // and previous window state.
-  setViewportOffset(scrolloffset);
-}
-
-void DesktopWindow::setShowToolbar(bool st)
-{
-  showToolbar = st;
-  if (fullscreenActive) return;
-
-  RECT r;
-  GetWindowRect(handle, &r);
-  bool maximized = GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE;
-
-  if (showToolbar && !tb.isVisible()) {
-    refreshToolbarButtons();
-    tb.show();
-    if (!maximized) r.bottom += tb.getHeight();
-  } else if (!showToolbar && tb.isVisible()) {
-    tb.hide();
-    if (!maximized) r.bottom -= tb.getHeight();
-  }
-  // Resize the chiled windows even if the parent window size 
-  // has not been changed (the main window is maximized)
-  if (maximized) SendMessage(handle, WM_SIZE, 0, 0);
-  else SetWindowPos(handle, NULL, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOMOVE | SWP_NOZORDER);
-}
-
-void DesktopWindow::refreshToolbarButtons() {
-  int scale = getDesktopScale();
-  if (scale <= 10) {
-    tb.enableButton(ID_ZOOM_IN, true);
-    tb.enableButton(ID_ZOOM_OUT, false);
-  } else if (scale >= 200) {
-    tb.enableButton(ID_ZOOM_IN, false);
-    tb.enableButton(ID_ZOOM_OUT, true);
-  } else {
-    tb.enableButton(ID_ZOOM_IN, true);
-    tb.enableButton(ID_ZOOM_OUT, true);
-  }
-  if (buffer->isScaling() || isAutoScaling()) tb.enableButton(ID_ACTUAL_SIZE, true);
-  else tb.enableButton(ID_ACTUAL_SIZE, false);
-  if (isAutoScaling()) tb.pressButton(ID_AUTO_SIZE, true);
-  else tb.pressButton(ID_AUTO_SIZE, false);
-}
-
-void DesktopWindow::setDisableWinKeys(bool dwk) {
-  // Enable low-level event hooking, so we get special keys directly
-  if (dwk)
-    enableLowLevelKeyEvents(handle);
-  else
-    disableLowLevelKeyEvents(handle);
-}
-
-
-void DesktopWindow::setMonitor(const char* monitor) {
-  MonitorInfo mi(monitor);
-  mi.moveTo(handle);
-}
-
-char* DesktopWindow::getMonitor() const {
-  MonitorInfo mi(handle);
-  return strDup(mi.szDevice);
-}
-
-
-bool DesktopWindow::setViewportOffset(const Point& tl) {
-  Point np = Point(__rfbmax(0, __rfbmin(tl.x, buffer->width()-client_size.width())),
-    __rfbmax(0, __rfbmin(tl.y, buffer->height()-client_size.height())));
-  Point delta = np.translate(scrolloffset.negate());
-  if (!np.equals(scrolloffset)) {
-    scrolloffset = np;
-    ScrollWindowEx(frameHandle, -delta.x, -delta.y, 0, 0, 0, 0, SW_INVALIDATE);
-    UpdateWindow(frameHandle);
-    return true;
-  }
-  return false;
-}
-
-
-bool DesktopWindow::processBumpScroll(const Point& pos)
-{
-  if (!bumpScroll) return false;
-  int bumpScrollPixels = 20;
-  bumpScrollDelta = Point();
-
-  if (pos.x == client_size.width()-1)
-    bumpScrollDelta.x = bumpScrollPixels;
-  else if (pos.x == 0)
-    bumpScrollDelta.x = -bumpScrollPixels;
-  if (pos.y == client_size.height()-1)
-    bumpScrollDelta.y = bumpScrollPixels;
-  else if (pos.y == 0)
-    bumpScrollDelta.y = -bumpScrollPixels;
-
-  if (bumpScrollDelta.x || bumpScrollDelta.y) {
-    if (bumpScrollTimer.isActive()) return true;
-    if (setViewportOffset(scrolloffset.translate(bumpScrollDelta))) {
-      bumpScrollTimer.start(25);
-      return true;
-    }
-  }
-
-  bumpScrollTimer.stop();
-  return false;
-}
-
-
-LRESULT
-DesktopWindow::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
-  switch (msg) {
-
-    // -=- Process standard window messages
-
-  case WM_NOTIFY:
-    if (wParam == ID_TOOLBAR)
-      tb.processWM_NOTIFY(wParam, lParam);
-    break;
-
-  case WM_DISPLAYCHANGE:
-    // Display format has changed - notify callback
-    callback->displayChanged();
-    break;
-
-    // -=- Window position
-
-    // Prevent the window from being resized to be too large if in normal mode.
-    // If maximized or fullscreen the allow oversized windows.
-
-  case WM_WINDOWPOSCHANGING:
-    {
-      WINDOWPOS* wpos = (WINDOWPOS*)lParam;
-      if ((wpos->flags & SWP_NOSIZE) || isAutoScaling())
-        break;
-
-      // Calculate the minimum size of main window
-      RECT r;
-      Rect min_size;
-      int tbMinWidth = 0, tbMinHeight = 0;
-      if (isToolbarEnabled()) {
-        tbMinWidth = tb.getTotalWidth();
-        tbMinHeight = tb.getHeight();
-        SetRect(&r, 0, 0, tbMinWidth, tbMinHeight);
-        AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
-        min_size = Rect(r.left, r.top, r.right, r.bottom);
-      }
-
-      // Work out how big the window should ideally be
-      DWORD current_style = GetWindowLong(frameHandle, GWL_STYLE);
-      DWORD style = current_style & ~(WS_VSCROLL | WS_HSCROLL);
-      DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
-
-      SetRect(&r, 0, 0, buffer->width(), buffer->height());
-      AdjustWindowRectEx(&r, style, FALSE, style_ex);
-      Rect reqd_size = Rect(r.left, r.top, r.right, r.bottom);
-      if (current_style & WS_VSCROLL)
-        reqd_size.br.x += GetSystemMetrics(SM_CXVSCROLL);
-      if (current_style & WS_HSCROLL)
-        reqd_size.br.y += GetSystemMetrics(SM_CXHSCROLL);
-
-      SetRect(&r, reqd_size.tl.x, reqd_size.tl.y, reqd_size.br.x, reqd_size.br.y);
-      if (isToolbarEnabled())
-        r.bottom += tb.getHeight();
-      AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
-      reqd_size = Rect(r.left, r.top, r.right, r.bottom);
-
-      RECT current;
-      GetWindowRect(handle, &current);
-
-      if (min_size.width() > reqd_size.width()) {
-        reqd_size.tl.x = min_size.tl.x;
-        reqd_size.br.x = min_size.br.x;
-      }
-      if (min_size.height() > reqd_size.height()) {
-        reqd_size.tl.y = min_size.tl.y;
-        reqd_size.br.y = min_size.br.y;
-      }
-
-      if (!(GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE) && !fullscreenActive) {
-        // Ensure that the window isn't resized too large or too small
-        if ((wpos->cx < min_size.width()) && isToolbarEnabled()) {
-          wpos->cx = min_size.width();
-          wpos->x = current.left;
-        } else if ((wpos->cx > reqd_size.width())) {
-          wpos->cx = reqd_size.width();
-          wpos->x = current.left;
-        }
-        if ((wpos->cy < min_size.height()) && isToolbarEnabled()) {
-          wpos->cy = min_size.height();
-          wpos->y = current.top;
-        } else if (wpos->cy > reqd_size.height()) {
-          wpos->cy = reqd_size.height();
-          wpos->y = current.top;
-        }
-      }
-    }
-    break;
-
-    // Resize child windows and update window size info we have cached.
-
-  case WM_SIZE:
-    {
-      Point old_offset = desktopToClient(Point(0, 0));
-      RECT r;
-
-      // Resize child windows
-      GetClientRect(handle, &r);
-      if (tb.isVisible()) {
-        MoveWindow(frameHandle, 0, tb.getHeight(), r.right, r.bottom - tb.getHeight(), TRUE);
-      } else {
-        MoveWindow(frameHandle, 0, 0, r.right, r.bottom, TRUE);
-      }
-      tb.autoSize();
- 
-      // Update the cached sizing information
-      GetWindowRect(frameHandle, &r);
-      window_size = Rect(r.left, r.top, r.right, r.bottom);
-      GetClientRect(frameHandle, &r);
-      client_size = Rect(r.left, r.top, r.right, r.bottom);
-
-      // Perform the AutoScaling operation
-      if (isAutoScaling()) {
-        fitBufferToWindow(false);
-      } else {
-        // Determine whether scrollbars are required
-        calculateScrollBars();
-      }
-
-      // Redraw if required
-      if ((!old_offset.equals(desktopToClient(Point(0, 0)))) || isAutoScaling())
-        InvalidateRect(frameHandle, 0, TRUE);
-    }
-    break;
-
-    // -=- Bump-scrolling
-
-  case WM_TIMER:
-    switch (wParam) {
-    case TIMER_BUMPSCROLL:
-      if (!setViewportOffset(scrolloffset.translate(bumpScrollDelta)))
-        bumpScrollTimer.stop();
-      break;
-    case TIMER_POINTER_INTERVAL:
-    case TIMER_POINTER_3BUTTON:
-      ptr.handleTimer(callback, wParam);
-      break;
-    case TIMER_UPDATE:
-      updateWindow();
-      break;
-    }
-    break;
-
-    // -=- Track whether or not the window has focus
-
-  case WM_SETFOCUS:
-    has_focus = true;
-    break;
-  case WM_KILLFOCUS:
-    has_focus = false;
-    cursorOutsideBuffer();
-    // Restore the keyboard to a consistent state
-    kbd.releaseAllKeys(callback);
-    break;
-
-    // -=- If the menu is about to be shown, make sure it's up to date
-
-  case WM_INITMENU:
-    callback->refreshMenu(true);
-    break;
-
-    // -=- Handle the extra window menu items
-
-    // Pass system menu messages to the callback and only attempt
-    // to process them ourselves if the callback returns false.
-  case WM_SYSCOMMAND:
-    // Call the supplied callback
-    if (callback->sysCommand(wParam, lParam))
-      break;
-
-    // - Not processed by the callback, so process it as a system message
-    switch (wParam & 0xfff0) {
-
-      // When restored, ensure that full-screen mode is re-enabled if required.
-    case SC_RESTORE:
-      {
-      if (GetWindowLong(handle, GWL_STYLE) & WS_MINIMIZE) {
-        rfb::win32::SafeDefWindowProc(handle, msg, wParam, lParam);
-        setFullscreen(fullscreenRestore);
-      }
-      else if (fullscreenActive)
-        setFullscreen(false);
-      else
-        rfb::win32::SafeDefWindowProc(handle, msg, wParam, lParam);
-
-      return 0;
-      }
-
-      // If we are maximized or minimized then that cancels full-screen mode.
-    case SC_MINIMIZE:
-    case SC_MAXIMIZE:
-      fullscreenRestore = fullscreenActive;
-      setFullscreen(false);
-      break;
-
-    }
-    break;
-
-    // Treat all menu commands as system menu commands
-  case WM_COMMAND:
-    SendMessage(handle, WM_SYSCOMMAND, wParam, lParam);
-    return 0;
-
-    // -=- Handle keyboard input
-
-  case WM_KEYUP:
-  case WM_KEYDOWN:
-    // Hook the MenuKey to pop-up the window menu
-    if (menuKey && (wParam == menuKey)) {
-
-      bool ctrlDown = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
-      bool altDown = (GetAsyncKeyState(VK_MENU) & 0x8000) != 0;
-      bool shiftDown = (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0;
-      if (!(ctrlDown || altDown || shiftDown)) {
-
-        // If MenuKey is being released then pop-up the menu
-        if ((msg == WM_KEYDOWN)) {
-          // Make sure it's up to date
-          //
-          // NOTE: Here we call refreshMenu only to grey out Move and Size
-          //       menu items. Other things will be refreshed once again
-          //       while processing the WM_INITMENU message.
-          //
-          callback->refreshMenu(false);
-
-          // Show it under the pointer
-          POINT pt;
-          GetCursorPos(&pt);
-          cursorInBuffer = false;
-          TrackPopupMenu(GetSystemMenu(handle, FALSE),
-            TPM_CENTERALIGN | TPM_VCENTERALIGN, pt.x, pt.y, 0, handle, 0);
-        }
-
-        // Ignore the MenuKey keypress for both press & release events
-        return 0;
-      }
-    }
-	case WM_SYSKEYDOWN:
-	case WM_SYSKEYUP:
-    kbd.keyEvent(callback, wParam, lParam, (msg == WM_KEYDOWN) || (msg == WM_SYSKEYDOWN));
-    return 0;
-
-    // -=- Handle mouse wheel scroll events
-
-#ifdef WM_MOUSEWHEEL
-  case WM_MOUSEWHEEL:
-    processMouseMessage(msg, wParam, lParam);
-    break;
-#endif
-
-    // -=- Handle the window closing
-
-  case WM_CLOSE:
-    vlog.debug("WM_CLOSE %x", handle);
-    callback->closeWindow();
-    break;
-
-  }
-
-  return rfb::win32::SafeDefWindowProc(handle, msg, wParam, lParam);
-}
-
-LRESULT
-DesktopWindow::processFrameMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
-  switch (msg) {
-
-    // -=- Paint the remote frame buffer
-
-  case WM_PAINT:
-    {
-      PAINTSTRUCT ps;
-      HDC paintDC = BeginPaint(frameHandle, &ps);
-      if (!paintDC)
-        throw rdr::SystemException("unable to BeginPaint", GetLastError());
-      Rect pr = Rect(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
-
-      if (!pr.is_empty()) {
-
-        // Draw using the correct palette
-        PaletteSelector pSel(paintDC, windowPalette.getHandle());
-
-        if (buffer->bitmap) {
-          // Update the bitmap's palette
-          if (palette_changed) {
-            palette_changed = false;
-            buffer->refreshPalette();
-          }
-
-          // Get device context
-          BitmapDC bitmapDC(paintDC, buffer->bitmap);
-
-          // Blit the border if required
-          Rect bufpos = desktopToClient(buffer->getRect());
-          if (!pr.enclosed_by(bufpos)) {
-            vlog.debug("draw border");
-            HBRUSH black = (HBRUSH) GetStockObject(BLACK_BRUSH);
-            RECT r;
-            SetRect(&r, 0, 0, bufpos.tl.x, client_size.height()); FillRect(paintDC, &r, black);
-            SetRect(&r, bufpos.tl.x, 0, bufpos.br.x, bufpos.tl.y); FillRect(paintDC, &r, black);
-            SetRect(&r, bufpos.br.x, 0, client_size.width(), client_size.height()); FillRect(paintDC, &r, black);
-            SetRect(&r, bufpos.tl.x, bufpos.br.y, bufpos.br.x, client_size.height()); FillRect(paintDC, &r, black);
-          }
-
-          // Do the blit
-          Point buf_pos = clientToDesktop(pr.tl);
-
-          if (!BitBlt(paintDC, pr.tl.x, pr.tl.y, pr.width(), pr.height(),
-                      bitmapDC, buf_pos.x, buf_pos.y, SRCCOPY))
-            throw rdr::SystemException("unable to BitBlt to window", GetLastError());
-        }
-      }
-
-      EndPaint(frameHandle, &ps);
-
-      // - Notify the callback that a paint message has finished processing
-      callback->paintCompleted();
-    }
-    return 0;
-
-    // -=- Palette management
-
-  case WM_PALETTECHANGED:
-    vlog.debug("WM_PALETTECHANGED");
-    if ((HWND)wParam == frameHandle) {
-      vlog.debug("ignoring");
-      break;
-    }
-  case WM_QUERYNEWPALETTE:
-    vlog.debug("re-selecting palette");
-    {
-      WindowDC wdc(frameHandle);
-      PaletteSelector pSel(wdc, windowPalette.getHandle());
-      if (pSel.isRedrawRequired()) {
-        InvalidateRect(frameHandle, 0, FALSE);
-        UpdateWindow(frameHandle);
-      }
-    }
-    return TRUE;
-
-  case WM_VSCROLL:
-  case WM_HSCROLL: 
-    {
-      Point delta;
-      int newpos = (msg == WM_VSCROLL) ? scrolloffset.y : scrolloffset.x;
-
-      switch (LOWORD(wParam)) {
-      case SB_PAGEUP: newpos -= 50; break;
-      case SB_PAGEDOWN: newpos += 50; break;
-      case SB_LINEUP: newpos -= 5; break;
-      case SB_LINEDOWN: newpos += 5; break;
-      case SB_THUMBTRACK:
-      case SB_THUMBPOSITION: newpos = HIWORD(wParam); break;
-      default: vlog.info("received unknown scroll message");
-      };
-
-      if (msg == WM_HSCROLL)
-        setViewportOffset(Point(newpos, scrolloffset.y));
-      else
-        setViewportOffset(Point(scrolloffset.x, newpos));
-  
-      SCROLLINFO si;
-      si.cbSize = sizeof(si); 
-      si.fMask  = SIF_POS; 
-      si.nPos   = newpos; 
-      SetScrollInfo(frameHandle, (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ, &si, TRUE); 
-    }
-    break;
-
-    // -=- Cursor shape/visibility handling
-
-  case WM_SETCURSOR:
-    if (LOWORD(lParam) != HTCLIENT)
-      break;
-    SetCursor(cursorInBuffer ? dotCursor : arrowCursor);
-    return TRUE;
-
-  case WM_MOUSELEAVE:
-    trackingMouseLeave = false;
-    cursorOutsideBuffer();
-    return 0;
-
-    // -=- Mouse input handling
-
-  case WM_MOUSEMOVE:
-  case WM_LBUTTONUP:
-  case WM_MBUTTONUP:
-  case WM_RBUTTONUP:
-  case WM_LBUTTONDOWN:
-  case WM_MBUTTONDOWN:
-  case WM_RBUTTONDOWN:
-    processMouseMessage(msg, wParam, lParam);
-    break;
-  }
-
-  return rfb::win32::SafeDefWindowProc(frameHandle, msg, wParam, lParam);
-}
-
-void
-DesktopWindow::processMouseMessage(UINT msg, WPARAM wParam, LPARAM lParam)
-{
-  if (!has_focus) {
-    cursorOutsideBuffer();
-    return;
-  }
-
-  if (!trackingMouseLeave) {
-    TRACKMOUSEEVENT tme;
-    tme.cbSize = sizeof(TRACKMOUSEEVENT);
-    tme.dwFlags = TME_LEAVE;
-    tme.hwndTrack = frameHandle;
-    _TrackMouseEvent(&tme);
-    trackingMouseLeave = true;
-  }
-  int mask = 0;
-  if (LOWORD(wParam) & MK_LBUTTON) mask |= 1;
-  if (LOWORD(wParam) & MK_MBUTTON) mask |= 2;
-  if (LOWORD(wParam) & MK_RBUTTON) mask |= 4;
-
-#ifdef WM_MOUSEWHEEL
-  if (msg == WM_MOUSEWHEEL) {
-    int delta = (short)HIWORD(wParam);
-    int repeats = (abs(delta)+119) / 120;
-    int wheelMask = (delta > 0) ? 8 : 16;
-    vlog.debug("repeats %d, mask %d\n",repeats,wheelMask);
-    for (int i=0; i<repeats; i++) {
-      ptr.pointerEvent(callback, oldpos, mask | wheelMask);
-      ptr.pointerEvent(callback, oldpos, mask);
-    }
-  } else {
-#endif
-    Point clientPos = Point(LOWORD(lParam), HIWORD(lParam));
-    Point p = clientToDesktop(clientPos);
-
-    // If the mouse is not within the server buffer area, do nothing
-    cursorInBuffer = buffer->getRect().contains(p);
-    if (!cursorInBuffer) {
-      cursorOutsideBuffer();
-      return;
-    }
-
-    // If we're locally rendering the cursor then redraw it
-    if (cursorAvailable) {
-      // - Render the cursor!
-      if (!p.equals(cursorPos)) {
-        hideLocalCursor();
-        cursorPos = p;
-        showLocalCursor();
-        if (cursorVisible)
-          hideSystemCursor();
-      }
-    }
-
-    // If we are doing bump-scrolling then try that first...
-    if (processBumpScroll(clientPos))
-      return;
-
-    // Send a pointer event to the server
-    oldpos = p;
-    if (buffer->isScaling()) {
-      p.x /= buffer->getScaleRatioX();
-      p.y /= buffer->getScaleRatioY();
-    }
-    ptr.pointerEvent(callback, p, mask);
-#ifdef WM_MOUSEWHEEL
-  }
-#endif
-}
-
-void DesktopWindow::updateWindow()
-{
-  Rect rect;
-
-  updateTimer.stop();
-
-  rect = damage.get_bounding_rect();
-  damage.clear();
-
-  RECT invalid = {rect.tl.x, rect.tl.y, rect.br.x, rect.br.y};
-  InvalidateRect(frameHandle, &invalid, FALSE);
-}
-
-void
-DesktopWindow::hideLocalCursor() {
-  // - Blit the cursor backing store over the cursor
-  // *** ALWAYS call this BEFORE changing buffer PF!!!
-  if (cursorVisible) {
-    cursorVisible = false;
-    buffer->DIBSectionBuffer::imageRect(cursorBackingRect, cursorBacking.data);
-    invalidateDesktopRect(cursorBackingRect, false);
-  }
-}
-
-void
-DesktopWindow::showLocalCursor() {
-  if (cursorAvailable && !cursorVisible && cursorInBuffer) {
-    if (!buffer->getScaledPixelFormat().equal(cursor.getPF()) ||
-      cursor.getRect().is_empty()) {
-      vlog.info("attempting to render invalid local cursor");
-      cursorAvailable = false;
-      showSystemCursor();
-      return;
-    }
-    cursorVisible = true;
-    
-    cursorBackingRect = cursor.getRect().translate(cursorPos).translate(cursor.hotspot.negate());
-    cursorBackingRect = cursorBackingRect.intersect(buffer->getRect());
-    buffer->getImage(cursorBacking.data, cursorBackingRect);
-
-    renderLocalCursor();
-
-    invalidateDesktopRect(cursorBackingRect, false);
-    // Since we render the cursor onto the framebuffer, we need to update
-    // right away to get a responsive cursor.
-    updateWindow();
-  }
-}
-
-void DesktopWindow::cursorOutsideBuffer()
-{
-  cursorInBuffer = false;
-  hideLocalCursor();
-  showSystemCursor();
-}
-
-void
-DesktopWindow::renderLocalCursor()
-{
-  Rect r = cursor.getRect();
-  r = r.translate(cursorPos).translate(cursor.hotspot.negate());
-  buffer->DIBSectionBuffer::maskRect(r, cursor.data, cursor.mask.buf);
-}
-
-void
-DesktopWindow::hideSystemCursor() {
-  if (systemCursorVisible) {
-    vlog.debug("hide system cursor");
-    systemCursorVisible = false;
-    ShowCursor(FALSE);
-  }
-}
-
-void
-DesktopWindow::showSystemCursor() {
-  if (!systemCursorVisible) {
-    vlog.debug("show system cursor");
-    systemCursorVisible = true;
-    ShowCursor(TRUE);
-  }
-}
-
-
-bool
-DesktopWindow::invalidateDesktopRect(const Rect& crect, bool scaling) {
-  Rect rect;
-  if (buffer->isScaling() && scaling) {
-    rect = desktopToClient(buffer->calculateScaleBoundary(crect));
-  } else rect = desktopToClient(crect);
-  if (rect.intersect(client_size).is_empty()) return false;
-  damage.assign_union(rfb::Region(rect));
-  if (!updateTimer.isActive())
-    updateTimer.start(100);
-  return true;
-}
-
-
-void
-DesktopWindow::notifyClipboardChanged(const char* text, int len) {
-  callback->clientCutText(text, len);
-}
-
-
-void
-DesktopWindow::setPF(const PixelFormat& pf) {
-  // If the cursor is the wrong format then clear it
-  if (!pf.equal(buffer->getScaledPixelFormat()))
-    setCursor(0, 0, Point(), 0, 0);
-
-  // Update the desktop buffer
-  buffer->setPF(pf);
-  
-  // Redraw the window
-  InvalidateRect(frameHandle, 0, FALSE);
-}
-
-void
-DesktopWindow::setSize(int w, int h) {
-  vlog.debug("setSize %dx%d", w, h);
-
-  // If the locally-rendered cursor is visible then remove it
-  hideLocalCursor();
-
-  // Resize the backing buffer
-  buffer->setSize(w, h);
-
-  // Calculate the pixel buffer aspect correlation. It's used
-  // for the autoScaling operation.
-  aspect_corr = (double)w / h;
-
-  // If the window is not maximised or full-screen then resize it
-  if (!(GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE) && !fullscreenActive) {
-    // Resize the window to the required size
-    RECT r = {0, 0, w, h};
-    AdjustWindowRectEx(&r, GetWindowLong(frameHandle, GWL_STYLE), FALSE,
-                       GetWindowLong(frameHandle, GWL_EXSTYLE));
-    if (isToolbarEnabled())
-      r.bottom += tb.getHeight();
-    AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
-
-    // Resize about the center of the window, and clip to current monitor
-    MonitorInfo mi(handle);
-    resizeWindow(handle, r.right-r.left, r.bottom-r.top);
-    mi.clipTo(handle);
-  } else {
-    // Ensure the screen contents are consistent
-    InvalidateRect(frameHandle, 0, FALSE);
-  }
-
-  // Enable/disable scrollbars as appropriate
-  calculateScrollBars();
-}
-
-void DesktopWindow::setAutoScaling(bool as) { 
-  autoScaling = as;
-  if (isToolbarEnabled()) refreshToolbarButtons();
-  if (as) fitBufferToWindow();
-}
-
-void DesktopWindow::setDesktopScale(int scale_) {
-  if (buffer->getScale() == scale_ || scale_ <= 0) return;
-  bool state = buffer->isScaling();
-  buffer->setScale(scale_);
-  state ^= buffer->isScaling();
-  if (state) convertCursorToBuffer();
-  if (isToolbarEnabled()) refreshToolbarButtons();
-  if (!(isAutoScaling() || isFullscreen() || (GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE))) resizeDesktopWindowToBuffer();
-  printScale();
-  InvalidateRect(frameHandle, 0, FALSE);
-}
-
-void DesktopWindow::setDesktopScaleFilter(unsigned int scaleFilterID) { 
-  if (scaleFilterID == getDesktopScaleFilterID() || scaleFilterID > scaleFilterMaxNumber) return;
-  buffer->setScaleFilter(scaleFilterID);
-  InvalidateRect(frameHandle, 0, FALSE);
-}
-
-void DesktopWindow::convertCursorToBuffer() {
-  if (memcmp(&(cursor.getPF()), &(buffer->getPF()), sizeof(PixelBuffer)) == 0) return;
-  internalSetCursor = true;
-  setCursor(cursorWidth, cursorHeight, cursorHotspot, cursorImage, cursorMask);
-  internalSetCursor = false;
-}
-
-void DesktopWindow::fitBufferToWindow(bool repaint) {
-  double scale_ratio;
-  double resized_aspect_corr = double(client_size.width()) / client_size.height();
-  DWORD style = GetWindowLong(frameHandle, GWL_STYLE);
-  if (style & (WS_VSCROLL | WS_HSCROLL)) {
-    style &= ~(WS_VSCROLL | WS_HSCROLL);
-    SetWindowLong(frameHandle, GWL_STYLE, style);
-    SetWindowPos(frameHandle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
-    // Update the cached client size
-    RECT r;
-    GetClientRect(frameHandle, &r);
-    client_size = Rect(r.left, r.top, r.right, r.bottom);
-  }
-  bool state = buffer->isScaling();
-  if (resized_aspect_corr > aspect_corr) {
-    scale_ratio = (double)client_size.height() / buffer->getSrcHeight();
-    buffer->setScaleWindowSize(ceil(buffer->getSrcWidth()*scale_ratio), client_size.height());
-  } else { 
-    scale_ratio = (double)client_size.width() / buffer->getSrcWidth();
-    buffer->setScaleWindowSize(client_size.width(), ceil(buffer->getSrcHeight()*scale_ratio));
-  }
-  state ^= buffer->isScaling();
-  if (state) convertCursorToBuffer();
-  printScale();
-  InvalidateRect(frameHandle, 0, FALSE);
-}
-
-void DesktopWindow::printScale() {
-  setName(desktopName);
-}
-
-void
-DesktopWindow::setCursor(int w, int h, const Point& hotspot, void* data, void* mask) {
-  hideLocalCursor();
-
-  cursor.hotspot = hotspot;
-
-  cursor.setSize(w, h);
-  cursor.setPF(buffer->getScaledPixelFormat());
-
-  // Convert the current cursor pixel format to bpp32 if scaling mode is on.
-  // It need because ScaledDIBSection buffer always works with bpp32 pixel data
-  // in scaling mode.
-  if (buffer->isScaling()) {
-    U8 *ptr = (U8*)cursor.data;
-    U8 *dataPtr = (U8*)data;
-    U32 pixel = 0;
-    int bytesPerPixel = buffer->getPixelFormat().bpp / 8;
-    int pixelCount = w * h;
-    PixelFormat pf = buffer->getPixelFormat();
-
-    while (pixelCount--) {
-      if (bytesPerPixel == 1) {
-        pixel = *dataPtr++;
-      } else if (bytesPerPixel == 2) {
-        int b0 = *dataPtr++; int b1 = *dataPtr++;
-        pixel =  b1 << 8 | b0;
-      } else if (bytesPerPixel == 4) {
-        int b0 = *dataPtr++; int b1 = *dataPtr++;
-        int b2 = *dataPtr++; int b3 = *dataPtr++;
-        pixel = b3 << 24 | b2 << 16 | b1 << 8 | b0;
-      } else {
-        pixel = 0;
-      }
-      *ptr++ = (U8)((((pixel >> pf.blueShift ) & pf.blueMax ) * 255 + pf.blueMax /2) / pf.blueMax);
-      *ptr++ = (U8)((((pixel >> pf.greenShift) & pf.greenMax) * 255 + pf.greenMax/2) / pf.greenMax);
-      *ptr++ = (U8)((((pixel >> pf.redShift  ) & pf.redMax  ) * 255 + pf.redMax  /2) / pf.redMax);
-      *ptr++ = (U8)0;
-    }
-  } else {
-    cursor.imageRect(cursor.getRect(), data);
-  }
-  memcpy(cursor.mask.buf, mask, cursor.maskLen());
-  cursor.crop();
-
-  cursorBacking.setSize(w, h);
-  cursorBacking.setPF(buffer->getScaledPixelFormat());
-
-  cursorAvailable = true;
-
-  showLocalCursor();
-
-  // Save the cursor parameters
-  if (!internalSetCursor) {
-    if (cursorImage) delete [] cursorImage;
-    if (cursorMask) delete [] cursorMask;
-    int cursorImageSize = (buffer->getPixelFormat().bpp/8) * w * h; 
-    cursorImage = new U8[cursorImageSize];
-    cursorMask = new U8[cursor.maskLen()];
-    memcpy(cursorImage, data, cursorImageSize);
-    memcpy(cursorMask, mask, cursor.maskLen());
-    cursorWidth = w;
-    cursorHeight = h;
-    cursorHotspot = hotspot;
-  }
-}
-
-PixelFormat
-DesktopWindow::getNativePF() const {
-  vlog.debug("getNativePF()");
-  return WindowDC(handle).getPF();
-}
-
-
-void
-DesktopWindow::refreshWindowPalette(int start, int count) {
-  vlog.debug("refreshWindowPalette(%d, %d)", start, count);
-
-  Colour colours[256];
-  if (count > 256) {
-    vlog.debug("%d palette entries", count);
-    throw rdr::Exception("too many palette entries");
-  }
-
-  // Copy the palette from the DIBSectionBuffer
-  ColourMap* cm = buffer->getColourMap();
-  if (!cm) return;
-  for (int i=0; i<count; i++) {
-    int r, g, b;
-    cm->lookup(i, &r, &g, &b);
-    colours[i].r = r;
-    colours[i].g = g;
-    colours[i].b = b;
-  }
-
-  // Set the window palette
-  windowPalette.setEntries(start, count, colours);
-
-  // Cause the window to be redrawn
-  palette_changed = true;
-  InvalidateRect(handle, 0, FALSE);
-}
-
-
-void DesktopWindow::calculateScrollBars() {
-  // Calculate the required size of window
-  DWORD current_style = GetWindowLong(frameHandle, GWL_STYLE);
-  DWORD style = current_style & ~(WS_VSCROLL | WS_HSCROLL);
-  DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
-  DWORD old_style;
-  RECT r;
-  SetRect(&r, 0, 0, buffer->width(), buffer->height());
-  AdjustWindowRectEx(&r, style, FALSE, style_ex);
-  Rect reqd_size = Rect(r.left, r.top, r.right, r.bottom);
-
-  if (!bumpScroll) {
-    // We only enable scrollbars if bump-scrolling is not active.
-    // Effectively, this means if full-screen is not active,
-    // but I think it's better to make these things explicit.
-    
-    // Work out whether scroll bars are required
-    do {
-      old_style = style;
-
-      if (!(style & WS_HSCROLL) && (reqd_size.width() > window_size.width())) {
-        style |= WS_HSCROLL;
-        reqd_size.br.y += GetSystemMetrics(SM_CXHSCROLL);
-      }
-      if (!(style & WS_VSCROLL) && (reqd_size.height() > window_size.height())) {
-        style |= WS_VSCROLL;
-        reqd_size.br.x += GetSystemMetrics(SM_CXVSCROLL);
-      }
-    } while (style != old_style);
-  }
-
-  // Tell Windows to update the window style & cached settings
-  if (style != current_style) {
-    SetWindowLong(frameHandle, GWL_STYLE, style);
-    SetWindowPos(frameHandle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
-  }
-
-  // Update the scroll settings
-  SCROLLINFO si;
-  if (style & WS_VSCROLL) {
-    si.cbSize = sizeof(si); 
-    si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS; 
-    si.nMin   = 0; 
-    si.nMax   = buffer->height(); 
-    si.nPage  = buffer->height() - (reqd_size.height() - window_size.height()); 
-    maxscrolloffset.y = __rfbmax(0, si.nMax-si.nPage);
-    scrolloffset.y = __rfbmin(maxscrolloffset.y, scrolloffset.y);
-    si.nPos   = scrolloffset.y;
-    SetScrollInfo(frameHandle, SB_VERT, &si, TRUE);
-  }
-  if (style & WS_HSCROLL) {
-    si.cbSize = sizeof(si); 
-    si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS; 
-    si.nMin   = 0;
-    si.nMax   = buffer->width(); 
-    si.nPage  = buffer->width() - (reqd_size.width() - window_size.width()); 
-    maxscrolloffset.x = __rfbmax(0, si.nMax-si.nPage);
-    scrolloffset.x = __rfbmin(maxscrolloffset.x, scrolloffset.x);
-    si.nPos   = scrolloffset.x;
-    SetScrollInfo(frameHandle, SB_HORZ, &si, TRUE);
-  }
-
-  // Update the cached client size
-  GetClientRect(frameHandle, &r);
-  client_size = Rect(r.left, r.top, r.right, r.bottom);
-}
-
-void DesktopWindow::resizeDesktopWindowToBuffer() {
-  RECT r;
-  DWORD style = GetWindowLong(frameHandle, GWL_STYLE) & ~(WS_VSCROLL | WS_HSCROLL);
-  DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
-
-  // Calculate the required size of the desktop window
-  SetRect(&r, 0, 0, buffer->width(), buffer->height());
-  AdjustWindowRectEx(&r, style, FALSE, style_ex);
-  if (isToolbarEnabled())
-    r.bottom += tb.getHeight();
-  AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
-
-  // Set the required size, center the main window and clip to the current monitor
-  SetWindowPos(handle, 0, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
-  centerWindow(handle, NULL);
-  MonitorInfo mi(getMonitor());
-  mi.clipTo(handle);
-
-  // Enable/disable scrollbars as appropriate
-  calculateScrollBars();      
-}
-
-
-void DesktopWindow::framebufferUpdateEnd()
-{
-  updateWindow();
-}
-
-
-void
-DesktopWindow::setName(const char* name) {
-  if (name != desktopName) {
-    strCopy(desktopName, name, sizeof(desktopName));
-  }
-  char *newTitle = new char[strlen(desktopName)+20];
-  sprintf(newTitle, "TigerVNC: %.240s @ %i%%", desktopName, getDesktopScale());
-  SetWindowText(handle, TStr(newTitle));
-  delete [] newTitle;
-}
-
-
-void
-DesktopWindow::serverCutText(const char* str, rdr::U32 len) {
-  CharArray t(len+1);
-  memcpy(t.buf, str, len);
-  t.buf[len] = 0;
-  clipboard.setClipText(t.buf);
-}
-
-
-void DesktopWindow::fillRect(const Rect& r, Pixel pix) {
-  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
-  if (cursorBackingRect.overlaps(img_rect)) hideLocalCursor();
-  buffer->fillRect(r, pix);
-  invalidateDesktopRect(r);
-}
-void DesktopWindow::imageRect(const Rect& r, void* pixels) {
-  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
-  if (cursorBackingRect.overlaps(img_rect)) hideLocalCursor();
-  buffer->imageRect(r, pixels);
-  invalidateDesktopRect(r);
-}
-void DesktopWindow::copyRect(const Rect& r, int srcX, int srcY) {
-  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
-  if (cursorBackingRect.overlaps(img_rect) ||
-      cursorBackingRect.overlaps(Rect(srcX, srcY, srcX+img_rect.width(), srcY+img_rect.height())))
-    hideLocalCursor();
-  buffer->copyRect(r, Point(r.tl.x-srcX, r.tl.y-srcY));
-  invalidateDesktopRect(r);
-}
-
-void DesktopWindow::invertRect(const Rect& r) {
-  int stride;
-  rdr::U8* p = buffer->isScaling() ? buffer->getPixelsRW(buffer->calculateScaleBoundary(r), &stride) 
-   : buffer->getPixelsRW(r, &stride);
-  for (int y = 0; y < r.height(); y++) {
-    for (int x = 0; x < r.width(); x++) {
-      switch (buffer->getPF().bpp) {
-      case 8:  ((rdr::U8* )p)[x+y*stride] ^= 0xff;       break;
-      case 16: ((rdr::U16*)p)[x+y*stride] ^= 0xffff;     break;
-      case 32: ((rdr::U32*)p)[x+y*stride] ^= 0xffffffff; break;
-      }
-    }
-  }
-  invalidateDesktopRect(r);
-}
+/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * 
+ * This 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 software 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 software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#include <windows.h>
+#include <commctrl.h>
+#include <math.h>
+#include <rfb/Configuration.h>
+#include <rfb/LogWriter.h>
+#include <rfb_win32/WMShatter.h>
+#include <rfb_win32/LowLevelKeyEvents.h>
+#include <rfb_win32/MonitorInfo.h>
+#include <rfb_win32/DeviceContext.h>
+#include <rfb_win32/Win32Util.h>
+#include <rfb_win32/MsgBox.h>
+#include <rfb/util.h>
+#include <vncviewer/DesktopWindow.h>
+#include <vncviewer/resource.h>
+
+using namespace rfb;
+using namespace rfb::win32;
+
+
+// - Statics & consts
+
+static LogWriter vlog("DesktopWindow");
+
+const int TIMER_BUMPSCROLL = 1;
+const int TIMER_POINTER_INTERVAL = 2;
+const int TIMER_POINTER_3BUTTON = 3;
+const int TIMER_UPDATE = 4;
+
+
+//
+// -=- DesktopWindowClass
+
+//
+// Window class used as the basis for all DesktopWindow instances
+//
+
+class DesktopWindowClass {
+public:
+  DesktopWindowClass();
+  ~DesktopWindowClass();
+  ATOM classAtom;
+  HINSTANCE instance;
+};
+
+int ConfirmQuitDialog()
+{
+    int msgboxID = MessageBox(
+        NULL,
+        (LPCWSTR)L"Do you want to abort this session?",
+		(LPCWSTR)L"TigerVNC Viewer: Confirm Quit",
+        MB_YESNO
+    );
+
+    switch (msgboxID)
+    {
+    case IDYES:
+        return 1;
+        break;
+    case IDNO:
+        return 0;
+        break;
+    }
+
+    return 1;
+}
+
+LRESULT CALLBACK DesktopWindowProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+  LRESULT result = 0;
+  if (msg == WM_CREATE)
+    SetWindowLong(wnd, GWL_USERDATA, (long)((CREATESTRUCT*)lParam)->lpCreateParams);
+  else if (msg == WM_DESTROY)
+    SetWindowLong(wnd, GWL_USERDATA, 0);
+  DesktopWindow* _this = (DesktopWindow*) GetWindowLong(wnd, GWL_USERDATA);
+  if (!_this) {
+    vlog.info("null _this in %x, message %u", wnd, msg);
+    return rfb::win32::SafeDefWindowProc(wnd, msg, wParam, lParam);
+  }
+
+  try {
+    result = _this->processMessage(msg, wParam, lParam);
+  } catch (rfb::UnsupportedPixelFormatException &e) {
+    MsgBox(0, LPTSTR(e.str()), MB_OK | MB_ICONINFORMATION);
+    _this->getCallback()->closeWindow();
+  } catch (rdr::Exception& e) {
+    vlog.error("untrapped: %s", e.str());
+  }
+
+  return result;
+};
+
+static HCURSOR dotCursor = (HCURSOR)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDC_DOT_CURSOR), IMAGE_CURSOR, 0, 0, LR_SHARED);
+static HCURSOR arrowCursor = (HCURSOR)LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED); 
+
+DesktopWindowClass::DesktopWindowClass() : classAtom(0) {
+  WNDCLASS wndClass;
+  wndClass.style = 0;
+  wndClass.lpfnWndProc = DesktopWindowProc;
+  wndClass.cbClsExtra = 0;
+  wndClass.cbWndExtra = 0;
+  wndClass.hInstance = instance = GetModuleHandle(0);
+  wndClass.hIcon = (HICON)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_SHARED);
+  if (!wndClass.hIcon)
+    printf("unable to load icon:%ld", GetLastError());
+  wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+  wndClass.hbrBackground = NULL;
+  wndClass.lpszMenuName = 0;
+  wndClass.lpszClassName = _T("rfb::win32::DesktopWindowClass");
+  classAtom = RegisterClass(&wndClass);
+  if (!classAtom) {
+    throw rdr::SystemException("unable to register DesktopWindow window class", GetLastError());
+  }
+}
+
+DesktopWindowClass::~DesktopWindowClass() {
+  if (classAtom) {
+    UnregisterClass((const TCHAR*)classAtom, instance);
+  }
+}
+
+static DesktopWindowClass baseClass;
+
+//
+// -=- FrameClass
+
+//
+// Window class used for child windows that display pixel data
+//
+
+class FrameClass {
+public:
+  FrameClass();
+  ~FrameClass();
+  ATOM classAtom;
+  HINSTANCE instance;
+};
+
+LRESULT CALLBACK FrameProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+  LRESULT result = 0;
+  if (msg == WM_CREATE)
+    SetWindowLong(wnd, GWL_USERDATA, (long)((CREATESTRUCT*)lParam)->lpCreateParams);
+  else if (msg == WM_DESTROY)
+    SetWindowLong(wnd, GWL_USERDATA, 0);
+  DesktopWindow* _this = (DesktopWindow*) GetWindowLong(wnd, GWL_USERDATA);
+  if (!_this) {
+    vlog.info("null _this in %x, message %u", wnd, msg);
+    return rfb::win32::SafeDefWindowProc(wnd, msg, wParam, lParam);
+  }
+
+  try {
+    result = _this->processFrameMessage(msg, wParam, lParam);
+  } catch (rdr::Exception& e) {
+    vlog.error("untrapped: %s", e.str());
+  }
+
+  return result;
+}
+
+FrameClass::FrameClass() : classAtom(0) {
+  WNDCLASS wndClass;
+  wndClass.style = 0;
+  wndClass.lpfnWndProc = FrameProc;
+  wndClass.cbClsExtra = 0;
+  wndClass.cbWndExtra = 0;
+  wndClass.hInstance = instance = GetModuleHandle(0);
+  wndClass.hIcon = 0;
+  wndClass.hCursor = NULL;
+  wndClass.hbrBackground = NULL;
+  wndClass.lpszMenuName = 0;
+  wndClass.lpszClassName = _T("rfb::win32::FrameClass");
+  classAtom = RegisterClass(&wndClass);
+  if (!classAtom) {
+    throw rdr::SystemException("unable to register Frame window class", GetLastError());
+  }
+}
+
+FrameClass::~FrameClass() {
+  if (classAtom) {
+    UnregisterClass((const TCHAR*)classAtom, instance);
+  }
+}
+
+FrameClass frameClass;
+
+
+//
+// -=- DesktopWindow instance implementation
+//
+
+DesktopWindow::DesktopWindow(Callback* cb) 
+  : bumpScroll(false), palette_changed(false), fullscreenActive(false), 
+    fullscreenRestore(false), systemCursorVisible(true), trackingMouseLeave(false), 
+    cursorInBuffer(false), cursorVisible(false), cursorAvailable(false), 
+    internalSetCursor(false), cursorImage(0), cursorMask(0), 
+    cursorWidth(0), cursorHeight(0), showToolbar(false), 
+    buffer(0), has_focus(false), autoScaling(false),
+	allowClose(true),
+    window_size(0, 0, 32, 32),  client_size(0, 0, 16, 16), handle(0), 
+    frameHandle(0), callback(cb) {
+
+  // Create the window
+  const char* name = "DesktopWindow";
+  handle = CreateWindow((const TCHAR*)baseClass.classAtom, TStr(name),
+    WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+    0, 0, 10, 10, 0, 0, baseClass.instance, this);
+  if (!handle)
+    throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
+  vlog.debug("created window \"%s\" (%x)", name, handle);
+
+  // Create the toolbar
+  tb.create(handle);
+  vlog.debug("created toolbar window \"%s\" (%x)", "ViewerToolBar", tb.getHandle());
+
+  // Create the frame window
+  frameHandle = CreateWindowEx(WS_EX_CLIENTEDGE, (const TCHAR*)frameClass.classAtom,
+    0, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,
+    CW_USEDEFAULT, CW_USEDEFAULT, handle, 0, frameClass.instance, this);
+  if (!frameHandle) {
+    throw rdr::SystemException("unable to create rfb frame window instance", GetLastError());
+  }
+  vlog.debug("created window \"%s\" (%x)", "Frame Window", frameHandle);
+
+  // Initialise the CPointer pointer handler
+  ptr.setHWND(frameHandle);
+  ptr.setIntervalTimerId(TIMER_POINTER_INTERVAL);
+  ptr.set3ButtonTimerId(TIMER_POINTER_3BUTTON);
+
+  // Initialise the bumpscroll timer
+  bumpScrollTimer.setHWND(handle);
+  bumpScrollTimer.setId(TIMER_BUMPSCROLL);
+
+  // Initialise the update timer
+  updateTimer.setHWND(handle);
+  updateTimer.setId(TIMER_UPDATE);
+
+  // Hook the clipboard
+  clipboard.setNotifier(this);
+
+  // Create the backing buffer
+  buffer = new win32::ScaledDIBSectionBuffer(frameHandle);
+
+  // Show the window
+  centerWindow(handle, 0);
+  ShowWindow(handle, SW_SHOW);
+}
+
+DesktopWindow::~DesktopWindow() {
+  vlog.debug("~DesktopWindow");
+  showSystemCursor();
+  if (handle) {
+    disableLowLevelKeyEvents(handle);
+    DestroyWindow(handle);
+    handle = 0;
+  }
+  delete buffer;
+  if (cursorImage) delete [] cursorImage;
+  if (cursorMask) delete [] cursorMask;
+  vlog.debug("~DesktopWindow done");
+}
+
+
+void DesktopWindow::setFullscreen(bool fs) {
+  if (fs && !fullscreenActive) {
+    fullscreenActive = bumpScroll = true;
+
+    // Un-minimize the window if required
+    if (GetWindowLong(handle, GWL_STYLE) & WS_MINIMIZE)
+      ShowWindow(handle, SW_RESTORE);
+
+    // Save the current window position
+    GetWindowRect(handle, &fullscreenOldRect);
+
+    // Find the size of the display the window is on
+    MonitorInfo mi(handle);
+
+    // Hide the toolbar
+    if (tb.isVisible())
+      tb.hide();
+    SetWindowLong(frameHandle, GWL_EXSTYLE, 0);
+
+    // Set the window full-screen
+    DWORD flags = GetWindowLong(handle, GWL_STYLE);
+    fullscreenOldFlags = flags;
+    flags = flags & ~(WS_CAPTION | WS_THICKFRAME | WS_MAXIMIZE | WS_MINIMIZE);
+    vlog.debug("flags=%x", flags);
+
+    SetWindowLong(handle, GWL_STYLE, flags);
+    SetWindowPos(handle, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top,
+      mi.rcMonitor.right-mi.rcMonitor.left,
+      mi.rcMonitor.bottom-mi.rcMonitor.top,
+      SWP_FRAMECHANGED);
+  } else if (!fs && fullscreenActive) {
+    fullscreenActive = bumpScroll = false;
+
+    // Show the toolbar
+    if (showToolbar)
+      tb.show();
+    SetWindowLong(frameHandle, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
+
+    // Set the window non-fullscreen
+    SetWindowLong(handle, GWL_STYLE, fullscreenOldFlags);
+
+    // Set the window position
+    SetWindowPos(handle, HWND_NOTOPMOST,
+      fullscreenOldRect.left, fullscreenOldRect.top,
+      fullscreenOldRect.right - fullscreenOldRect.left, 
+      fullscreenOldRect.bottom - fullscreenOldRect.top,
+      SWP_FRAMECHANGED);
+  }
+
+  // Adjust the viewport offset to cope with change in size between FS
+  // and previous window state.
+  setViewportOffset(scrolloffset);
+}
+
+void DesktopWindow::setShowToolbar(bool st)
+{
+  showToolbar = st;
+  if (fullscreenActive) return;
+
+  RECT r;
+  GetWindowRect(handle, &r);
+  bool maximized = GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE;
+
+  if (showToolbar && !tb.isVisible()) {
+    refreshToolbarButtons();
+    tb.show();
+    if (!maximized) r.bottom += tb.getHeight();
+  } else if (!showToolbar && tb.isVisible()) {
+    tb.hide();
+    if (!maximized) r.bottom -= tb.getHeight();
+  }
+  // Resize the chiled windows even if the parent window size 
+  // has not been changed (the main window is maximized)
+  if (maximized) SendMessage(handle, WM_SIZE, 0, 0);
+  else SetWindowPos(handle, NULL, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOMOVE | SWP_NOZORDER);
+}
+
+void DesktopWindow::refreshToolbarButtons() {
+  int scale = getDesktopScale();
+  if (scale <= 10) {
+    tb.enableButton(ID_ZOOM_IN, true);
+    tb.enableButton(ID_ZOOM_OUT, false);
+  } else if (scale >= 200) {
+    tb.enableButton(ID_ZOOM_IN, false);
+    tb.enableButton(ID_ZOOM_OUT, true);
+  } else {
+    tb.enableButton(ID_ZOOM_IN, true);
+    tb.enableButton(ID_ZOOM_OUT, true);
+  }
+  if (buffer->isScaling() || isAutoScaling()) tb.enableButton(ID_ACTUAL_SIZE, true);
+  else tb.enableButton(ID_ACTUAL_SIZE, false);
+  if (isAutoScaling()) tb.pressButton(ID_AUTO_SIZE, true);
+  else tb.pressButton(ID_AUTO_SIZE, false);
+}
+
+void DesktopWindow::setDisableWinKeys(bool dwk) {
+  // Enable low-level event hooking, so we get special keys directly
+  if (dwk)
+    enableLowLevelKeyEvents(handle);
+  else
+    disableLowLevelKeyEvents(handle);
+}
+
+
+void DesktopWindow::setMonitor(const char* monitor) {
+  MonitorInfo mi(monitor);
+  mi.moveTo(handle);
+}
+
+char* DesktopWindow::getMonitor() const {
+  MonitorInfo mi(handle);
+  return strDup(mi.szDevice);
+}
+
+
+bool DesktopWindow::setViewportOffset(const Point& tl) {
+  Point np = Point(__rfbmax(0, __rfbmin(tl.x, buffer->width()-client_size.width())),
+    __rfbmax(0, __rfbmin(tl.y, buffer->height()-client_size.height())));
+  Point delta = np.translate(scrolloffset.negate());
+  if (!np.equals(scrolloffset)) {
+    scrolloffset = np;
+    ScrollWindowEx(frameHandle, -delta.x, -delta.y, 0, 0, 0, 0, SW_INVALIDATE);
+    UpdateWindow(frameHandle);
+    return true;
+  }
+  return false;
+}
+
+
+bool DesktopWindow::processBumpScroll(const Point& pos)
+{
+  if (!bumpScroll) return false;
+  int bumpScrollPixels = 20;
+  bumpScrollDelta = Point();
+
+  if (pos.x == client_size.width()-1)
+    bumpScrollDelta.x = bumpScrollPixels;
+  else if (pos.x == 0)
+    bumpScrollDelta.x = -bumpScrollPixels;
+  if (pos.y == client_size.height()-1)
+    bumpScrollDelta.y = bumpScrollPixels;
+  else if (pos.y == 0)
+    bumpScrollDelta.y = -bumpScrollPixels;
+
+  if (bumpScrollDelta.x || bumpScrollDelta.y) {
+    if (bumpScrollTimer.isActive()) return true;
+    if (setViewportOffset(scrolloffset.translate(bumpScrollDelta))) {
+      bumpScrollTimer.start(25);
+      return true;
+    }
+  }
+
+  bumpScrollTimer.stop();
+  return false;
+}
+
+
+LRESULT
+DesktopWindow::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
+  switch (msg) {
+
+    // -=- Process standard window messages
+
+  case WM_NOTIFY:
+    if (wParam == ID_TOOLBAR)
+      tb.processWM_NOTIFY(wParam, lParam);
+    break;
+
+  case WM_DISPLAYCHANGE:
+    // Display format has changed - notify callback
+    callback->displayChanged();
+    break;
+
+    // -=- Window position
+
+    // Prevent the window from being resized to be too large if in normal mode.
+    // If maximized or fullscreen the allow oversized windows.
+
+  case WM_WINDOWPOSCHANGING:
+    {
+      WINDOWPOS* wpos = (WINDOWPOS*)lParam;
+      if ((wpos->flags & SWP_NOSIZE) || isAutoScaling())
+        break;
+
+      // Calculate the minimum size of main window
+      RECT r;
+      Rect min_size;
+      int tbMinWidth = 0, tbMinHeight = 0;
+      if (isToolbarEnabled()) {
+        tbMinWidth = tb.getTotalWidth();
+        tbMinHeight = tb.getHeight();
+        SetRect(&r, 0, 0, tbMinWidth, tbMinHeight);
+        AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
+        min_size = Rect(r.left, r.top, r.right, r.bottom);
+      }
+
+      // Work out how big the window should ideally be
+      DWORD current_style = GetWindowLong(frameHandle, GWL_STYLE);
+      DWORD style = current_style & ~(WS_VSCROLL | WS_HSCROLL);
+      DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
+
+      SetRect(&r, 0, 0, buffer->width(), buffer->height());
+      AdjustWindowRectEx(&r, style, FALSE, style_ex);
+      Rect reqd_size = Rect(r.left, r.top, r.right, r.bottom);
+      if (current_style & WS_VSCROLL)
+        reqd_size.br.x += GetSystemMetrics(SM_CXVSCROLL);
+      if (current_style & WS_HSCROLL)
+        reqd_size.br.y += GetSystemMetrics(SM_CXHSCROLL);
+
+      SetRect(&r, reqd_size.tl.x, reqd_size.tl.y, reqd_size.br.x, reqd_size.br.y);
+      if (isToolbarEnabled())
+        r.bottom += tb.getHeight();
+      AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
+      reqd_size = Rect(r.left, r.top, r.right, r.bottom);
+
+      RECT current;
+      GetWindowRect(handle, &current);
+
+      if (min_size.width() > reqd_size.width()) {
+        reqd_size.tl.x = min_size.tl.x;
+        reqd_size.br.x = min_size.br.x;
+      }
+      if (min_size.height() > reqd_size.height()) {
+        reqd_size.tl.y = min_size.tl.y;
+        reqd_size.br.y = min_size.br.y;
+      }
+
+      if (!(GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE) && !fullscreenActive) {
+        // Ensure that the window isn't resized too large or too small
+        if ((wpos->cx < min_size.width()) && isToolbarEnabled()) {
+          wpos->cx = min_size.width();
+          wpos->x = current.left;
+        } else if ((wpos->cx > reqd_size.width())) {
+          wpos->cx = reqd_size.width();
+          wpos->x = current.left;
+        }
+        if ((wpos->cy < min_size.height()) && isToolbarEnabled()) {
+          wpos->cy = min_size.height();
+          wpos->y = current.top;
+        } else if (wpos->cy > reqd_size.height()) {
+          wpos->cy = reqd_size.height();
+          wpos->y = current.top;
+        }
+      }
+    }
+    break;
+
+    // Resize child windows and update window size info we have cached.
+
+  case WM_SIZE:
+    {
+      Point old_offset = desktopToClient(Point(0, 0));
+      RECT r;
+
+      // Resize child windows
+      GetClientRect(handle, &r);
+      if (tb.isVisible()) {
+        MoveWindow(frameHandle, 0, tb.getHeight(), r.right, r.bottom - tb.getHeight(), TRUE);
+      } else {
+        MoveWindow(frameHandle, 0, 0, r.right, r.bottom, TRUE);
+      }
+      tb.autoSize();
+ 
+      // Update the cached sizing information
+      GetWindowRect(frameHandle, &r);
+      window_size = Rect(r.left, r.top, r.right, r.bottom);
+      GetClientRect(frameHandle, &r);
+      client_size = Rect(r.left, r.top, r.right, r.bottom);
+
+      // Perform the AutoScaling operation
+      if (isAutoScaling()) {
+        fitBufferToWindow(false);
+      } else {
+        // Determine whether scrollbars are required
+        calculateScrollBars();
+      }
+
+      // Redraw if required
+      if ((!old_offset.equals(desktopToClient(Point(0, 0)))) || isAutoScaling())
+        InvalidateRect(frameHandle, 0, TRUE);
+    }
+    break;
+
+    // -=- Bump-scrolling
+
+  case WM_TIMER:
+    switch (wParam) {
+    case TIMER_BUMPSCROLL:
+      if (!setViewportOffset(scrolloffset.translate(bumpScrollDelta)))
+        bumpScrollTimer.stop();
+      break;
+    case TIMER_POINTER_INTERVAL:
+    case TIMER_POINTER_3BUTTON:
+      ptr.handleTimer(callback, wParam);
+      break;
+    case TIMER_UPDATE:
+      updateWindow();
+      break;
+    }
+    break;
+
+    // -=- Track whether or not the window has focus
+
+  case WM_SETFOCUS:
+    has_focus = true;
+    break;
+  case WM_KILLFOCUS:
+    has_focus = false;
+    cursorOutsideBuffer();
+    // Restore the keyboard to a consistent state
+    kbd.releaseAllKeys(callback);
+    break;
+
+    // -=- If the menu is about to be shown, make sure it's up to date
+
+  case WM_INITMENU:
+    callback->refreshMenu(true);
+    break;
+
+    // -=- Handle the extra window menu items
+
+    // Pass system menu messages to the callback and only attempt
+    // to process them ourselves if the callback returns false.
+  case WM_SYSCOMMAND:
+    // Call the supplied callback
+    if (callback->sysCommand(wParam, lParam))
+      break;
+
+    // - Not processed by the callback, so process it as a system message
+    switch (wParam & 0xfff0) {
+
+      // When restored, ensure that full-screen mode is re-enabled if required.
+    case SC_RESTORE:
+      {
+      if (GetWindowLong(handle, GWL_STYLE) & WS_MINIMIZE) {
+        rfb::win32::SafeDefWindowProc(handle, msg, wParam, lParam);
+        setFullscreen(fullscreenRestore);
+      }
+      else if (fullscreenActive)
+        setFullscreen(false);
+      else
+        rfb::win32::SafeDefWindowProc(handle, msg, wParam, lParam);
+
+      return 0;
+      }
+
+      // If we are maximized or minimized then that cancels full-screen mode.
+    case SC_MINIMIZE:
+    case SC_MAXIMIZE:
+      fullscreenRestore = fullscreenActive;
+      setFullscreen(false);
+      break;
+
+    }
+    break;
+
+    // Treat all menu commands as system menu commands
+  case WM_COMMAND:
+    SendMessage(handle, WM_SYSCOMMAND, wParam, lParam);
+    return 0;
+
+    // -=- Handle keyboard input
+
+  case WM_KEYUP:
+  case WM_KEYDOWN:
+    // Hook the MenuKey to pop-up the window menu
+    if (menuKey && (wParam == menuKey)) {
+
+      bool ctrlDown = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
+      bool altDown = (GetAsyncKeyState(VK_MENU) & 0x8000) != 0;
+      bool shiftDown = (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0;
+      if (!(ctrlDown || altDown || shiftDown)) {
+
+        // If MenuKey is being released then pop-up the menu
+        if ((msg == WM_KEYDOWN)) {
+          // Make sure it's up to date
+          //
+          // NOTE: Here we call refreshMenu only to grey out Move and Size
+          //       menu items. Other things will be refreshed once again
+          //       while processing the WM_INITMENU message.
+          //
+          callback->refreshMenu(false);
+
+          // Show it under the pointer
+          POINT pt;
+          GetCursorPos(&pt);
+          cursorInBuffer = false;
+          TrackPopupMenu(GetSystemMenu(handle, FALSE),
+            TPM_CENTERALIGN | TPM_VCENTERALIGN, pt.x, pt.y, 0, handle, 0);
+        }
+
+        // Ignore the MenuKey keypress for both press & release events
+        return 0;
+      }
+    }
+	case WM_SYSKEYDOWN:
+	case WM_SYSKEYUP:
+    kbd.keyEvent(callback, wParam, lParam, (msg == WM_KEYDOWN) || (msg == WM_SYSKEYDOWN));
+    return 0;
+
+    // -=- Handle mouse wheel scroll events
+
+#ifdef WM_MOUSEWHEEL
+  case WM_MOUSEWHEEL:
+    processMouseMessage(msg, wParam, lParam);
+    break;
+#endif
+
+    // -=- Handle the window closing
+
+  case WM_CLOSE:
+	vlog.debug("WM_CLOSE %x", handle);
+	if (!allowClose) {
+		vlog.debug("WM_CLOSE %x not allowed, so not closing window", handle);
+		msg = WM_NULL;
+	}else if(ConfirmQuitDialog()) {
+		callback->closeWindow();
+	}
+	else {
+		vlog.debug("WM_CLOSE aborted by user");
+		msg = WM_NULL;
+	}
+    break;
+
+  }
+
+  return rfb::win32::SafeDefWindowProc(handle, msg, wParam, lParam);
+}
+
+LRESULT
+DesktopWindow::processFrameMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
+  switch (msg) {
+
+    // -=- Paint the remote frame buffer
+
+  case WM_PAINT:
+    {
+      PAINTSTRUCT ps;
+      HDC paintDC = BeginPaint(frameHandle, &ps);
+      if (!paintDC)
+        throw rdr::SystemException("unable to BeginPaint", GetLastError());
+      Rect pr = Rect(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+
+      if (!pr.is_empty()) {
+
+        // Draw using the correct palette
+        PaletteSelector pSel(paintDC, windowPalette.getHandle());
+
+        if (buffer->bitmap) {
+          // Update the bitmap's palette
+          if (palette_changed) {
+            palette_changed = false;
+            buffer->refreshPalette();
+          }
+
+          // Get device context
+          BitmapDC bitmapDC(paintDC, buffer->bitmap);
+
+          // Blit the border if required
+          Rect bufpos = desktopToClient(buffer->getRect());
+          if (!pr.enclosed_by(bufpos)) {
+            vlog.debug("draw border");
+            HBRUSH black = (HBRUSH) GetStockObject(BLACK_BRUSH);
+            RECT r;
+            SetRect(&r, 0, 0, bufpos.tl.x, client_size.height()); FillRect(paintDC, &r, black);
+            SetRect(&r, bufpos.tl.x, 0, bufpos.br.x, bufpos.tl.y); FillRect(paintDC, &r, black);
+            SetRect(&r, bufpos.br.x, 0, client_size.width(), client_size.height()); FillRect(paintDC, &r, black);
+            SetRect(&r, bufpos.tl.x, bufpos.br.y, bufpos.br.x, client_size.height()); FillRect(paintDC, &r, black);
+          }
+
+          // Do the blit
+          Point buf_pos = clientToDesktop(pr.tl);
+
+          if (!BitBlt(paintDC, pr.tl.x, pr.tl.y, pr.width(), pr.height(),
+                      bitmapDC, buf_pos.x, buf_pos.y, SRCCOPY))
+            throw rdr::SystemException("unable to BitBlt to window", GetLastError());
+        }
+      }
+
+      EndPaint(frameHandle, &ps);
+
+      // - Notify the callback that a paint message has finished processing
+      callback->paintCompleted();
+    }
+    return 0;
+
+    // -=- Palette management
+
+  case WM_PALETTECHANGED:
+    vlog.debug("WM_PALETTECHANGED");
+    if ((HWND)wParam == frameHandle) {
+      vlog.debug("ignoring");
+      break;
+    }
+  case WM_QUERYNEWPALETTE:
+    vlog.debug("re-selecting palette");
+    {
+      WindowDC wdc(frameHandle);
+      PaletteSelector pSel(wdc, windowPalette.getHandle());
+      if (pSel.isRedrawRequired()) {
+        InvalidateRect(frameHandle, 0, FALSE);
+        UpdateWindow(frameHandle);
+      }
+    }
+    return TRUE;
+
+  case WM_VSCROLL:
+  case WM_HSCROLL: 
+    {
+      Point delta;
+      int newpos = (msg == WM_VSCROLL) ? scrolloffset.y : scrolloffset.x;
+
+      switch (LOWORD(wParam)) {
+      case SB_PAGEUP: newpos -= 50; break;
+      case SB_PAGEDOWN: newpos += 50; break;
+      case SB_LINEUP: newpos -= 5; break;
+      case SB_LINEDOWN: newpos += 5; break;
+      case SB_THUMBTRACK:
+      case SB_THUMBPOSITION: newpos = HIWORD(wParam); break;
+      default: vlog.info("received unknown scroll message");
+      };
+
+      if (msg == WM_HSCROLL)
+        setViewportOffset(Point(newpos, scrolloffset.y));
+      else
+        setViewportOffset(Point(scrolloffset.x, newpos));
+  
+      SCROLLINFO si;
+      si.cbSize = sizeof(si); 
+      si.fMask  = SIF_POS; 
+      si.nPos   = newpos; 
+      SetScrollInfo(frameHandle, (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ, &si, TRUE); 
+    }
+    break;
+
+    // -=- Cursor shape/visibility handling
+
+  case WM_SETCURSOR:
+    if (LOWORD(lParam) != HTCLIENT)
+      break;
+    SetCursor(cursorInBuffer ? dotCursor : arrowCursor);
+    return TRUE;
+
+  case WM_MOUSELEAVE:
+    trackingMouseLeave = false;
+    cursorOutsideBuffer();
+    return 0;
+
+    // -=- Mouse input handling
+
+  case WM_MOUSEMOVE:
+  case WM_LBUTTONUP:
+  case WM_MBUTTONUP:
+  case WM_RBUTTONUP:
+  case WM_LBUTTONDOWN:
+  case WM_MBUTTONDOWN:
+  case WM_RBUTTONDOWN:
+    processMouseMessage(msg, wParam, lParam);
+    break;
+  }
+
+  return rfb::win32::SafeDefWindowProc(frameHandle, msg, wParam, lParam);
+}
+
+void
+DesktopWindow::processMouseMessage(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+  if (!has_focus) {
+    cursorOutsideBuffer();
+    return;
+  }
+
+  if (!trackingMouseLeave) {
+    TRACKMOUSEEVENT tme;
+    tme.cbSize = sizeof(TRACKMOUSEEVENT);
+    tme.dwFlags = TME_LEAVE;
+    tme.hwndTrack = frameHandle;
+    _TrackMouseEvent(&tme);
+    trackingMouseLeave = true;
+  }
+  int mask = 0;
+  if (LOWORD(wParam) & MK_LBUTTON) mask |= 1;
+  if (LOWORD(wParam) & MK_MBUTTON) mask |= 2;
+  if (LOWORD(wParam) & MK_RBUTTON) mask |= 4;
+
+#ifdef WM_MOUSEWHEEL
+  if (msg == WM_MOUSEWHEEL) {
+    int delta = (short)HIWORD(wParam);
+    int repeats = (abs(delta)+119) / 120;
+    int wheelMask = (delta > 0) ? 8 : 16;
+    vlog.debug("repeats %d, mask %d\n",repeats,wheelMask);
+    for (int i=0; i<repeats; i++) {
+      ptr.pointerEvent(callback, oldpos, mask | wheelMask);
+      ptr.pointerEvent(callback, oldpos, mask);
+    }
+  } else {
+#endif
+    Point clientPos = Point(LOWORD(lParam), HIWORD(lParam));
+    Point p = clientToDesktop(clientPos);
+
+    // If the mouse is not within the server buffer area, do nothing
+    cursorInBuffer = buffer->getRect().contains(p);
+    if (!cursorInBuffer) {
+      cursorOutsideBuffer();
+      return;
+    }
+
+    // If we're locally rendering the cursor then redraw it
+    if (cursorAvailable) {
+      // - Render the cursor!
+      if (!p.equals(cursorPos)) {
+        hideLocalCursor();
+        cursorPos = p;
+        showLocalCursor();
+        if (cursorVisible)
+          hideSystemCursor();
+      }
+    }
+
+    // If we are doing bump-scrolling then try that first...
+    if (processBumpScroll(clientPos))
+      return;
+
+    // Send a pointer event to the server
+    oldpos = p;
+    if (buffer->isScaling()) {
+      p.x /= buffer->getScaleRatioX();
+      p.y /= buffer->getScaleRatioY();
+    }
+    ptr.pointerEvent(callback, p, mask);
+#ifdef WM_MOUSEWHEEL
+  }
+#endif
+}
+
+void DesktopWindow::updateWindow()
+{
+  Rect rect;
+
+  updateTimer.stop();
+
+  rect = damage.get_bounding_rect();
+  damage.clear();
+
+  RECT invalid = {rect.tl.x, rect.tl.y, rect.br.x, rect.br.y};
+  InvalidateRect(frameHandle, &invalid, FALSE);
+}
+
+void
+DesktopWindow::hideLocalCursor() {
+  // - Blit the cursor backing store over the cursor
+  // *** ALWAYS call this BEFORE changing buffer PF!!!
+  if (cursorVisible) {
+    cursorVisible = false;
+    buffer->DIBSectionBuffer::imageRect(cursorBackingRect, cursorBacking.data);
+    invalidateDesktopRect(cursorBackingRect, false);
+  }
+}
+
+void
+DesktopWindow::showLocalCursor() {
+  if (cursorAvailable && !cursorVisible && cursorInBuffer) {
+    if (!buffer->getScaledPixelFormat().equal(cursor.getPF()) ||
+      cursor.getRect().is_empty()) {
+      vlog.info("attempting to render invalid local cursor");
+      cursorAvailable = false;
+      showSystemCursor();
+      return;
+    }
+    cursorVisible = true;
+    
+    cursorBackingRect = cursor.getRect().translate(cursorPos).translate(cursor.hotspot.negate());
+    cursorBackingRect = cursorBackingRect.intersect(buffer->getRect());
+    buffer->getImage(cursorBacking.data, cursorBackingRect);
+
+    renderLocalCursor();
+
+    invalidateDesktopRect(cursorBackingRect, false);
+    // Since we render the cursor onto the framebuffer, we need to update
+    // right away to get a responsive cursor.
+    updateWindow();
+  }
+}
+
+void DesktopWindow::cursorOutsideBuffer()
+{
+  cursorInBuffer = false;
+  hideLocalCursor();
+  showSystemCursor();
+}
+
+void
+DesktopWindow::renderLocalCursor()
+{
+  Rect r = cursor.getRect();
+  r = r.translate(cursorPos).translate(cursor.hotspot.negate());
+  buffer->DIBSectionBuffer::maskRect(r, cursor.data, cursor.mask.buf);
+}
+
+void
+DesktopWindow::hideSystemCursor() {
+  if (systemCursorVisible) {
+    vlog.debug("hide system cursor");
+    systemCursorVisible = false;
+    ShowCursor(FALSE);
+  }
+}
+
+void
+DesktopWindow::showSystemCursor() {
+  if (!systemCursorVisible) {
+    vlog.debug("show system cursor");
+    systemCursorVisible = true;
+    ShowCursor(TRUE);
+  }
+}
+
+
+bool
+DesktopWindow::invalidateDesktopRect(const Rect& crect, bool scaling) {
+  Rect rect;
+  if (buffer->isScaling() && scaling) {
+    rect = desktopToClient(buffer->calculateScaleBoundary(crect));
+  } else rect = desktopToClient(crect);
+  if (rect.intersect(client_size).is_empty()) return false;
+  damage.assign_union(rfb::Region(rect));
+  if (!updateTimer.isActive())
+    updateTimer.start(100);
+  return true;
+}
+
+
+void
+DesktopWindow::notifyClipboardChanged(const char* text, int len) {
+  callback->clientCutText(text, len);
+}
+
+
+void
+DesktopWindow::setPF(const PixelFormat& pf) {
+  // If the cursor is the wrong format then clear it
+  if (!pf.equal(buffer->getScaledPixelFormat()))
+    setCursor(0, 0, Point(), 0, 0);
+
+  // Update the desktop buffer
+  buffer->setPF(pf);
+  
+  // Redraw the window
+  InvalidateRect(frameHandle, 0, FALSE);
+}
+
+void
+DesktopWindow::setSize(int w, int h) {
+  vlog.debug("setSize %dx%d", w, h);
+
+  // If the locally-rendered cursor is visible then remove it
+  hideLocalCursor();
+
+  // Resize the backing buffer
+  buffer->setSize(w, h);
+
+  // Calculate the pixel buffer aspect correlation. It's used
+  // for the autoScaling operation.
+  aspect_corr = (double)w / h;
+
+  // If the window is not maximised or full-screen then resize it
+  if (!(GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE) && !fullscreenActive) {
+    // Resize the window to the required size
+    RECT r = {0, 0, w, h};
+    AdjustWindowRectEx(&r, GetWindowLong(frameHandle, GWL_STYLE), FALSE,
+                       GetWindowLong(frameHandle, GWL_EXSTYLE));
+    if (isToolbarEnabled())
+      r.bottom += tb.getHeight();
+    AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
+
+    // Resize about the center of the window, and clip to current monitor
+    MonitorInfo mi(handle);
+    resizeWindow(handle, r.right-r.left, r.bottom-r.top);
+    mi.clipTo(handle);
+  } else {
+    // Ensure the screen contents are consistent
+    InvalidateRect(frameHandle, 0, FALSE);
+  }
+
+  // Enable/disable scrollbars as appropriate
+  calculateScrollBars();
+}
+
+void DesktopWindow::setAutoScaling(bool as) { 
+  autoScaling = as;
+  if (isToolbarEnabled()) refreshToolbarButtons();
+  if (as) fitBufferToWindow();
+}
+
+void DesktopWindow::setAllowClose(bool ac) { 
+  allowClose = ac;
+}
+
+void DesktopWindow::setDesktopScale(int scale_) {
+  if (buffer->getScale() == scale_ || scale_ <= 0) return;
+  bool state = buffer->isScaling();
+  buffer->setScale(scale_);
+  state ^= buffer->isScaling();
+  if (state) convertCursorToBuffer();
+  if (isToolbarEnabled()) refreshToolbarButtons();
+  if (!(isAutoScaling() || isFullscreen() || (GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE))) resizeDesktopWindowToBuffer();
+  printScale();
+  InvalidateRect(frameHandle, 0, FALSE);
+}
+
+void DesktopWindow::setDesktopScaleFilter(unsigned int scaleFilterID) { 
+  if (scaleFilterID == getDesktopScaleFilterID() || scaleFilterID > scaleFilterMaxNumber) return;
+  buffer->setScaleFilter(scaleFilterID);
+  InvalidateRect(frameHandle, 0, FALSE);
+}
+
+void DesktopWindow::convertCursorToBuffer() {
+  if (memcmp(&(cursor.getPF()), &(buffer->getPF()), sizeof(PixelBuffer)) == 0) return;
+  internalSetCursor = true;
+  setCursor(cursorWidth, cursorHeight, cursorHotspot, cursorImage, cursorMask);
+  internalSetCursor = false;
+}
+
+void DesktopWindow::fitBufferToWindow(bool repaint) {
+  double scale_ratio;
+  double resized_aspect_corr = double(client_size.width()) / client_size.height();
+  DWORD style = GetWindowLong(frameHandle, GWL_STYLE);
+  if (style & (WS_VSCROLL | WS_HSCROLL)) {
+    style &= ~(WS_VSCROLL | WS_HSCROLL);
+    SetWindowLong(frameHandle, GWL_STYLE, style);
+    SetWindowPos(frameHandle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+    // Update the cached client size
+    RECT r;
+    GetClientRect(frameHandle, &r);
+    client_size = Rect(r.left, r.top, r.right, r.bottom);
+  }
+  bool state = buffer->isScaling();
+  if (resized_aspect_corr > aspect_corr) {
+    scale_ratio = (double)client_size.height() / buffer->getSrcHeight();
+    buffer->setScaleWindowSize(ceil(buffer->getSrcWidth()*scale_ratio), client_size.height());
+  } else { 
+    scale_ratio = (double)client_size.width() / buffer->getSrcWidth();
+    buffer->setScaleWindowSize(client_size.width(), ceil(buffer->getSrcHeight()*scale_ratio));
+  }
+  state ^= buffer->isScaling();
+  if (state) convertCursorToBuffer();
+  printScale();
+  InvalidateRect(frameHandle, 0, FALSE);
+}
+
+void DesktopWindow::printScale() {
+  setName(desktopName);
+}
+
+void
+DesktopWindow::setCursor(int w, int h, const Point& hotspot, void* data, void* mask) {
+  hideLocalCursor();
+
+  cursor.hotspot = hotspot;
+
+  cursor.setSize(w, h);
+  cursor.setPF(buffer->getScaledPixelFormat());
+
+  // Convert the current cursor pixel format to bpp32 if scaling mode is on.
+  // It need because ScaledDIBSection buffer always works with bpp32 pixel data
+  // in scaling mode.
+  if (buffer->isScaling()) {
+    U8 *ptr = (U8*)cursor.data;
+    U8 *dataPtr = (U8*)data;
+    U32 pixel = 0;
+    int bytesPerPixel = buffer->getPixelFormat().bpp / 8;
+    int pixelCount = w * h;
+    PixelFormat pf = buffer->getPixelFormat();
+
+    while (pixelCount--) {
+      if (bytesPerPixel == 1) {
+        pixel = *dataPtr++;
+      } else if (bytesPerPixel == 2) {
+        int b0 = *dataPtr++; int b1 = *dataPtr++;
+        pixel =  b1 << 8 | b0;
+      } else if (bytesPerPixel == 4) {
+        int b0 = *dataPtr++; int b1 = *dataPtr++;
+        int b2 = *dataPtr++; int b3 = *dataPtr++;
+        pixel = b3 << 24 | b2 << 16 | b1 << 8 | b0;
+      } else {
+        pixel = 0;
+      }
+      *ptr++ = (U8)((((pixel >> pf.blueShift ) & pf.blueMax ) * 255 + pf.blueMax /2) / pf.blueMax);
+      *ptr++ = (U8)((((pixel >> pf.greenShift) & pf.greenMax) * 255 + pf.greenMax/2) / pf.greenMax);
+      *ptr++ = (U8)((((pixel >> pf.redShift  ) & pf.redMax  ) * 255 + pf.redMax  /2) / pf.redMax);
+      *ptr++ = (U8)0;
+    }
+  } else {
+    cursor.imageRect(cursor.getRect(), data);
+  }
+  memcpy(cursor.mask.buf, mask, cursor.maskLen());
+  cursor.crop();
+
+  cursorBacking.setSize(w, h);
+  cursorBacking.setPF(buffer->getScaledPixelFormat());
+
+  cursorAvailable = true;
+
+  showLocalCursor();
+
+  // Save the cursor parameters
+  if (!internalSetCursor) {
+    if (cursorImage) delete [] cursorImage;
+    if (cursorMask) delete [] cursorMask;
+    int cursorImageSize = (buffer->getPixelFormat().bpp/8) * w * h; 
+    cursorImage = new U8[cursorImageSize];
+    cursorMask = new U8[cursor.maskLen()];
+    memcpy(cursorImage, data, cursorImageSize);
+    memcpy(cursorMask, mask, cursor.maskLen());
+    cursorWidth = w;
+    cursorHeight = h;
+    cursorHotspot = hotspot;
+  }
+}
+
+PixelFormat
+DesktopWindow::getNativePF() const {
+  vlog.debug("getNativePF()");
+  return WindowDC(handle).getPF();
+}
+
+
+void
+DesktopWindow::refreshWindowPalette(int start, int count) {
+  vlog.debug("refreshWindowPalette(%d, %d)", start, count);
+
+  Colour colours[256];
+  if (count > 256) {
+    vlog.debug("%d palette entries", count);
+    throw rdr::Exception("too many palette entries");
+  }
+
+  // Copy the palette from the DIBSectionBuffer
+  ColourMap* cm = buffer->getColourMap();
+  if (!cm) return;
+  for (int i=0; i<count; i++) {
+    int r, g, b;
+    cm->lookup(i, &r, &g, &b);
+    colours[i].r = r;
+    colours[i].g = g;
+    colours[i].b = b;
+  }
+
+  // Set the window palette
+  windowPalette.setEntries(start, count, colours);
+
+  // Cause the window to be redrawn
+  palette_changed = true;
+  InvalidateRect(handle, 0, FALSE);
+}
+
+
+void DesktopWindow::calculateScrollBars() {
+  // Calculate the required size of window
+  DWORD current_style = GetWindowLong(frameHandle, GWL_STYLE);
+  DWORD style = current_style & ~(WS_VSCROLL | WS_HSCROLL);
+  DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
+  DWORD old_style;
+  RECT r;
+  SetRect(&r, 0, 0, buffer->width(), buffer->height());
+  AdjustWindowRectEx(&r, style, FALSE, style_ex);
+  Rect reqd_size = Rect(r.left, r.top, r.right, r.bottom);
+
+  if (!bumpScroll) {
+    // We only enable scrollbars if bump-scrolling is not active.
+    // Effectively, this means if full-screen is not active,
+    // but I think it's better to make these things explicit.
+    
+    // Work out whether scroll bars are required
+    do {
+      old_style = style;
+
+      if (!(style & WS_HSCROLL) && (reqd_size.width() > window_size.width())) {
+        style |= WS_HSCROLL;
+        reqd_size.br.y += GetSystemMetrics(SM_CXHSCROLL);
+      }
+      if (!(style & WS_VSCROLL) && (reqd_size.height() > window_size.height())) {
+        style |= WS_VSCROLL;
+        reqd_size.br.x += GetSystemMetrics(SM_CXVSCROLL);
+      }
+    } while (style != old_style);
+  }
+
+  // Tell Windows to update the window style & cached settings
+  if (style != current_style) {
+    SetWindowLong(frameHandle, GWL_STYLE, style);
+    SetWindowPos(frameHandle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+  }
+
+  // Update the scroll settings
+  SCROLLINFO si;
+  if (style & WS_VSCROLL) {
+    si.cbSize = sizeof(si); 
+    si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS; 
+    si.nMin   = 0; 
+    si.nMax   = buffer->height(); 
+    si.nPage  = buffer->height() - (reqd_size.height() - window_size.height()); 
+    maxscrolloffset.y = __rfbmax(0, si.nMax-si.nPage);
+    scrolloffset.y = __rfbmin(maxscrolloffset.y, scrolloffset.y);
+    si.nPos   = scrolloffset.y;
+    SetScrollInfo(frameHandle, SB_VERT, &si, TRUE);
+  }
+  if (style & WS_HSCROLL) {
+    si.cbSize = sizeof(si); 
+    si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS; 
+    si.nMin   = 0;
+    si.nMax   = buffer->width(); 
+    si.nPage  = buffer->width() - (reqd_size.width() - window_size.width()); 
+    maxscrolloffset.x = __rfbmax(0, si.nMax-si.nPage);
+    scrolloffset.x = __rfbmin(maxscrolloffset.x, scrolloffset.x);
+    si.nPos   = scrolloffset.x;
+    SetScrollInfo(frameHandle, SB_HORZ, &si, TRUE);
+  }
+
+  // Update the cached client size
+  GetClientRect(frameHandle, &r);
+  client_size = Rect(r.left, r.top, r.right, r.bottom);
+}
+
+void DesktopWindow::resizeDesktopWindowToBuffer() {
+  RECT r;
+  DWORD style = GetWindowLong(frameHandle, GWL_STYLE) & ~(WS_VSCROLL | WS_HSCROLL);
+  DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
+
+  // Calculate the required size of the desktop window
+  SetRect(&r, 0, 0, buffer->width(), buffer->height());
+  AdjustWindowRectEx(&r, style, FALSE, style_ex);
+  if (isToolbarEnabled())
+    r.bottom += tb.getHeight();
+  AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
+
+  // Set the required size, center the main window and clip to the current monitor
+  SetWindowPos(handle, 0, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
+  centerWindow(handle, NULL);
+  MonitorInfo mi(getMonitor());
+  mi.clipTo(handle);
+
+  // Enable/disable scrollbars as appropriate
+  calculateScrollBars();      
+}
+
+
+void DesktopWindow::framebufferUpdateEnd()
+{
+  updateWindow();
+}
+
+
+void
+DesktopWindow::setName(const char* name) {
+  if (name != desktopName) {
+    strCopy(desktopName, name, sizeof(desktopName));
+  }
+  char *newTitle = new char[strlen(desktopName)+20];
+  sprintf(newTitle, "TigerVNC: %.240s @ %i%%", desktopName, getDesktopScale());
+  SetWindowText(handle, TStr(newTitle));
+  delete [] newTitle;
+}
+
+
+void
+DesktopWindow::serverCutText(const char* str, rdr::U32 len) {
+  CharArray t(len+1);
+  memcpy(t.buf, str, len);
+  t.buf[len] = 0;
+  clipboard.setClipText(t.buf);
+}
+
+
+void DesktopWindow::fillRect(const Rect& r, Pixel pix) {
+  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
+  if (cursorBackingRect.overlaps(img_rect)) hideLocalCursor();
+  buffer->fillRect(r, pix);
+  invalidateDesktopRect(r);
+}
+void DesktopWindow::imageRect(const Rect& r, void* pixels) {
+  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
+  if (cursorBackingRect.overlaps(img_rect)) hideLocalCursor();
+  buffer->imageRect(r, pixels);
+  invalidateDesktopRect(r);
+}
+void DesktopWindow::copyRect(const Rect& r, int srcX, int srcY) {
+  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
+  if (cursorBackingRect.overlaps(img_rect) ||
+      cursorBackingRect.overlaps(Rect(srcX, srcY, srcX+img_rect.width(), srcY+img_rect.height())))
+    hideLocalCursor();
+  buffer->copyRect(r, Point(r.tl.x-srcX, r.tl.y-srcY));
+  invalidateDesktopRect(r);
+}
+
+void DesktopWindow::invertRect(const Rect& r) {
+  int stride;
+  rdr::U8* p = buffer->isScaling() ? buffer->getPixelsRW(buffer->calculateScaleBoundary(r), &stride) 
+   : buffer->getPixelsRW(r, &stride);
+  for (int y = 0; y < r.height(); y++) {
+    for (int x = 0; x < r.width(); x++) {
+      switch (buffer->getPF().bpp) {
+      case 8:  ((rdr::U8* )p)[x+y*stride] ^= 0xff;       break;
+      case 16: ((rdr::U16*)p)[x+y*stride] ^= 0xffff;     break;
+      case 32: ((rdr::U32*)p)[x+y*stride] ^= 0xffffffff; break;
+      }
+    }
+  }
+  invalidateDesktopRect(r);
+}
diff -urN win/vncviewer/DesktopWindow.h win.new/vncviewer/DesktopWindow.h
--- win/vncviewer/DesktopWindow.h	2009-11-26 16:51:06.000000000 +0100
+++ win.new/vncviewer/DesktopWindow.h	2009-11-26 15:19:23.000000000 +0100
@@ -87,6 +87,7 @@
       void setSize(int w, int h);
       void setColour(int i, int r, int g, int b) {buffer->setColour(i, r, g, b);}
       void setAutoScaling(bool as);
+	  void setAllowClose(bool ac);
       bool isAutoScaling() const { return autoScaling; }
       void setDesktopScale(int scale);
       int  getDesktopScale() const { return buffer->getScale(); }
@@ -274,6 +275,7 @@
       double aspect_corr;
       bool has_focus;
       bool autoScaling;
+	  bool allowClose;
       Rect window_size;
       Rect client_size;
       Point scrolloffset;
diff -urN win/vncviewer/OptionsDialog.cxx win.new/vncviewer/OptionsDialog.cxx
--- win/vncviewer/OptionsDialog.cxx	2009-11-26 16:51:03.000000000 +0100
+++ win.new/vncviewer/OptionsDialog.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -166,6 +166,8 @@
     setItemChecked(IDC_ACCEPT_BELL, dlg->options.acceptBell);
     setItemChecked(IDC_AUTO_RECONNECT, dlg->options.autoReconnect);
     setItemChecked(IDC_SHOW_TOOLBAR, dlg->options.showToolbar);
+	setItemChecked(IDC_SOUND_SUPPORT, dlg->options.soundSupport);
+	setItemChecked(IDC_ALLOW_CLOSE, dlg->options.allowClose);
     char scale_values[10][20] = {
       "10","25","50","75","90","100","125","150","200","Auto"
     };
@@ -175,10 +177,11 @@
         (WPARAM)i, (LPARAM)(int FAR*)scale_values[i]);
     }
     if (dlg->options.autoScaling) {
-      SetDlgItemText(handle, IDC_COMBO_SCALE, "Auto");
+      SetDlgItemText(handle, IDC_COMBO_SCALE, LPCWSTR("Auto"));
     } else {
       SetDlgItemInt(handle, IDC_COMBO_SCALE, dlg->options.scale, FALSE);
     }
+
   }
   virtual bool onOk() {
     dlg->options.shared = isItemChecked(IDC_CONN_SHARED);
@@ -189,13 +192,15 @@
     dlg->options.acceptBell = isItemChecked(IDC_ACCEPT_BELL);
     dlg->options.autoReconnect = isItemChecked(IDC_AUTO_RECONNECT);
     dlg->options.showToolbar = isItemChecked(IDC_SHOW_TOOLBAR);
+	dlg->options.soundSupport = isItemChecked(IDC_SOUND_SUPPORT);
+	dlg->options.allowClose = isItemChecked(IDC_ALLOW_CLOSE);
     int s = GetDlgItemInt(handle, IDC_COMBO_SCALE, NULL, FALSE);
     if (s > 0) {
       dlg->options.scale = s;
       dlg->options.autoScaling = false;
     } else {
       char scaleStr[20];
-      GetDlgItemText(handle, IDC_COMBO_SCALE, scaleStr, 20);
+      GetDlgItemText(handle, IDC_COMBO_SCALE, LPTSTR(scaleStr), 20);
       if (strcmp(scaleStr, "Auto") == 0) {
         dlg->options.autoScaling = true;
       }
@@ -212,7 +217,7 @@
           int index = SendMessage(handleComboScale, CB_GETCURSEL, 0, 0);
           SendMessage(handleComboScale, CB_GETLBTEXT, (WPARAM)index, (LPARAM)scaleStr);
         } else {
-          GetDlgItemText(handle, IDC_COMBO_SCALE, scaleStr, 20);
+          GetDlgItemText(handle, IDC_COMBO_SCALE, LPTSTR(scaleStr), 20);
         }
         return true;
       }
diff -urN win/vncviewer/resource.h win.new/vncviewer/resource.h
--- win/vncviewer/resource.h	2009-11-26 16:51:05.000000000 +0100
+++ win.new/vncviewer/resource.h	2009-11-26 15:19:23.000000000 +0100
@@ -86,6 +86,8 @@
 #define IDC_STATIC_SCALE                1097
 #define IDC_COMBO_SCALE                 1098
 #define IDC_STATIC_PERCENT              1099
+#define IDC_SOUND_SUPPORT				1100
+#define IDC_ALLOW_CLOSE					1101
 #define ID_TOOLBAR                      4002
 #define ID_CLOSE                        4003
 #define ID_OPTIONS                      4004
diff -urN win/vncviewer/ViewerToolBar.cxx win.new/vncviewer/ViewerToolBar.cxx
--- win/vncviewer/ViewerToolBar.cxx	2009-11-26 16:51:07.000000000 +0100
+++ win.new/vncviewer/ViewerToolBar.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -20,6 +20,7 @@
 
 #include <vncviewer/ViewerToolBar.h>
 #include <vncviewer/resource.h>
+#include <tchar.h>
 
 void ViewerToolBar::create(HWND parentHwnd) {
   // Create the toolbar panel
@@ -63,34 +64,34 @@
 
       switch (TTStr->hdr.idFrom) {
       case ID_OPTIONS:
-        TTStr->lpszText = "Connection options...";
+        TTStr->lpszText = _T("Connection options...");
         break;
       case ID_INFO:
-        TTStr->lpszText = "Connection info";
+        TTStr->lpszText = _T("Connection info");
         break;
       case ID_FULLSCREEN:
-        TTStr->lpszText = "Full screen";
+        TTStr->lpszText = _T("Full screen");
         break;
       case ID_REQUEST_REFRESH:
-        TTStr->lpszText = "Request screen refresh";
+        TTStr->lpszText = _T("Request screen refresh");
         break;
       case ID_SEND_CAD:
-        TTStr->lpszText = "Send Ctrl-Alt-Del";
+        TTStr->lpszText = _T("Send Ctrl-Alt-Del");
         break;
       case ID_SEND_CTLESC:
-        TTStr->lpszText = "Send Ctrl-Esc";
+        TTStr->lpszText = _T("Send Ctrl-Esc");
         break;
       case ID_CTRL_KEY:
-        TTStr->lpszText = "Send Ctrl key press/release";
+        TTStr->lpszText = _T("Send Ctrl key press/release");
         break;
       case ID_ALT_KEY:
-        TTStr->lpszText = "Send Alt key press/release";
+        TTStr->lpszText = _T("Send Alt key press/release");
         break;
       case ID_NEW_CONNECTION:
-        TTStr->lpszText = "New connection...";
+        TTStr->lpszText = _T("New connection...");
         break;
       case ID_CONN_SAVE_AS:
-        TTStr->lpszText = "Save connection info as...";
+        TTStr->lpszText = _T("Save connection info as...");
         break;
       default:
         break;
diff -urN win/vncviewer/vncviewer.rc win.new/vncviewer/vncviewer.rc
--- win/vncviewer/vncviewer.rc	2009-11-26 16:51:08.000000000 +0100
+++ win.new/vncviewer/vncviewer.rc	2009-11-26 15:19:23.000000000 +0100
@@ -147,9 +147,10 @@
     CONTROL         120,IDI_ICON,"Static",SS_BITMAP | SS_REALSIZEIMAGE,5,6,
                     20,20
     RTEXT           "Server:",IDC_STATIC,43,6,37,13,SS_CENTERIMAGE
-    RTEXT           "Encryption:",IDC_STATIC,43,24,37,12,SS_CENTERIMAGE
-    COMBOBOX        IDC_SECURITY_LEVEL,85,24,105,76,CBS_DROPDOWNLIST | 
-                    CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    //RTEXT           "Encryption:",IDC_STATIC,43,24,37,12,SS_CENTERIMAGE
+    //COMBOBOX        IDC_SECURITY_LEVEL,85,24,105,76,CBS_DROPDOWNLIST | 
+    //                CBS_SORT | WS_VSCROLL | WS_TABSTOP
+	//Disabled encryption selection dialog, as it is not supported yet
 END
 
 IDD_ABOUT DIALOG DISCARDABLE  0, 0, 249, 92
@@ -226,6 +227,10 @@
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,85,202,15
     CONTROL         "Offer to automatically reconnect",IDC_AUTO_RECONNECT,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,100,202,15
+	CONTROL			"Enable sound support",IDC_SOUND_SUPPORT,
+					"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,115,202,15
+	CONTROL			"Allow closing the VNC window",IDC_ALLOW_CLOSE,
+					"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,130,202,15
     CONTROL         "Show toolbar",IDC_SHOW_TOOLBAR,"Button",BS_AUTOCHECKBOX | 
                     WS_TABSTOP,106,25,103,15
     COMBOBOX        IDC_COMBO_SCALE,138,40,42,134,CBS_DROPDOWN | CBS_SORT | 
diff -urN win/vncviewer/vncviewer.vcproj win.new/vncviewer/vncviewer.vcproj
--- win/vncviewer/vncviewer.vcproj	1970-01-01 01:00:00.000000000 +0100
+++ win.new/vncviewer/vncviewer.vcproj	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,1307 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="vncviewer"
+	ProjectGUID="{D3ADDDCF-94CA-4D99-9F68-9BBCF0F68158}"
+	TargetFrameworkVersion="0"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\..\Debug"
+			IntermediateDirectory=".\..\Debug\vncviewer"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Debug/vncviewer.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_DEBUG;_WINDOWS;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug\vncviewer/vncviewer.pch"
+				AssemblerListingLocation=".\..\Debug\vncviewer/"
+				ObjectFile=".\..\Debug\vncviewer/"
+				ProgramDataBaseFileName=".\..\Debug\vncviewer/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Debug\ /Fd..\Debug\vncviewer /MTd buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile=".\..\Debug/vncviewer.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug/vncviewer.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug/vncviewer.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug Unicode|Win32"
+			OutputDirectory=".\..\Debug_Unicode"
+			IntermediateDirectory=".\..\Debug_Unicode\vncviewer"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Debug_Unicode/vncviewer.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/D &quot;HAVE_GNUTLS&quot;"
+				Optimization="0"
+				AdditionalIncludeDirectories="..;../../common;../../gnutls"
+				PreprocessorDefinitions="_WINDOWS;_DEBUG;WIN32;UNICODE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\vncviewer/vncviewer.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\vncviewer/"
+				ObjectFile=".\..\Debug_Unicode\vncviewer/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\vncviewer/"
+				BrowseInformation="1"
+				WarningLevel="2"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Debug_Unicode\ /Fd..\Debug_Unicode\vncviewer /MTd buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				UseLibraryDependencyInputs="false"
+				AdditionalOptions="&quot;..\..\gnutls\w32gnutls.lib&quot; &quot;..\..\gnutls\w32gcrypt.lib&quot; &quot;..\..\gnutls\w32gpgerror.lib&quot;"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile=".\..\Debug_Unicode/vncviewer.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug_Unicode/vncviewer.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug_Unicode/vncviewer.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\..\Release"
+			IntermediateDirectory=".\..\Release\vncviewer"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Release/vncviewer.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\vncviewer/vncviewer.pch"
+				AssemblerListingLocation=".\..\Release\vncviewer/"
+				ObjectFile=".\..\Release\vncviewer/"
+				ProgramDataBaseFileName=".\..\Release\vncviewer/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Release\ /Fd..\Release\vncviewer /MT buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile=".\..\Release/vncviewer.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/vncviewer.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/vncviewer.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Released Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Debug_Unicode/vncviewer.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/D &quot;HAVE_GNUTLS&quot;"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				OmitFramePointers="false"
+				EnableFiberSafeOptimizations="false"
+				AdditionalIncludeDirectories="..;../../common;../../gnutls"
+				PreprocessorDefinitions="_WINDOWS;_NDEBUG;WIN32;UNICODE"
+				StringPooling="true"
+				MinimalRebuild="false"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release_Unicode\vncviewer/vncviewer.pch"
+				AssemblerListingLocation=".\..\Release_Unicode\vncviewer/"
+				ObjectFile=".\..\Release_Unicode\vncviewer/"
+				ProgramDataBaseFileName=".\..\Release_Unicode\vncviewer/"
+				BrowseInformation="0"
+				WarningLevel="2"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="0"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_NDEBUG"
+				Culture="2057"
+				AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Release_Unicode\ /Fd..\Release_Unicode\vncviewer /MTd buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				UseLibraryDependencyInputs="false"
+				AdditionalOptions="&quot;..\..\gnutls\w32gnutls.lib&quot; &quot;..\..\gnutls\w32gcrypt.lib&quot; &quot;..\..\gnutls\w32gpgerror.lib&quot;"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile=".\..\Release_Unicode/vncviewer.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				IgnoreDefaultLibraryNames=""
+				GenerateDebugInformation="false"
+				ProgramDatabaseFile=".\..\Release_Unicode/vncviewer.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release_Unicode/vncviewer.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Release/vncviewer.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..;../../common;../../gnutls"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;WIN32;UNICODE;HAVE_GNUTLS"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\vncviewer/vncviewer.pch"
+				AssemblerListingLocation=".\..\Release\vncviewer/"
+				ObjectFile=".\..\Release\vncviewer/"
+				ProgramDataBaseFileName=".\..\Release\vncviewer/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+				AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Release\ /Fd..\Release\vncviewer /MT buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="&quot;..\..\gnutls\w32gnutls.lib&quot; &quot;..\..\gnutls\w32gcrypt.lib&quot; &quot;..\..\gnutls\w32gpgerror.lib&quot;"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile=".\..\Release/vncviewer.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/vncviewer.pdb"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/vncviewer.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+			>
+			<File
+				RelativePath="buildTime.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CConn.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CConnOptions.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="CConnThread.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ConnectingDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ConnectionDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="DesktopWindow.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="InfoDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="OptionsDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="UserPasswdDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ViewerToolBar.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="vncviewer.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="vncviewer.rc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+						AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+						AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl"
+			>
+			<File
+				RelativePath="CConn.h"
+				>
+			</File>
+			<File
+				RelativePath="CConnOptions.h"
+				>
+			</File>
+			<File
+				RelativePath="CConnThread.h"
+				>
+			</File>
+			<File
+				RelativePath="ConnectingDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="ConnectionDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="DesktopWindow.h"
+				>
+			</File>
+			<File
+				RelativePath="InfoDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="ListenServer.h"
+				>
+			</File>
+			<File
+				RelativePath="ListenTrayIcon.h"
+				>
+			</File>
+			<File
+				RelativePath="MRU.h"
+				>
+			</File>
+			<File
+				RelativePath="OptionsDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="UserPasswdDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="ViewerToolBar.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+			>
+			<File
+				RelativePath="cursor1.cur"
+				>
+			</File>
+			<File
+				RelativePath="ftdir.ico"
+				>
+			</File>
+			<File
+				RelativePath="ftfile.ico"
+				>
+			</File>
+			<File
+				RelativePath="ftreload.ico"
+				>
+			</File>
+			<File
+				RelativePath="ftup.ico"
+				>
+			</File>
+			<File
+				RelativePath="toolbar.bmp"
+				>
+			</File>
+			<File
+				RelativePath="vncviewer.bmp"
+				>
+			</File>
+			<File
+				RelativePath="vncviewer.exe.manifest"
+				>
+			</File>
+			<File
+				RelativePath="vncviewer.ico"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff -urN win/winvnc/ControlPanel.cxx win.new/winvnc/ControlPanel.cxx
--- win/winvnc/ControlPanel.cxx	2009-11-26 16:51:12.000000000 +0100
+++ win.new/winvnc/ControlPanel.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -18,9 +18,9 @@
 void ControlPanel::initDialog()
 {
   TCHAR *ColumnsStrings[] = {
-    "IP address",
-    "Time connected",
-    "Status"
+    _T("IP address"),
+    _T("Time connected"),
+    _T("Status")
   };
   InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 3, ColumnsStrings,
                 LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
diff -urN win/winvnc/VNCServerWin32.cxx win.new/winvnc/VNCServerWin32.cxx
--- win/winvnc/VNCServerWin32.cxx	2009-11-26 16:51:12.000000000 +0100
+++ win.new/winvnc/VNCServerWin32.cxx	2009-11-26 15:19:23.000000000 +0100
@@ -25,6 +25,7 @@
 #include <rfb_win32/CurrentUser.h>
 #include <rfb_win32/Service.h>
 #include <rfb/SSecurityFactoryStandard.h>
+#include <rfb/SSecurityFactoryTLS.h>
 #include <rfb/Hostname.h>
 #include <rfb/LogWriter.h>
 
@@ -33,6 +34,8 @@
 using namespace winvnc;
 using namespace network;
 
+SSecurityFactoryTLS TLSfactory;
+
 static LogWriter vlog("VNCServerWin32");
 
 
@@ -54,7 +57,7 @@
 VNCServerWin32::VNCServerWin32()
   : command(NoCommand), commandSig(commandLock),
     commandEvent(CreateEvent(0, TRUE, FALSE, 0)),
-    vncServer(CStr(ComputerName().buf), &desktop),
+	vncServer(CStr(ComputerName().buf), &desktop, &TLSfactory),
     hostThread(0), runServer(false), isDesktopStarted(false),
     httpServer(&vncServer), config(&sockMgr), trayIcon(0),
     rfbSock(&sockMgr), httpSock(&sockMgr),
diff -urN win/winvnc/winvnc.vcproj win.new/winvnc/winvnc.vcproj
--- win/winvnc/winvnc.vcproj	1970-01-01 01:00:00.000000000 +0100
+++ win.new/winvnc/winvnc.vcproj	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,1113 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="winvnc"
+	ProjectGUID="{37376EA9-D030-4B38-9795-7202F265DE2A}"
+	TargetFrameworkVersion="0"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug Unicode|Win32"
+			OutputDirectory=".\..\Debug_Unicode"
+			IntermediateDirectory=".\..\Debug_Unicode\winvnc"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Debug_Unicode/winvnc.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_CONSOLE;_DEBUG;WIN32;UNICODE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\winvnc/winvnc.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\winvnc/"
+				ObjectFile=".\..\Debug_Unicode\winvnc/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\winvnc/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Debug_Unicode /Fd..\Debug_Unicode\winvnc /MTd buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/FIXED:NO"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile="..\Debug_Unicode/winvnc4.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug_Unicode/winvnc4.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug_Unicode/winvnc.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\..\Debug"
+			IntermediateDirectory=".\..\Debug\winvnc"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Debug/winvnc.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug\winvnc/winvnc.pch"
+				AssemblerListingLocation=".\..\Debug\winvnc/"
+				ObjectFile=".\..\Debug\winvnc/"
+				ProgramDataBaseFileName=".\..\Debug\winvnc/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Debug\ /Fd..\Debug\winvnc /MTd buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/FIXED:NO"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile="../Debug/winvnc4.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug/winvnc4.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug/winvnc.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\..\Release"
+			IntermediateDirectory=".\..\Release\winvnc"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Release/winvnc.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\winvnc/winvnc.pch"
+				AssemblerListingLocation=".\..\Release\winvnc/"
+				ObjectFile=".\..\Release\winvnc/"
+				ProgramDataBaseFileName=".\..\Release\winvnc/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Release\ /Fd..\Release\winvnc /MT buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile="../Release/winvnc4.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/winvnc4.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/winvnc.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Released Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Debug_Unicode/winvnc.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="_CONSOLE;_NDEBUG;WIN32;UNICODE"
+				StringPooling="true"
+				MinimalRebuild="false"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release_Unicode\winvnc/winvnc.pch"
+				AssemblerListingLocation=".\..\Release_Unicode\winvnc/"
+				ObjectFile=".\..\Release_Unicode\winvnc/"
+				ProgramDataBaseFileName=".\..\Release_Unicode\winvnc/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="0"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Debug_Unicode /Fd..\Debug_Unicode\winvnc /MTd buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/FIXED:NO"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile="..\Release_Unicode/winvnc4.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="false"
+				ProgramDatabaseFile=".\..\Release_Unicode/winvnc4.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release_Unicode/winvnc.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\..\Release/winvnc.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories="..,../../common"
+				PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;UNICODE;HAVE_GNUTLS"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\winvnc/winvnc.pch"
+				AssemblerListingLocation=".\..\Release\winvnc/"
+				ObjectFile=".\..\Release\winvnc/"
+				ProgramDataBaseFileName=".\..\Release\winvnc/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				Description="Updating buildTime"
+				CommandLine="cl /c /nologo /Fo..\Release\ /Fd..\Release\winvnc /MT buildTime.cxx"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="ws2_32.lib version.lib comctl32.lib"
+				OutputFile="../Release/winvnc4.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\..\Release/winvnc4.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release/winvnc.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+			>
+			<File
+				RelativePath="buildTime.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ControlPanel.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="JavaViewer.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="ManagedListener.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="QueryConnectDialog.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="STrayIcon.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="VNCServerService.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="VNCServerWin32.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="winvnc.cxx"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="winvnc.rc"
+				>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl"
+			>
+			<File
+				RelativePath="AddNewClientDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="ControlPanel.h"
+				>
+			</File>
+			<File
+				RelativePath="JavaViewer.h"
+				>
+			</File>
+			<File
+				RelativePath="ManagedListener.h"
+				>
+			</File>
+			<File
+				RelativePath="QueryConnectDialog.h"
+				>
+			</File>
+			<File
+				RelativePath="STrayIcon.h"
+				>
+			</File>
+			<File
+				RelativePath="VNCServerService.h"
+				>
+			</File>
+			<File
+				RelativePath="VNCServerWin32.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+			>
+			<File
+				RelativePath="connecte.ico"
+				>
+			</File>
+			<File
+				RelativePath="connected.ico"
+				>
+			</File>
+			<File
+				RelativePath="icon_dis.ico"
+				>
+			</File>
+			<File
+				RelativePath="..\..\common\javabin\logo150x150.gif"
+				>
+			</File>
+			<File
+				RelativePath="winvnc.bmp"
+				>
+			</File>
+			<File
+				RelativePath="winvnc.ico"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath="..\..\common\javabin\index.vnc"
+			>
+		</File>
+		<File
+			RelativePath="..\..\common\javabin\vncviewer.jar"
+			>
+		</File>
+		<File
+			RelativePath="winvnc4.exe.manifest"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff -urN win/wm_hooks/wm_hooks.vcproj win.new/wm_hooks/wm_hooks.vcproj
--- win/wm_hooks/wm_hooks.vcproj	1970-01-01 01:00:00.000000000 +0100
+++ win.new/wm_hooks/wm_hooks.vcproj	2009-11-26 15:19:23.000000000 +0100
@@ -0,0 +1,626 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="wm_hooks"
+	ProjectGUID="{B0A5671B-4337-454D-BAD3-0FE8C555A532}"
+	TargetFrameworkVersion="0"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\../Debug"
+			IntermediateDirectory=".\..\Debug\wm_hooks"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\../Debug/wm_hooks.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".."
+				PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;WM_HOOKS_EXPORTS;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug\wm_hooks/wm_hooks.pch"
+				AssemblerListingLocation=".\..\Debug\wm_hooks/"
+				ObjectFile=".\..\Debug\wm_hooks/"
+				ProgramDataBaseFileName=".\..\Debug\wm_hooks/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="../../common/rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile=".\../Debug/wm_hooks.dll"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ModuleDefinitionFile=".\wm_hooks.def"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\../Debug/wm_hooks.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\../Debug/wm_hooks.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\../Debug/wm_hooks.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug Unicode|Win32"
+			OutputDirectory=".\..\Debug_Unicode"
+			IntermediateDirectory=".\..\Debug_Unicode\wm_hooks"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug_Unicode/wm_hooks.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".."
+				PreprocessorDefinitions="_DEBUG;UNICODE;_WINDOWS;_USRDLL;WM_HOOKS_EXPORTS;WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				PrecompiledHeaderFile=".\..\Debug_Unicode\wm_hooks/wm_hooks.pch"
+				AssemblerListingLocation=".\..\Debug_Unicode\wm_hooks/"
+				ObjectFile=".\..\Debug_Unicode\wm_hooks/"
+				ProgramDataBaseFileName=".\..\Debug_Unicode\wm_hooks/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				ForcedIncludeFiles="../../common/rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile=".\..\Debug_Unicode/wm_hooks.dll"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				ModuleDefinitionFile=".\wm_hooks.def"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\..\Debug_Unicode/wm_hooks.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\..\Debug_Unicode/wm_hooks.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Debug_Unicode/wm_hooks.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\../Release"
+			IntermediateDirectory=".\..\Release\wm_hooks"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\../Release/wm_hooks.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories=".."
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;WM_HOOKS_EXPORTS;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\wm_hooks/wm_hooks.pch"
+				AssemblerListingLocation=".\..\Release\wm_hooks/"
+				ObjectFile=".\..\Release\wm_hooks/"
+				ProgramDataBaseFileName=".\..\Release\wm_hooks/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="../../common/rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile=".\../Release/wm_hooks.dll"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ModuleDefinitionFile=".\wm_hooks.def"
+				ProgramDatabaseFile=".\../Release/wm_hooks.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\../Release/wm_hooks.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\../Release/wm_hooks.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Released Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\Debug_Unicode/wm_hooks.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				AdditionalIncludeDirectories=".."
+				PreprocessorDefinitions="_NDEBUG;UNICODE;_WINDOWS;_USRDLL;WM_HOOKS_EXPORTS;WIN32"
+				StringPooling="true"
+				MinimalRebuild="false"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release_Unicode\wm_hooks/wm_hooks.pch"
+				AssemblerListingLocation=".\..\Release_Unicode\wm_hooks/"
+				ObjectFile=".\..\Release_Unicode\wm_hooks/"
+				ProgramDataBaseFileName=".\..\Release_Unicode\wm_hooks/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="0"
+				ForcedIncludeFiles="../../common/rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile=".\..\Release_Unicode/wm_hooks.dll"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				ModuleDefinitionFile=".\wm_hooks.def"
+				GenerateDebugInformation="false"
+				ProgramDatabaseFile=".\..\Release_Unicode/wm_hooks.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\..\Release_Unicode/wm_hooks.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\..\Release_Unicode/wm_hooks.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Unicode|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\../Release/wm_hooks.tlb"
+				HeaderFileName=""
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				AdditionalIncludeDirectories=".."
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;WM_HOOKS_EXPORTS;WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				PrecompiledHeaderFile=".\..\Release\wm_hooks/wm_hooks.pch"
+				AssemblerListingLocation=".\..\Release\wm_hooks/"
+				ObjectFile=".\..\Release\wm_hooks/"
+				ProgramDataBaseFileName=".\..\Release\wm_hooks/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				ForcedIncludeFiles="../../common/rdr/msvcwarning.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile=".\../Release/wm_hooks.dll"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ModuleDefinitionFile=".\wm_hooks.def"
+				ProgramDatabaseFile=".\../Release/wm_hooks.pdb"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary=".\../Release/wm_hooks.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				SuppressStartupBanner="true"
+				OutputFile=".\../Release/wm_hooks.bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+			>
+			<File
+				RelativePath="wm_hooks.cxx"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						AdditionalIncludeDirectories=""
+						PreprocessorDefinitions=""
+						ForcedIncludeFiles=""
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="wm_hooks.def"
+				>
+			</File>
+			<File
+				RelativePath="wm_hooks.rc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Released Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+						AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK\Include\mfc&quot;"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release Unicode|Win32"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						PreprocessorDefinitions=""
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl"
+			>
+			<File
+				RelativePath="wm_hooks.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
