Check-in [bcacc7133f]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed several remaining 64-bits related problems. Moved ODS (for OutputDebugString) to its own unit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | win64
Files: files | file ages | folders
SHA1: bcacc7133f3ece95b8d6bf79496fa48661435725
User & Date: tinus 2019-03-15 19:59:25
Context
2019-03-16
09:29
'Edit filters' also checks for sample file in DLL folder if not present in the config folder, and copies it if necessary. Use secure links in about form. Added plugin DLL file name as property to TNppPlugin. Removed obsolete 'Replace Hello World' command. Identify debug version of plugin in menu. Fixed version info in project (and set to 1.3.2.0). check-in: 3546a794ad user: tinus tags: win64
2019-03-15
19:59
Fixed several remaining 64-bits related problems. Moved ODS (for OutputDebugString) to its own unit. check-in: bcacc7133f user: tinus tags: win64
18:14
Grafted Win64-related changes from [23338c7949] and [f09c69e9b9] into their own branch, to make it easier to create a proper 64-bits release. check-in: e1f6b8f94e user: tinus tags: win64
Changes

Added src/Debug.pas.























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
unit Debug;

interface

procedure ODS(const DebugOutput: string); overload;
procedure ODS(const DebugOutput: string; const Args: array of const); overload;

implementation
uses
  Classes, SysUtils,
  Windows,
  L_SpecialFolders;

var
  OutputLog: TStreamWriter;

