123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using Kbg.NppPluginNET.PluginInfrastructure;
- using System;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- using HelloNppPluginDockWindow;
- // ReSharper disable once CheckNamespace
- public class Main
- {
- public const string PluginName = nameof(HelloNppPluginDockWindow);
- public static void CommandMenuInit()
- {
- PluginBase.SetCommand(0, "Show hello form", ShowHi);
- PluginBase.SetCommand(0, "Show hello form (dockable)", ShowHiDockable);
- }
- public static void SetToolBarIcon()
- {
- }
- public static void PluginCleanUp()
- {
- }
- public static void OnNotification(ScNotification notification)
- {
- }
- private static void ShowHi()
- {
- var sayHiForm = new SayHiForm { StartPosition = FormStartPosition.CenterParent };
- sayHiForm.Show(new Win32Window(PluginBase.nppData._nppHandle));
- }
- private static void ShowHiDockable()
- {
- var sayHiForm = new SayHiForm();
- sayHiForm.Text += " (dockable)";
- sayHiForm.label1.Text += " (dockable)";
- // dlgID: the dlgDlg should be the index of funcItem where the current function pointer is in
- // this case is 15.. so the initial value of funcItem[15]._cmdID - not the updated internal one !
- // uMask: define the default docking behaviour
- var nppTbData = new NppTbData
- {
- pszModuleName = PluginName,
- hClient = sayHiForm.Handle,
- pszName = sayHiForm.Text,
- hIconTab = (uint)sayHiForm.Icon.Handle,
- uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR,
- //dlgID = 15,
- };
- var ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData));
- Marshal.StructureToPtr(nppTbData, ptrNppTbData, false);
- Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, IntPtr.Zero, ptrNppTbData);
- }
- }
|