public NppPluginForm(string name, NppTbMsg msg = NppTbMsg.DWS_DF_CONT_RIGHT, int id = -1, bool toolbaricon = false) { this.name = name; FormMask |= msg; this.id = id; if(toolbaricon) NppPluginNETEventbus.OnNPPN_TBMODIFICATION += new NppPluginNETEventbus.OnNPPN_TBMODIFICATIONHandler(NppPluginNETEventbus_OnNPPN_TBMODIFICATION); }
static T ShowDockablePanel <T>(string name, int panelId, NppTbMsg tbMsg) where T : Form, new() { if (!dockedManagedPanels.ContainsKey(panelId)) { var panel = new T(); DockPanel(panel, panelId, name, null, tbMsg); //this will also add the panel to the dockedManagedPanels //disabled chck box in menu item since tracking of the visibility of the output panes is impossible (N++ limitation) //Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_SETMENUITEMCHECK, FuncItems.Items[panelId]._cmdID, 1); } else { ToggleDockedPanelVisible(dockedManagedPanels[panelId], panelId); } return((T)dockedManagedPanels[panelId]); }
public void Register(string formName, Form form, string title, int index, NppTbMsg flags) { Validate.IsTrue(!Forms.ContainsKey(formName)); NppTbData data = new NppTbData { hClient = form.Handle, pszName = title, uMask = flags, dlgID = index, pszModuleName = "Sql Easy Studio" }; IntPtr hwnd = Marshal.AllocHGlobal(Marshal.SizeOf(data)); Marshal.StructureToPtr(data, hwnd, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, hwnd); Forms.Add(formName, new PluginForm(form)); }
public static void DockPanel(Form panel, int scriptId, string name, Icon tollbarIcon, NppTbMsg tbMsg, bool initiallyVisible = true) { var tbIcon = tollbarIcon ?? Utils.NppBitmapToIcon(Resources.Resources.css_logo_16x16); //tbIcon = Utils.NppBitmapToIcon(Properties.Resources.css_logo_16x16); NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = panel.Handle; _nppTbData.pszName = name; // 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 ! _nppTbData.dlgID = scriptId; // define the default docking behaviour _nppTbData.uMask = tbMsg; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_SETMENUITEMCHECK, Plugin.FuncItems.Items[scriptId]._cmdID, 1); //from this moment the panel is visible if (!initiallyVisible) { SetDockedPanelVisible(panel, scriptId, initiallyVisible); } if (dockedManagedPanels.ContainsKey(scriptId)) { //there is already another panel Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_DMMHIDE, 0, dockedManagedPanels[scriptId]); dockedManagedPanels[scriptId] = panel.Handle; } else { dockedManagedPanels.Add(scriptId, panel.Handle); } }
/// <summary> /// Creates structure with dialog parameters and returns pointer on that structure. /// </summary> /// <param name="form">Form to describe</param> /// <param name="shownName">Name to show at form caption</param> /// <param name="dialogId">Plugin command index</param> /// <param name="settings">Bit-mask with window settings</param> private static IntPtr CreateNppToolbarDataPointer(Form form, string shownName, int dialogId, NppTbMsg settings, Icon icon) { NppTbData _nppTbData = new NppTbData { hClient = form.Handle, pszName = shownName, dlgID = dialogId, uMask = settings, hIconTab = (uint)icon.Handle, pszModuleName = PluginName }; return(GetStructPointer(_nppTbData)); }