{ ------------------------------------------------------------------------------------------------ }
procedure ODS(const DebugOutput: string); overload;
begin
  OutputDebugString(PChar('PreviewHTML['+IntToHex(GetCurrentThreadId, 4)+']: ' + DebugOutput));
  {$IFDEF DEBUG}
  if OutputLog = nil then begin
    OutputLog := TStreamWriter.Create(TFileStream.Create(ChangeFileExt(TSpecialFolders.DLLFullName, '.log'), fmCreate or fmShareDenyWrite), TEncoding.UTF8);
    OutputLog.OwnStream;
    OutputLog.BaseStream.Seek(0, soFromEnd);
  end;
  OutputLog.Write(FormatDateTime('yyyy-MM-dd hh:nn:ss.zzz: ', Now));
  OutputLog.WriteLine(DebugOutput.Replace(#10, #10 + StringOfChar(' ', 25)));
  {$ENDIF}
end {ODS};
{ ------------------------------------------------------------------------------------------------ }
procedure ODS(const DebugOutput: string; const Args: array of const); overload;
begin
  ODS(Format(DebugOutput, Args));
end{ODS};


initialization

finalization
  OutputLog.Free;

end.

Changes to src/F_PreviewHTML.dfm.

103
104
105
106
107
108
109


110
111

112
113
114
115
116
117
118
        TabOrder = 0
        OnStatusTextChange = wbIEStatusTextChange
        OnTitleChange = wbIETitleChange
        OnBeforeNavigate2 = wbIEBeforeNavigate2
        OnDocumentComplete = wbIEDocumentComplete
        OnStatusBar = wbIEStatusBar
        OnNewWindow3 = wbIENewWindow3


        ControlData = {
          4C000000173400002C2700000000000000000000000000000000000000000000

          000000004C000000000000000000000001000000E0D057007335CF11AE690800
          2B2E12620B000000000000004C0000000114020000000000C000000000000046
          8000000000000000000000000000000000000000000000000000000000000000
          00000000000000000100000000000000000000000000000000000000}
      end
    end
  end







>
>

<
>







103
104
105
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120
        TabOrder = 0
        OnStatusTextChange = wbIEStatusTextChange
        OnTitleChange = wbIETitleChange
        OnBeforeNavigate2 = wbIEBeforeNavigate2
        OnDocumentComplete = wbIEDocumentComplete
        OnStatusBar = wbIEStatusBar
        OnNewWindow3 = wbIENewWindow3
        ExplicitWidth = 557
        ExplicitHeight = 418
        ControlData = {

          4C0000002D2F00007A2300000000000000000000000000000000000000000000
          000000004C000000000000000000000001000000E0D057007335CF11AE690800
          2B2E12620B000000000000004C0000000114020000000000C000000000000046
          8000000000000000000000000000000000000000000000000000000000000000
          00000000000000000100000000000000000000000000000000000000}
      end
    end
  end

Changes to src/F_PreviewHTML.pas.

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
717
718
719
720
721
722
723
724
725
726
727
728
729
    procedure ForgetBuffer(const BufferID: TBufferID);
    procedure DisplayPreview(HTML: string; const BufferID: TBufferID);
  end;

var
  frmHTMLPreview: TfrmHTMLPreview;

procedure ODS(const DebugOutput: string); overload;
procedure ODS(const DebugOutput: string; const Args: array of const); overload;

////////////////////////////////////////////////////////////////////////////////////////////////////
implementation
uses
  ShellAPI, ComObj, StrUtils, IOUtils, Masks, MSHTML,
  RegExpr, L_SpecialFolders,

  WebBrowser, SciSupport, U_Npp_PreviewHTML;

{$R *.dfm}

var
  OutputLog: TStreamWriter;

{ ------------------------------------------------------------------------------------------------ }
procedure ODS(const DebugOutput: string); overload;
begin
  OutputDebugString(PChar('PreviewHTML['+IntToHex(GetCurrentThreadId, 4)+']: ' + DebugOutput));
  if OutputLog = nil then begin
    OutputLog := TStreamWriter.Create(TFileStream.Create(ChangeFileExt(TSpecialFolders.DLLFullName, '.log'), fmCreate or fmShareDenyWrite), TEncoding.UTF8);
    OutputLog.OwnStream;
    OutputLog.BaseStream.Seek(0, soFromEnd);
  end;
  OutputLog.Write(FormatDateTime('yyyy-MM-dd hh:nn:ss.zzz: ', Now));
  OutputLog.WriteLine(DebugOutput);
end {ODS};
{ ------------------------------------------------------------------------------------------------ }
procedure ODS(const DebugOutput: string; const Args: array of const); overload;
begin
  ODS(Format(DebugOutput, Args));
end{ODS};


{ ================================================================================================ }

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormCreate(Sender: TObject);
begin
  FScrollPositions := TDictionary<TBufferID,TPoint>.Create;
................................................................................
procedure TfrmHTMLPreview.wbIETitleChange(ASender: TObject; const Text: WideString);
begin
  inherited;
  self.UpdateDisplayInfo(StringReplace(Text, 'about:blank', '', [rfReplaceAll]));
end;


initialization

finalization
  OutputLog.Free;

end.







<
<
<





>



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<

66
67
68
69
70
71
72



73
74
75
76
77
78
79
80
81






















82
83
84
85
86
87
88
...
693
694
695
696
697
698
699





700
    procedure ForgetBuffer(const BufferID: TBufferID);
    procedure DisplayPreview(HTML: string; const BufferID: TBufferID);
  end;

var
  frmHTMLPreview: TfrmHTMLPreview;




////////////////////////////////////////////////////////////////////////////////////////////////////
implementation
uses
  ShellAPI, ComObj, StrUtils, IOUtils, Masks, MSHTML,
  RegExpr, L_SpecialFolders,
  Debug,
  WebBrowser, SciSupport, U_Npp_PreviewHTML;

{$R *.dfm}























{ ================================================================================================ }

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormCreate(Sender: TObject);
begin
  FScrollPositions := TDictionary<TBufferID,TPoint>.Create;
................................................................................
procedure TfrmHTMLPreview.wbIETitleChange(ASender: TObject; const Text: WideString);
begin
  inherited;
  self.UpdateDisplayInfo(StringReplace(Text, 'about:blank', '', [rfReplaceAll]));
end;







end.

Changes to src/U_CustomFilter.pas.

34
35
36
37
38
39
40

41
42
43
44
45
46
47

////////////////////////////////////////////////////////////////////////////////////////////////////
implementation

uses
  IOUtils,
  process, Pipes,

  F_PreviewHTML;

{ TCustomFilterThread }

{ ------------------------------------------------------------------------------------------------ }
constructor TCustomFilterThread.Create(const Data: TFilterData);
begin







>







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

////////////////////////////////////////////////////////////////////////////////////////////////////
implementation

uses
  IOUtils,
  process, Pipes,
  Debug,
  F_PreviewHTML;

{ TCustomFilterThread }

{ ------------------------------------------------------------------------------------------------ }
constructor TCustomFilterThread.Create(const Data: TFilterData);
begin

Changes to src/U_Npp_PreviewHTML.pas.

48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
...
119
120
121
122
123
124
125

126
127
128
129
130
131
132

var
  Npp: TNppPluginPreviewHTML;

////////////////////////////////////////////////////////////////////////////////////////////////////
implementation
uses
  WebBrowser, Registry;


{ ------------------------------------------------------------------------------------------------ }
procedure _FuncReplaceHelloWorld; cdecl;
begin
  Npp.CommandReplaceHelloWorld;
end;
{ ------------------------------------------------------------------------------------------------ }
................................................................................
{ ================================================================================================ }
{ TNppPluginPreviewHTML }

{ ------------------------------------------------------------------------------------------------ }
constructor TNppPluginPreviewHTML.Create;
begin
  inherited;

  self.PluginName := '&Preview HTML';
end {TNppPluginPreviewHTML.Create};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.SetInfo(NppData: TNppData);
var
  IEVersion: string;







|
>







 







>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

var
  Npp: TNppPluginPreviewHTML;

////////////////////////////////////////////////////////////////////////////////////////////////////
implementation
uses
  WebBrowser, Registry,
  Debug;

{ ------------------------------------------------------------------------------------------------ }
procedure _FuncReplaceHelloWorld; cdecl;
begin
  Npp.CommandReplaceHelloWorld;
end;
{ ------------------------------------------------------------------------------------------------ }
................................................................................
{ ================================================================================================ }
{ TNppPluginPreviewHTML }

{ ------------------------------------------------------------------------------------------------ }
constructor TNppPluginPreviewHTML.Create;
begin
  inherited;
  ODS('TNppPluginPreviewHTML.Create');
  self.PluginName := '&Preview HTML';
end {TNppPluginPreviewHTML.Create};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.SetInfo(NppData: TNppData);
var
  IEVersion: string;

Changes to src/lib/NppDockingForms.pas.

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
{var
  r:Integer;}

begin
  self.HandleNeeded;
  //self.Visible := true;

  FillChar(self.ToolbarData,sizeof(TToolbarData),0);

  if (not self.Icon.Empty) then
  begin
    self.ToolbarData.IconTab := self.Icon.Handle;
    self.ToolbarData.Mask := self.ToolbarData.Mask or DWS_ICONTAB;
  end;

................................................................................
  GetMem(self.ToolbarData.AdditionalInfo, 1000*sizeof(nppPChar));

{$IFDEF NPPUNICODE}
  StringToWideChar(self.Caption, self.ToolbarData.Title, 500);
  GetModuleFileNameW(HInstance, self.ToolbarData.ModuleName, 1000);
  StringToWideChar(ExtractFileName(self.ToolbarData.ModuleName), self.ToolbarData.ModuleName, 1000);
  StringToWideChar('', self.ToolbarData.AdditionalInfo, 1);
  {r:=}SendMessageW(self.Npp.NppData.NppHandle, NPPM_DMMREGASDCKDLG, 0, NativeInt(@self.ToolbarData));
{$ELSE}
  StrCopy(self.ToolbarData.Title, PChar(self.Caption));
  GetModuleFileNameA(HInstance, self.ToolbarData.ModuleName, 1000);
  StrLCopy(self.ToolbarData.ModuleName, PChar(ExtractFileName(self.ToolbarData.ModuleName)), 1000);
  StrCopy(self.ToolbarData.AdditionalInfo, PChar(''));
  {r:=}
  SendMessageA(self.Npp.NppData.NppHandle, NPPM_DMMREGASDCKDLG, 0, NativeInt(@self.ToolbarData));
{$ENDIF}

  self.Visible := true;
end;

procedure TNppDockingForm.Show;
begin
................................................................................
// This hack prevents the Win Dialog default procedure from an endless loop while
// looking for the prevoius component, while in a floating state.
// I still don't know why the pointer climbs up to the docking dialog that holds this one
// but this works for now.
procedure TNppDockingForm.RemoveControlParent(control: TControl);
var
  wincontrol: TWinControl;
  i, r: NativeInt;
begin
  if (control is TWinControl) then
  begin
    wincontrol := control as TWinControl;
    wincontrol.HandleNeeded;
    r := Windows.GetWindowLong(wincontrol.Handle, GWL_EXSTYLE);
    if (r and WS_EX_CONTROLPARENT = WS_EX_CONTROLPARENT) then







|







 







|






|







 







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
{var
  r:Integer;}

begin
  self.HandleNeeded;
  //self.Visible := true;

  self.ToolbarData := Default(TToolbarData);

  if (not self.Icon.Empty) then
  begin
    self.ToolbarData.IconTab := self.Icon.Handle;
    self.ToolbarData.Mask := self.ToolbarData.Mask or DWS_ICONTAB;
  end;

................................................................................
  GetMem(self.ToolbarData.AdditionalInfo, 1000*sizeof(nppPChar));

{$IFDEF NPPUNICODE}
  StringToWideChar(self.Caption, self.ToolbarData.Title, 500);
  GetModuleFileNameW(HInstance, self.ToolbarData.ModuleName, 1000);
  StringToWideChar(ExtractFileName(self.ToolbarData.ModuleName), self.ToolbarData.ModuleName, 1000);
  StringToWideChar('', self.ToolbarData.AdditionalInfo, 1);
  {r:=}SendMessageW(self.Npp.NppData.NppHandle, NPPM_DMMREGASDCKDLG, 0, LPARAM(@self.ToolbarData));
{$ELSE}
  StrCopy(self.ToolbarData.Title, PChar(self.Caption));
  GetModuleFileNameA(HInstance, self.ToolbarData.ModuleName, 1000);
  StrLCopy(self.ToolbarData.ModuleName, PChar(ExtractFileName(self.ToolbarData.ModuleName)), 1000);
  StrCopy(self.ToolbarData.AdditionalInfo, PChar(''));
  {r:=}
  SendMessageA(self.Npp.NppData.NppHandle, NPPM_DMMREGASDCKDLG, 0, LPARAM(@self.ToolbarData));
{$ENDIF}

  self.Visible := true;
end;

procedure TNppDockingForm.Show;
begin
................................................................................
// This hack prevents the Win Dialog default procedure from an endless loop while
// looking for the prevoius component, while in a floating state.
// I still don't know why the pointer climbs up to the docking dialog that holds this one
// but this works for now.
procedure TNppDockingForm.RemoveControlParent(control: TControl);
var
  wincontrol: TWinControl;
  i, r: integer;
begin
  if (control is TWinControl) then
  begin
    wincontrol := control as TWinControl;
    wincontrol.HandleNeeded;
    r := Windows.GetWindowLong(wincontrol.Handle, GWL_EXSTYLE);
    if (r and WS_EX_CONTROLPARENT = WS_EX_CONTROLPARENT) then

Changes to src/lib/NppPluginInclude.pas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
procedure DLLEntryPoint(dwReason: DWord);
begin
  case dwReason of
  DLL_PROCESS_ATTACH:
  begin
    // create the main object
    //Npp := TDbgpNppPlugin.Create;
  end;
  DLL_PROCESS_DETACH:
  begin
    try
      if Assigned(Npp) then
        Npp.Free;
    except
................................................................................

procedure beNotified(sn: PSCNotification); cdecl; export;
begin
  if Assigned(Npp) then
    Npp.BeNotified(sn);
end;

function messageProc(msg: Integer; _wParam: WPARAM; _lParam: LPARAM): LRESULT; cdecl; export;
var xmsg:TMessage;
begin
  xmsg.Msg := msg;
  xmsg.WParam := _wParam;
  xmsg.LParam := _lParam;
  xmsg.Result := 0;
  if Assigned(Npp) then






|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
procedure DLLEntryPoint(dwReason: DWord);
begin
  case dwReason of
  DLL_PROCESS_ATTACH:
  begin
    // create the main object
//    Npp := TDbgpNppPlugin.Create;
  end;
  DLL_PROCESS_DETACH:
  begin
    try
      if Assigned(Npp) then
        Npp.Free;
    except
................................................................................

procedure beNotified(sn: PSCNotification); cdecl; export;
begin
  if Assigned(Npp) then
    Npp.BeNotified(sn);
end;

function messageProc(msg: UINT; _wParam: WPARAM; _lParam: LPARAM): LRESULT; cdecl; export;
var xmsg:TMessage;
begin
  xmsg.Msg := msg;
  xmsg.WParam := _wParam;
  xmsg.LParam := _lParam;
  xmsg.Result := 0;
  if Assigned(Npp) then

Changes to src/lib/SciSupport.pas.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

{$DEFINE MACRO_SUPPORT}

uses Windows;

type
  TScintillaMessageFnc = function(ptr : Pointer; Msg: UINT; wParam: WPARAM; lParam : LPARAM) : LRESULT; cdecl;
  uptr_t = Longword;
  sptr_t = Longint;
  TNotifyHeader = record
	  hwndFrom : HWND;
	  idFrom : uptr_t;
	  code : NativeUInt;
  end;
  PSCNotification = ^TSCNotification;
  TSCNotification = record
    nmhdr 		          : TNotifyHeader;
    position    	      : Integer;		// SCN_STYLENEEDED, SCN_MODIFIED
    ch 			            : Integer;		// SCN_CHARADDED, SCN_KEY
    modifiers		        : Integer;		// SCN_KEY







|
|

|
|
|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

{$DEFINE MACRO_SUPPORT}

uses Windows;

type
  TScintillaMessageFnc = function(ptr : Pointer; Msg: UINT; wParam: WPARAM; lParam : LPARAM) : LRESULT; cdecl;
  uptr_t = ULONG_PTR;
  sptr_t = LONG_PTR;
  TNotifyHeader = record
    hwndFrom : HWND;
    idFrom : uptr_t;
    code : Cardinal;
  end;
  PSCNotification = ^TSCNotification;
  TSCNotification = record
    nmhdr 		          : TNotifyHeader;
    position    	      : Integer;		// SCN_STYLENEEDED, SCN_MODIFIED
    ch 			            : Integer;		// SCN_CHARADDED, SCN_KEY
    modifiers		        : Integer;		// SCN_KEY

Changes to src/lib/nppplugin.pas.

450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
...
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
...
516
517
518
519
520
521
522


523
524
525
526
527
528
529
...
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
...
640
641
642
643
644
645
646
647

648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666

667
668
669
670
671
672

673
674
675
676
677
678
679
680
681
682
683
684
685
686

  PFUNCPLUGINCMD = procedure; cdecl;

  _TFuncItem = record
    ItemName: Array[0..FuncItemNameLen-1] of nppChar;
    Func: PFUNCPLUGINCMD;
    CmdID: Integer;
    Checked: Boolean;
    ShortcutKey: PShortcutKey;
  end;

  TToolbarData = record
    ClientHandle: HWND;
    Title: nppPChar;
    DlgId: Integer;
................................................................................
    function Caption: string;

    function CmdIdFromDlgId(DlgId: Integer): Integer;

    // needed for DLL export.. wrappers are in the main dll file.
    procedure SetInfo(NppData: TNppData); virtual;
    function GetName: nppPChar;
    function GetFuncsArray(var FuncsCount: Integer): Pointer;
    procedure BeNotified(sn: PSCNotification);
    procedure MessageProc(var Msg: TMessage); virtual;

    // hooks
    procedure DoNppnToolbarModification; virtual;
    procedure DoNppnShutdown; virtual;
    procedure DoNppnBufferActivated(const BufferID: THandle); virtual;
................................................................................

    // helpers
    property ConfigDir: string  read GetPluginsConfigDir;
  end;


implementation



{ TNppPlugin }

{ This is hacking for troubble...
  We need to unset the Application handler so that the forms
  don't get berserk and start throwing OS error 1004.
  This happens because the main NPP HWND is already lost when the
................................................................................
  SetLength(s, StrLen(PChar(s)));
  filename := s;

  r := SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_GETCURRENTPOS, 0, 0);
  Line := SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_LINEFROMPOSITION, r, 0);
end;

function TNppPlugin.GetFuncsArray(var FuncsCount: Integer): Pointer;
begin
  FuncsCount := Length(self.FuncArray);
  Result := self.FuncArray;
end;

function TNppPlugin.GetName: nppPChar;
begin
  Result := nppPChar(self.PluginName);
end;

................................................................................
  end;
  Result := FConfigDir;
end;

procedure TNppPlugin.BeNotified(sn: PSCNotification);
begin
  try
    if HWND(sn^.nmhdr.hwndFrom) = self.NppData.NppHandle then begin

      case sn.nmhdr.code of
        NPPN_TB_MODIFICATION: begin
          self.DoNppnToolbarModification;
        end;
        NPPN_SHUTDOWN: begin
          self.DoNppnShutdown;
        end;
        NPPN_BUFFERACTIVATED: begin
          self.DoNppnBufferActivated(sn.nmhdr.idFrom);
        end;
        NPPN_FILEBEFORECLOSE: begin
          FClosingBufferID := SendMessage(HWND(sn.nmhdr.hwndFrom), NPPM_GETCURRENTBUFFERID, 0, 0);
  //        self.DoNppnBeforeFileClose(FClosingBufferID);
        end;
        NPPN_FILECLOSED: begin
          self.DoNppnFileClosed(FClosingBufferID);
        end;
      end;
    end else begin

      case sn.nmhdr.code of
        SCN_MODIFIED: begin
          Self.DoModified(HWND(sn.nmhdr.hwndFrom), sn.modificationType);
        end;
        SCN_UPDATEUI: begin
          self.DoUpdateUI(HWND(sn.nmhdr.hwndFrom), sn.updated);

        end;
      end;
    end;
    // @todo
  except
    on E: Exception do begin
      OutputDebugString(PChar(Format('%s> %s: "%s"', [PluginName, E.ClassName, E.Message])));
    end;
  end;
end;

procedure TNppPlugin.MessageProc(var Msg: TMessage);
//var
//  hm: HMENU;







|







 







|







 







>
>







 







|


|







 







|
>











|







>


|


<
>






|







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
...
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
...
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
...
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
...
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675

676
677
678
679
680
681
682
683
684
685
686
687
688
689
690

  PFUNCPLUGINCMD = procedure; cdecl;

  _TFuncItem = record
    ItemName: Array[0..FuncItemNameLen-1] of nppChar;
    Func: PFUNCPLUGINCMD;
    CmdID: Integer;
    Checked: BOOL;
    ShortcutKey: PShortcutKey;
  end;

  TToolbarData = record
    ClientHandle: HWND;
    Title: nppPChar;
    DlgId: Integer;
................................................................................
    function Caption: string;

    function CmdIdFromDlgId(DlgId: Integer): Integer;

    // needed for DLL export.. wrappers are in the main dll file.
    procedure SetInfo(NppData: TNppData); virtual;
    function GetName: nppPChar;
    function GetFuncsArray(out FuncsCount: Integer): Pointer;
    procedure BeNotified(sn: PSCNotification);
    procedure MessageProc(var Msg: TMessage); virtual;

    // hooks
    procedure DoNppnToolbarModification; virtual;
    procedure DoNppnShutdown; virtual;
    procedure DoNppnBufferActivated(const BufferID: THandle); virtual;
................................................................................

    // helpers
    property ConfigDir: string  read GetPluginsConfigDir;
  end;


implementation
uses
  Debug;

{ TNppPlugin }

{ This is hacking for troubble...
  We need to unset the Application handler so that the forms
  don't get berserk and start throwing OS error 1004.
  This happens because the main NPP HWND is already lost when the
................................................................................
  SetLength(s, StrLen(PChar(s)));
  filename := s;

  r := SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_GETCURRENTPOS, 0, 0);
  Line := SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_LINEFROMPOSITION, r, 0);
