Check-in [dcf6086ee4]
Not logged in

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

Overview
Comment:Tries to read the installed version of IE from iexplore.exe's file version info. Otherwise, tries from svcVersion as well as from Version in HKLM\Software\Microsoft\Internet Explorer. Moved composition of the plugin's menu items from the constructor to the override of SetInfo, since we now need the config dir, and we don't know that until we have a handle to the Npp window.
Timelines: family | ancestors | descendants | both | version-override
Files: files | file ages | folders
SHA1:dcf6086ee44568faaf30c5dcaa5c9a814f55b3ce
User & Date: Martijn 2013-07-14 09:37:53
References
2013-07-14
10:14 Fixed ticket [72b989980b]: IE10 not allowed plus 4 other changes artifact: 78f5c478e4 user: tinus
Context
2013-07-14
10:00
Merged in changes from version-override (v1.3.1.0) check-in: ee91dce380 user: Martijn tags: updatecheck
09:44
Release of v1.3.1.0 check-in: 4159519e53 user: Martijn tags: trunk, release, src-1.3.1.0
09:37
Tries to read the installed version of IE from iexplore.exe's file version info. Otherwise, tries from svcVersion as well as from Version in HKLM\Software\Microsoft\Internet Explorer. Moved composition of the plugin's menu items from the constructor to the override of SetInfo, since we now need the config dir, and we don't know that until we have a handle to the Npp window. Closed-Leaf check-in: dcf6086ee4 user: Martijn tags: version-override
2013-07-12
20:02
Moved GetSettings to the plugin class. Read eventual version override from settings file (but it doesn't seem to work yet). check-in: ef8f24d6c5 user: Martijn tags: version-override
Changes

Changes to src/F_PreviewHTML.pas.

102
103
104
105
106
107
108

109
110
111
112
113
114
115
  //self.KeyPreview := true; // special hack for input forms
  self.OnFloat := self.FormFloat;
  self.OnDock := self.FormDock;
  inherited;
  FBufferID := -1;
  with TNppPluginPreviewHTML(Npp).GetSettings() do begin
    tmrAutorefresh.Interval := ReadInteger('Autorefresh', 'Interval', tmrAutorefresh.Interval);

  end;
end {TfrmHTMLPreview.FormCreate};
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FScrollPositions);
  FreeAndNil(FFilterThread);







>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  //self.KeyPreview := true; // special hack for input forms
  self.OnFloat := self.FormFloat;
  self.OnDock := self.FormDock;
  inherited;
  FBufferID := -1;
  with TNppPluginPreviewHTML(Npp).GetSettings() do begin
    tmrAutorefresh.Interval := ReadInteger('Autorefresh', 'Interval', tmrAutorefresh.Interval);
    Free;
  end;
end {TfrmHTMLPreview.FormCreate};
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FScrollPositions);
  FreeAndNil(FFilterThread);

Changes to src/U_Npp_PreviewHTML.pas.

10
11
12
13
14
15
16



17
18
19
20
21
22
23
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
113
114
115
...
163
164
165
166
167
168
169






























































170
171
172
173
174
175
176

type
  TNppPluginPreviewHTML = class(TNppPlugin)
  private
    FSettings: TIniFile;
  public
    constructor Create;



    procedure CommandShowPreview;
    procedure CommandSetIEVersion(const BrowserEmulation: Integer);
    procedure CommandOpenFile(const Filename: nppString);
    procedure CommandShowAbout;
    procedure CommandReplaceHelloWorld;

    procedure DoNppnToolbarModification; override;
................................................................................
  Npp: TNppPluginPreviewHTML;

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

{ ================================================================================================ }
{ TNppPluginPreviewHTML }

{ ------------------------------------------------------------------------------------------------ }
constructor TNppPluginPreviewHTML.Create;
var
  IEVersion: string;
  MajorIEVersion, Code, EmulatedVersion: Integer;
  sk: TShortcutKey;
