Fixed error reporting on wrong OS or disabled DWM.

Removed TaskDialog for those errors (CommCtrl 6.0 not loaded before Form is shown, InitCommonControlsEx doesn't work, must fix somewhere).
This commit is contained in:
Lorenz Cuno Klopfenstein 2010-06-20 11:55:34 +02:00
parent 8fba47cbeb
commit 11edb1ed58
6 changed files with 103 additions and 56 deletions

View file

@ -223,6 +223,7 @@ namespace OnTopReplica {
protected override void OnResize(EventArgs e) {
base.OnResize(e);
this.GlassMargins = (_regionBoxShowing) ?
new Margins(ClientSize.Width - _regionBox.Width, 0, 0, 0) :
new Margins(-1);
@ -231,39 +232,19 @@ namespace OnTopReplica {
protected override void OnShown(EventArgs e) {
base.OnShown(e);
//Do some checks in order to verify the presence of desktop composition
if (!VistaControls.OsSupport.IsVistaOrBetter) {
MessageBox.Show(Strings.ErrorNoDwm, Strings.ErrorNoDwmTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
return;
}
if (!VistaControls.OsSupport.IsCompositionEnabled) {
VistaControls.TaskDialog.TaskDialog dlg = new VistaControls.TaskDialog.TaskDialog(Strings.ErrorDwmOff, Strings.ErrorGenericTitle, Strings.ErrorDwmOffContent);
dlg.ExpandedControlText = Strings.ErrorDetailsAero;
dlg.ExpandedInformation = Strings.ErrorDetailsAeroInfo;
dlg.CommonButtons = TaskDialogButton.Close;
dlg.CommonIcon = VistaControls.TaskDialog.TaskDialogIcon.Stop;
dlg.Show();
this.Close();
return;
}
//Get a window manager
_windowManager = new WindowManager();
//Install NotifyIcon
taskIcon = new NotifyIcon();
taskIcon.Text = Strings.ApplicationName;
taskIcon.Icon = Properties.Resources.main_icon;
taskIcon.Visible = true;
taskIcon.ContextMenuStrip = menuIconContext;
taskIcon = new NotifyIcon {
Text = Strings.ApplicationName,
Icon = Properties.Resources.main_icon,
Visible = true,
ContextMenuStrip = menuIconContext
};
taskIcon.DoubleClick += new EventHandler(TaskIcon_doubleclick);
//Reload position settings
//Reload position settings if needed
if (_startOverride) {
Location = _startLocation;
Size = _startSize;
@ -274,7 +255,6 @@ namespace OnTopReplica {
}
//Glassify window
this.GlassMargins = new VistaControls.Dwm.Margins(-1);
SetGlass(Settings.Default.UseGlass);
}

View file

@ -19,7 +19,6 @@
<StartupObject>OnTopReplica.Program</StartupObject>
<ExcludedPermissions>
</ExcludedPermissions>
<ApplicationManifest>Properties\OnTopReplica.exe.manifest</ApplicationManifest>
<SignAssembly>false</SignAssembly>
<ManifestCertificateThumbprint>DB79D77572EF10838D6A2CECDDE738C6570E7995</ManifestCertificateThumbprint>
<ManifestKeyFile>OnTopReplica_TemporaryKey.pfx</ManifestKeyFile>
@ -66,6 +65,7 @@
<DocumentationFile>
</DocumentationFile>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -79,6 +79,13 @@
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>OnTopReplica.exe.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Deployment" />
@ -105,6 +112,7 @@
</Compile>
<Compile Include="CloneClickEventArgs.cs" />
<Compile Include="CloseRequestEventArgs.cs" />
<None Include="CommonControls.cs" />
<Compile Include="EnumerationExtensions.cs" />
<Compile Include="FullscreenMode.cs" />
<Compile Include="HotKeyManager.cs" />
@ -237,7 +245,9 @@
<None Include="Assets\reduce.png" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\OnTopReplica.exe.manifest" />
<None Include="OnTopReplica.exe.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Assets\flag_danish.png" />
<Content Include="Assets\window_multiple16.ico" />
</ItemGroup>
@ -326,6 +336,10 @@
</PublishFile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View file

@ -1,4 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory>http://www.klopfenstein.net/public/Uploads/ontopreplica/|http://www.klopfenstein.net/download.aspx%3ffile=ontopreplica%252fsetup.exe/|http://www.klopfenstein.net/lorenz/programming/ontopreplica/|http://www.klopfenstein.net/lorenz/programming/|http://lorenz.klopfenstein.net/</InstallUrlHistory>
@ -11,4 +12,7 @@
<ErrorReportUrlHistory>
</ErrorReportUrlHistory>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
</application>
</compatibility>
<assemblyIdentity processorArchitecture="*" type="win32" name="OnTopReplica"/>
<description>Lightweight clone of a window.</description>
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*" />
</dependentAssembly>
</dependency>
-->
</asmv1:assembly>

View file

@ -6,6 +6,7 @@ using System.Threading;
using System.Globalization;
using System.Drawing;
using System.IO;
using VistaControls.TaskDialog;
namespace OnTopReplica
{
@ -18,15 +19,19 @@ namespace OnTopReplica
//Hook abort handler
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Check for DWM
if (!CanStart)
return;
//Update settings if needed
if (Settings.Default.MustUpdate) {
Settings.Default.Upgrade();
Settings.Default.MustUpdate = false;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool reloadSettings = false;
Point reloadLocation = new Point();
Size reloadSize = new Size();
@ -55,6 +60,34 @@ namespace OnTopReplica
Settings.Default.Save();
}
/// <summary>
/// Checks whether OnTopReplica can start or not.
/// </summary>
private static bool CanStart {
get {
//Do some checks in order to verify the presence of desktop composition
if (!VistaControls.OsSupport.IsVistaOrBetter) {
MessageBox.Show(Strings.ErrorNoDwm, Strings.ErrorNoDwmTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (!VistaControls.OsSupport.IsCompositionEnabled) {
MessageBox.Show(Strings.ErrorDwmOffContent, Strings.ErrorDwmOff, MessageBoxButtons.OK, MessageBoxIcon.Error);
/*var dlg = new TaskDialog(Strings.ErrorDwmOff, Strings.ErrorGenericTitle, Strings.ErrorDwmOffContent) {
ExpandedControlText = Strings.ErrorDetailsAero,
ExpandedInformation = Strings.ErrorDetailsAeroInfo,
CommonButtons = TaskDialogButton.Close,
CommonIcon = VistaControls.TaskDialog.TaskDialogIcon.Stop
};
dlg.Show();*/
return false;
}
return true;
}
}
static CultureInfo _languageChangeCode = Settings.Default.Language;
/// <summary>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</asmv1:assembly>