end;

function TNppPlugin.GetFuncsArray(out FuncsCount: Integer): Pointer;
begin
  FuncsCount := Length(self.FuncArray);
  Result := @self.FuncArray[0];
end;

function TNppPlugin.GetName: nppPChar;
begin
  Result := nppPChar(self.PluginName);
end;

................................................................................
  end;
  Result := FConfigDir;
end;

procedure TNppPlugin.BeNotified(sn: PSCNotification);
begin
  try
    if sn^.nmhdr.hwndFrom = self.NppData.NppHandle then begin
//      ODS('BeNotified from Notepad++ %d', [sn.nmhdr.code]);
      case sn.nmhdr.code of
        NPPN_TB_MODIFICATION: begin
          self.DoNppnToolbarModification;
        end;
        NPPN_SHUTDOWN: begin
          self.DoNppnShutdown;
        end;
        NPPN_BUFFERACTIVATED: begin
          self.DoNppnBufferActivated(sn.nmhdr.idFrom);
        end;
        NPPN_FILEBEFORECLOSE: begin
          FClosingBufferID := SendMessage(sn.nmhdr.hwndFrom, NPPM_GETCURRENTBUFFERID, 0, 0);
  //        self.DoNppnBeforeFileClose(FClosingBufferID);
        end;
        NPPN_FILECLOSED: begin
          self.DoNppnFileClosed(FClosingBufferID);
        end;
      end;
    end else begin