begin
  inherited;
  self.PluginName := '&Preview HTML';

  sk.IsShift := True; sk.IsCtrl := true; sk.IsAlt := False;
  sk.Key := 'H'; // Ctrl-Shift-H
  self.AddFuncItem('&Preview HTML', _FuncShowPreview, sk);

  IEVersion := GetIEVersion;
  with GetSettings do begin
    IEVersion := ReadString('Emulation', 'IE version', IEVersion);
  end;
  Val(IEVersion, MajorIEVersion, Code);
  if Code <= 1 then
    MajorIEVersion := 0;

  EmulatedVersion := GetBrowserEmulation div 1000;

  if MajorIEVersion > 7 then begin
    self.AddFuncSeparator;
    self.AddFuncItem('View as IE&7', _FuncSetIE7, EmulatedVersion = 7);
  end;

  if MajorIEVersion >= 8 then
    self.AddFuncItem('View as IE&8', _FuncSetIE8, EmulatedVersion = 8);
  if MajorIEVersion >= 9 then
    self.AddFuncItem('View as IE&9', _FuncSetIE9, EmulatedVersion = 9);
  if MajorIEVersion >= 10 then
    self.AddFuncItem('View as IE1&0', _FuncSetIE10, EmulatedVersion = 10);
  if MajorIEVersion >= 11 then
    self.AddFuncItem('View as IE1&1', _FuncSetIE11, EmulatedVersion = 11);
  if MajorIEVersion >= 12 then
    self.AddFuncItem('View as IE1&2', _FuncSetIE12, EmulatedVersion = 12);
  if MajorIEVersion >= 13 then
    self.AddFuncItem('View as IE1&3', _FuncSetIE13, EmulatedVersion = 13);

  self.AddFuncSeparator;

  self.AddFuncItem('Edit &settings', _FuncOpenSettings);
  self.AddFuncItem('Edit &filter definitions', _FuncOpenFilters);

  self.AddFuncSeparator;

  self.AddFuncItem('&About', _FuncShowAbout);
end {TNppPluginPreviewHTML.Create};

{ ------------------------------------------------------------------------------------------------ }
procedure _FuncReplaceHelloWorld; cdecl;
begin
  Npp.CommandReplaceHelloWorld;
end;
{ ------------------------------------------------------------------------------------------------ }
procedure _FuncOpenSettings; cdecl;
................................................................................
end;
{ ------------------------------------------------------------------------------------------------ }
procedure _FuncSetIE13; cdecl;
begin
  Npp.CommandSetIEVersion(13000);
end;
































































