diff --git a/CsvQuery/CsvQuery.csproj b/CsvQuery/CsvQuery.csproj
index 5f91b8f..429ec6a 100644
--- a/CsvQuery/CsvQuery.csproj
+++ b/CsvQuery/CsvQuery.csproj
@@ -252,7 +252,8 @@
-
+
+
diff --git a/CsvQuery/Main.cs b/CsvQuery/Main.cs
index 5940bb3..b5596dd 100644
--- a/CsvQuery/Main.cs
+++ b/CsvQuery/Main.cs
@@ -107,7 +107,7 @@ public static void OnNotification(ScNotification notification)
public static void CommandMenuInit()
{
- PluginBase.AddMenuItem("Toggle query window", ToggleQueryWindow, false, new ShortcutKey(true, true, false, Keys.C));
+ PluginBase.AddMenuItem("Toggle CSV Query window", ToggleQueryWindow, false, new ShortcutKey(true, true, false, Keys.C));
PluginBase.AddMenuItem("Manual parse settings", ParseWithManualSettings);
PluginBase.AddMenuItem("List parsed files", ListSqliteTables);
PluginBase.AddMenuItem("---", null);
@@ -155,22 +155,35 @@ private static void ParseWithManualSettings()
public static void SetToolBarIcon()
{
- var icons = new toolbarIcons { hToolbarBmp = Resources.cq.GetHbitmap() };
- using (var iconPointer = new TemporaryPointer(icons))
+ if (NotepadPPGateway.GetNppMajorVersion() < 8)
{
- Win32.SendMessage(PluginBase.nppData._nppHandle,
- (uint)NppMsg.NPPM_ADDTOOLBARICON,
- PluginBase.GetMenuItemId("Toggle query window"),
- iconPointer.Pointer);
+ // Old way - for backwards compatibility to Npp before 8.0
+ var icons = new toolbarIcons { hToolbarBmp = Resources.cq.GetHbitmap() };
+ using (var iconPointer = new TemporaryPointer(icons))
+ {
+ Win32.SendMessage(PluginBase.nppData._nppHandle,
+ (uint)NppMsg.NPPM_ADDTOOLBARICON,
+ PluginBase.GetMenuItemId("Toggle CSV Query window"),
+ iconPointer.Pointer);
+ }
+ }
+ else
+ {
+ // New way - for 8.0 and up (dark mode support)
+ var icons2 = new toolbarIconsWithDarkMode
+ {
+ hToolbarBmp = Resources.cq.GetHbitmap(),
+ hToolbarIcon = Resources.CsvQueryIconLight.Handle,
+ hToolbarIconDarkMode = Resources.CsvQueryIconDark.Handle,
+ };
+ using (var iconPointer = new TemporaryPointer(icons2))
+ {
+ Win32.SendMessage(PluginBase.nppData._nppHandle,
+ (uint)NppMsg.NPPM_ADDTOOLBARICON_FORDARKMODE,
+ PluginBase.GetMenuItemId("Toggle CSV Query window"),
+ iconPointer.Pointer);
+ }
}
-
- //var iconPointer = Marshal.AllocHGlobal(Marshal.SizeOf(icons));
- //Marshal.StructureToPtr(icons, iconPointer, false);
- //Win32.SendMessage(PluginBase.nppData._nppHandle,
- // (uint)NppMsg.NPPM_ADDTOOLBARICON,
- // PluginBase.GetMenuItemId("Toggle query window"),
- // iconPointer);
- //Marshal.FreeHGlobal(iconPointer);
}
public static void PluginCleanUp()
@@ -322,7 +335,7 @@ public static void QueryWindowVisible(bool? show = null, bool supressAnalysis =
{
hClient = QueryWindow.Handle,
pszName = "CSV Query",
- dlgID = PluginBase.GetMenuItemId("Toggle query window"),
+ dlgID = PluginBase.GetMenuItemId("Toggle CSV Query window"),
uMask = NppTbMsg.DWS_DF_CONT_BOTTOM | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR,
hIconTab = (uint) queryWindowIcon.Handle,
pszModuleName = PluginName
@@ -342,7 +355,7 @@ public static void QueryWindowVisible(bool? show = null, bool supressAnalysis =
{
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, QueryWindow.Handle);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
- PluginBase.GetMenuItemId("Toggle query window"),
+ PluginBase.GetMenuItemId("Toggle CSV Query window"),
1);
}
else
@@ -351,7 +364,7 @@ public static void QueryWindowVisible(bool? show = null, bool supressAnalysis =
0, QueryWindow.Handle);
Win32.SendMessage(PluginBase.nppData._nppHandle,
(uint)NppMsg.NPPM_SETMENUITEMCHECK,
- PluginBase.GetMenuItemId("Toggle query window"), 0);
+ PluginBase.GetMenuItemId("Toggle CSV Query window"), 0);
}
}
}
diff --git a/CsvQuery/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets b/CsvQuery/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets
index 897e76c..b7bdd41 100644
--- a/CsvQuery/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets
+++ b/CsvQuery/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets
@@ -1,6 +1,15 @@
-
-
-
+
+
+
+
+
+ $(DevEnvDir)\..\..\VC\bin
+
+
+
-
+
diff --git a/CsvQuery/PluginInfrastructure/Msgs_h.cs b/CsvQuery/PluginInfrastructure/Msgs_h.cs
index e56aeff..707756d 100644
--- a/CsvQuery/PluginInfrastructure/Msgs_h.cs
+++ b/CsvQuery/PluginInfrastructure/Msgs_h.cs
@@ -519,6 +519,14 @@ public enum NppMsg : uint
///
NPPM_SAVEFILE = Constants.NPPMSG + 94,
+ ///
+ /// VOID NPPM_ADDTOOLBARICON_FORDARKMODE(UINT funcItem[X]._cmdID, toolbarIconsWithDarkMode iconHandles)
+ /// Use NPPM_ADDTOOLBARICON_FORDARKMODE instead obsolete NPPM_ADDTOOLBARICON which doesn't support the dark mode
+ /// 2 formats / 3 icons are needed: 1 * BMP + 2 * ICO
+ /// All 3 handles below should be set so the icon will be displayed correctly if toolbar icon sets are changed by users, also in dark mode
+ ///
+ NPPM_ADDTOOLBARICON_FORDARKMODE = Constants.NPPMSG + 101,
+
RUNCOMMAND_USER = Constants.WM_USER + 3000,
NPPM_GETFULLCURRENTPATH = RUNCOMMAND_USER + FULL_CURRENT_PATH,
NPPM_GETCURRENTDIRECTORY = RUNCOMMAND_USER + CURRENT_DIRECTORY,
diff --git a/CsvQuery/PluginInfrastructure/NotepadPPGateway.cs b/CsvQuery/PluginInfrastructure/NotepadPPGateway.cs
index 23e4ed1..de32811 100644
--- a/CsvQuery/PluginInfrastructure/NotepadPPGateway.cs
+++ b/CsvQuery/PluginInfrastructure/NotepadPPGateway.cs
@@ -61,6 +61,12 @@ public static IntPtr GetCurrentBufferId()
return Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETCURRENTBUFFERID, Unused, Unused);
}
+ public static int GetNppMajorVersion()
+ {
+ var version = Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETNPPVERSION, Unused, Unused).ToInt32();
+ return version >> 16;
+ }
+
public void OpenFileInNpp(string filename)
{
// NPPM_DOOPEN
diff --git a/CsvQuery/Properties/CSVQueryIcon.png b/CsvQuery/Properties/CSVQueryIcon.png
index 62ceb20..24908ac 100644
Binary files a/CsvQuery/Properties/CSVQueryIcon.png and b/CsvQuery/Properties/CSVQueryIcon.png differ
diff --git a/CsvQuery/Properties/CsvQueryIconDark.ico b/CsvQuery/Properties/CsvQueryIconDark.ico
new file mode 100644
index 0000000..c9c4ce8
Binary files /dev/null and b/CsvQuery/Properties/CsvQueryIconDark.ico differ
diff --git a/CsvQuery/Properties/CsvQueryIconLight.ico b/CsvQuery/Properties/CsvQueryIconLight.ico
new file mode 100644
index 0000000..c42c550
Binary files /dev/null and b/CsvQuery/Properties/CsvQueryIconLight.ico differ
diff --git a/CsvQuery/Properties/Resources.Designer.cs b/CsvQuery/Properties/Resources.Designer.cs
index 653161d..b95a769 100644
--- a/CsvQuery/Properties/Resources.Designer.cs
+++ b/CsvQuery/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace CsvQuery.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -73,9 +73,19 @@ internal static System.Drawing.Bitmap cq {
///
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
///
- internal static System.Drawing.Icon CQIcon {
+ internal static System.Drawing.Icon CsvQueryIconDark {
get {
- object obj = ResourceManager.GetObject("CQIcon", resourceCulture);
+ object obj = ResourceManager.GetObject("CsvQueryIconDark", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ ///
+ internal static System.Drawing.Icon CsvQueryIconLight {
+ get {
+ object obj = ResourceManager.GetObject("CsvQueryIconLight", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
diff --git a/CsvQuery/Properties/Resources.resx b/CsvQuery/Properties/Resources.resx
index e8bd9b3..091b98c 100644
--- a/CsvQuery/Properties/Resources.resx
+++ b/CsvQuery/Properties/Resources.resx
@@ -127,7 +127,10 @@
CSV Query
-
- ..\Resources\CQIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ CsvQueryIconDark.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ CsvQueryIconLight.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
\ No newline at end of file
diff --git a/CsvQuery/Resources/CQIcon.ico b/CsvQuery/Resources/CQIcon.ico
deleted file mode 100644
index 1011932..0000000
Binary files a/CsvQuery/Resources/CQIcon.ico and /dev/null differ