//      ODS('BeNotified from Scintilla %d', [sn.nmhdr.code]);
      case sn.nmhdr.code of
        SCN_MODIFIED: begin
          Self.DoModified(sn.nmhdr.hwndFrom, sn.modificationType);
        end;
        SCN_UPDATEUI: begin

          self.DoUpdateUI(sn.nmhdr.hwndFrom, sn.updated);
        end;
      end;
    end;
    // @todo
  except
    on E: Exception do begin
      ODS('%s> %s: "%s"', [PluginName, E.ClassName, E.Message]);
    end;
  end;
end;

procedure TNppPlugin.MessageProc(var Msg: TMessage);
//var
//  hm: HMENU;

Changes to src/prj/PreviewHTML.dpr.

25
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
42
43

  U_Npp_PreviewHTML in '..\U_Npp_PreviewHTML.pas',
  F_About in '..\F_About.pas' {AboutForm},
  F_PreviewHTML in '..\F_PreviewHTML.pas' {frmHTMLPreview},
  WebBrowser in '..\lib\WebBrowser.pas',
  L_VersionInfoW in '..\common\L_VersionInfoW.pas',
  L_SpecialFolders in '..\common\L_SpecialFolders.pas',
  RegExpr in '..\common\RegExpr.pas',
  U_CustomFilter in '..\U_CustomFilter.pas';