{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.CommandOpenFile(const Filename: nppString);
var
  FullPath: nppString;
begin
  try







>
>
>







 







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







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
50
51
52
53
54
55
56























































57
58
59
60
61
62
63
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

type
  TNppPluginPreviewHTML = class(TNppPlugin)
  private
    FSettings: TIniFile;
  public
    constructor Create;

    procedure SetInfo(NppData: TNppData); override;

    procedure CommandShowPreview;
    procedure CommandSetIEVersion(const BrowserEmulation: Integer);
    procedure CommandOpenFile(const Filename: nppString);
    procedure CommandShowAbout;
    procedure CommandReplaceHelloWorld;

    procedure DoNppnToolbarModification; override;
................................................................................
  Npp: TNppPluginPreviewHTML;

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
























































{ ------------------------------------------------------------------------------------------------ }
procedure _FuncReplaceHelloWorld; cdecl;
begin
  Npp.CommandReplaceHelloWorld;
end;
{ ------------------------------------------------------------------------------------------------ }
procedure _FuncOpenSettings; cdecl;
................................................................................
end;
{ ------------------------------------------------------------------------------------------------ }
procedure _FuncSetIE13; cdecl;
begin
  Npp.CommandSetIEVersion(13000);
end;


{ ================================================================================================ }
{ TNppPluginPreviewHTML }

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

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.SetInfo(NppData: TNppData);
var
  IEVersion: string;
  MajorIEVersion, Code, EmulatedVersion: Integer;
  sk: TShortcutKey;
begin
  inherited;

  sk.IsShift := True; sk.IsCtrl := true; sk.IsAlt := False;
  sk.Key := 'H'; // Ctrl-Shift-H
  self.AddFuncItem('&Preview HTML', _FuncShowPreview, sk);

  IEVersion := GetIEVersion;
  with GetSettings do begin
    IEVersion := ReadString('Emulation', 'Installed IE version', IEVersion);
    Free;
  end;
  Val(IEVersion, MajorIEVersion, Code);
  if Code <= 1 then
    MajorIEVersion := 0;

  EmulatedVersion := GetBrowserEmulation div 1000;

  if MajorIEVersion > 7 then begin
    self.AddFuncSeparator;
    self.AddFuncItem('View as IE&7', _FuncSetIE7, EmulatedVersion = 7);
  end;

  if MajorIEVersion >= 8 then
    self.AddFuncItem('View as IE&8', _FuncSetIE8, EmulatedVersion = 8);
  if MajorIEVersion >= 9 then
    self.AddFuncItem('View as IE&9', _FuncSetIE9, EmulatedVersion = 9);
  if MajorIEVersion >= 10 then
    self.AddFuncItem('View as IE1&0', _FuncSetIE10, EmulatedVersion = 10);
  if MajorIEVersion >= 11 then
    self.AddFuncItem('View as IE1&1', _FuncSetIE11, EmulatedVersion = 11);
  if MajorIEVersion >= 12 then
    self.AddFuncItem('View as IE1&2', _FuncSetIE12, EmulatedVersion = 12);
  if MajorIEVersion >= 13 then
    self.AddFuncItem('View as IE1&3', _FuncSetIE13, EmulatedVersion = 13);

  self.AddFuncSeparator;

  self.AddFuncItem('Edit &settings', _FuncOpenSettings);
  self.AddFuncItem('Edit &filter definitions', _FuncOpenFilters);

  self.AddFuncSeparator;

  self.AddFuncItem('&About', _FuncShowAbout);
end {TNppPluginPreviewHTML.SetInfo};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.CommandOpenFile(const Filename: nppString);
var
  FullPath: nppString;
begin
  try

Changes to src/lib/WebBrowser.pas.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
145
146
147
148
149
150
151



152
153












154
155
156
157
158



159
160
161
162
163
164
165
166
167
168
169
170

function GetBrowserEmulation: Integer;
procedure SetBrowserEmulation(const Value: Integer);
function GetIEVersion: string;

implementation
uses
  SysUtils, Forms, ActiveX, Variants, Registry, Windows;

{ ------------------------------------------------------------------------------------------------ }
procedure TWBHelper.ExecJS(const Code: string);
begin
  GetDocument.parentWindow.execScript(Code, 'JScript');
end;

................................................................................
    RegKey.Free;
  end;
end {SetBrowserEmulation};

{ ------------------------------------------------------------------------------------------------ }
function GetIEVersion: string;
var



  Reg: TRegistry;
begin












  try
    Reg := TRegistry.Create;
    try
      Reg.RootKey := HKEY_LOCAL_MACHINE;
      Reg.OpenKeyReadOnly('Software\Microsoft\Internet Explorer');



      Result := Reg.ReadString('Version');
      Reg.CloseKey;
    finally
      Reg.Free;
    end;
  except
    Result := '';
  end;
end {GetIEVersion};


end.







|







 







>
>
>


>
>
>
>
>
>
>
>
>
>
>
>





>
>
>
|











20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

function GetBrowserEmulation: Integer;
procedure SetBrowserEmulation(const Value: Integer);
function GetIEVersion: string;

implementation
uses
  SysUtils, Forms, ActiveX, Variants, Registry, Windows, L_VersionInfoW;

{ ------------------------------------------------------------------------------------------------ }
procedure TWBHelper.ExecJS(const Code: string);
begin
  GetDocument.parentWindow.execScript(Code, 'JScript');
end;

................................................................................
    RegKey.Free;
  end;
end {SetBrowserEmulation};

{ ------------------------------------------------------------------------------------------------ }
function GetIEVersion: string;
var
  Exe: string;
  Dummy: PChar;
  VerInfo: TFileVersionInfo;
  Reg: TRegistry;
begin
  SetLength(Exe, MAX_PATH);
  SetLength(Exe, SearchPath(nil, 'iexplore.exe', nil, MAX_PATH, PChar(Exe), Dummy));
  if Length(Exe) > 0 then begin
    VerInfo := TFileVersionInfo.Create(Exe);
    try
      Result := Format('%d.%d.%d.%d', [VerInfo.MajorVersion, VerInfo.MinorVersion, VerInfo.Revision, VerInfo.Build]);
      Exit;
    finally
      VerInfo.Free;
    end;
  end;

  try
    Reg := TRegistry.Create;
    try
      Reg.RootKey := HKEY_LOCAL_MACHINE;
      Reg.OpenKeyReadOnly('Software\Microsoft\Internet Explorer');
      if Reg.ValueExists('svcVersion') then
        Result := Reg.ReadString('svcVersion')
      else
        Result := Reg.ReadString('Version');
      Reg.CloseKey;
    finally
      Reg.Free;
    end;
  except
    Result := '';
  end;
end {GetIEVersion};


end.

Changes to src/lib/nppplugin.pas.

510
511
512
513
514
515
516

517
518
519
520
521
522
523

    // df
    function DoOpen(filename: String): boolean; overload;
    function DoOpen(filename: String; Line: Integer): boolean; overload;
    procedure GetFileLine(var filename: String; var Line: Integer);
    function GetWord: string;


    property ConfigDir: string  read GetPluginsConfigDir;
  end;


implementation

{ TNppPlugin }







>







510
511
512
513
514
515
516
517
518
519
520
521
522
523
524

    // df
    function DoOpen(filename: String): boolean; overload;
    function DoOpen(filename: String; Line: Integer): boolean; overload;
    procedure GetFileLine(var filename: String; var Line: Integer);
    function GetWord: string;

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


implementation

{ TNppPlugin }

Changes to src/prj/PreviewHTML.dproj.

23
24
25
26
27
28
29






30
31
32
33
34
35
36
..
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
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
			<Cfg_1>true</Cfg_1>
			<CfgParent>Base</CfgParent>
			<Base>true</Base>






		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
			<Cfg_2>true</Cfg_2>
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
................................................................................
			<DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_1)'!=''">
			<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
			<DCC_DebugInformation>false</DCC_DebugInformation>
			<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
			<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>




		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_2)'!=''">
			<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)'!=''">
			<VerInfo_MinorVer>4</VerInfo_MinorVer>
			<VerInfo_Debug>true</VerInfo_Debug>
			<VerInfo_Keys>CompanyName=Voronwë;FileDescription=HTML Preview plugin for Notepad++;FileVersion=1.4.0.0;InternalName=PreviewHTML;LegalCopyright=© Martijn Coppoolse;LegalTrademarks=;OriginalFilename=PreviewHTML.dll;ProductName=Notepad++;ProductVersion=6.0.0.0;Comments=http://martijn.coppoolse.com/software</VerInfo_Keys>
			<PostBuildEvent><![CDATA[]]></PostBuildEvent>
		</PropertyGroup>
		<ItemGroup>
			<DelphiCompile Include="$(MainSource)">
				<MainSource>MainSource</MainSource>
			</DelphiCompile>
			<RcCompile Include="PreviewHTML_TB.rc">







