Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit c12f4ed

Browse files
authored
Merge pull request #81 from BdR76/master
CheckMenuItem toggle checkmark on/off
2 parents b27b180 + d69d2c0 commit c12f4ed

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Demo Plugin/NppManagedPluginDemo/Demo.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,7 @@ static void insertDateTime(bool longFormat)
290290

291291
static void checkInsertHtmlCloseTag()
292292
{
293-
doCloseTag = !doCloseTag;
294-
295-
int i = Win32.CheckMenuItem(Win32.GetMenu(PluginBase.nppData._nppHandle), PluginBase._funcItems.Items[9]._cmdID,
296-
Win32.MF_BYCOMMAND | (doCloseTag ? Win32.MF_CHECKED : Win32.MF_UNCHECKED));
293+
PluginBase.CheckMenuItemToggle(9, ref doCloseTag); // 9 = menu item index
297294
}
298295

299296
static Regex regex = new Regex(@"[\._\-:\w]", RegexOptions.Compiled);

Visual Studio Project Template C#/PluginInfrastructure/NppPluginNETBase.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ internal static void SetCommand(int index, string commandName, NppFuncItemDelega
3636
_funcItems.Add(funcItem);
3737
}
3838

39+
// menuitem with checkmark, toggle visible checkmark on/off
40+
internal static void CheckMenuItemToggle(int idx, ref bool value)
41+
{
42+
// toggle value
43+
value = !value;
44+
45+
Win32.CheckMenuItem(Win32.GetMenu(nppData._nppHandle), _funcItems.Items[idx]._cmdID, Win32.MF_BYCOMMAND | (value ? Win32.MF_CHECKED : Win32.MF_UNCHECKED));
46+
}
47+
3948
internal static IntPtr GetCurrentScintilla()
4049
{
4150
int curScintilla;

0 commit comments

Comments
 (0)