{$R *.res}

{$Include '..\lib\NppPluginInclude.pas'}

begin
  { First, assign the procedure to the DLLProc variable }
  DllProc := @DLLEntryPoint;
  { Now invoke the procedure to reflect that the DLL is attaching to the process }
  DLLEntryPoint(DLL_PROCESS_ATTACH);
end.








|
>











>
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  U_Npp_PreviewHTML in '..\U_Npp_PreviewHTML.pas',
  F_About in '..\F_About.pas' {AboutForm},
  F_PreviewHTML in '..\F_PreviewHTML.pas' {frmHTMLPreview},
  WebBrowser in '..\lib\WebBrowser.pas',
  L_VersionInfoW in '..\common\L_VersionInfoW.pas',
  L_SpecialFolders in '..\common\L_SpecialFolders.pas',
  RegExpr in '..\common\RegExpr.pas',
  U_CustomFilter in '..\U_CustomFilter.pas',
  Debug;

{$R *.res}

{$Include '..\lib\NppPluginInclude.pas'}

begin
  { First, assign the procedure to the DLLProc variable }
  DllProc := @DLLEntryPoint;
  { Now invoke the procedure to reflect that the DLL is attaching to the process }
  DLLEntryPoint(DLL_PROCESS_ATTACH);
end.