>
>
>
>
>
>







 







>
>
>
>








|

|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
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
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
			<Cfg_1>true</Cfg_1>
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
			<Cfg_1_Win32>true</Cfg_1_Win32>
			<CfgParent>Cfg_1</CfgParent>
			<Cfg_1>true</Cfg_1>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
			<Cfg_2>true</Cfg_2>
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
................................................................................
			<DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_1)'!=''">
			<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
			<DCC_DebugInformation>false</DCC_DebugInformation>
			<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
			<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
			<VerInfo_Keys>CompanyName=Voronwë;FileDescription=HTML Preview plugin for Notepad++;FileVersion=1.3.1.0;InternalName=PreviewHTML;LegalCopyright=© Martijn Coppoolse;LegalTrademarks=;OriginalFilename=PreviewHTML.dll;ProductName=Notepad++;ProductVersion=6.0.0.0;Comments=http://martijn.coppoolse.com/software</VerInfo_Keys>
			<VerInfo_Release>1</VerInfo_Release>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_2)'!=''">
			<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)'!=''">
			<VerInfo_Release>1</VerInfo_Release>
			<VerInfo_Debug>true</VerInfo_Debug>
			<VerInfo_Keys>CompanyName=Voronwë;FileDescription=HTML Preview plugin for Notepad++;FileVersion=1.3.1.0;InternalName=PreviewHTML;LegalCopyright=© Martijn Coppoolse;LegalTrademarks=;OriginalFilename=PreviewHTML.dll;ProductName=Notepad++;ProductVersion=6.0.0.0;Comments=http://martijn.coppoolse.com/software</VerInfo_Keys>
			<PostBuildEvent><![CDATA[]]></PostBuildEvent>
		</PropertyGroup>
		<ItemGroup>
			<DelphiCompile Include="$(MainSource)">
				<MainSource>MainSource</MainSource>
			</DelphiCompile>
			<RcCompile Include="PreviewHTML_TB.rc">