Class TNppForm

Unit

Declaration

type TNppForm = class(TForm)

Description

Default implementation of a basic (non-docking) plugin dialog

Hierarchy

Overview

Fields

Public Npp: TNppPlugin;
Public DefaultCloseAction: TCloseAction;

Methods

Public constructor Create(AOwner: TComponent); overload; override;
Public constructor Create(const Plugin: TNppPlugin); reintroduce; overload;
Public destructor Destroy; override;
Public function ShowModal: Integer; override;
Public function WantChildKey(Child: TControl; var Message: TMessage): Boolean; override;
Protected function SafeSendMessage(Hndl: HWND; Msg: Cardinal; _WParam: NativeUInt = 0; _LParam: NativeInt = 0): LRESULT; overload;
Protected function SafeSendMessage(Hndl: HWND; Msg: Cardinal; _WParam: NativeUInt = 0; _LParam: Pointer = nil): LRESULT; overload;
Public procedure SubclassAndTheme(DmFlag: Cardinal); virtual;
Public procedure ToggleDarkMode; virtual;
Protected procedure DoClose(var Action: TCloseAction); override;
Protected procedure HandleCloseQuery(Sender: TObject; var CanClose: Boolean); virtual;
Protected procedure RegisterForm();
Protected procedure UnregisterForm();

Description

Fields

Public Npp: TNppPlugin;

This item has no description.

Public DefaultCloseAction: TCloseAction;

This item has no description.

Methods

Public constructor Create(AOwner: TComponent); overload; override;

Overrides the base constructor to create a new TNppForm instance.

Note
This overload does not initialize the Npp member. Two-phase initialization is required when this constructor is called explicitly or implicitly, as, for example, by calling Application.CreateForm; e.g.,

interface

uses
  NppPlugin, NppForms, Forms;

type
  TPlugin = class(TNppPlugin)
  // ...
  end;

  TPluginForm = class(TNppForm)
  // ...
  end;

var
  MyForm: TPluginForm;

implementation

constructor TPlugin.Create;
begin
  Application.CreateForm(TPluginForm, MyForm);
  MyForm.Npp := Self;
end;

Public constructor Create(const Plugin: TNppPlugin); reintroduce; overload;

Creates a new TNppForm instance and initializes the Npp member.

Parameters
Plugin [in]
an instance of TNppPlugin; it should be initialized when DLLExports.DLLEntryPoint receives DLL_PROCESS_ATTACH
Public destructor Destroy; override;

This item has no description.

Public function ShowModal: Integer; override;

Displays this TNppForm in its own message loop, but without disabling the parent window.

Note
Not implemented for Delphi plugins.
Whereas Delphi treats Notepad++ itself as the main application, and disables the editor as expected, the main application handle of an LCL program should never be reassigned after initialization. The LCL's default ShowModal method attempts to hide the parent window. But if the main application handle belongs to Notepad++, hiding it makes the editor window disappear, with no user-accessible way to focus it again, requiring the Task Manager to ultimately shut it down.
Warning
If the user does not explicitly close the modal form, the message loop created by this method will continue running even after Notepad++ has been shut down. The Task Manager can be used to kill the form in such cases.

Public function WantChildKey(Child: TControl; var Message: TMessage): Boolean; override;

This item has no description.

Protected function SafeSendMessage(Hndl: HWND; Msg: Cardinal; _WParam: NativeUInt = 0; _LParam: NativeInt = 0): LRESULT; overload;

Sends a plugin or Scintilla API message to a dialog window

Protected function SafeSendMessage(Hndl: HWND; Msg: Cardinal; _WParam: NativeUInt = 0; _LParam: Pointer = nil): LRESULT; overload;

Sends a plugin or Scintilla API message to a dialog window when the LPARAM is a pointer

Public procedure SubclassAndTheme(DmFlag: Cardinal); virtual;

This item has no description.

Public procedure ToggleDarkMode; virtual;

This item has no description.

Protected procedure DoClose(var Action: TCloseAction); override;

Allows this TNppForm instance to replace the given TCloseAction with DefaultCloseAction

Protected procedure HandleCloseQuery(Sender: TObject; var CanClose: Boolean); virtual;

Added to ensure that Free Pascal plugin dialogs respond to the X close button after ShowModal is called.

Note
Not implemented for Delphi plugins.

Protected procedure RegisterForm();

Sends NPPM_MODELESSDIALOG with MODELESSDIALOGADD

Protected procedure UnregisterForm();

Sends NPPM_MODELESSDIALOG with MODELESSDIALOGREMOVE