Changes to src/prj/PreviewHTML.dproj.

69
70
71
72
73
74
75


76
77
78
79
80
81
82
..
84
85
86
87
88
89
90

91
92
93
94
95
96
97
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
        <DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
        <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base_Win64)'!=''">
        <DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
        <BT_BuildType>Debug</BT_BuildType>
        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>


    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1)'!=''">
        <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
        <DCC_DebugInformation>0</DCC_DebugInformation>
        <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
        <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
    </PropertyGroup>
................................................................................
        <VerInfo_Debug>true</VerInfo_Debug>
        <VerInfo_PreRelease>true</VerInfo_PreRelease>
        <PostBuildEvent><![CDATA[]]></PostBuildEvent>
        <DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo>
        <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
        <DCC_Optimize>false</DCC_Optimize>
        <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>

    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
        <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
    </PropertyGroup>
    <ItemGroup>
        <DelphiCompile Include="$(MainSource)">
            <MainSource>MainSource</MainSource>
................................................................................
        <Borland.ProjectType/>
        <BorlandProject>
            <Delphi.Personality>
                <Source>
                    <Source Name="MainSource">PreviewHTML.dpr</Source>
                </Source>
                <Excluded_Packages>
                    <Excluded_Packages Name="$(BDSBIN)\dcloffice2k240.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
                    <Excluded_Packages Name="$(BDSBIN)\dclofficexp240.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
                    <Excluded_Packages Name="W:\Lib\BPL\RaizeComponentsVcl310.bpl">Raize Components VCL</Excluded_Packages>
                </Excluded_Packages>
                <VersionInfo>
                    <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
                    <VersionInfo Name="AutoIncBuild">False</VersionInfo>
                    <VersionInfo Name="MajorVer">1</VersionInfo>
                    <VersionInfo Name="MinorVer">2</VersionInfo>
                    <VersionInfo Name="Release">0</VersionInfo>







