diff --git a/Directory.Build.props b/Directory.Build.props
index 82cd9b810..4f289abe8 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -16,7 +16,7 @@
true
true
- net471
+ net471
@@ -25,8 +25,8 @@
- false
- true
+ false
+ true
diff --git a/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs b/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
index 6d0d5d757..fb609898a 100644
--- a/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
+++ b/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -33,9 +33,9 @@ namespace Greenshot.Controls {
private static Image _scaledCheckbox;
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
- if (_scaledCheckbox == null || _scaledCheckbox.Size != CoreConfig.IconSize) {
+ if (_scaledCheckbox == null || _scaledCheckbox.Size != CoreConfig.ScaledIconSize) {
_scaledCheckbox?.Dispose();
- _scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, CoreConfig.IconSize.Width, CoreConfig.IconSize.Height, null);
+ _scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, CoreConfig.ScaledIconSize.Width, CoreConfig.ScaledIconSize.Height, null);
}
Rectangle old = e.ImageRectangle;
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, _scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
diff --git a/Greenshot/Drawing/LineContainer.cs b/Greenshot/Drawing/LineContainer.cs
index 9c5898854..8915867cc 100644
--- a/Greenshot/Drawing/LineContainer.cs
+++ b/Greenshot/Drawing/LineContainer.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -32,10 +32,10 @@ namespace Greenshot.Drawing {
///
/// Description of LineContainer.
///
- [Serializable()]
+ [Serializable()]
public class LineContainer : DrawableContainer {
public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10;
-
+
public LineContainer(Surface parent) : base(parent) {
Init();
}
@@ -45,7 +45,7 @@ namespace Greenshot.Drawing {
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, true);
}
-
+
protected override void OnDeserialized(StreamingContext context)
{
Init();
@@ -55,7 +55,7 @@ namespace Greenshot.Drawing {
Adorners.Add(new MoveAdorner(this, Positions.TopLeft));
Adorners.Add(new MoveAdorner(this, Positions.BottomRight));
}
-
+
public override void Draw(Graphics graphics, RenderMode rm) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
@@ -91,7 +91,7 @@ namespace Greenshot.Drawing {
graphics.DrawLine(pen, Left, Top, Left + Width, Top + Height);
}
}
-
+
public override bool ClickableAt(int x, int y) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) +5;
if (lineThickness > 0)
@@ -102,13 +102,13 @@ namespace Greenshot.Drawing {
};
using GraphicsPath path = new GraphicsPath();
path.AddLine(Left, Top, Left + Width, Top + Height);
- return path.IsOutlineVisible(x, y, pen);
+ return path.IsOutlineVisible(x, y, pen);
}
return false;
}
-
+
protected override ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
return ScaleHelper.LineAngleRoundBehavior.Instance;
- }
+ }
}
}
diff --git a/Greenshot/Forms/ImageEditorForm.Designer.cs b/Greenshot/Forms/ImageEditorForm.Designer.cs
index e386ca572..1e0689fd5 100644
--- a/Greenshot/Forms/ImageEditorForm.Designer.cs
+++ b/Greenshot/Forms/ImageEditorForm.Designer.cs
@@ -293,7 +293,7 @@ namespace Greenshot {
// toolsToolStrip
//
this.toolsToolStrip.ClickThrough = true;
- this.toolsToolStrip.ImageScalingSize = coreConfiguration.IconSize;
+ this.toolsToolStrip.ImageScalingSize = coreConfiguration.ScaledIconSize;
this.toolsToolStrip.Dock = System.Windows.Forms.DockStyle.None;
this.toolsToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.toolsToolStrip.Renderer = new CustomToolStripProfessionalRenderer();
@@ -529,7 +529,7 @@ namespace Greenshot {
// menuStrip1
//
this.menuStrip1.ClickThrough = true;
- this.menuStrip1.ImageScalingSize = coreConfiguration.IconSize;
+ this.menuStrip1.ImageScalingSize = coreConfiguration.ScaledIconSize;
this.menuStrip1.Dock = System.Windows.Forms.DockStyle.Fill;
this.menuStrip1.Stretch = true;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -858,7 +858,7 @@ namespace Greenshot {
// destinationsToolStrip
//
this.destinationsToolStrip.ClickThrough = true;
- this.destinationsToolStrip.ImageScalingSize = coreConfiguration.IconSize;
+ this.destinationsToolStrip.ImageScalingSize = coreConfiguration.ScaledIconSize;
this.destinationsToolStrip.Dock = System.Windows.Forms.DockStyle.Fill;
this.destinationsToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.destinationsToolStrip.Name = "toolStrip1";
@@ -1014,10 +1014,10 @@ namespace Greenshot {
//
this.propertiesToolStrip.AutoSize = false;
this.propertiesToolStrip.ClickThrough = true;
- this.propertiesToolStrip.ImageScalingSize = coreConfiguration.IconSize;
+ this.propertiesToolStrip.ImageScalingSize = coreConfiguration.ScaledIconSize;
this.propertiesToolStrip.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertiesToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
- this.propertiesToolStrip.MinimumSize = new System.Drawing.Size(150, coreConfiguration.IconSize.Height + 10);
+ this.propertiesToolStrip.MinimumSize = new System.Drawing.Size(150, coreConfiguration.ScaledIconSize.Height + 10);
this.propertiesToolStrip.Name = "propertiesToolStrip";
this.propertiesToolStrip.Stretch = true;
this.propertiesToolStrip.TabIndex = 2;
diff --git a/Greenshot/Forms/MainForm.Designer.cs b/Greenshot/Forms/MainForm.Designer.cs
index 61f7ec29d..a93b815d0 100644
--- a/Greenshot/Forms/MainForm.Designer.cs
+++ b/Greenshot/Forms/MainForm.Designer.cs
@@ -203,7 +203,7 @@ namespace Greenshot {
// contextmenu_quicksettings
//
this.contextmenu_quicksettings.Name = "contextmenu_quicksettings";
- this.contextmenu_quicksettings.Size = new System.Drawing.Size(170, coreConfiguration.IconSize.Height + 8);
+ this.contextmenu_quicksettings.Size = new System.Drawing.Size(170, coreConfiguration.ScaledIconSize.Height + 8);
//
// contextmenu_settings
//
diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs
index 7a5aaf748..dff93324f 100644
--- a/Greenshot/Forms/MainForm.cs
+++ b/Greenshot/Forms/MainForm.cs
@@ -549,7 +549,7 @@ namespace Greenshot {
///
private void OnIconSizeChanged(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == "IconSize") {
- contextMenu.ImageScalingSize = coreConfiguration.IconSize;
+ contextMenu.ImageScalingSize = coreConfiguration.ScaledIconSize;
string ieExePath = PluginUtils.GetExePath("iexplore.exe");
if (!string.IsNullOrEmpty(ieExePath)) {
contextmenu_captureie.Image = PluginUtils.GetCachedExeIcon(ieExePath, 0);
@@ -614,7 +614,7 @@ namespace Greenshot {
/// true if onedrive has hotkeys turned on
private static bool IsOneDriveBlockingHotkey()
{
- if (!Environment.OSVersion.IsWindows10())
+ if (!WindowsVersion.IsWindows10OrLater)
{
return false;
}
diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs
index b38f72fbd..369f568f6 100644
--- a/Greenshot/Forms/SettingsForm.cs
+++ b/Greenshot/Forms/SettingsForm.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -50,7 +50,7 @@ namespace Greenshot {
public SettingsForm() {
InitializeComponent();
-
+
// Make sure the store isn't called to early, that's why we do it manually
ManualStoreFields = true;
}
@@ -154,8 +154,8 @@ namespace Greenshot {
}
comboBox.SelectedItem = Language.Translate(selectedValue);
}
-
-
+
+
///
/// Get the selected enum value from the combobox, uses generics
///
@@ -175,7 +175,7 @@ namespace Greenshot {
}
return returnValue;
}
-
+
private void SetWindowCaptureMode(WindowCaptureMode selectedWindowCaptureMode) {
WindowCaptureMode[] availableModes;
if (!DWM.IsDwmEnabled()) {
@@ -189,7 +189,7 @@ namespace Greenshot {
}
PopulateComboBox(combobox_window_capture_mode, availableModes, selectedWindowCaptureMode);
}
-
+
private void DisplayPluginTab() {
if (!PluginHelper.Instance.HasPlugins()) {
tabcontrol.TabPages.Remove(tab_plugins);
@@ -199,9 +199,9 @@ namespace Greenshot {
listview_plugins.Items.Clear();
listview_plugins.Columns.Clear();
string[] columns = {
- Language.GetString("settings_plugins_name"),
- Language.GetString("settings_plugins_version"),
- Language.GetString("settings_plugins_createdby"),
+ Language.GetString("settings_plugins_name"),
+ Language.GetString("settings_plugins_version"),
+ Language.GetString("settings_plugins_createdby"),
Language.GetString("settings_plugins_dllpath")};
foreach (string column in columns) {
listview_plugins.Columns.Add(column);
@@ -218,7 +218,7 @@ namespace Greenshot {
}
listview_plugins.EndUpdate();
listview_plugins.Refresh();
-
+
// Disable the configure button, it will be enabled when a plugin is selected AND isConfigurable
button_pluginconfigure.Enabled = false;
}
@@ -254,7 +254,7 @@ namespace Greenshot {
UpdateDestinationDescriptions();
UpdateClipboardFormatDescriptions();
}
-
+
// Check the settings and somehow visibly mark when something is incorrect
private bool CheckSettings() {
return CheckFilenamePattern() && CheckStorageLocationPath();
@@ -273,21 +273,21 @@ namespace Greenshot {
}
DisplayTextBoxValidity(textbox_screenshotname, settingsOk);
-
+
return settingsOk;
}
private bool CheckStorageLocationPath() {
- bool settingsOk = Directory.Exists(FilenameHelper.FillVariables(textbox_storagelocation.Text, false));
+ bool settingsOk = Directory.Exists(FilenameHelper.FillVariables(textbox_storagelocation.Text, false));
DisplayTextBoxValidity(textbox_storagelocation, settingsOk);
return settingsOk;
}
private void DisplayTextBoxValidity(GreenshotTextBox textbox, bool valid) {
- if (valid) {
+ if (valid) {
// "Added" feature #3547158
textbox.BackColor = Environment.OSVersion.Version.Major >= 6 ? SystemColors.Window : SystemColors.Control;
- } else {
+ } else {
textbox.BackColor = Color.Red;
}
}
@@ -334,6 +334,7 @@ namespace Greenshot {
listview_destinations.Items.Clear();
listview_destinations.ListViewItemSorter = new ListviewWithDestinationComparer();
ImageList imageList = new ImageList();
+ imageList.ImageSize = coreConfiguration.ScaledIconSize;
listview_destinations.SmallImageList = imageList;
int imageNr = -1;
foreach (IDestination currentDestination in DestinationHelper.GetAllDestinations()) {
@@ -376,7 +377,7 @@ namespace Greenshot {
item.Tag = clipboardFormat;
item.Checked = coreConfiguration.ClipboardFormats.Contains(clipboardFormat);
}
-
+
if (Language.CurrentLanguage != null) {
combobox_language.SelectedValue = Language.CurrentLanguage;
}
@@ -419,10 +420,10 @@ namespace Greenshot {
checkbox_autostartshortcut.Checked = StartupHelper.HasRunUser();
}
}
-
+
numericUpDown_daysbetweencheck.Value = coreConfiguration.UpdateCheckInterval;
numericUpDown_daysbetweencheck.Enabled = !coreConfiguration.Values["UpdateCheckInterval"].IsFixed;
- numericUpdownIconSize.Value = coreConfiguration.IconSize.Width /16 * 16;
+ numericUpdownIconSize.Value = coreConfiguration.ScaledIconSize.Width /16 * 16;
CheckDestinationSettings();
}
@@ -570,7 +571,7 @@ namespace Greenshot {
}
colorButton_window_background.Visible = false;
}
-
+
///
/// Check the destination settings
///
@@ -582,7 +583,7 @@ namespace Greenshot {
destinationsEnabled = !coreConfiguration.Values["Destinations"].IsFixed;
}
listview_destinations.Enabled = destinationsEnabled;
-
+
foreach(int index in listview_destinations.CheckedIndices) {
ListViewItem item = listview_destinations.Items[index];
if (item.Tag is IDestination destinationFromTag && destinationFromTag.Designation.Equals(ClipboardDestination.DESIGNATION)) {
diff --git a/Greenshot/Forms/ToolStripMenuSelectList.cs b/Greenshot/Forms/ToolStripMenuSelectList.cs
index ab739eaa6..7d2ff66a0 100644
--- a/Greenshot/Forms/ToolStripMenuSelectList.cs
+++ b/Greenshot/Forms/ToolStripMenuSelectList.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -50,9 +50,9 @@ namespace Greenshot.Forms {
Identifier = identifier;
CheckOnClick = false;
_multiCheckAllowed = allowMultiCheck;
- if (_defaultImage == null || _defaultImage.Size != CoreConfig.IconSize) {
+ if (_defaultImage == null || _defaultImage.Size != CoreConfig.ScaledIconSize) {
_defaultImage?.Dispose();
- _defaultImage = ImageHelper.CreateEmpty(CoreConfig.IconSize.Width, CoreConfig.IconSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Color.Transparent, 96f, 96f);
+ _defaultImage = ImageHelper.CreateEmpty(CoreConfig.ScaledIconSize.Width, CoreConfig.ScaledIconSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Color.Transparent, 96f, 96f);
}
Image = _defaultImage;
}
@@ -63,7 +63,7 @@ namespace Greenshot.Forms {
/// gets or sets the currently checked item
///
public ToolStripMenuSelectListItem CheckedItem {
-
+
get {
IEnumerator items = DropDownItems.GetEnumerator();
while (items.MoveNext()) {
@@ -86,7 +86,7 @@ namespace Greenshot.Forms {
}
}
}
-
+
///
/// gets or sets the currently checked items
///
@@ -126,7 +126,7 @@ namespace Greenshot.Forms {
}
}
}
-
+
private void ItemCheckStateChanged(object sender, EventArgs e) {
if (_updateInProgress) {
return;
@@ -140,7 +140,7 @@ namespace Greenshot.Forms {
_updateInProgress = false;
CheckedChanged?.Invoke(this, new ItemCheckedChangedEventArgs(toolStripMenuSelectListItem));
}
-
+
///
/// adds an item to the select list
///
@@ -171,7 +171,7 @@ namespace Greenshot.Forms {
}
DropDownItems.Add(toolStripMenuSelectListItem);
}
-
+
///
/// adds an item to the select list
///
@@ -180,7 +180,7 @@ namespace Greenshot.Forms {
public void AddItem(string label, Image image) {
AddItem(label, image, null, false);
}
-
+
///
/// adds an item to the select list
///
@@ -189,7 +189,7 @@ namespace Greenshot.Forms {
public void AddItem(string label, object data) {
AddItem(label, null, data, false);
}
-
+
///
/// adds an item to the select list
///
@@ -197,8 +197,8 @@ namespace Greenshot.Forms {
public void AddItem(string label) {
AddItem(label, null, null, false);
}
-
-
+
+
///
/// adds an item to the select list
///
@@ -208,7 +208,7 @@ namespace Greenshot.Forms {
public void AddItem(string label, Image image, bool isChecked) {
AddItem(label, image, null, isChecked);
}
-
+
///
/// adds an item to the select list
///
@@ -218,7 +218,7 @@ namespace Greenshot.Forms {
public void AddItem(string label, object data, bool isChecked) {
AddItem(label, null, data, isChecked);
}
-
+
///
/// adds an item to the select list
///
@@ -227,7 +227,7 @@ namespace Greenshot.Forms {
public void AddItem(string label, bool isChecked) {
AddItem(label, null, null, isChecked);
}
-
+
///
/// unchecks all items of the list
///
@@ -243,7 +243,7 @@ namespace Greenshot.Forms {
}
}
}
-
+
///
/// Event class for the CheckedChanged event in the ToolStripMenuSelectList
///
@@ -256,7 +256,7 @@ namespace Greenshot.Forms {
Item = item;
}
}
-
+
///
/// Wrapper around the ToolStripMenuItem, which can contain an object
/// Also the Checked property hides the normal checked property so we can render our own check
diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs
index 498e5f3fa..5f52af746 100644
--- a/GreenshotJiraPlugin/Forms/JiraForm.cs
+++ b/GreenshotJiraPlugin/Forms/JiraForm.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -115,7 +115,7 @@ namespace GreenshotJiraPlugin.Forms {
public async Task UploadAsync(IBinaryContainer attachment) {
attachment.Filename = jiraFilenameBox.Text;
await _jiraConnector.AttachAsync(_selectedIssue.Key, attachment);
-
+
if (!string.IsNullOrEmpty(jiraCommentBox.Text)) {
await _jiraConnector.AddCommentAsync(_selectedIssue.Key, jiraCommentBox.Text);
}
@@ -153,7 +153,7 @@ namespace GreenshotJiraPlugin.Forms {
jiraListView.Columns.Add(translation);
}
var imageList = new ImageList {
- ImageSize = CoreConfig.IconSize
+ ImageSize = CoreConfig.ScaledIconSize
};
jiraListView.SmallImageList = imageList;
jiraListView.LargeImageList = imageList;
diff --git a/GreenshotJiraPlugin/JiraConnector.cs b/GreenshotJiraPlugin/JiraConnector.cs
index 0d0925fa2..804491415 100644
--- a/GreenshotJiraPlugin/JiraConnector.cs
+++ b/GreenshotJiraPlugin/JiraConnector.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -56,7 +56,7 @@ namespace GreenshotJiraPlugin {
{
if (args.PropertyName == nameof(CoreConfig.IconSize))
{
- JiraPlugin.Instance.JiraConnector._jiraClient?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height });
+ JiraPlugin.Instance.JiraConnector._jiraClient?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.ScaledIconSize.Width, Height = CoreConfig.ScaledIconSize.Height });
}
};
@@ -99,7 +99,7 @@ namespace GreenshotJiraPlugin {
return false;
}
_jiraClient = JiraClient.Create(new Uri(JiraConfig.Url));
- _jiraClient.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height });
+ _jiraClient.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.ScaledIconSize.Width, Height = CoreConfig.ScaledIconSize.Height });
_jiraClient.SetBasicAuthentication(user, password);
_issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraClient);
@@ -127,7 +127,7 @@ namespace GreenshotJiraPlugin {
}
return true;
}
-
+
///
/// Use the credentials dialog, this will show if there are not correct credentials.
/// If there are credentials, call the real login.
@@ -189,7 +189,7 @@ namespace GreenshotJiraPlugin {
}
///
- /// Get the favorite filters
+ /// Get the favorite filters
///
/// List with filters
public async Task> GetFavoriteFiltersAsync(CancellationToken cancellationToken = default)
diff --git a/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj b/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj
index 37f42746a..b5e4884bc 100644
--- a/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj
+++ b/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj
@@ -14,18 +14,36 @@
-
+
-
-
-
-
-
-
+
+ true
+ runtime
+
+
+ true
+ runtime
+
+
+ true
+ runtime
+
+
+ true
+ runtime
+
+
+ true
+ runtime
+
+
+ True
+ runtime
+
True
+ runtime
-
-
+
diff --git a/GreenshotPlugin/Core/AbstractDestination.cs b/GreenshotPlugin/Core/AbstractDestination.cs
index c5b01ad3b..0a0220642 100644
--- a/GreenshotPlugin/Core/AbstractDestination.cs
+++ b/GreenshotPlugin/Core/AbstractDestination.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -35,7 +35,7 @@ namespace GreenshotPlugin.Core {
public abstract class AbstractDestination : IDestination {
private static readonly ILog Log = LogManager.GetLogger(typeof(AbstractDestination));
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection();
-
+
public virtual int CompareTo(object obj) {
if (!(obj is IDestination other)) {
return 1;
@@ -150,7 +150,7 @@ namespace GreenshotPlugin.Core {
ExportInformation exportInformation = new ExportInformation(Designation, Language.GetString("settings_destination_picker"));
var menu = new ContextMenuStrip
{
- ImageScalingSize = CoreConfig.IconSize,
+ ImageScalingSize = CoreConfig.ScaledIconSize,
Tag = null,
TopLevel = true
};
@@ -292,7 +292,7 @@ namespace GreenshotPlugin.Core {
};
AddTagEvents(basisMenuItem, menu, Description);
basisMenuItem.Click -= destinationClickHandler;
- basisMenuItem.Click += destinationClickHandler;
+ basisMenuItem.Click += destinationClickHandler;
if (IsDynamic && addDynamics) {
basisMenuItem.DropDownOpening += delegate
@@ -330,6 +330,6 @@ namespace GreenshotPlugin.Core {
return basisMenuItem;
}
-
+
}
}
diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs
index df19a9532..de6657676 100644
--- a/GreenshotPlugin/Core/CoreConfiguration.cs
+++ b/GreenshotPlugin/Core/CoreConfiguration.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -45,7 +45,7 @@ namespace GreenshotPlugin.Core {
RELEASE_CANDIDATE,
RELEASE
}
-
+
public enum ClickActions {
DO_NOTHING,
OPEN_LAST_IN_EXPLORER,
@@ -104,7 +104,7 @@ namespace GreenshotPlugin.Core {
public bool PlayCameraSound { get; set; } = false;
[IniProperty("ShowTrayNotification", LanguageKey="settings_shownotify",Description="Show a notification from the systray when a capture is taken.", DefaultValue="true")]
public bool ShowTrayNotification { get; set; } = true;
-
+
[IniProperty("OutputFilePath", Description="Output file path.")]
public string OutputFilePath { get; set; }
[IniProperty("OutputFileAllowOverwrite", Description = "If the target file already exists True will make Greenshot always overwrite and False will display a 'Save-As' dialog.", DefaultValue = "true")]
@@ -267,7 +267,7 @@ namespace GreenshotPlugin.Core {
public Size Win10BorderCrop { get; set; }
private Size _iconSize;
- [IniProperty("IconSize", Description = "Defines the size of the icons (e.g. for the buttons in the editor), default value 16,16 anything bigger will cause scaling", DefaultValue = "16,16")]
+ [IniProperty("BaseIconSize", Description = "Defines the base size of the icons (e.g. for the buttons in the editor), default value 16,16 and it's scaled to the current DPI", DefaultValue = "16,16")]
public Size IconSize {
get {
return _iconSize;
@@ -295,6 +295,8 @@ namespace GreenshotPlugin.Core {
}
}
+ public Size ScaledIconSize => DpiHelper.ScaleWithCurrentDpi(_iconSize);
+
[IniProperty("WebRequestTimeout", Description = "The connect timeout value for webrequets, these are seconds", DefaultValue = "100")]
public int WebRequestTimeout { get; set; }
[IniProperty("WebRequestReadWriteTimeout", Description = "The read/write timeout value for webrequets, these are seconds", DefaultValue = "100")]
@@ -371,7 +373,7 @@ namespace GreenshotPlugin.Core {
}
return null;
}
-
+
///
/// This method will be called before converting the property, making to possible to correct a certain value
/// Can be used when migration is needed
@@ -494,7 +496,7 @@ namespace GreenshotPlugin.Core {
NoDWMCaptureForProduct[i] = NoDWMCaptureForProduct[i].ToLower();
}
}
-
+
if (AutoCropDifference < 0) {
AutoCropDifference = 0;
}
diff --git a/GreenshotPlugin/Core/DpiHelper.cs b/GreenshotPlugin/Core/DpiHelper.cs
new file mode 100644
index 000000000..df947bdbb
--- /dev/null
+++ b/GreenshotPlugin/Core/DpiHelper.cs
@@ -0,0 +1,711 @@
+using GreenshotPlugin.Core.Enums;
+using GreenshotPlugin.UnmanagedHelpers;
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GreenshotPlugin.Core
+{
+ ///
+ /// This handles DPI changes see
+ /// Writing DPI-Aware Desktop and Win32 Applications
+ ///
+ public static class DpiHelper
+ {
+ private static readonly ILog Log = LogManager.GetLogger(typeof(DpiHelper));
+
+ ///
+ /// This is the default DPI for the screen
+ ///
+ public const uint DefaultScreenDpi = 96;
+
+ ///
+ /// Retrieve the current DPI for the UI element which is related to this DpiHandler
+ ///
+ public static uint Dpi { get; private set; } = GetDpiForSystem();
+
+ ///
+ /// Calculate a DPI scale factor
+ ///
+ /// uint
+ /// double
+ public static float DpiScaleFactor(uint dpi)
+ {
+ return (float)dpi / DefaultScreenDpi;
+ }
+
+ ///
+ /// Scale the supplied number according to the supplied dpi
+ ///
+ /// double with e.g. the width 16 for 16x16 images
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// double with the scaled number
+ public static float ScaleWithDpi(float someNumber, uint dpi, Func scaleModifier = null)
+ {
+ var dpiScaleFactor = DpiScaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiScaleFactor = scaleModifier(dpiScaleFactor);
+ }
+ return dpiScaleFactor * someNumber;
+ }
+
+ ///
+ /// Scale the supplied number according to the supplied dpi
+ ///
+ /// int with e.g. 16 for 16x16 images
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// Scaled width
+ public static int ScaleWithDpi(int number, uint dpi, Func scaleModifier = null)
+ {
+ var dpiScaleFactor = DpiScaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiScaleFactor = scaleModifier(dpiScaleFactor);
+ }
+ return (int)(dpiScaleFactor * number);
+ }
+
+ ///
+ /// Scale the supplied Size according to the supplied dpi
+ ///
+ /// Size to resize
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// NativeSize scaled
+ public static Size ScaleWithDpi(Size size, uint dpi, Func scaleModifier = null)
+ {
+ var dpiScaleFactor = DpiScaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiScaleFactor = scaleModifier(dpiScaleFactor);
+ }
+ return new Size((int)(dpiScaleFactor * size.Width), (int)(dpiScaleFactor * size.Height));
+ }
+
+ ///
+ /// Scale the supplied NativePoint according to the supplied dpi
+ ///
+ /// NativePoint to resize
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// NativePoint scaled
+ public static Point ScaleWithDpi(Point size, uint dpi, Func scaleModifier = null)
+ {
+ var dpiScaleFactor = DpiScaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiScaleFactor = scaleModifier(dpiScaleFactor);
+ }
+ return new Point((int)(dpiScaleFactor * size.X), (int)(dpiScaleFactor * size.Y));
+ }
+
+ ///
+ /// Scale the supplied NativeSizeFloat according to the supplied dpi
+ ///
+ /// PointF
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// PointF
+ public static PointF ScaleWithDpi(PointF point, uint dpi, Func scaleModifier = null)
+ {
+ var dpiScaleFactor = DpiScaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiScaleFactor = scaleModifier(dpiScaleFactor);
+ }
+ return new PointF(dpiScaleFactor * point.X, dpiScaleFactor * point.Y);
+ }
+
+ ///
+ /// Scale the supplied NativeSizeFloat according to the supplied dpi
+ ///
+ /// NativeSizeFloat to resize
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// NativeSize scaled
+ public static SizeF ScaleWithDpi(SizeF size, uint dpi, Func scaleModifier = null)
+ {
+ var dpiScaleFactor = DpiScaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiScaleFactor = scaleModifier(dpiScaleFactor);
+ }
+ return new SizeF(dpiScaleFactor * size.Width, dpiScaleFactor * size.Height);
+ }
+
+ ///
+ /// Scale the supplied number to the current dpi
+ ///
+ /// double with e.g. a width like 16 for 16x16 images
+ /// A function which can modify the scale factor
+ /// double with scaled number
+ public static float ScaleWithCurrentDpi(float someNumber, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(someNumber, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Scale the supplied number to the current dpi
+ ///
+ /// int with e.g. a width like 16 for 16x16 images
+ /// A function which can modify the scale factor
+ /// int with scaled number
+ public static int ScaleWithCurrentDpi(int someNumber, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(someNumber, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Scale the supplied NativeSize to the current dpi
+ ///
+ /// NativeSize to scale
+ /// A function which can modify the scale factor
+ /// NativeSize scaled
+ public static Size ScaleWithCurrentDpi(Size size, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(size, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Scale the supplied NativeSizeFloat to the current dpi
+ ///
+ /// NativeSizeFloat to scale
+ /// A function which can modify the scale factor
+ /// NativeSizeFloat scaled
+ public static SizeF ScaleWithCurrentDpi(SizeF size, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(size, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Scale the supplied NativePoint to the current dpi
+ ///
+ /// NativePoint to scale
+ /// A function which can modify the scale factor
+ /// NativePoint scaled
+ public static Point ScaleWithCurrentDpi(Point point, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(point, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Scale the supplied PointF to the current dpi
+ ///
+ /// PointF to scale
+ /// A function which can modify the scale factor
+ /// PointF scaled
+ public static PointF ScaleWithCurrentDpi(PointF point, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(point, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Calculate a DPI unscale factor
+ ///
+ /// uint
+ /// float
+ public static float DpiUnscaleFactor(uint dpi)
+ {
+ return (float)DefaultScreenDpi / dpi;
+ }
+
+ ///
+ /// Unscale the supplied number according to the supplied dpi
+ ///
+ /// double with e.g. the scaled width
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// double with the unscaled number
+ public static float UnscaleWithDpi(float someNumber, uint dpi, Func scaleModifier = null)
+ {
+ var dpiUnscaleFactor = DpiUnscaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiUnscaleFactor = scaleModifier(dpiUnscaleFactor);
+ }
+ return dpiUnscaleFactor * someNumber;
+ }
+
+ ///
+ /// Unscale the supplied number according to the supplied dpi
+ ///
+ /// int with a scaled width
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// Unscaled width
+ public static int UnscaleWithDpi(int number, uint dpi, Func scaleModifier = null)
+ {
+ var dpiUnscaleFactor = DpiUnscaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiUnscaleFactor = scaleModifier(dpiUnscaleFactor);
+ }
+ return (int)(dpiUnscaleFactor * number);
+ }
+
+ ///
+ /// Unscale the supplied NativeSize according to the supplied dpi
+ ///
+ /// NativeSize to unscale
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// Size unscaled
+ public static Size UnscaleWithDpi(Size size, uint dpi, Func scaleModifier = null)
+ {
+ var dpiUnscaleFactor = DpiUnscaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiUnscaleFactor = scaleModifier(dpiUnscaleFactor);
+ }
+ return new Size((int)(dpiUnscaleFactor * size.Width), (int)(dpiUnscaleFactor * size.Height));
+ }
+
+ ///
+ /// Unscale the supplied Point according to the supplied dpi
+ ///
+ /// Point to unscale
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// Point unscaled
+ public static Point UnscaleWithDpi(Point point, uint dpi, Func scaleModifier = null)
+ {
+ var dpiUnscaleFactor = DpiUnscaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiUnscaleFactor = scaleModifier(dpiUnscaleFactor);
+ }
+ return new Point((int)(dpiUnscaleFactor * point.X), (int)(dpiUnscaleFactor * point.Y));
+ }
+
+ ///
+ /// unscale the supplied NativeSizeFloat according to the supplied dpi
+ ///
+ /// NativeSizeFloat to resize
+ /// current dpi, normal is 96.
+ /// A function which can modify the scale factor
+ /// SizeF unscaled
+ public static SizeF UnscaleWithDpi(SizeF size, uint dpi, Func scaleModifier = null)
+ {
+ float dpiUnscaleFactor = DpiUnscaleFactor(dpi);
+ if (scaleModifier != null)
+ {
+ dpiUnscaleFactor = scaleModifier(dpiUnscaleFactor);
+ }
+ return new SizeF(dpiUnscaleFactor * size.Width, dpiUnscaleFactor * size.Height);
+ }
+
+ ///
+ /// Unscale the supplied number to the current dpi
+ ///
+ /// double with e.g. a width like 16 for 16x16 images
+ /// A function which can modify the scale factor
+ /// double with unscaled number
+ public static float UnscaleWithCurrentDpi(float someNumber, Func scaleModifier = null)
+ {
+ return UnscaleWithDpi(someNumber, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Unscale the supplied number to the current dpi
+ ///
+ /// int with e.g. a width like 16 for 16x16 images
+ /// A function which can modify the scale factor
+ /// int with unscaled number
+ public static int UnscaleWithCurrentDpi(int someNumber, Func scaleModifier = null)
+ {
+ return UnscaleWithDpi(someNumber, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Unscale the supplied NativeSize to the current dpi
+ ///
+ /// Size to unscale
+ /// A function which can modify the scale factor
+ /// Size unscaled
+ public static Size UnscaleWithCurrentDpi(Size size, Func scaleModifier = null)
+ {
+ return UnscaleWithDpi(size, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Unscale the supplied NativeSizeFloat to the current dpi
+ ///
+ /// NativeSizeFloat to unscale
+ /// A function which can modify the scale factor
+ /// NativeSizeFloat unscaled
+ public static SizeF UnscaleWithCurrentDpi(SizeF size, Func scaleModifier = null)
+ {
+ return UnscaleWithDpi(size, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Unscale the supplied NativePoint to the current dpi
+ ///
+ /// NativePoint to unscale
+ /// A function which can modify the scale factor
+ /// NativePoint unscaled
+ public static Point UnscaleWithCurrentDpi(Point point, Func scaleModifier = null)
+ {
+ return UnscaleWithDpi(point, Dpi, scaleModifier);
+ }
+
+ ///
+ /// Unscale the supplied NativePointFloat to the current dpi
+ ///
+ /// NativePointFloat to unscale
+ /// A function which can modify the scale factor
+ /// NativePointFloat unscaled
+ public static PointF UnscaleWithCurrentDpi(PointF point, Func scaleModifier = null)
+ {
+ return ScaleWithDpi(point, Dpi, scaleModifier);
+ }
+
+ ///
+ /// public wrapper for EnableNonClientDpiScaling, this also checks if the function is available.
+ ///
+ /// IntPtr
+ /// true if it worked
+ public static bool TryEnableNonClientDpiScaling(IntPtr hWnd)
+ {
+ // EnableNonClientDpiScaling is only available on Windows 10 and later
+ if (!WindowsVersion.IsWindows10OrLater)
+ {
+ return false;
+ }
+
+ var result = EnableNonClientDpiScaling(hWnd);
+ if (result.Succeeded())
+ {
+ return true;
+ }
+
+ var error = Win32.GetLastErrorCode();
+ if (Log.IsDebugEnabled)
+ {
+ Log.DebugFormat("Error enabling non client dpi scaling : {0}", Win32.GetMessage(error));
+ }
+
+ return false;
+ }
+
+ ///
+ /// Make the current process DPI Aware, this should be done via the manifest but sometimes this is not possible.
+ ///
+ /// bool true if it was possible to change the DPI awareness
+ public static bool EnableDpiAware()
+ {
+ // We can only test this for Windows 8.1 or later
+ if (!WindowsVersion.IsWindows81OrLater)
+ {
+ Log.Debug("An application can only be DPI aware starting with Window 8.1 and later.");
+ return false;
+ }
+
+ if (WindowsVersion.IsWindows10BuildOrLater(15063))
+ {
+ if (IsValidDpiAwarenessContext(DpiAwarenessContext.PerMonitorAwareV2))
+ {
+ SetProcessDpiAwarenessContext(DpiAwarenessContext.PerMonitorAwareV2);
+ }
+ else
+ {
+ SetProcessDpiAwarenessContext(DpiAwarenessContext.PerMonitorAwareV2);
+ }
+
+ return true;
+ }
+ return SetProcessDpiAwareness(DpiAwareness.PerMonitorAware).Succeeded();
+ }
+
+ ///
+ /// Check if the process is DPI Aware, an DpiHandler doesn't make sense if not.
+ ///
+ public static bool IsDpiAware
+ {
+ get
+ {
+ // We can only test this for Windows 8.1 or later
+ if (!WindowsVersion.IsWindows81OrLater)
+ {
+ Log.Debug("An application can only be DPI aware starting with Window 8.1 and later.");
+ return false;
+ }
+
+ using var process = Process.GetCurrentProcess();
+ GetProcessDpiAwareness(process.Handle, out var dpiAwareness);
+ if (Log.IsDebugEnabled)
+ {
+ Log.DebugFormat("Process {0} has a Dpi awareness {1}", process.ProcessName, dpiAwareness);
+ }
+
+ return dpiAwareness != DpiAwareness.Unaware && dpiAwareness != DpiAwareness.Invalid;
+ }
+ }
+
+ ///
+ /// Retrieve the DPI value for the supplied window handle
+ ///
+ /// IntPtr
+ /// dpi value
+ public static uint GetDpi(IntPtr hWnd)
+ {
+ if (!User32.IsWindow(hWnd))
+ {
+ return DefaultScreenDpi;
+ }
+
+ // Use the easiest method, but this only works for Windows 10
+ if (WindowsVersion.IsWindows10OrLater)
+ {
+ return GetDpiForWindow(hWnd);
+ }
+
+ // Use the second easiest method, but this only works for Windows 8.1 or later
+ if (WindowsVersion.IsWindows81OrLater)
+ {
+ var hMonitor = User32.MonitorFromWindow(hWnd, MonitorFrom.DefaultToNearest);
+ // ReSharper disable once UnusedVariable
+ if (GetDpiForMonitor(hMonitor, MonitorDpiType.EffectiveDpi, out var dpiX, out var dpiY))
+ {
+ return dpiX;
+ }
+ }
+
+ // Fallback to the global DPI settings
+ using var hdc = SafeWindowDcHandle.FromWindow(hWnd);
+ if (hdc == null)
+ {
+ return DefaultScreenDpi;
+ }
+ return (uint)GDI32.GetDeviceCaps(hdc, DeviceCaps.LOGPIXELSX);
+ }
+
+ ///
+ /// See details GetProcessDpiAwareness function
+ /// Retrieves the dots per inch (dpi) awareness of the specified process.
+ ///
+ /// IntPtr with handle of the process that is being queried. If this parameter is NULL, the current process is queried.
+ /// out DpiAwareness - The DPI awareness of the specified process. Possible values are from the PROCESS_DPI_AWARENESS enumeration.
+ /// HResult
+ [DllImport("shcore")]
+ private static extern HResult GetProcessDpiAwareness(IntPtr processHandle, out DpiAwareness value);
+
+ ///
+ /// Sets the current process to a specified dots per inch (dpi) awareness level. The DPI awareness levels are from the PROCESS_DPI_AWARENESS enumeration.
+ /// See SetProcessDpiAwareness function
+ ///
+ /// DpiAwareness
+ /// HResult
+ [DllImport("shcore")]
+ private static extern HResult SetProcessDpiAwareness(DpiAwareness dpiAwareness);
+
+ ///
+ /// It is recommended that you set the process-default DPI awareness via application manifest. See Setting the default DPI awareness for a process for more information. Setting the process-default DPI awareness via API call can lead to unexpected application behavior.
+ ///
+ /// Sets the current process to a specified dots per inch (dpi) awareness context. The DPI awareness contexts are from the DPI_AWARENESS_CONTEXT value.
+ /// Remarks:
+ /// This API is a more advanced version of the previously existing SetProcessDpiAwareness API, allowing for the process default to be set to the finer-grained DPI_AWARENESS_CONTEXT values. Most importantly, this allows you to programmatically set Per Monitor v2 as the process default value, which is not possible with the previous API.
+ ///
+ /// This method sets the default DPI_AWARENESS_CONTEXT for all threads within an application. Individual threads can have their DPI awareness changed from the default with the SetThreadDpiAwarenessContext method.
+ /// See SetProcessDpiAwarenessContext function
+ ///
+ /// DpiAwarenessContext
+ /// bool
+ [DllImport("User32.dll", SetLastError = true)]
+ private static extern bool SetProcessDpiAwarenessContext(DpiAwarenessContext dpiAwarenessContext);
+
+ ///
+ /// See more at GetDpiForWindow function
+ /// Returns the dots per inch (dpi) value for the associated window.
+ ///
+ /// IntPtr
+ /// uint with dpi
+ [DllImport("User32.dll")]
+ private static extern uint GetDpiForWindow(IntPtr hWnd);
+
+ ///
+ /// See
+ /// GetDpiForMonitor function
+ /// Queries the dots per inch (dpi) of a display.
+ ///
+ /// IntPtr
+ /// MonitorDpiType
+ /// out int for the horizontal dpi
+ /// out int for the vertical dpi
+ /// true if all okay
+ [DllImport("shcore")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool GetDpiForMonitor(IntPtr hMonitor, MonitorDpiType dpiType, out uint dpiX, out uint dpiY);
+
+ ///
+ /// See EnableNonClientDpiScaling function
+ ///
+ /// IntPtr
+ /// bool
+ [DllImport("User32.dll", SetLastError = true)]
+ private static extern HResult EnableNonClientDpiScaling(IntPtr hWnd);
+
+ ///
+ /// See GetDpiForSystem function
+ /// Returns the system DPI.
+ ///
+ /// uint with the system DPI
+ [DllImport("User32.dll")]
+ private static extern uint GetDpiForSystem();
+
+ ///
+ /// Converts a point in a window from logical coordinates into physical coordinates, regardless of the dots per inch (dpi) awareness of the caller. For more information about DPI awareness levels, see PROCESS_DPI_AWARENESS.
+ /// See more at LogicalToPhysicalPointForPerMonitorDPI function
+ ///
+ /// IntPtr A handle to the window whose transform is used for the conversion.
+ /// A pointer to a POINT structure that specifies the logical coordinates to be converted. The new physical coordinates are copied into this structure if the function succeeds.
+ /// bool
+ [DllImport("User32.dll")]
+ private static extern bool LogicalToPhysicalPointForPerMonitorDPI(IntPtr hWnd, ref POINT point);
+
+ ///
+ /// Converts a point in a window from logical coordinates into physical coordinates, regardless of the dots per inch (dpi) awareness of the caller. For more information about DPI awareness levels, see PROCESS_DPI_AWARENESS.
+ /// See more at PhysicalToLogicalPointForPerMonitorDPI function
+ ///
+ /// IntPtr A handle to the window whose transform is used for the conversion.
+ /// NativePoint A pointer to a POINT structure that specifies the physical/screen coordinates to be converted. The new logical coordinates are copied into this structure if the function succeeds.
+ /// bool
+ [DllImport("User32.dll")]
+ private static extern bool PhysicalToLogicalPointForPerMonitorDPI(IntPtr hWnd, ref POINT point);
+
+ ///
+ /// See SystemParametersInfo function
+ /// Retrieves the value of one of the system-wide parameters, taking into account the provided DPI value.
+ ///
+ ///
+ /// SystemParametersInfoActions The system-wide parameter to be retrieved.
+ /// This function is only intended for use with SPI_GETICONTITLELOGFONT, SPI_GETICONMETRICS, or SPI_GETNONCLIENTMETRICS. See SystemParametersInfo for more information on these values.
+ ///
+ ///
+ /// A parameter whose usage and format depends on the system parameter being queried or set. For more
+ /// information about system-wide parameters, see the uiAction parameter. If not otherwise indicated, you must specify
+ /// zero for this parameter.
+ ///
+ /// IntPtr
+ /// SystemParametersInfoBehaviors
+ /// uint with dpi value
+ /// bool
+ [DllImport("User32.dll", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool SystemParametersInfoForDpi(SystemParametersInfoActions uiAction, uint uiParam, IntPtr pvParam, SystemParametersInfoBehaviors fWinIni, uint dpi);
+
+ ///
+ /// See GetThreadDpiAwarenessContext function
+ /// Gets the DPI_AWARENESS_CONTEXT for the current thread.
+ ///
+ /// This method will return the latest DPI_AWARENESS_CONTEXT sent to SetThreadDpiAwarenessContext. If SetThreadDpiAwarenessContext was never called for this thread, then the return value will equal the default DPI_AWARENESS_CONTEXT for the process.
+ ///
+ /// DpiAwarenessContext
+ [DllImport("User32.dll")]
+ private static extern DpiAwarenessContext GetThreadDpiAwarenessContext();
+
+ ///
+ /// Set the DPI awareness for the current thread to the provided value.
+ ///
+ /// DpiAwarenessContext the new value for the current thread
+ /// DpiAwarenessContext previous value
+ [DllImport("User32.dll")]
+ private static extern DpiAwarenessContext SetThreadDpiAwarenessContext(DpiAwarenessContext dpiAwarenessContext);
+
+ ///
+ /// Retrieves the DpiAwareness value from a DpiAwarenessContext.
+ ///
+ /// DpiAwarenessContext
+ /// DpiAwareness
+ [DllImport("User32.dll")]
+ private static extern DpiAwareness GetAwarenessFromDpiAwarenessContext(DpiAwarenessContext dpiAwarenessContext);
+
+ ///
+ /// Retrieves the DPI from a given DPI_AWARENESS_CONTEXT handle. This enables you to determine the DPI of a thread without needed to examine a window created within that thread.
+ ///
+ /// DpiAwarenessContext
+ /// uint with dpi value
+ [DllImport("User32.dll")]
+ private static extern uint GetDpiFromDpiAwarenessContext(DpiAwarenessContext dpiAwarenessContext);
+
+ ///
+ /// Determines if a specified DPI_AWARENESS_CONTEXT is valid and supported by the current system.
+ ///
+ /// DpiAwarenessContext The context that you want to determine if it is supported.
+ /// bool true if supported otherwise false
+ [DllImport("User32.dll")]
+ private static extern bool IsValidDpiAwarenessContext(DpiAwarenessContext dpiAwarenessContext);
+
+ ///
+ /// Returns the DPI_HOSTING_BEHAVIOR of the specified window.
+ ///
+ /// This API allows you to examine the hosting behavior of a window after it has been created. A window's hosting behavior is the hosting behavior of the thread in which the window was created, as set by a call to SetThreadDpiHostingBehavior. This is a permanent value and cannot be changed after the window is created, even if the thread's hosting behavior is changed.
+ ///
+ /// DpiHostingBehavior
+ [DllImport("User32.dll")]
+ private static extern DpiHostingBehavior GetWindowDpiHostingBehavior();
+
+ ///
+ /// See more at SetThreadDpiHostingBehavior function
+ /// Sets the thread's DPI_HOSTING_BEHAVIOR. This behavior allows windows created in the thread to host child windows with a different DPI_AWARENESS_CONTEXT.
+ ///
+ /// DPI_HOSTING_BEHAVIOR enables a mixed content hosting behavior, which allows parent windows created in the thread to host child windows with a different DPI_AWARENESS_CONTEXT value. This property only effects new windows created within this thread while the mixed hosting behavior is active. A parent window with this hosting behavior is able to host child windows with different DPI_AWARENESS_CONTEXT values, regardless of whether the child windows have mixed hosting behavior enabled.
+ ///
+ /// This hosting behavior does not allow for windows with per-monitor DPI_AWARENESS_CONTEXT values to be hosted until windows with DPI_AWARENESS_CONTEXT values of system or unaware.
+ ///
+ /// To avoid unexpected outcomes, a thread's DPI_HOSTING_BEHAVIOR should be changed to support mixed hosting behaviors only when creating a new window which needs to support those behaviors. Once that window is created, the hosting behavior should be switched back to its default value.
+ ///
+ /// This API is used to change the thread's DPI_HOSTING_BEHAVIOR from its default value. This is only necessary if your app needs to host child windows from plugins and third-party components that do not support per-monitor-aware context. This is most likely to occur if you are updating complex applications to support per-monitor DPI_AWARENESS_CONTEXT behaviors.
+ ///
+ /// Enabling mixed hosting behavior will not automatically adjust the thread's DPI_AWARENESS_CONTEXT to be compatible with legacy content. The thread's awareness context must still be manually changed before new windows are created to host such content.
+ ///
+ /// DpiHostingBehavior
+ /// previous DpiHostingBehavior
+ [DllImport("User32.dll")]
+ private static extern DpiHostingBehavior SetThreadDpiHostingBehavior(DpiHostingBehavior dpiHostingBehavior);
+
+ ///
+ ///Retrieves the DPI_HOSTING_BEHAVIOR from the current thread.
+ ///
+ /// DpiHostingBehavior
+ [DllImport("User32.dll")]
+ private static extern DpiHostingBehavior GetThreadDpiHostingBehavior();
+
+ ///
+ /// Overrides the default per-monitor DPI scaling behavior of a child window in a dialog.
+ /// This function returns TRUE if the operation was successful, and FALSE otherwise. To get extended error information, call GetLastError.
+ ///
+ /// Possible errors are ERROR_INVALID_HANDLE if passed an invalid HWND, and ERROR_ACCESS_DENIED if the windows belongs to another process.
+ ///
+ /// The behaviors are specified as values from the DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS enum. This function follows the typical two-parameter approach to setting flags, where a mask specifies the subset of the flags to be changed.
+ ///
+ /// It is valid to set these behaviors on any window. It does not matter if the window is currently a child of a dialog at the point in time that SetDialogControlDpiChangeBehavior is called. The behaviors are retained and will take effect only when the window is an immediate child of a dialog that has per-monitor DPI scaling enabled.
+ ///
+ /// This API influences individual controls within dialogs. The dialog-wide per-monitor DPI scaling behavior is controlled by SetDialogDpiChangeBehavior.
+ ///
+ /// IntPtr A handle for the window whose behavior will be modified.
+ /// DialogScalingBehaviors A mask specifying the subset of flags to be changed.
+ /// DialogScalingBehaviors The desired value to be set for the specified subset of flags.
+ /// bool
+ [DllImport("User32.dll")]
+ private static extern bool SetDialogControlDpiChangeBehavior(IntPtr hWnd, DialogScalingBehaviors mask, DialogScalingBehaviors values);
+
+ ///
+ /// Retrieves and per-monitor DPI scaling behavior overrides of a child window in a dialog.
+ /// The flags set on the given window. If passed an invalid handle, this function will return zero, and set its last error to ERROR_INVALID_HANDLE.
+ ///
+ /// IntPtr A handle for the window whose behavior will be modified.
+ /// DialogScalingBehaviors
+ [DllImport("User32.dll")]
+ private static extern DialogScalingBehaviors GetDialogControlDpiChangeBehavior(IntPtr hWnd);
+ }
+}
diff --git a/GreenshotPlugin/Core/Enums/DialogDpiChangeBehaviors.cs b/GreenshotPlugin/Core/Enums/DialogDpiChangeBehaviors.cs
new file mode 100644
index 000000000..fa5b61635
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/DialogDpiChangeBehaviors.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// In Per Monitor v2 contexts, dialogs will automatically respond to DPI changes by resizing themselves and re-computing the positions of their child windows (here referred to as re-layouting). This enum works in conjunction with SetDialogDpiChangeBehavior in order to override the default DPI scaling behavior for dialogs.
+ /// This does not affect DPI scaling behavior for the child windows of dialogs(beyond re-layouting), which is controlled by DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS.
+ ///
+ [Flags]
+ public enum DialogDpiChangeBehaviors
+ {
+ ///
+ /// The default behavior of the dialog manager. In response to a DPI change, the dialog manager will re-layout each control, update the font on each control, resize the dialog, and update the dialog's own font.
+ ///
+ Default = 0,
+
+ ///
+ /// Prevents the dialog manager from responding to WM_GETDPISCALEDSIZE and WM_DPICHANGED, disabling all default DPI scaling behavior.
+ ///
+ DisableAll = 1,
+
+ ///
+ /// Prevents the dialog manager from resizing the dialog in response to a DPI change.
+ ///
+ DisableResize = 2,
+
+ ///
+ /// Prevents the dialog manager from re-layouting all of the dialogue's immediate children HWNDs in response to a DPI change.
+ ///
+ DisableControlRelayout = 3
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/DialogScalingBehaviors.cs b/GreenshotPlugin/Core/Enums/DialogScalingBehaviors.cs
new file mode 100644
index 000000000..4de8e4c35
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/DialogScalingBehaviors.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// Describes per-monitor DPI scaling behavior overrides for child windows within dialogs. The values in this enumeration are bitfields and can be combined.
+ ///
+ /// This enum is used with SetDialogControlDpiChangeBehavior in order to override the default per-monitor DPI scaling behavior for a child window within a dialog.
+ ///
+ /// These settings only apply to individual controls within dialogs. The dialog-wide per-monitor DPI scaling behavior of a dialog is controlled by DIALOG_DPI_CHANGE_BEHAVIORS.
+ ///
+ [Flags]
+ public enum DialogScalingBehaviors
+ {
+ ///
+ /// The default behavior of the dialog manager. The dialog managed will update the font, size, and position of the child window on DPI changes.
+ ///
+ Default = 0,
+
+ ///
+ /// Prevents the dialog manager from sending an updated font to the child window via WM_SETFONT in response to a DPI change.
+ ///
+ DisableFontUpdate = 1,
+
+ ///
+ /// Prevents the dialog manager from resizing and repositioning the child window in response to a DPI change.
+ ///
+ DisableRelayout = 2
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/DpiAwareness.cs b/GreenshotPlugin/Core/Enums/DpiAwareness.cs
new file mode 100644
index 000000000..7dd22431e
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/DpiAwareness.cs
@@ -0,0 +1,40 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// Identifies the dots per inch (dpi) setting for a thread, process, or window.
+ /// Can be used everywhere ProcessDpiAwareness is passed.
+ ///
+ public enum DpiAwareness
+ {
+ ///
+ /// Invalid DPI awareness. This is an invalid DPI awareness value.
+ ///
+ Invalid = -1,
+
+ ///
+ /// DPI unaware.
+ /// This process does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).
+ /// It will be automatically scaled by the system on any other DPI setting.
+ ///
+ Unaware = 0,
+
+ ///
+ /// System DPI aware.
+ /// This process does not scale for DPI changes.
+ /// It will query for the DPI once and use that value for the lifetime of the process.
+ /// If the DPI changes, the process will not adjust to the new DPI value.
+ /// It will be automatically scaled up or down by the system when the DPI changes from the system value.
+ ///
+ SystemAware = 1,
+
+ ///
+ /// Per monitor DPI aware.
+ /// This process checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.
+ /// These processes are not automatically scaled by the system.
+ ///
+ PerMonitorAware = 2
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/DpiAwarenessContext.cs b/GreenshotPlugin/Core/Enums/DpiAwarenessContext.cs
new file mode 100644
index 000000000..276d73550
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/DpiAwarenessContext.cs
@@ -0,0 +1,46 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ ///
+ public enum DpiAwarenessContext
+ {
+ ///
+ /// DPI unaware.
+ /// This window does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).
+ /// It will be automatically scaled by the system on any other DPI setting.
+ ///
+ Unaware = -1,
+
+ ///
+ /// System DPI aware.
+ /// This window does not scale for DPI changes.
+ /// It will query for the DPI once and use that value for the lifetime of the process.
+ /// If the DPI changes, the process will not adjust to the new DPI value.
+ /// It will be automatically scaled up or down by the system when the DPI changes from the system value.
+ ///
+ SystemAware = -2,
+
+ ///
+ /// Per monitor DPI aware.
+ /// This window checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.
+ /// These processes are not automatically scaled by the system.
+ ///
+ PerMonitorAware = -3,
+
+ ///
+ /// Also known as Per Monitor v2. An advancement over the original per-monitor DPI awareness mode, which enables applications to access new DPI-related scaling behaviors on a per top-level window basis.
+ /// Per Monitor v2 was made available in the Creators Update of Windows 10, and is not available on earlier versions of the operating system.
+ /// The additional behaviors introduced are as follows:
+ /// * Child window DPI change notifications - In Per Monitor v2 contexts, the entire window tree is notified of any DPI changes that occur.
+ /// * Scaling of non-client area - All windows will automatically have their non-client area drawn in a DPI sensitive fashion. Calls to EnableNonClientDpiScaling are unnecessary.
+ /// * Scaling of Win32 menus - All NTUSER menus created in Per Monitor v2 contexts will be scaling in a per-monitor fashion.
+ /// * Dialog Scaling - Win32 dialogs created in Per Monitor v2 contexts will automatically respond to DPI changes.
+ /// * Improved scaling of comctl32 controls - Various comctl32 controls have improved DPI scaling behavior in Per Monitor v2 contexts.
+ /// * Improved theming behavior - UxTheme handles opened in the context of a Per Monitor v2 window will operate in terms of the DPI associated with that window.
+ ///
+ PerMonitorAwareV2 = -4
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/DpiHostingBehavior.cs b/GreenshotPlugin/Core/Enums/DpiHostingBehavior.cs
new file mode 100644
index 000000000..0b0abf686
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/DpiHostingBehavior.cs
@@ -0,0 +1,28 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// Identifies the DPI hosting behavior for a window.
+ /// This behavior allows windows created in the thread to host child windows with a different DPI_AWARENESS_CONTEXT
+ ///
+ public enum DpiHostingBehavior
+ {
+ ///
+ /// Invalid DPI hosting behavior. This usually occurs if the previous SetThreadDpiHostingBehavior call used an invalid parameter.
+ ///
+ Invalid = -1,
+
+ ///
+ /// Default DPI hosting behavior. The associated window behaves as normal, and cannot create or re-parent child windows with a different DPI_AWARENESS_CONTEXT.
+ ///
+ Default = 0,
+
+ ///
+ /// Mixed DPI hosting behavior. This enables the creation and re-parenting of child windows with different DPI_AWARENESS_CONTEXT. These child windows will be independently scaled by the OS.
+ ///
+ Mixed = 1
+
+ }
+}
\ No newline at end of file
diff --git a/GreenshotWin10Plugin/Native/HResult.cs b/GreenshotPlugin/Core/Enums/HResult.cs
similarity index 60%
rename from GreenshotWin10Plugin/Native/HResult.cs
rename to GreenshotPlugin/Core/Enums/HResult.cs
index 9a36be173..55f61aaf0 100644
--- a/GreenshotWin10Plugin/Native/HResult.cs
+++ b/GreenshotPlugin/Core/Enums/HResult.cs
@@ -1,11 +1,25 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program 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 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
-namespace GreenshotWin10Plugin.Native
+using System.Diagnostics.CodeAnalysis;
+
+namespace GreenshotPlugin.Core.Enums
{
///
/// The HRESULT represents Windows error codes
diff --git a/GreenshotPlugin/Core/Enums/MonitorDpiType.cs b/GreenshotPlugin/Core/Enums/MonitorDpiType.cs
new file mode 100644
index 000000000..ebe0033b4
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/MonitorDpiType.cs
@@ -0,0 +1,40 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// See
+ ///
+ /// MONITOR_DPI_TYPE
+ /// enumeration
+ ///
+ ///
+ [Flags]
+ public enum MonitorDpiType
+ {
+ ///
+ /// The effective DPI.
+ /// This value should be used when determining the correct scale factor for scaling UI elements.
+ /// This incorporates the scale factor set by the user for this specific display.
+ ///
+ EffectiveDpi = 0,
+
+ ///
+ /// The angular DPI.
+ /// This DPI ensures rendering at a compliant angular resolution on the screen.
+ /// This does not include the scale factor set by the user for this specific display
+ ///
+ AngularDpi = 1,
+
+ ///
+ /// The raw DPI.
+ /// This value is the linear DPI of the screen as measured on the screen itself.
+ /// Use this value when you want to read the pixel density and not the recommended scaling setting.
+ /// This does not include the scale factor set by the user for this specific display and is not guaranteed to be a
+ /// supported DPI value.
+ ///
+ RawDpi = 2
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/MonitorFrom.cs b/GreenshotPlugin/Core/Enums/MonitorFrom.cs
new file mode 100644
index 000000000..57e57a390
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/MonitorFrom.cs
@@ -0,0 +1,30 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// Flags for the MonitorFromRect / MonitorFromWindow "flags" field
+ /// see MonitorFromRect function
+ /// or see MonitorFromWindow function
+ ///
+ [Flags]
+ public enum MonitorFrom : uint
+ {
+ ///
+ /// Returns a handle to the display monitor that is nearest to the rectangle.
+ ///
+ DefaultToNearest = 0,
+
+ ///
+ /// Returns NULL. (why??)
+ ///
+ DefaultToNull = 1,
+
+ ///
+ /// Returns a handle to the primary display monitor.
+ ///
+ DefaultToPrimary = 2
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/SystemParametersInfoActions.cs b/GreenshotPlugin/Core/Enums/SystemParametersInfoActions.cs
new file mode 100644
index 000000000..62a4eb5f4
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/SystemParametersInfoActions.cs
@@ -0,0 +1,1390 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Diagnostics.CodeAnalysis;
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// SPI_ System-wide parameter - Used in SystemParametersInfo function
+ ///
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public enum SystemParametersInfoActions : uint
+ {
+ ///
+ /// No value
+ ///
+ SPI_NONE = 0,
+
+ ///
+ /// Determines whether the warning beeper is on.
+ /// The pvParam parameter must point to a BOOL variable that receives TRUE if the beeper is on, or FALSE if it is off.
+ ///
+ SPI_GETBEEP = 0x0001,
+
+ ///
+ /// Turns the warning beeper on or off. The uiParam parameter specifies TRUE for on, or FALSE for off.
+ ///
+ SPI_SETBEEP = 0x0002,
+
+ ///
+ /// Retrieves the two mouse threshold values and the mouse speed.
+ ///
+ SPI_GETMOUSE = 0x0003,
+
+ ///
+ /// Sets the two mouse threshold values and the mouse speed.
+ ///
+ SPI_SETMOUSE = 0x0004,
+
+ ///
+ /// Retrieves the border multiplier factor that determines the width of a window's sizing border.
+ /// The pvParam parameter must point to an integer variable that receives this value.
+ ///
+ SPI_GETBORDER = 0x0005,
+
+ ///
+ /// Sets the border multiplier factor that determines the width of a window's sizing border.
+ /// The uiParam parameter specifies the new value.
+ ///
+ SPI_SETBORDER = 0x0006,
+
+ ///
+ /// Retrieves the keyboard repeat-speed setting, which is a value in the range from 0 (approximately 2.5 repetitions
+ /// per second)
+ /// through 31 (approximately 30 repetitions per second). The actual repeat rates are hardware-dependent and may vary
+ /// from
+ /// a linear scale by as much as 20%. The pvParam parameter must point to a DWORD variable that receives the setting
+ ///
+ SPI_GETKEYBOARDSPEED = 0x000A,
+
+ ///
+ /// Sets the keyboard repeat-speed setting. The uiParam parameter must specify a value in the range from 0
+ /// (approximately 2.5 repetitions per second) through 31 (approximately 30 repetitions per second).
+ /// The actual repeat rates are hardware-dependent and may vary from a linear scale by as much as 20%.
+ /// If uiParam is greater than 31, the parameter is set to 31.
+ ///
+ SPI_SETKEYBOARDSPEED = 0x000B,
+
+ ///
+ /// Not implemented.
+ ///
+ SPI_LANGDRIVER = 0x000C,
+
+ ///
+ /// Sets or retrieves the width, in pixels, of an icon cell. The system uses this rectangle to arrange icons in large
+ /// icon view.
+ /// To set this value, set uiParam to the new value and set pvParam to null. You cannot set this value to less than
+ /// SM_CXICON.
+ /// To retrieve this value, pvParam must point to an integer that receives the current value.
+ ///
+ SPI_ICONHORIZONTALSPACING = 0x000D,
+
+ ///
+ /// Retrieves the screen saver time-out value, in seconds. The pvParam parameter must point to an integer variable that
+ /// receives the value.
+ ///
+ SPI_GETSCREENSAVETIMEOUT = 0x000E,
+
+ ///
+ /// Sets the screen saver time-out value to the value of the uiParam parameter. This value is the amount of time, in
+ /// seconds,
+ /// that the system must be idle before the screen saver activates.
+ ///
+ SPI_SETSCREENSAVETIMEOUT = 0x000F,
+
+ ///
+ /// Determines whether screen saving is enabled. The pvParam parameter must point to a bool variable that receives TRUE
+ /// if screen saving is enabled, or FALSE otherwise.
+ /// Does not work for Windows 7: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx
+ ///
+ SPI_GETSCREENSAVEACTIVE = 0x0010,
+
+ ///
+ /// Sets the state of the screen saver. The uiParam parameter specifies TRUE to activate screen saving, or FALSE to
+ /// deactivate it.
+ ///
+ SPI_SETSCREENSAVEACTIVE = 0x0011,
+
+ ///
+ /// Retrieves the current granularity value of the desktop sizing grid. The pvParam parameter must point to an integer
+ /// variable
+ /// that receives the granularity.
+ ///
+ SPI_GETGRIDGRANULARITY = 0x0012,
+
+ ///
+ /// Sets the granularity of the desktop sizing grid to the value of the uiParam parameter.
+ ///
+ SPI_SETGRIDGRANULARITY = 0x0013,
+
+ ///
+ /// Sets the desktop wallpaper. The value of the pvParam parameter determines the new wallpaper. To specify a wallpaper
+ /// bitmap,
+ /// set pvParam to point to a null-terminated string containing the name of a bitmap file. Setting pvParam to ""
+ /// removes the wallpaper.
+ /// Setting pvParam to SETWALLPAPER_DEFAULT or null reverts to the default wallpaper.
+ ///
+ SPI_SETDESKWALLPAPER = 0x0014,
+
+ ///
+ /// Sets the current desktop pattern by causing Windows to read the Pattern= setting from the WIN.INI file.
+ ///
+ SPI_SETDESKPATTERN = 0x0015,
+
+ ///
+ /// Retrieves the keyboard repeat-delay setting, which is a value in the range from 0 (approximately 250 ms delay)
+ /// through 3
+ /// (approximately 1 second delay). The actual delay associated with each value may vary depending on the hardware. The
+ /// pvParam parameter must point to an integer variable that receives the setting.
+ ///
+ SPI_GETKEYBOARDDELAY = 0x0016,
+
+ ///
+ /// Sets the keyboard repeat-delay setting. The uiParam parameter must specify 0, 1, 2, or 3, where zero sets the
+ /// shortest delay
+ /// (approximately 250 ms) and 3 sets the longest delay (approximately 1 second). The actual delay associated with each
+ /// value may
+ /// vary depending on the hardware.
+ ///
+ SPI_SETKEYBOARDDELAY = 0x0017,
+
+ ///
+ /// Sets or retrieves the height, in pixels, of an icon cell.
+ /// To set this value, set uiParam to the new value and set pvParam to null. You cannot set this value to less than
+ /// SM_CYICON.
+ /// To retrieve this value, pvParam must point to an integer that receives the current value.
+ ///
+ SPI_ICONVERTICALSPACING = 0x0018,
+
+ ///
+ /// Determines whether icon-title wrapping is enabled. The pvParam parameter must point to a bool variable that
+ /// receives TRUE
+ /// if enabled, or FALSE otherwise.
+ ///
+ SPI_GETICONTITLEWRAP = 0x0019,
+
+ ///
+ /// Turns icon-title wrapping on or off. The uiParam parameter specifies TRUE for on, or FALSE for off.
+ ///
+ SPI_SETICONTITLEWRAP = 0x001A,
+
+ ///
+ /// Determines whether pop-up menus are left-aligned or right-aligned, relative to the corresponding menu-bar item.
+ /// The pvParam parameter must point to a bool variable that receives TRUE if left-aligned, or FALSE otherwise.
+ ///
+ SPI_GETMENUDROPALIGNMENT = 0x001B,
+
+ ///
+ /// Sets the alignment value of pop-up menus. The uiParam parameter specifies TRUE for right alignment, or FALSE for
+ /// left alignment.
+ ///
+ SPI_SETMENUDROPALIGNMENT = 0x001C,
+
+ ///
+ /// Sets the width of the double-click rectangle to the value of the uiParam parameter.
+ /// The double-click rectangle is the rectangle within which the second click of a double-click must fall for it to be
+ /// registered
+ /// as a double-click.
+ /// To retrieve the width of the double-click rectangle, call GetSystemMetrics with the SM_CXDOUBLECLK flag.
+ ///
+ SPI_SETDOUBLECLKWIDTH = 0x001D,
+
+ ///
+ /// Sets the height of the double-click rectangle to the value of the uiParam parameter.
+ /// The double-click rectangle is the rectangle within which the second click of a double-click must fall for it to be
+ /// registered
+ /// as a double-click.
+ /// To retrieve the height of the double-click rectangle, call GetSystemMetrics with the SM_CYDOUBLECLK flag.
+ ///
+ SPI_SETDOUBLECLKHEIGHT = 0x001E,
+
+ ///
+ /// Retrieves the logical font information for the current icon-title font. The uiParam parameter specifies the size of
+ /// a LOGFONT structure,
+ /// and the pvParam parameter must point to the LOGFONT structure to fill in.
+ ///
+ SPI_GETICONTITLELOGFONT = 0x001F,
+
+ ///
+ /// Sets the double-click time for the mouse to the value of the uiParam parameter. The double-click time is the
+ /// maximum number
+ /// of milliseconds that can occur between the first and second clicks of a double-click. You can also call the
+ /// SetDoubleClickTime
+ /// function to set the double-click time. To get the current double-click time, call the GetDoubleClickTime function.
+ ///
+ SPI_SETDOUBLECLICKTIME = 0x0020,
+
+ ///
+ /// Swaps or restores the meaning of the left and right mouse buttons. The uiParam parameter specifies TRUE to swap the
+ /// meanings
+ /// of the buttons, or FALSE to restore their original meanings.
+ ///
+ SPI_SETMOUSEBUTTONSWAP = 0x0021,
+
+ ///
+ /// Sets the font that is used for icon titles. The uiParam parameter specifies the size of a LOGFONT structure,
+ /// and the pvParam parameter must point to a LOGFONT structure.
+ ///
+ SPI_SETICONTITLELOGFONT = 0x0022,
+
+ ///
+ /// This flag is obsolete. Previous versions of the system use this flag to determine whether ALT+TAB fast task
+ /// switching is enabled.
+ /// For Windows 95, Windows 98, and Windows NT version 4.0 and later, fast task switching is always enabled.
+ ///
+ SPI_GETFASTTASKSWITCH = 0x0023,
+
+ ///
+ /// This flag is obsolete. Previous versions of the system use this flag to enable or disable ALT+TAB fast task
+ /// switching.
+ /// For Windows 95, Windows 98, and Windows NT version 4.0 and later, fast task switching is always enabled.
+ ///
+ SPI_SETFASTTASKSWITCH = 0x0024,
+
+ ///
+ /// Sets dragging of full windows either on or off. The uiParam parameter specifies TRUE for on, or FALSE for off.
+ /// Windows 95: This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.
+ ///
+ SPI_SETDRAGFULLWINDOWS = 0x0025,
+
+ ///
+ /// Determines whether dragging of full windows is enabled. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// if enabled, or FALSE otherwise.
+ /// Windows 95: This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.
+ ///
+ SPI_GETDRAGFULLWINDOWS = 0x0026,
+
+ ///
+ /// Retrieves the metrics associated with the nonclient area of nonminimized windows. The pvParam parameter must point
+ /// to a NONCLIENTMETRICS structure that receives the information. Set the cbSize member of this structure and the
+ /// uiParam parameter
+ /// to sizeof(NONCLIENTMETRICS).
+ ///
+ SPI_GETNONCLIENTMETRICS = 0x0029,
+
+ ///
+ /// Sets the metrics associated with the nonclient area of nonminimized windows. The pvParam parameter must point
+ /// to a NONCLIENTMETRICS structure that contains the new parameters. Set the cbSize member of this structure
+ /// and the uiParam parameter to sizeof(NONCLIENTMETRICS). Also, the lfHeight member of the LOGFONT structure must be a
+ /// negative value.
+ ///
+ SPI_SETNONCLIENTMETRICS = 0x002A,
+
+ ///
+ /// Retrieves the metrics associated with minimized windows. The pvParam parameter must point to a MINIMIZEDMETRICS
+ /// structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(MINIMIZEDMETRICS).
+ ///
+ SPI_GETMINIMIZEDMETRICS = 0x002B,
+
+ ///
+ /// Sets the metrics associated with minimized windows. The pvParam parameter must point to a MINIMIZEDMETRICS
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(MINIMIZEDMETRICS).
+ ///
+ SPI_SETMINIMIZEDMETRICS = 0x002C,
+
+ ///
+ /// Retrieves the metrics associated with icons. The pvParam parameter must point to an ICONMETRICS structure that
+ /// receives
+ /// the information. Set the cbSize member of this structure and the uiParam parameter to sizeof(ICONMETRICS).
+ ///
+ SPI_GETICONMETRICS = 0x002D,
+
+ ///
+ /// Sets the metrics associated with icons. The pvParam parameter must point to an ICONMETRICS structure that contains
+ /// the new parameters. Set the cbSize member of this structure and the uiParam parameter to sizeof(ICONMETRICS).
+ ///
+ SPI_SETICONMETRICS = 0x002E,
+
+ ///
+ /// Sets the size of the work area. The work area is the portion of the screen not obscured by the system taskbar
+ /// or by application desktop toolbars. The pvParam parameter is a pointer to a RECT structure that specifies the new
+ /// work area rectangle,
+ /// expressed in virtual screen coordinates. In a system with multiple display monitors, the function sets the work
+ /// area
+ /// of the monitor that contains the specified rectangle.
+ ///
+ SPI_SETWORKAREA = 0x002F,
+
+ ///
+ /// Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not
+ /// obscured
+ /// by the system taskbar or by application desktop toolbars. The pvParam parameter must point to a RECT structure that
+ /// receives
+ /// the coordinates of the work area, expressed in virtual screen coordinates.
+ /// To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function.
+ ///
+ SPI_GETWORKAREA = 0x0030,
+
+ ///
+ /// Windows Me/98/95: Pen windows is being loaded or unloaded. The uiParam parameter is TRUE when loading and FALSE
+ /// when unloading pen windows. The pvParam parameter is null.
+ ///
+ SPI_SETPENWINDOWS = 0x0031,
+
+ ///
+ /// Retrieves information about the HighContrast accessibility feature. The pvParam parameter must point to a
+ /// HIGHCONTRAST structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(HIGHCONTRAST).
+ /// For a general discussion, see remarks.
+ /// Windows NT: This value is not supported.
+ ///
+ ///
+ /// There is a difference between the High Contrast color scheme and the High Contrast Mode. The High Contrast color
+ /// scheme changes
+ /// the system colors to colors that have obvious contrast; you switch to this color scheme by using the Display
+ /// Options in the control panel.
+ /// The High Contrast Mode, which uses SPI_GETHIGHCONTRAST and SPI_SETHIGHCONTRAST, advises applications to modify
+ /// their appearance
+ /// for visually-impaired users. It involves such things as audible warning to users and customized color scheme
+ /// (using the Accessibility Options in the control panel). For more information, see HIGHCONTRAST on MSDN.
+ /// For more information on general accessibility features, see Accessibility on MSDN.
+ ///
+ SPI_GETHIGHCONTRAST = 0x0042,
+
+ ///
+ /// Sets the parameters of the HighContrast accessibility feature. The pvParam parameter must point to a HIGHCONTRAST
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(HIGHCONTRAST).
+ /// Windows NT: This value is not supported.
+ ///
+ SPI_SETHIGHCONTRAST = 0x0043,
+
+ ///
+ /// Determines whether the user relies on the keyboard instead of the mouse, and wants applications to display keyboard
+ /// interfaces
+ /// that would otherwise be hidden. The pvParam parameter must point to a BOOL variable that receives TRUE
+ /// if the user relies on the keyboard; or FALSE otherwise.
+ /// Windows NT: This value is not supported.
+ ///
+ SPI_GETKEYBOARDPREF = 0x0044,
+
+ ///
+ /// Sets the keyboard preference. The uiParam parameter specifies TRUE if the user relies on the keyboard instead of
+ /// the mouse,
+ /// and wants applications to display keyboard interfaces that would otherwise be hidden; uiParam is FALSE otherwise.
+ /// Windows NT: This value is not supported.
+ ///
+ SPI_SETKEYBOARDPREF = 0x0045,
+
+ ///
+ /// Determines whether a screen reviewer utility is running. A screen reviewer utility directs textual information to
+ /// an output device,
+ /// such as a speech synthesizer or Braille display. When this flag is set, an application should provide textual
+ /// information
+ /// in situations where it would otherwise present the information graphically.
+ /// The pvParam parameter is a pointer to a BOOL variable that receives TRUE if a screen reviewer utility is running,
+ /// or FALSE otherwise.
+ /// Windows NT: This value is not supported.
+ ///
+ SPI_GETSCREENREADER = 0x0046,
+
+ ///
+ /// Determines whether a screen review utility is running. The uiParam parameter specifies TRUE for on, or FALSE for
+ /// off.
+ /// Windows NT: This value is not supported.
+ ///
+ SPI_SETSCREENREADER = 0x0047,
+
+ ///
+ /// Retrieves the animation effects associated with user actions. The pvParam parameter must point to an ANIMATIONINFO
+ /// structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(ANIMATIONINFO).
+ ///
+ SPI_GETANIMATION = 0x0048,
+
+ ///
+ /// Sets the animation effects associated with user actions. The pvParam parameter must point to an ANIMATIONINFO
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(ANIMATIONINFO).
+ ///
+ SPI_SETANIMATION = 0x0049,
+
+ ///
+ /// Determines whether the font smoothing feature is enabled. This feature uses font antialiasing to make font curves
+ /// appear smoother
+ /// by painting pixels at different gray levels.
+ /// The pvParam parameter must point to a BOOL variable that receives TRUE if the feature is enabled, or FALSE if it is
+ /// not.
+ /// Windows 95: This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.
+ ///
+ SPI_GETFONTSMOOTHING = 0x004A,
+
+ ///
+ /// Enables or disables the font smoothing feature, which uses font antialiasing to make font curves appear smoother
+ /// by painting pixels at different gray levels.
+ /// To enable the feature, set the uiParam parameter to TRUE. To disable the feature, set uiParam to FALSE.
+ /// Windows 95: This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.
+ ///
+ SPI_SETFONTSMOOTHING = 0x004B,
+
+ ///
+ /// Sets the width, in pixels, of the rectangle used to detect the start of a drag operation. Set uiParam to the new
+ /// value.
+ /// To retrieve the drag width, call GetSystemMetrics with the SM_CXDRAG flag.
+ ///
+ SPI_SETDRAGWIDTH = 0x004C,
+
+ ///
+ /// Sets the height, in pixels, of the rectangle used to detect the start of a drag operation. Set uiParam to the new
+ /// value.
+ /// To retrieve the drag height, call GetSystemMetrics with the SM_CYDRAG flag.
+ ///
+ SPI_SETDRAGHEIGHT = 0x004D,
+
+ ///
+ /// Used internally; applications should not use this value.
+ ///
+ SPI_SETHANDHELD = 0x004E,
+
+ ///
+ /// Retrieves the time-out value for the low-power phase of screen saving. The pvParam parameter must point to an
+ /// integer variable
+ /// that receives the value. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_GETLOWPOWERTIMEOUT = 0x004F,
+
+ ///
+ /// Retrieves the time-out value for the power-off phase of screen saving. The pvParam parameter must point to an
+ /// integer variable
+ /// that receives the value. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_GETPOWEROFFTIMEOUT = 0x0050,
+
+ ///
+ /// Sets the time-out value, in seconds, for the low-power phase of screen saving. The uiParam parameter specifies the
+ /// new value.
+ /// The pvParam parameter must be null. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_SETLOWPOWERTIMEOUT = 0x0051,
+
+ ///
+ /// Sets the time-out value, in seconds, for the power-off phase of screen saving. The uiParam parameter specifies the
+ /// new value.
+ /// The pvParam parameter must be null. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_SETPOWEROFFTIMEOUT = 0x0052,
+
+ ///
+ /// Determines whether the low-power phase of screen saving is enabled. The pvParam parameter must point to a BOOL
+ /// variable
+ /// that receives TRUE if enabled, or FALSE if disabled. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_GETLOWPOWERACTIVE = 0x0053,
+
+ ///
+ /// Determines whether the power-off phase of screen saving is enabled. The pvParam parameter must point to a BOOL
+ /// variable
+ /// that receives TRUE if enabled, or FALSE if disabled. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_GETPOWEROFFACTIVE = 0x0054,
+
+ ///
+ /// Activates or deactivates the low-power phase of screen saving. Set uiParam to 1 to activate, or zero to deactivate.
+ /// The pvParam parameter must be null. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_SETLOWPOWERACTIVE = 0x0055,
+
+ ///
+ /// Activates or deactivates the power-off phase of screen saving. Set uiParam to 1 to activate, or zero to deactivate.
+ /// The pvParam parameter must be null. This flag is supported for 32-bit applications only.
+ /// Windows NT, Windows Me/98: This flag is supported for 16-bit and 32-bit applications.
+ /// Windows 95: This flag is supported for 16-bit applications only.
+ ///
+ SPI_SETPOWEROFFACTIVE = 0x0056,
+
+ ///
+ /// Reloads the system cursors. Set the uiParam parameter to zero and the pvParam parameter to null.
+ ///
+ SPI_SETCURSORS = 0x0057,
+
+ ///
+ /// Reloads the system icons. Set the uiParam parameter to zero and the pvParam parameter to null.
+ ///
+ SPI_SETICONS = 0x0058,
+
+ ///
+ /// Retrieves the input locale identifier for the system default input language. The pvParam parameter must point
+ /// to an HKL variable that receives this value. For more information, see Languages, Locales, and Keyboard Layouts on
+ /// MSDN.
+ ///
+ SPI_GETDEFAULTINPUTLANG = 0x0059,
+
+ ///
+ /// Sets the default input language for the system shell and applications. The specified language must be displayable
+ /// using the current system character set. The pvParam parameter must point to an HKL variable that contains
+ /// the input locale identifier for the default language. For more information, see Languages, Locales, and Keyboard
+ /// Layouts on MSDN.
+ ///
+ SPI_SETDEFAULTINPUTLANG = 0x005A,
+
+ ///
+ /// Sets the hot key set for switching between input languages. The uiParam and pvParam parameters are not used.
+ /// The value sets the shortcut keys in the keyboard property sheets by reading the registry again. The registry must
+ /// be set before this flag is used. the path in the registry is \HKEY_CURRENT_USER\keyboard layout\toggle. Valid
+ /// values are "1" = ALT+SHIFT, "2" = CTRL+SHIFT, and "3" = none.
+ ///
+ SPI_SETLANGTOGGLE = 0x005B,
+
+ ///
+ /// Windows 95: Determines whether the Windows extension, Windows Plus!, is installed. Set the uiParam parameter to 1.
+ /// The pvParam parameter is not used. The function returns TRUE if the extension is installed, or FALSE if it is not.
+ ///
+ SPI_GETWINDOWSEXTENSION = 0x005C,
+
+ ///
+ /// Enables or disables the Mouse Trails feature, which improves the visibility of mouse cursor movements by briefly
+ /// showing
+ /// a trail of cursors and quickly erasing them.
+ /// To disable the feature, set the uiParam parameter to zero or 1. To enable the feature, set uiParam to a value
+ /// greater than 1
+ /// to indicate the number of cursors drawn in the trail.
+ /// Windows 2000/NT: This value is not supported.
+ ///
+ SPI_SETMOUSETRAILS = 0x005D,
+
+ ///
+ /// Determines whether the Mouse Trails feature is enabled. This feature improves the visibility of mouse cursor
+ /// movements
+ /// by briefly showing a trail of cursors and quickly erasing them.
+ /// The pvParam parameter must point to an integer variable that receives a value. If the value is zero or 1, the
+ /// feature is disabled.
+ /// If the value is greater than 1, the feature is enabled and the value indicates the number of cursors drawn in the
+ /// trail.
+ /// The uiParam parameter is not used.
+ /// Windows 2000/NT: This value is not supported.
+ ///
+ SPI_GETMOUSETRAILS = 0x005E,
+
+ ///
+ /// Windows Me/98: Used internally; applications should not use this flag.
+ ///
+ SPI_SETSCREENSAVERRUNNING = 0x0061,
+
+ ///
+ /// Same as SPI_SETSCREENSAVERRUNNING.
+ ///
+ SPI_SCREENSAVERRUNNING = SPI_SETSCREENSAVERRUNNING,
+ //#endif /* WINVER >= 0x0400 */
+
+ ///
+ /// Retrieves information about the FilterKeys accessibility feature. The pvParam parameter must point to a FILTERKEYS
+ /// structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(FILTERKEYS).
+ ///
+ SPI_GETFILTERKEYS = 0x0032,
+
+ ///
+ /// Sets the parameters of the FilterKeys accessibility feature. The pvParam parameter must point to a FILTERKEYS
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(FILTERKEYS).
+ ///
+ SPI_SETFILTERKEYS = 0x0033,
+
+ ///
+ /// Retrieves information about the ToggleKeys accessibility feature. The pvParam parameter must point to a TOGGLEKEYS
+ /// structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(TOGGLEKEYS).
+ ///
+ SPI_GETTOGGLEKEYS = 0x0034,
+
+ ///
+ /// Sets the parameters of the ToggleKeys accessibility feature. The pvParam parameter must point to a TOGGLEKEYS
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(TOGGLEKEYS).
+ ///
+ SPI_SETTOGGLEKEYS = 0x0035,
+
+ ///
+ /// Retrieves information about the MouseKeys accessibility feature. The pvParam parameter must point to a MOUSEKEYS
+ /// structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(MOUSEKEYS).
+ ///
+ SPI_GETMOUSEKEYS = 0x0036,
+
+ ///
+ /// Sets the parameters of the MouseKeys accessibility feature. The pvParam parameter must point to a MOUSEKEYS
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(MOUSEKEYS).
+ ///
+ SPI_SETMOUSEKEYS = 0x0037,
+
+ ///
+ /// Determines whether the Show Sounds accessibility flag is on or off. If it is on, the user requires an application
+ /// to present information visually in situations where it would otherwise present the information only in audible
+ /// form.
+ /// The pvParam parameter must point to a BOOL variable that receives TRUE if the feature is on, or FALSE if it is off.
+ /// Using this value is equivalent to calling GetSystemMetrics (SM_SHOWSOUNDS). That is the recommended call.
+ ///
+ SPI_GETSHOWSOUNDS = 0x0038,
+
+ ///
+ /// Sets the parameters of the SoundSentry accessibility feature. The pvParam parameter must point to a SOUNDSENTRY
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(SOUNDSENTRY).
+ ///
+ SPI_SETSHOWSOUNDS = 0x0039,
+
+ ///
+ /// Retrieves information about the StickyKeys accessibility feature. The pvParam parameter must point to a STICKYKEYS
+ /// structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(STICKYKEYS).
+ ///
+ SPI_GETSTICKYKEYS = 0x003A,
+
+ ///
+ /// Sets the parameters of the StickyKeys accessibility feature. The pvParam parameter must point to a STICKYKEYS
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(STICKYKEYS).
+ ///
+ SPI_SETSTICKYKEYS = 0x003B,
+
+ ///
+ /// Retrieves information about the time-out period associated with the accessibility features. The pvParam parameter
+ /// must point
+ /// to an ACCESSTIMEOUT structure that receives the information. Set the cbSize member of this structure and the
+ /// uiParam parameter
+ /// to sizeof(ACCESSTIMEOUT).
+ ///
+ SPI_GETACCESSTIMEOUT = 0x003C,
+
+ ///
+ /// Sets the time-out period associated with the accessibility features. The pvParam parameter must point to an
+ /// ACCESSTIMEOUT
+ /// structure that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(ACCESSTIMEOUT).
+ ///
+ SPI_SETACCESSTIMEOUT = 0x003D,
+
+ ///
+ /// Windows Me/98/95: Retrieves information about the SerialKeys accessibility feature. The pvParam parameter must
+ /// point
+ /// to a SERIALKEYS structure that receives the information. Set the cbSize member of this structure and the uiParam
+ /// parameter
+ /// to sizeof(SERIALKEYS).
+ /// Windows Server 2003, Windows XP/2000/NT: Not supported. The user controls this feature through the control panel.
+ ///
+ SPI_GETSERIALKEYS = 0x003E,
+
+ ///
+ /// Windows Me/98/95: Sets the parameters of the SerialKeys accessibility feature. The pvParam parameter must point
+ /// to a SERIALKEYS structure that contains the new parameters. Set the cbSize member of this structure and the uiParam
+ /// parameter
+ /// to sizeof(SERIALKEYS).
+ /// Windows Server 2003, Windows XP/2000/NT: Not supported. The user controls this feature through the control panel.
+ ///
+ SPI_SETSERIALKEYS = 0x003F,
+ //#endif /* WINVER >= 0x0400 */
+
+ ///
+ /// Retrieves information about the SoundSentry accessibility feature. The pvParam parameter must point to a
+ /// SOUNDSENTRY structure
+ /// that receives the information. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(SOUNDSENTRY).
+ ///
+ SPI_GETSOUNDSENTRY = 0x0040,
+
+ ///
+ /// Sets the parameters of the SoundSentry accessibility feature. The pvParam parameter must point to a SOUNDSENTRY
+ /// structure
+ /// that contains the new parameters. Set the cbSize member of this structure and the uiParam parameter to
+ /// sizeof(SOUNDSENTRY).
+ ///
+ SPI_SETSOUNDSENTRY = 0x0041,
+
+ ///
+ /// Determines whether the snap-to-default-button feature is enabled. If enabled, the mouse cursor automatically moves
+ /// to the default button, such as OK or Apply, of a dialog box. The pvParam parameter must point to a BOOL variable
+ /// that receives TRUE if the feature is on, or FALSE if it is off.
+ /// Windows 95: Not supported.
+ ///
+ SPI_GETSNAPTODEFBUTTON = 0x005F,
+
+ ///
+ /// Enables or disables the snap-to-default-button feature. If enabled, the mouse cursor automatically moves to the
+ /// default button,
+ /// such as OK or Apply, of a dialog box. Set the uiParam parameter to TRUE to enable the feature, or FALSE to disable
+ /// it.
+ /// Applications should use the ShowWindow function when displaying a dialog box so the dialog manager can position the
+ /// mouse cursor.
+ /// Windows 95: Not supported.
+ ///
+ SPI_SETSNAPTODEFBUTTON = 0x0060,
+
+ ///
+ /// Retrieves the width, in pixels, of the rectangle within which the mouse pointer has to stay for TrackMouseEvent
+ /// to generate a WM_MOUSEHOVER message. The pvParam parameter must point to a UINT variable that receives the width.
+ /// Windows 95: Not supported.
+ ///
+ SPI_GETMOUSEHOVERWIDTH = 0x0062,
+
+ ///
+ /// Retrieves the width, in pixels, of the rectangle within which the mouse pointer has to stay for TrackMouseEvent
+ /// to generate a WM_MOUSEHOVER message. The pvParam parameter must point to a UINT variable that receives the width.
+ /// Windows 95: Not supported.
+ ///
+ SPI_SETMOUSEHOVERWIDTH = 0x0063,
+
+ ///
+ /// Retrieves the height, in pixels, of the rectangle within which the mouse pointer has to stay for TrackMouseEvent
+ /// to generate a WM_MOUSEHOVER message. The pvParam parameter must point to a UINT variable that receives the height.
+ /// Windows 95: Not supported.
+ ///
+ SPI_GETMOUSEHOVERHEIGHT = 0x0064,
+
+ ///
+ /// Sets the height, in pixels, of the rectangle within which the mouse pointer has to stay for TrackMouseEvent
+ /// to generate a WM_MOUSEHOVER message. Set the uiParam parameter to the new height.
+ /// Windows 95: Not supported.
+ ///
+ SPI_SETMOUSEHOVERHEIGHT = 0x0065,
+
+ ///
+ /// Retrieves the time, in milliseconds, that the mouse pointer has to stay in the hover rectangle for TrackMouseEvent
+ /// to generate a WM_MOUSEHOVER message. The pvParam parameter must point to a UINT variable that receives the time.
+ /// Windows 95: Not supported.
+ ///
+ SPI_GETMOUSEHOVERTIME = 0x0066,
+
+ ///
+ /// Sets the time, in milliseconds, that the mouse pointer has to stay in the hover rectangle for TrackMouseEvent
+ /// to generate a WM_MOUSEHOVER message. This is used only if you pass HOVER_DEFAULT in the dwHoverTime parameter in
+ /// the call to TrackMouseEvent. Set the uiParam parameter to the new time.
+ /// Windows 95: Not supported.
+ ///
+ SPI_SETMOUSEHOVERTIME = 0x0067,
+
+ ///
+ /// Retrieves the number of lines to scroll when the mouse wheel is rotated. The pvParam parameter must point
+ /// to a UINT variable that receives the number of lines. The default value is 3.
+ /// Windows 95: Not supported.
+ ///
+ SPI_GETWHEELSCROLLLINES = 0x0068,
+
+ ///
+ /// Sets the number of lines to scroll when the mouse wheel is rotated. The number of lines is set from the uiParam
+ /// parameter.
+ /// The number of lines is the suggested number of lines to scroll when the mouse wheel is rolled without using
+ /// modifier keys.
+ /// If the number is 0, then no scrolling should occur. If the number of lines to scroll is greater than the number of
+ /// lines viewable,
+ /// and in particular if it is WHEEL_PAGESCROLL (#defined as UINT_MAX), the scroll operation should be interpreted
+ /// as clicking once in the page down or page up regions of the scroll bar.
+ /// Windows 95: Not supported.
+ ///
+ SPI_SETWHEELSCROLLLINES = 0x0069,
+
+ ///
+ /// Retrieves the time, in milliseconds, that the system waits before displaying a shortcut menu when the mouse cursor
+ /// is
+ /// over a submenu item. The pvParam parameter must point to a DWORD variable that receives the time of the delay.
+ /// Windows 95: Not supported.
+ ///
+ SPI_GETMENUSHOWDELAY = 0x006A,
+
+ ///
+ /// Sets uiParam to the time, in milliseconds, that the system waits before displaying a shortcut menu when the mouse
+ /// cursor is
+ /// over a submenu item.
+ /// Windows 95: Not supported.
+ ///
+ SPI_SETMENUSHOWDELAY = 0x006B,
+
+ ///
+ /// Determines whether the IME status window is visible (on a per-user basis). The pvParam parameter must point to a
+ /// BOOL variable
+ /// that receives TRUE if the status window is visible, or FALSE if it is not.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETSHOWIMEUI = 0x006E,
+
+ ///
+ /// Sets whether the IME status window is visible or not on a per-user basis. The uiParam parameter specifies TRUE for
+ /// on or FALSE for off.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETSHOWIMEUI = 0x006F,
+
+ ///
+ /// Retrieves the current mouse speed. The mouse speed determines how far the pointer will move based on the distance
+ /// the mouse moves.
+ /// The pvParam parameter must point to an integer that receives a value which ranges between 1 (slowest) and 20
+ /// (fastest).
+ /// A value of 10 is the default. The value can be set by an end user using the mouse control panel application or
+ /// by an application using SPI_SETMOUSESPEED.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETMOUSESPEED = 0x0070,
+
+ ///
+ /// Sets the current mouse speed. The pvParam parameter is an integer between 1 (slowest) and 20 (fastest). A value of
+ /// 10 is the default.
+ /// This value is typically set using the mouse control panel application.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETMOUSESPEED = 0x0071,
+
+ ///
+ /// Determines whether a screen saver is currently running on the window station of the calling process.
+ /// The pvParam parameter must point to a BOOL variable that receives TRUE if a screen saver is currently running, or
+ /// FALSE otherwise.
+ /// Note that only the interactive window station, "WinSta0", can have a screen saver running.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETSCREENSAVERRUNNING = 0x0072,
+
+ ///
+ /// Retrieves the full path of the bitmap file for the desktop wallpaper. The pvParam parameter must point to a buffer
+ /// that receives a null-terminated path string. Set the uiParam parameter to the size, in characters, of the pvParam
+ /// buffer. The returned string will not exceed MAX_PATH characters. If there is no desktop wallpaper, the returned
+ /// string is empty.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETDESKWALLPAPER = 0x0073,
+
+ ///
+ /// Determines whether active window tracking (activating the window the mouse is on) is on or off. The pvParam
+ /// parameter must point
+ /// to a BOOL variable that receives TRUE for on, or FALSE for off.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETACTIVEWINDOWTRACKING = 0x1000,
+
+ ///
+ /// Sets active window tracking (activating the window the mouse is on) either on or off. Set pvParam to TRUE for on or
+ /// FALSE for off.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETACTIVEWINDOWTRACKING = 0x1001,
+
+ ///
+ /// Determines whether the menu animation feature is enabled. This master switch must be on to enable menu animation
+ /// effects.
+ /// The pvParam parameter must point to a BOOL variable that receives TRUE if animation is enabled and FALSE if it is
+ /// disabled.
+ /// If animation is enabled, SPI_GETMENUFADE indicates whether menus use fade or slide animation.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETMENUANIMATION = 0x1002,
+
+ ///
+ /// Enables or disables menu animation. This master switch must be on for any menu animation to occur.
+ /// The pvParam parameter is a BOOL variable; set pvParam to TRUE to enable animation and FALSE to disable animation.
+ /// If animation is enabled, SPI_GETMENUFADE indicates whether menus use fade or slide animation.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETMENUANIMATION = 0x1003,
+
+ ///
+ /// Determines whether the slide-open effect for combo boxes is enabled. The pvParam parameter must point to a BOOL
+ /// variable
+ /// that receives TRUE for enabled, or FALSE for disabled.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETCOMBOBOXANIMATION = 0x1004,
+
+ ///
+ /// Enables or disables the slide-open effect for combo boxes. Set the pvParam parameter to TRUE to enable the gradient
+ /// effect,
+ /// or FALSE to disable it.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETCOMBOBOXANIMATION = 0x1005,
+
+ ///
+ /// Determines whether the smooth-scrolling effect for list boxes is enabled. The pvParam parameter must point to a
+ /// BOOL variable
+ /// that receives TRUE for enabled, or FALSE for disabled.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETLISTBOXSMOOTHSCROLLING = 0x1006,
+
+ ///
+ /// Enables or disables the smooth-scrolling effect for list boxes. Set the pvParam parameter to TRUE to enable the
+ /// smooth-scrolling effect,
+ /// or FALSE to disable it.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETLISTBOXSMOOTHSCROLLING = 0x1007,
+
+ ///
+ /// Determines whether the gradient effect for window title bars is enabled. The pvParam parameter must point to a BOOL
+ /// variable
+ /// that receives TRUE for enabled, or FALSE for disabled. For more information about the gradient effect, see the
+ /// GetSysColor function.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETGRADIENTCAPTIONS = 0x1008,
+
+ ///
+ /// Enables or disables the gradient effect for window title bars. Set the pvParam parameter to TRUE to enable it, or
+ /// FALSE to disable it.
+ /// The gradient effect is possible only if the system has a color depth of more than 256 colors. For more information
+ /// about
+ /// the gradient effect, see the GetSysColor function.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETGRADIENTCAPTIONS = 0x1009,
+
+ ///
+ /// Determines whether menu access keys are always underlined. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// if menu access keys are always underlined, and FALSE if they are underlined only when the menu is activated by the
+ /// keyboard.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETKEYBOARDCUES = 0x100A,
+
+ ///
+ /// Sets the underlining of menu access key letters. The pvParam parameter is a BOOL variable. Set pvParam to TRUE to
+ /// always underline menu
+ /// access keys, or FALSE to underline menu access keys only when the menu is activated from the keyboard.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETKEYBOARDCUES = 0x100B,
+
+ ///
+ /// Same as SPI_GETKEYBOARDCUES.
+ ///
+ SPI_GETMENUUNDERLINES = SPI_GETKEYBOARDCUES,
+
+ ///
+ /// Same as SPI_SETKEYBOARDCUES.
+ ///
+ SPI_SETMENUUNDERLINES = SPI_SETKEYBOARDCUES,
+
+ ///
+ /// Determines whether windows activated through active window tracking will be brought to the top. The pvParam
+ /// parameter must point
+ /// to a BOOL variable that receives TRUE for on, or FALSE for off.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETACTIVEWNDTRKZORDER = 0x100C,
+
+ ///
+ /// Determines whether or not windows activated through active window tracking should be brought to the top. Set
+ /// pvParam to TRUE
+ /// for on or FALSE for off.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETACTIVEWNDTRKZORDER = 0x100D,
+
+ ///
+ /// Determines whether hot tracking of user-interface elements, such as menu names on menu bars, is enabled. The
+ /// pvParam parameter
+ /// must point to a BOOL variable that receives TRUE for enabled, or FALSE for disabled.
+ /// Hot tracking means that when the cursor moves over an item, it is highlighted but not selected. You can query this
+ /// value to decide
+ /// whether to use hot tracking in the user interface of your application.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETHOTTRACKING = 0x100E,
+
+ ///
+ /// Enables or disables hot tracking of user-interface elements such as menu names on menu bars. Set the pvParam
+ /// parameter to TRUE
+ /// to enable it, or FALSE to disable it.
+ /// Hot-tracking means that when the cursor moves over an item, it is highlighted but not selected.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETHOTTRACKING = 0x100F,
+
+ ///
+ /// Determines whether menu fade animation is enabled. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// when fade animation is enabled and FALSE when it is disabled. If fade animation is disabled, menus use slide
+ /// animation.
+ /// This flag is ignored unless menu animation is enabled, which you can do using the SPI_SETMENUANIMATION flag.
+ /// For more information, see AnimateWindow.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETMENUFADE = 0x1012,
+
+ ///
+ /// Enables or disables menu fade animation. Set pvParam to TRUE to enable the menu fade effect or FALSE to disable it.
+ /// If fade animation is disabled, menus use slide animation. he The menu fade effect is possible only if the system
+ /// has a color depth of more than 256 colors. This flag is ignored unless SPI_MENUANIMATION is also set. For more
+ /// information,
+ /// see AnimateWindow.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETMENUFADE = 0x1013,
+
+ ///
+ /// Determines whether the selection fade effect is enabled. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// if enabled or FALSE if disabled.
+ /// The selection fade effect causes the menu item selected by the user to remain on the screen briefly while fading
+ /// out
+ /// after the menu is dismissed.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETSELECTIONFADE = 0x1014,
+
+ ///
+ /// Set pvParam to TRUE to enable the selection fade effect or FALSE to disable it.
+ /// The selection fade effect causes the menu item selected by the user to remain on the screen briefly while fading
+ /// out
+ /// after the menu is dismissed. The selection fade effect is possible only if the system has a color depth of more
+ /// than 256 colors.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETSELECTIONFADE = 0x1015,
+
+ ///
+ /// Determines whether ToolTip animation is enabled. The pvParam parameter must point to a BOOL variable that receives
+ /// TRUE
+ /// if enabled or FALSE if disabled. If ToolTip animation is enabled, SPI_GETTOOLTIPFADE indicates whether ToolTips use
+ /// fade or slide animation.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETTOOLTIPANIMATION = 0x1016,
+
+ ///
+ /// Set pvParam to TRUE to enable ToolTip animation or FALSE to disable it. If enabled, you can use SPI_SETTOOLTIPFADE
+ /// to specify fade or slide animation.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETTOOLTIPANIMATION = 0x1017,
+
+ ///
+ /// If SPI_SETTOOLTIPANIMATION is enabled, SPI_GETTOOLTIPFADE indicates whether ToolTip animation uses a fade effect or
+ /// a slide effect.
+ /// The pvParam parameter must point to a BOOL variable that receives TRUE for fade animation or FALSE for slide
+ /// animation.
+ /// For more information on slide and fade effects, see AnimateWindow.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETTOOLTIPFADE = 0x1018,
+
+ ///
+ /// If the SPI_SETTOOLTIPANIMATION flag is enabled, use SPI_SETTOOLTIPFADE to indicate whether ToolTip animation uses a
+ /// fade effect
+ /// or a slide effect. Set pvParam to TRUE for fade animation or FALSE for slide animation. The tooltip fade effect is
+ /// possible only
+ /// if the system has a color depth of more than 256 colors. For more information on the slide and fade effects,
+ /// see the AnimateWindow function.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETTOOLTIPFADE = 0x1019,
+
+ ///
+ /// Determines whether the cursor has a shadow around it. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// if the shadow is enabled, FALSE if it is disabled. This effect appears only if the system has a color depth of more
+ /// than 256 colors.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETCURSORSHADOW = 0x101A,
+
+ ///
+ /// Enables or disables a shadow around the cursor. The pvParam parameter is a BOOL variable. Set pvParam to TRUE to
+ /// enable the shadow
+ /// or FALSE to disable the shadow. This effect appears only if the system has a color depth of more than 256 colors.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETCURSORSHADOW = 0x101B,
+
+ ///
+ /// Retrieves the state of the Mouse Sonar feature. The pvParam parameter must point to a BOOL variable that receives
+ /// TRUE
+ /// if enabled or FALSE otherwise. For more information, see About Mouse Input on MSDN.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_GETMOUSESONAR = 0x101C,
+
+ ///
+ /// Turns the Sonar accessibility feature on or off. This feature briefly shows several concentric circles around the
+ /// mouse pointer when the user presses and releases the CTRL key. The pvParam parameter specifies TRUE for on and FALSE for off.
+ /// The default is off.
+ /// For more information, see About Mouse Input.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_SETMOUSESONAR = 0x101D,
+
+ ///
+ /// Retrieves the state of the Mouse ClickLock feature. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// if enabled, or FALSE otherwise. For more information, see About Mouse Input.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_GETMOUSECLICKLOCK = 0x101E,
+
+ ///
+ /// Turns the Mouse ClickLock accessibility feature on or off. This feature temporarily locks down the primary mouse
+ /// button
+ /// when that button is clicked and held down for the time specified by SPI_SETMOUSECLICKLOCKTIME. The uiParam
+ /// parameter specifies
+ /// TRUE for on,
+ /// or FALSE for off. The default is off. For more information, see Remarks and About Mouse Input on MSDN.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_SETMOUSECLICKLOCK = 0x101F,
+
+ ///
+ /// Retrieves the state of the Mouse Vanish feature. The pvParam parameter must point to a BOOL variable that receives
+ /// TRUE
+ /// if enabled or FALSE otherwise. For more information, see About Mouse Input on MSDN.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_GETMOUSEVANISH = 0x1020,
+
+ ///
+ /// Turns the Vanish feature on or off. This feature hides the mouse pointer when the user types; the pointer reappears
+ /// when the user moves the mouse. The pvParam parameter specifies TRUE for on and FALSE for off. The default is off.
+ /// For more information, see About Mouse Input on MSDN.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_SETMOUSEVANISH = 0x1021,
+
+ ///
+ /// Determines whether native User menus have flat menu appearance. The pvParam parameter must point to a BOOL variable
+ /// that returns TRUE if the flat menu appearance is set, or FALSE otherwise.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETFLATMENU = 0x1022,
+
+ ///
+ /// Enables or disables flat menu appearance for native User menus. Set pvParam to TRUE to enable flat menu appearance
+ /// or FALSE to disable it.
+ /// When enabled, the menu bar uses COLOR_MENUBAR for the menubar background, COLOR_MENU for the menu-popup background,
+ /// COLOR_MENUHILIGHT
+ /// for the fill of the current menu selection, and COLOR_HILIGHT for the outline of the current menu selection.
+ /// If disabled, menus are drawn using the same metrics and colors as in Windows 2000 and earlier.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETFLATMENU = 0x1023,
+
+ ///
+ /// Determines whether the drop shadow effect is enabled. The pvParam parameter must point to a BOOL variable that
+ /// returns TRUE
+ /// if enabled or FALSE if disabled.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETDROPSHADOW = 0x1024,
+
+ ///
+ /// Enables or disables the drop shadow effect. Set pvParam to TRUE to enable the drop shadow effect or FALSE to
+ /// disable it.
+ /// You must also have CS_DROPSHADOW in the window class style.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETDROPSHADOW = 0x1025,
+
+ ///
+ /// Retrieves a BOOL indicating whether an application can reset the screensaver's timer by calling the SendInput
+ /// function
+ /// to simulate keyboard or mouse input. The pvParam parameter must point to a BOOL variable that receives TRUE
+ /// if the simulated input will be blocked, or FALSE otherwise.
+ ///
+ SPI_GETBLOCKSENDINPUTRESETS = 0x1026,
+
+ ///
+ /// Determines whether an application can reset the screensaver's timer by calling the SendInput function to simulate
+ /// keyboard
+ /// or mouse input. The uiParam parameter specifies TRUE if the screensaver will not be deactivated by simulated input,
+ /// or FALSE if the screensaver will be deactivated by simulated input.
+ ///
+ SPI_SETBLOCKSENDINPUTRESETS = 0x1027,
+ //#endif /* _WIN32_WINNT >= 0x0501 */
+
+ ///
+ /// Determines whether UI effects are enabled or disabled. The pvParam parameter must point to a BOOL variable that
+ /// receives TRUE
+ /// if all UI effects are enabled, or FALSE if they are disabled.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETUIEFFECTS = 0x103E,
+
+ ///
+ /// Enables or disables UI effects. Set the pvParam parameter to TRUE to enable all UI effects or FALSE to disable all
+ /// UI effects.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETUIEFFECTS = 0x103F,
+
+ ///
+ /// Retrieves the amount of time following user input, in milliseconds, during which the system will not allow
+ /// applications
+ /// to force themselves into the foreground. The pvParam parameter must point to a DWORD variable that receives the
+ /// time.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000,
+
+ ///
+ /// Sets the amount of time following user input, in milliseconds, during which the system does not allow applications
+ /// to force themselves into the foreground. Set pvParam to the new timeout value.
+ /// The calling thread must be able to change the foreground window, otherwise the call fails.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001,
+
+ ///
+ /// Retrieves the active window tracking delay, in milliseconds. The pvParam parameter must point to a DWORD variable
+ /// that receives the time.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETACTIVEWNDTRKTIMEOUT = 0x2002,
+
+ ///
+ /// Sets the active window tracking delay. Set pvParam to the number of milliseconds to delay before activating the
+ /// window
+ /// under the mouse pointer.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETACTIVEWNDTRKTIMEOUT = 0x2003,
+
+ ///
+ /// Retrieves the number of times SetForegroundWindow will flash the taskbar button when rejecting a foreground switch
+ /// request.
+ /// The pvParam parameter must point to a DWORD variable that receives the value.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_GETFOREGROUNDFLASHCOUNT = 0x2004,
+
+ ///
+ /// Sets the number of times SetForegroundWindow will flash the taskbar button when rejecting a foreground switch
+ /// request.
+ /// Set pvParam to the number of times to flash.
+ /// Windows NT, Windows 95: This value is not supported.
+ ///
+ SPI_SETFOREGROUNDFLASHCOUNT = 0x2005,
+
+ ///
+ /// Retrieves the caret width in edit controls, in pixels. The pvParam parameter must point to a DWORD that receives
+ /// this value.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETCARETWIDTH = 0x2006,
+
+ ///
+ /// Sets the caret width in edit controls. Set pvParam to the desired width, in pixels. The default and minimum value
+ /// is 1.
+ /// Windows NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETCARETWIDTH = 0x2007,
+
+ ///
+ /// Retrieves the time delay before the primary mouse button is locked. The pvParam parameter must point to DWORD that
+ /// receives
+ /// the time delay. This is only enabled if SPI_SETMOUSECLICKLOCK is set to TRUE. For more information, see About Mouse
+ /// Input on MSDN.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_GETMOUSECLICKLOCKTIME = 0x2008,
+
+ ///
+ /// Turns the Mouse ClickLock accessibility feature on or off. This feature temporarily locks down the primary mouse
+ /// button
+ /// when that button is clicked and held down for the time specified by SPI_SETMOUSECLICKLOCKTIME. The uiParam
+ /// parameter
+ /// specifies TRUE for on, or FALSE for off. The default is off. For more information, see Remarks and About Mouse
+ /// Input on MSDN.
+ /// Windows 2000/NT, Windows 98/95: This value is not supported.
+ ///
+ SPI_SETMOUSECLICKLOCKTIME = 0x2009,
+
+ ///
+ /// Retrieves the type of font smoothing. The pvParam parameter must point to a UINT that receives the information.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETFONTSMOOTHINGTYPE = 0x200A,
+
+ ///
+ /// Sets the font smoothing type. The pvParam parameter points to a UINT that contains either FE_FONTSMOOTHINGSTANDARD,
+ /// if standard anti-aliasing is used, or FE_FONTSMOOTHINGCLEARTYPE, if ClearType is used. The default is
+ /// FE_FONTSMOOTHINGSTANDARD.
+ /// When using this option, the fWinIni parameter must be set to SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE; otherwise,
+ /// SystemParametersInfo fails.
+ ///
+ SPI_SETFONTSMOOTHINGTYPE = 0x200B,
+
+ ///
+ /// Retrieves a contrast value that is used in ClearType™ smoothing. The pvParam parameter must point to a UINT
+ /// that receives the information.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETFONTSMOOTHINGCONTRAST = 0x200C,
+
+ ///
+ /// Sets the contrast value used in ClearType smoothing. The pvParam parameter points to a UINT that holds the contrast
+ /// value.
+ /// Valid contrast values are from 1000 to 2200. The default value is 1400.
+ /// When using this option, the fWinIni parameter must be set to SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE; otherwise,
+ /// SystemParametersInfo fails.
+ /// SPI_SETFONTSMOOTHINGTYPE must also be set to FE_FONTSMOOTHINGCLEARTYPE.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETFONTSMOOTHINGCONTRAST = 0x200D,
+
+ ///
+ /// Retrieves the width, in pixels, of the left and right edges of the focus rectangle drawn with DrawFocusRect.
+ /// The pvParam parameter must point to a UINT.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETFOCUSBORDERWIDTH = 0x200E,
+
+ ///
+ /// Sets the height of the left and right edges of the focus rectangle drawn with DrawFocusRect to the value of the
+ /// pvParam parameter.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETFOCUSBORDERWIDTH = 0x200F,
+
+ ///
+ /// Retrieves the height, in pixels, of the top and bottom edges of the focus rectangle drawn with DrawFocusRect.
+ /// The pvParam parameter must point to a UINT.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_GETFOCUSBORDERHEIGHT = 0x2010,
+
+ ///
+ /// Sets the height of the top and bottom edges of the focus rectangle drawn with DrawFocusRect to the value of the
+ /// pvParam parameter.
+ /// Windows 2000/NT, Windows Me/98/95: This value is not supported.
+ ///
+ SPI_SETFOCUSBORDERHEIGHT = 0x2011,
+
+ ///
+ /// Not implemented.
+ ///
+ SPI_GETFONTSMOOTHINGORIENTATION = 0x2012,
+
+ ///
+ /// Not implemented.
+ ///
+ SPI_SETFONTSMOOTHINGORIENTATION = 0x2013
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/Enums/SystemParametersInfoBehaviors.cs b/GreenshotPlugin/Core/Enums/SystemParametersInfoBehaviors.cs
new file mode 100644
index 000000000..4b5872ae5
--- /dev/null
+++ b/GreenshotPlugin/Core/Enums/SystemParametersInfoBehaviors.cs
@@ -0,0 +1,28 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace GreenshotPlugin.Core.Enums
+{
+ ///
+ /// If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the
+ /// WM_SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change.
+ /// This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
+ /// or it can be one or more of the following values.
+ ///
+ public enum SystemParametersInfoBehaviors : uint
+ {
+ ///
+ /// Do nothing
+ ///
+ None = 0x00,
+
+ /// Writes the new system-wide parameter setting to the user profile.
+ UpdateIniFile = 0x01,
+
+ /// Broadcasts the WM_SETTINGCHANGE message after updating the user profile.
+ SendChange = 0x02,
+
+ /// Same as SPIF_SENDCHANGE.
+ SendWinIniChange = SendChange
+ }
+}
\ No newline at end of file
diff --git a/GreenshotWin10Plugin/Native/HResultExtensions.cs b/GreenshotPlugin/Core/HResultExtensions.cs
similarity index 95%
rename from GreenshotWin10Plugin/Native/HResultExtensions.cs
rename to GreenshotPlugin/Core/HResultExtensions.cs
index 55ec38073..bc0f8e4ba 100644
--- a/GreenshotWin10Plugin/Native/HResultExtensions.cs
+++ b/GreenshotPlugin/Core/HResultExtensions.cs
@@ -17,10 +17,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+using GreenshotPlugin.Core.Enums;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
-namespace GreenshotWin10Plugin.Native
+namespace GreenshotPlugin.Core
{
///
/// Extensions to handle the HResult
@@ -55,7 +56,7 @@ namespace GreenshotWin10Plugin.Native
/// HResult
public static void ThrowOnFailure(this HResult hResult)
{
- if (Failed(hResult))
+ if (hResult.Failed())
{
throw Marshal.GetExceptionForHR((int)hResult);
}
diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs
index 04d305d9d..a17f75d3d 100644
--- a/GreenshotPlugin/Core/ImageHelper.cs
+++ b/GreenshotPlugin/Core/ImageHelper.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -1203,7 +1203,7 @@ namespace GreenshotPlugin.Core {
public static Image Adjust(Image sourceImage, float brightness, float contrast, float gamma)
{
//create a blank bitmap the same size as original
- // If using 8bpp than the following exception comes: A Graphics object cannot be created from an image that has an indexed pixel format.
+ // If using 8bpp than the following exception comes: A Graphics object cannot be created from an image that has an indexed pixel format.
Bitmap newBitmap = CreateEmpty(sourceImage.Width, sourceImage.Height, PixelFormat.Format24bppRgb, Color.Empty, sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
using (ImageAttributes adjustAttributes = CreateAdjustAttributes(brightness, contrast, gamma))
{
@@ -1306,7 +1306,7 @@ namespace GreenshotPlugin.Core {
sourceRect.Intersect(bitmapRect);
}
- // If no pixelformat is supplied
+ // If no pixelformat is supplied
if (PixelFormat.DontCare == targetFormat || PixelFormat.Undefined == targetFormat)
{
if (SupportsPixelFormat(sourceImage.PixelFormat))
diff --git a/GreenshotPlugin/Core/OperatingSystemExtensions.cs b/GreenshotPlugin/Core/OperatingSystemExtensions.cs
deleted file mode 100644
index 3560576c6..000000000
--- a/GreenshotPlugin/Core/OperatingSystemExtensions.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub: https://github.com/greenshot
- *
- * This program 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 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-
-namespace GreenshotPlugin.Core
-{
- ///
- /// Extensions to help with querying the Operating System
- ///
- public static class OperatingSystemExtensions
- {
- ///
- /// Test if the current OS is Windows 10
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows 10
- public static bool IsWindows10(this OperatingSystem operatingSystem)
- {
- return operatingSystem.Version.Major == 10;
- }
-
- ///
- /// Test if the current OS is Windows 10 or later
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows 10 or later
- public static bool IsWindows10OrLater(this OperatingSystem operatingSystem)
- {
- return operatingSystem.Version.Major >= 10;
- }
-
- ///
- /// Test if the current OS is Windows 8(.1)
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows 8(.1)
- public static bool IsWindows8(this OperatingSystem operatingSystem)
- {
- return operatingSystem.Version.Major == 6 && operatingSystem.Version.Minor >= 2;
- }
-
- ///
- /// Test if the current OS is Windows 8 or later
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows 8 or later
- public static bool IsWindows8OrLater(this OperatingSystem operatingSystem)
- {
- return (operatingSystem.Version.Major == 6 && operatingSystem.Version.Minor >= 2) || operatingSystem.Version.Major > 6;
- }
-
- ///
- /// Test if the current OS is Windows 7 or later
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows 7 or later
- public static bool IsWindows7OrLater(this OperatingSystem operatingSystem)
- {
- return (operatingSystem.Version.Major == 6 && operatingSystem.Version.Minor >= 1) || operatingSystem.Version.Major > 6;
- }
-
- ///
- /// Test if the current OS is Windows Vista or later
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows Vista or later
- public static bool IsWindowsVistaOrLater(this OperatingSystem operatingSystem)
- {
- return operatingSystem.Version.Major >= 6;
- }
-
- ///
- /// Test if the current OS is Windows XP or later
- ///
- /// OperatingSystem from Environment.OSVersion
- /// true if we are running on Windows XP or later
- public static bool IsWindowsXpOrLater(this OperatingSystem operatingSystem)
- {
- // Windows 2000 is Major 5 minor 0
- return Environment.OSVersion.Version.Major > 5 || (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1);
- }
- }
-}
diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs
index fb3d3d66f..a24ed9629 100644
--- a/GreenshotPlugin/Core/WindowsHelper.cs
+++ b/GreenshotPlugin/Core/WindowsHelper.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -145,7 +145,7 @@ namespace GreenshotPlugin.Core {
private static readonly IList IgnoreHandles = new List();
private static readonly IList ExcludeProcessesFromFreeze = new List();
private static readonly IAppVisibility AppVisibility;
-
+
static WindowDetails() {
try
{
@@ -212,7 +212,7 @@ namespace GreenshotPlugin.Core {
public override int GetHashCode() {
return Handle.ToInt32();
}
-
+
public override bool Equals(object right) {
return Equals(right as WindowDetails);
}
@@ -226,11 +226,11 @@ namespace GreenshotPlugin.Core {
if (other is null) {
return false;
}
-
+
if (ReferenceEquals(this, other)) {
return true;
}
-
+
if (GetType() != other.GetType()){
return false;
}
@@ -377,7 +377,7 @@ namespace GreenshotPlugin.Core {
private static IEnumerable FindWindow(IList windows, string titlePattern, string classnamePattern) {
Regex titleRegexp = null;
Regex classnameRegexp = null;
-
+
if (titlePattern != null && titlePattern.Trim().Length > 0) {
titleRegexp = new Regex(titlePattern);
}
@@ -393,7 +393,7 @@ namespace GreenshotPlugin.Core {
}
}
}
-
+
///
/// Retrieve the child with matching classname
///
@@ -486,7 +486,7 @@ namespace GreenshotPlugin.Core {
public IEnumerable FindChildren(string titlePattern, string classnamePattern) {
return FindWindow(Children, titlePattern, classnamePattern);
}
-
+
///
/// Recursing helper method for the FindPath
///
@@ -620,7 +620,7 @@ namespace GreenshotPlugin.Core {
}
}
}
-
+
///
/// Gets/Sets whether the window is maximised or not.
///
@@ -650,14 +650,14 @@ namespace GreenshotPlugin.Core {
}
}
}
-
+
///
/// This doesn't work as good as is should, but does move the App out of the way...
///
public void HideApp() {
User32.ShowWindow(Handle, ShowWindowCommand.Hide);
}
-
+
///
/// Gets whether the window is visible.
///
@@ -697,7 +697,7 @@ namespace GreenshotPlugin.Core {
return User32.IsWindowVisible(Handle);
}
}
-
+
public bool HasParent {
get {
GetParent();
@@ -757,7 +757,7 @@ namespace GreenshotPlugin.Core {
_lastWindowRectangleRetrieveTime = now;
}
}
- if (gotFrameBounds && Environment.OSVersion.IsWindows10() && !Maximised)
+ if (gotFrameBounds && WindowsVersion.IsWindows10OrLater && !Maximised)
{
// Somehow DWM doesn't calculate it corectly, there is a 1 pixel border around the capture
// Remove this border, currently it's fixed but TODO: Make it depend on the OS?
@@ -775,7 +775,7 @@ namespace GreenshotPlugin.Core {
Log.WarnFormat("Couldn't retrieve the windows rectangle: {0}", Win32.GetMessage(error));
}
}
-
+
// Correction for maximized windows, only if it's not an app
if (!HasParent && !IsApp && Maximised) {
// Only if the border size can be retrieved
@@ -816,7 +816,7 @@ namespace GreenshotPlugin.Core {
return new Size(tmpRectangle.Right - tmpRectangle.Left, tmpRectangle.Bottom - tmpRectangle.Top);
}
}
-
+
///
/// Get the client rectangle, this is the part of the window inside the borders (drawable area)
///
@@ -841,7 +841,7 @@ namespace GreenshotPlugin.Core {
}
///
- /// Restores and Brings the window to the front,
+ /// Restores and Brings the window to the front,
/// assuming it is a visible application window.
///
public void Restore() {
@@ -969,7 +969,7 @@ namespace GreenshotPlugin.Core {
} else {
doesCaptureFit = true;
}
- } else if (!Environment.OSVersion.IsWindows8OrLater()) {
+ } else if (!WindowsVersion.IsWindows8OrLater) {
//GetClientRect(out windowRectangle);
GetBorderSize(out borderSize);
formLocation = new Point(windowRectangle.X - borderSize.Width, windowRectangle.Y - borderSize.Height);
@@ -986,7 +986,7 @@ namespace GreenshotPlugin.Core {
captureRectangle.Inflate(borderSize.Width, borderSize.Height);
} else {
// TODO: Also 8.x?
- if (Environment.OSVersion.IsWindows10())
+ if (WindowsVersion.IsWindows10OrLater)
{
captureRectangle.Inflate(Conf.Win10BorderCrop);
}
@@ -1017,7 +1017,7 @@ namespace GreenshotPlugin.Core {
// Intersect with screen
captureRectangle.Intersect(capture.ScreenBounds);
-
+
// Destination bitmap for the capture
Bitmap capturedBitmap = null;
bool frozen = false;
@@ -1064,7 +1064,7 @@ namespace GreenshotPlugin.Core {
Color colorizationColor = DWM.ColorizationColor;
// Modify by losing the transparency and increasing the intensity (as if the background color is white)
colorizationColor = Color.FromArgb(255, (colorizationColor.R + 255) >> 1, (colorizationColor.G + 255) >> 1, (colorizationColor.B + 255) >> 1);
- tempForm.BackColor = colorizationColor;
+ tempForm.BackColor = colorizationColor;
}
// Make sure everything is visible
tempForm.Refresh();
@@ -1079,7 +1079,7 @@ namespace GreenshotPlugin.Core {
}
if (capturedBitmap != null) {
// Not needed for Windows 8
- if (!Environment.OSVersion.IsWindows8OrLater()) {
+ if (!WindowsVersion.IsWindows8OrLater) {
// Only if the Inivalue is set, not maximized and it's not a tool window.
if (Conf.WindowCaptureRemoveCorners && !Maximised && (ExtendedWindowStyle & ExtendedWindowStyleFlags.WS_EX_TOOLWINDOW) == 0) {
// Remove corners
@@ -1099,7 +1099,7 @@ namespace GreenshotPlugin.Core {
UnfreezeWindow();
}
}
-
+
capture.Image = capturedBitmap;
// Make sure the capture location is the location of the window, not the copy
capture.Location = Location;
@@ -1181,7 +1181,7 @@ namespace GreenshotPlugin.Core {
}
return targetBuffer.UnlockAndReturnBitmap();
}
-
+
///
/// Helper method to get the window size for DWM Windows
///
@@ -1201,7 +1201,7 @@ namespace GreenshotPlugin.Core {
/// Helper method to get the window size for GDI Windows
///
/// out Rectangle
- /// bool true if it worked
+ /// bool true if it worked
private bool GetClientRect(out Rectangle rectangle) {
var windowInfo = new WindowInfo();
// Get the Window Info for this window
@@ -1209,12 +1209,12 @@ namespace GreenshotPlugin.Core {
rectangle = result ? windowInfo.rcClient.ToRectangle() : Rectangle.Empty;
return result;
}
-
+
///
/// Helper method to get the window size for GDI Windows
///
/// out Rectangle
- /// bool true if it worked
+ /// bool true if it worked
private bool GetWindowRect(out Rectangle rectangle) {
var windowInfo = new WindowInfo();
// Get the Window Info for this window
@@ -1227,7 +1227,7 @@ namespace GreenshotPlugin.Core {
/// Helper method to get the Border size for GDI Windows
///
/// out Size
- /// bool true if it worked
+ /// bool true if it worked
private bool GetBorderSize(out Size size) {
var windowInfo = new WindowInfo();
// Get the Window Info for this window
@@ -1280,7 +1280,7 @@ namespace GreenshotPlugin.Core {
public void ToForeground(bool workaround = true) {
ToForeground(Handle, workaround);
}
-
+
///
/// Get the region for a window
///
@@ -1295,7 +1295,7 @@ namespace GreenshotPlugin.Core {
}
return null;
}
-
+
private bool CanFreezeOrUnfreeze(string titleOrProcessname) {
if (string.IsNullOrEmpty(titleOrProcessname)) {
return false;
@@ -1397,13 +1397,13 @@ namespace GreenshotPlugin.Core {
exceptionOccured = User32.CreateWin32Exception("PrintWindow");
}
}
-
+
// Apply the region "transparency"
if (region != null && !region.IsEmpty(graphics)) {
graphics.ExcludeClip(region);
graphics.Clear(Color.Transparent);
}
-
+
graphics.Flush();
}
@@ -1421,7 +1421,7 @@ namespace GreenshotPlugin.Core {
}
return returnImage;
}
-
+
///
/// Constructs a new instance of this class for
/// the specified Window Handle.
@@ -1430,7 +1430,7 @@ namespace GreenshotPlugin.Core {
public WindowDetails(IntPtr hWnd) {
Handle = hWnd;
}
-
+
///
/// Gets an instance of the current active foreground window
///
@@ -1451,7 +1451,7 @@ namespace GreenshotPlugin.Core {
}
return null;
}
-
+
///
/// Check if this window is Greenshot
///
@@ -1469,7 +1469,7 @@ namespace GreenshotPlugin.Core {
return false;
}
}
-
+
///
/// Gets the Desktop window
///
@@ -1477,7 +1477,7 @@ namespace GreenshotPlugin.Core {
public static WindowDetails GetDesktopWindow() {
return new WindowDetails(User32.GetDesktopWindow());
}
-
+
///
/// Get all the top level windows
///
@@ -1715,7 +1715,7 @@ namespace GreenshotPlugin.Core {
if (window.Iconic) {
continue;
}
-
+
// Windows without size
Size windowSize = window.WindowRectangle.Size;
if (windowSize.Width == 0 || windowSize.Height == 0) {
@@ -1744,7 +1744,7 @@ namespace GreenshotPlugin.Core {
}
}
}
-
+
///
/// Get the AppLauncher
///
@@ -1760,7 +1760,7 @@ namespace GreenshotPlugin.Core {
}
return null;
}
-
+
///
/// Return true if the metro-app-launcher is visible
///
diff --git a/GreenshotPlugin/Core/WindowsVersion.cs b/GreenshotPlugin/Core/WindowsVersion.cs
new file mode 100644
index 000000000..3337fe5be
--- /dev/null
+++ b/GreenshotPlugin/Core/WindowsVersion.cs
@@ -0,0 +1,107 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+
+namespace GreenshotPlugin.Core
+{
+ ///
+ /// Extension methods to test the windows version
+ ///
+ public static class WindowsVersion
+ {
+ ///
+ /// Get the current windows version
+ ///
+ public static Version WinVersion { get; } = Environment.OSVersion.Version;
+
+ ///
+ /// Test if the current OS is Windows 10
+ ///
+ /// true if we are running on Windows 10
+ public static bool IsWindows10 { get; } = WinVersion.Major == 10;
+
+ ///
+ /// Test if the current OS is Windows 10 or later
+ ///
+ /// true if we are running on Windows 10 or later
+ public static bool IsWindows10OrLater { get; } = WinVersion.Major >= 10;
+
+ ///
+ /// Test if the current OS is Windows 7 or later
+ ///
+ /// true if we are running on Windows 7 or later
+ public static bool IsWindows7OrLater { get; } = WinVersion.Major == 6 && WinVersion.Minor >= 1 || WinVersion.Major > 6;
+
+ ///
+ /// Test if the current OS is Windows 8.0
+ ///
+ /// true if we are running on Windows 8.0
+ public static bool IsWindows8 { get; } = WinVersion.Major == 6 && WinVersion.Minor == 2;
+
+ ///
+ /// Test if the current OS is Windows 8(.1)
+ ///
+ /// true if we are running on Windows 8(.1)
+ public static bool IsWindows81 { get; } = WinVersion.Major == 6 && WinVersion.Minor == 3;
+
+ ///
+ /// Test if the current OS is Windows 8.0 or 8.1
+ ///
+ /// true if we are running on Windows 8.1 or 8.0
+ public static bool IsWindows8X { get; } = IsWindows8 || IsWindows81;
+
+ ///
+ /// Test if the current OS is Windows 8.1 or later
+ ///
+ /// true if we are running on Windows 8.1 or later
+ public static bool IsWindows81OrLater { get; } = WinVersion.Major == 6 && WinVersion.Minor >= 3 || WinVersion.Major > 6;
+
+ ///
+ /// Test if the current OS is Windows 8 or later
+ ///
+ /// true if we are running on Windows 8 or later
+ public static bool IsWindows8OrLater { get; } = WinVersion.Major == 6 && WinVersion.Minor >= 2 || WinVersion.Major > 6;
+
+ ///
+ /// Test if the current OS is Windows Vista
+ ///
+ /// true if we are running on Windows Vista or later
+ public static bool IsWindowsVista { get; } = WinVersion.Major >= 6 && WinVersion.Minor == 0;
+
+ ///
+ /// Test if the current OS is Windows Vista or later
+ ///
+ /// true if we are running on Windows Vista or later
+ public static bool IsWindowsVistaOrLater { get; } = WinVersion.Major >= 6;
+
+ ///
+ /// Test if the current OS is from before Windows Vista (e.g. Windows XP)
+ ///
+ /// true if we are running on Windows from before Vista
+ public static bool IsWindowsBeforeVista { get; } = WinVersion.Major < 6;
+
+ ///
+ /// Test if the current OS is Windows XP
+ ///
+ /// true if we are running on Windows XP or later
+ public static bool IsWindowsXp { get; } = WinVersion.Major == 5 && WinVersion.Minor >= 1;
+
+ ///
+ /// Test if the current OS is Windows XP or later
+ ///
+ /// true if we are running on Windows XP or later
+ public static bool IsWindowsXpOrLater { get; } = WinVersion.Major >= 5 || WinVersion.Major == 5 && WinVersion.Minor >= 1;
+
+ ///
+ /// Test if the current Windows version is 10 and the build number or later
+ /// See the build numbers here
+ ///
+ /// int
+ /// bool
+ public static bool IsWindows10BuildOrLater(int minimalBuildNumber)
+ {
+ return IsWindows10 && WinVersion.Build >= minimalBuildNumber;
+ }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotPlugin/IniFile/IniReader.cs b/GreenshotPlugin/IniFile/IniReader.cs
index 43541cd41..c2c120851 100644
--- a/GreenshotPlugin/IniFile/IniReader.cs
+++ b/GreenshotPlugin/IniFile/IniReader.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -25,12 +25,12 @@ using System.Text;
namespace Greenshot.IniFile {
///
- ///
+ /// The IniReader does exactly what it says, it reads the .ini file
///
public static class IniReader {
- private const string SectionStart = "[";
- private const string SectionEnd = "]";
- private const string Comment = ";";
+ private const char SectionStartToken = '[';
+ private const char SectionEndToken = ']';
+ private const char CommentToken = ';';
private static readonly char[] Assignment = { '=' };
///
@@ -52,11 +52,16 @@ namespace Greenshot.IniFile {
continue;
}
string cleanLine = line.Trim();
- if (cleanLine.Length == 0 || cleanLine.StartsWith(Comment)) {
+ if (cleanLine.Length == 0 || cleanLine[0] == CommentToken) {
continue;
}
- if (cleanLine.StartsWith(SectionStart)) {
- string section = line.Replace(SectionStart, string.Empty).Replace(SectionEnd, string.Empty).Trim();
+ if (cleanLine[0] == SectionStartToken) {
+ var sectionEndIndex = line.IndexOf(SectionEndToken,1);
+ if (sectionEndIndex <0)
+ {
+ continue;
+ }
+ string section = line.Substring(1,sectionEndIndex-1).Trim();
if (!ini.TryGetValue(section, out nameValues))
{
nameValues = new Dictionary();
diff --git a/GreenshotPlugin/UnmanagedHelpers/Shell32.cs b/GreenshotPlugin/UnmanagedHelpers/Shell32.cs
index 4b5f7d50c..cd53741a0 100644
--- a/GreenshotPlugin/UnmanagedHelpers/Shell32.cs
+++ b/GreenshotPlugin/UnmanagedHelpers/Shell32.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -155,7 +155,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
// Cleanup
User32.DestroyIcon(shfi.hIcon);
return icon;
- }
+ }
///
/// Returns an icon representation of an image contained in the specified file.
diff --git a/GreenshotPlugin/UnmanagedHelpers/User32.cs b/GreenshotPlugin/UnmanagedHelpers/User32.cs
index 9a4ed07db..8a889014e 100644
--- a/GreenshotPlugin/UnmanagedHelpers/User32.cs
+++ b/GreenshotPlugin/UnmanagedHelpers/User32.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program 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 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -30,6 +30,7 @@ using Microsoft.Win32.SafeHandles;
using System.Security;
using System.Security.Permissions;
using log4net;
+using GreenshotPlugin.Core.Enums;
namespace GreenshotPlugin.UnmanagedHelpers {
///
@@ -53,7 +54,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public const int PW_DEFAULT = 0x00;
public const int PW_CLIENTONLY = 0x01;
-
+
// For MonitorFromWindow
public const int MONITOR_DEFAULTTONULL = 0;
public const int MONITOR_DEFAULTTOPRIMARY = 1;
@@ -62,6 +63,19 @@ namespace GreenshotPlugin.UnmanagedHelpers {
[DllImport("user32", SetLastError = true)]
public static extern bool keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
+
+ ///
+ /// Determines whether the specified window handle identifies an existing window.
+ ///
+ /// A handle to the window to be tested.
+ ///
+ /// If the window handle identifies an existing window, the return value is true.
+ /// If the window handle does not identify an existing window, the return value is false.
+ ///
+ [DllImport("user32", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool IsWindow(IntPtr hWnd);
+
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindowVisible(IntPtr hWnd);
@@ -125,7 +139,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
[DllImport("user32", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
public static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int index, IntPtr styleFlags);
[DllImport("user32", SetLastError = true)]
- public static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
+ public static extern IntPtr MonitorFromWindow(IntPtr hwnd, MonitorFrom dwFlags);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr MonitorFromRect([In] ref RECT lprc, uint dwFlags);
[DllImport("user32", SetLastError = true)]
@@ -224,8 +238,18 @@ namespace GreenshotPlugin.UnmanagedHelpers {
[DllImport("user32", SetLastError = true)]
public static extern bool CloseDesktop(IntPtr hDesktop);
+ ///
+ /// The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area.
+ /// GetWindowDC assigns default attributes to the window device context each time it retrieves the device context.Previous attributes are lost.
+ /// See GetWindowDC function
+ ///
+ /// A handle to the window whose DC is to be retrieved. If this value is NULL, GetWindowDC retrieves the DC for the entire screen.
+ /// If the function succeeds, the return value is a handle to a device context for the specified window.
+ [DllImport("user32", SetLastError = true)]
+ public static extern IntPtr GetWindowDC(IntPtr hWnd);
- ///
+
+ ///
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7.
///
/// Point with cursor location, relative to the origin of the monitor setup
@@ -407,6 +431,21 @@ namespace GreenshotPlugin.UnmanagedHelpers {
return returnValue;
}
+ ///
+ /// Creates a DC as SafeWindowDcHandle for the whole of the specified hWnd
+ ///
+ /// IntPtr
+ /// SafeWindowDcHandle
+ public static SafeWindowDcHandle FromWindow(IntPtr hWnd)
+ {
+ if (hWnd == IntPtr.Zero)
+ {
+ return null;
+ }
+ var hDcDesktop = GetWindowDC(hWnd);
+ return new SafeWindowDcHandle(hWnd, hDcDesktop);
+ }
+
public static SafeWindowDcHandle FromDesktop() {
IntPtr hWndDesktop = User32.GetDesktopWindow();
IntPtr hDCDesktop = GetWindowDC(hWndDesktop);
diff --git a/GreenshotWin10Plugin/Native/DataTransferManagerHelper.cs b/GreenshotWin10Plugin/Native/DataTransferManagerHelper.cs
index 734d5f73f..2594b4338 100644
--- a/GreenshotWin10Plugin/Native/DataTransferManagerHelper.cs
+++ b/GreenshotWin10Plugin/Native/DataTransferManagerHelper.cs
@@ -19,6 +19,7 @@
* along with this program. If not, see .
*/
+using GreenshotPlugin.Core;
using System;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.DataTransfer;
diff --git a/GreenshotWin10Plugin/Native/IDataTransferManagerInterOp.cs b/GreenshotWin10Plugin/Native/IDataTransferManagerInterOp.cs
index 470c03f6b..a4cef4ce4 100644
--- a/GreenshotWin10Plugin/Native/IDataTransferManagerInterOp.cs
+++ b/GreenshotWin10Plugin/Native/IDataTransferManagerInterOp.cs
@@ -17,18 +17,19 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+using GreenshotPlugin.Core.Enums;
using System;
using System.Runtime.InteropServices;
using Windows.ApplicationModel.DataTransfer;
namespace GreenshotWin10Plugin.Native
{
- ///
- /// The IDataTransferManagerInterOp is documented here: https://msdn.microsoft.com/en-us/library/windows/desktop/jj542488(v=vs.85).aspx.
- /// This interface allows an app to tie the share context to a specific
- /// window using a window handle. Useful for Win32 apps.
- ///
- [ComImport, Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
+ ///
+ /// The IDataTransferManagerInterOp is documented here: https://msdn.microsoft.com/en-us/library/windows/desktop/jj542488(v=vs.85).aspx.
+ /// This interface allows an app to tie the share context to a specific
+ /// window using a window handle. Useful for Win32 apps.
+ ///
+ [ComImport, Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDataTransferManagerInterOp
{
diff --git a/GreenshotWin10Plugin/Win10Plugin.cs b/GreenshotWin10Plugin/Win10Plugin.cs
index 815ebc787..340d17f04 100644
--- a/GreenshotWin10Plugin/Win10Plugin.cs
+++ b/GreenshotWin10Plugin/Win10Plugin.cs
@@ -54,7 +54,7 @@ namespace GreenshotWin10Plugin
/// IEnumerable with the destinations
public IEnumerable Destinations()
{
- if (!Environment.OSVersion.IsWindows10OrLater())
+ if (!WindowsVersion.IsWindows10OrLater)
{
yield break;
}