>
>







 







>







 







|
|
<







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
139
140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
        <DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
        <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base_Win64)'!=''">
        <DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
        <BT_BuildType>Debug</BT_BuildType>
        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
        <Debugger_HostApplication>C:\MC\Run\Office\Np++\x64\notepad++.exe</Debugger_HostApplication>
        <VerInfo_MinorVer>0</VerInfo_MinorVer>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1)'!=''">
        <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
        <DCC_DebugInformation>0</DCC_DebugInformation>
        <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
        <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
    </PropertyGroup>
................................................................................
        <VerInfo_Debug>true</VerInfo_Debug>
        <VerInfo_PreRelease>true</VerInfo_PreRelease>
        <PostBuildEvent><![CDATA[]]></PostBuildEvent>
        <DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo>
        <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
        <DCC_Optimize>false</DCC_Optimize>
        <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
        <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
        <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
    </PropertyGroup>
    <ItemGroup>
        <DelphiCompile Include="$(MainSource)">
            <MainSource>MainSource</MainSource>
................................................................................
        <Borland.ProjectType/>
        <BorlandProject>
            <Delphi.Personality>
                <Source>
                    <Source Name="MainSource">PreviewHTML.dpr</Source>
                </Source>
                <Excluded_Packages>
                    <Excluded_Packages Name="$(BDSBIN)\dcloffice2k250.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
                    <Excluded_Packages Name="$(BDSBIN)\dclofficexp250.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>

                </Excluded_Packages>
                <VersionInfo>
                    <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
                    <VersionInfo Name="AutoIncBuild">False</VersionInfo>
                    <VersionInfo Name="MajorVer">1</VersionInfo>
                    <VersionInfo Name="MinorVer">2</VersionInfo>
                    <VersionInfo Name="Release">0</VersionInfo>