From ae5a222a8ce41b920593c2d2a7f3911acc7861f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 26 Aug 2016 13:55:46 +0000 Subject: h++ to use RichEdit50W control only git-svn-id: http://svn.miranda-ng.org/main/trunk@17209 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HistoryPlusPlus/HistoryGrid.pas | 2 - plugins/HistoryPlusPlus/historypp.dpr | 11 --- plugins/HistoryPlusPlus/historypp.dproj | 2 + plugins/HistoryPlusPlus/hpp_global.pas | 1 - plugins/HistoryPlusPlus/hpp_itemprocess.pas | 19 +++--- plugins/HistoryPlusPlus/hpp_richedit.pas | 100 ++++------------------------ 6 files changed, 23 insertions(+), 112 deletions(-) diff --git a/plugins/HistoryPlusPlus/HistoryGrid.pas b/plugins/HistoryPlusPlus/HistoryGrid.pas index 6954426099..0076e33b1c 100644 --- a/plugins/HistoryPlusPlus/HistoryGrid.pas +++ b/plugins/HistoryPlusPlus/HistoryGrid.pas @@ -3343,8 +3343,6 @@ begin P := Point(X - RichEditRect.Left, Y - RichEditRect.Top); ApplyItemToRich(Item); - if FRich.Version < 30 then - exit; // TOM is supported from RE 3.0 if not Assigned(FRich.RichEditOle) then exit; diff --git a/plugins/HistoryPlusPlus/historypp.dpr b/plugins/HistoryPlusPlus/historypp.dpr index 682377d73e..7a5a4dbd09 100644 --- a/plugins/HistoryPlusPlus/historypp.dpr +++ b/plugins/HistoryPlusPlus/historypp.dpr @@ -165,17 +165,6 @@ begin hppCodepage := Langpack_GetDefaultCodePage; if hppCodepage = CP_ACP then hppCodepage := GetACP(); - // Checking the version of richedit is available, need 2.0+ - hppRichEditVersion := InitRichEditLibrary; - if hppRichEditVersion < 20 then - begin - hppMessagebox(hppMainWindow, FormatCString( // single line to translation script - TranslateW - ('History++ module could not be loaded, Rich Edit 2.0+ module is missing.\nPress OK to continue loading Miranda.') - ), hppName + ' Information', MB_OK or MB_ICONINFORMATION); - Result := 1; - exit; - end; // init history functions later HookModulesLoad := HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoad); diff --git a/plugins/HistoryPlusPlus/historypp.dproj b/plugins/HistoryPlusPlus/historypp.dproj index 88f6028e9f..15842904da 100644 --- a/plugins/HistoryPlusPlus/historypp.dproj +++ b/plugins/HistoryPlusPlus/historypp.dproj @@ -133,6 +133,8 @@ ..\..\bin12\Debug64\Obj\hpp\ + W:\miranda-ng\bin12\Debug + W:\miranda-ng\bin12\Debug\Miranda32.exe true diff --git a/plugins/HistoryPlusPlus/hpp_global.pas b/plugins/HistoryPlusPlus/hpp_global.pas index d0b04669c6..c549f5b9c4 100644 --- a/plugins/HistoryPlusPlus/hpp_global.pas +++ b/plugins/HistoryPlusPlus/hpp_global.pas @@ -270,7 +270,6 @@ const var hppCodepage: Cardinal; - hppRichEditVersion: Integer; {$I m_historypp.inc} diff --git a/plugins/HistoryPlusPlus/hpp_itemprocess.pas b/plugins/HistoryPlusPlus/hpp_itemprocess.pas index 3d5204c4c4..858bd2daa5 100644 --- a/plugins/HistoryPlusPlus/hpp_itemprocess.pas +++ b/plugins/HistoryPlusPlus/hpp_itemprocess.pas @@ -96,7 +96,6 @@ type bbtype: TBBCodeType; rtf: PAnsiChar; html: PAnsiChar; - minRE: Integer; end; const @@ -116,21 +115,21 @@ const var bbCodes: array[0..bbCodesCount,bbStart..bbEnd] of TBBCodeInfo = ( - ((prefix:(ansi:'[b]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\b '; html:''; minRE: 10), + ((prefix:(ansi:'[b]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\b '; html:''), (prefix:(ansi:'[/b]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}'; html:'')), - ((prefix:(ansi:'[i]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\i '; html:''; minRE: 10), + ((prefix:(ansi:'[i]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\i '; html:''), (prefix:(ansi:'[/i]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}'; html:'')), - ((prefix:(ansi:'[u]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\ul '; html:''; minRE: 10), + ((prefix:(ansi:'[u]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\ul '; html:''), (prefix:(ansi:'[/u]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}'; html:'')), - ((prefix:(ansi:'[s]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\strike '; html:''; minRE: 10), + ((prefix:(ansi:'[s]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'{\strike '; html:''), (prefix:(ansi:'[/s]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}'; html:'')), - ((prefix:(ansi:'[color='); suffix:(ansi:']'); bbtype:bbColor; rtf:'{\cf%u '; html:''; minRE: 10), + ((prefix:(ansi:'[color='); suffix:(ansi:']'); bbtype:bbColor; rtf:'{\cf%u '; html:''), (prefix:(ansi:'[/color]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}'; html:'')), - ((prefix:(ansi:'[url='); suffix:(ansi:']'); bbtype:bbUrl; rtf:'{\field{\*\fldinst{HYPERLINK ":%s"}}{\fldrslt{\ul\cf%u'; html:''; minRE: 31), + ((prefix:(ansi:'[url='); suffix:(ansi:']'); bbtype:bbUrl; rtf:'{\field{\*\fldinst{HYPERLINK ":%s"}}{\fldrslt{\ul\cf%u'; html:''), (prefix:(ansi:'[/url]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}}}'; html:'')), - ((prefix:(ansi:'[size='); suffix:(ansi:']'); bbtype:bbSize; rtf:'{\fs%u '; html:''; minRE: 10), + ((prefix:(ansi:'[size='); suffix:(ansi:']'); bbtype:bbSize; rtf:'{\fs%u '; html:''), (prefix:(ansi:'[/size]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}'; html:'')), - ((prefix:(ansi:'[img]'); suffix:(ansi:nil); bbtype:bbImage; rtf:'[{\revised\ul\cf%u '; html:'['; minRE: 20), + ((prefix:(ansi:'[img]'); suffix:(ansi:nil); bbtype:bbImage; rtf:'[{\revised\ul\cf%u '; html:'['), (prefix:(ansi:'[/img]'); suffix:(ansi:nil); bbtype:bbSimple; rtf:'}]'; html:']')) ); @@ -278,8 +277,6 @@ begin bufEnd := StrECopy(TextBuffer.Buffer,PAnsiChar(S)); for i := 0 to High(bbCodes) do begin - if hppRichEditVersion < bbCodes[i, bbStart].minRE then - continue; bufPos := TextBuffer.Buffer; repeat newCode := nil; diff --git a/plugins/HistoryPlusPlus/hpp_richedit.pas b/plugins/HistoryPlusPlus/hpp_richedit.pas index 8ce5b97a49..6a626c2561 100644 --- a/plugins/HistoryPlusPlus/hpp_richedit.pas +++ b/plugins/HistoryPlusPlus/hpp_richedit.pas @@ -47,8 +47,6 @@ unit hpp_richedit; interface -{$DEFINE AllowMSFTEDIT} - uses Windows, Messages, Classes, RichEdit, ActiveX, Controls, StdCtrls, ComCtrls, Forms; @@ -944,7 +942,6 @@ type THppRichEdit = class(TCustomRichEdit) private - FVersion: Integer; FCodepage: Cardinal; FClickRange: TCharRange; FClickBtn: TMouseButton; @@ -964,7 +961,6 @@ type function UpdateHostNames: Boolean; protected procedure CreateParams(var Params: TCreateParams); override; - procedure CreateWindowHandle(const Params: TCreateParams); override; procedure CreateWnd; override; procedure URLClick(const URLText: String; Button: TMouseButton); dynamic; public @@ -977,7 +973,6 @@ type procedure ReplaceCharFormatRange(const fromCF, toCF: CHARFORMAT2; idx, len: Integer); procedure ReplaceCharFormat(const fromCF, toCF: CHARFORMAT2); property Codepage: Cardinal read FCodepage write FCodepage default CP_ACP; - property Version: Integer read FVersion; property RichEditOle: IRichEditOle read FRichEditOle; published published @@ -1078,8 +1073,6 @@ type true: (DataW: PChar); end; -function InitRichEditLibrary: Integer; - function GetRichRTF(RichEditHandle: THandle; var RTFStream: String; SelectionOnly, PlainText, NoObjects, PlainRTF: Boolean): Integer; overload; function GetRichRTF(RichEditHandle: THandle; var RTFStream: AnsiString; @@ -1119,13 +1112,13 @@ const SF_UNICODE = 16; SF_USECODEPAGE = 32; - RICHEDIT_CLASS20A = 'RICHEDIT20A'; - RICHEDIT_CLASS20W = 'RICHEDIT20W'; MSFTEDIT_CLASS = 'RICHEDIT50W'; +const + MSFTEDIT_DLL = 'MSFTEDIT.DLL'; var + emError : DWord; FRichEditModule: THandle = 0; - FRichEditVersion: Integer = 0; procedure Register; begin @@ -1146,60 +1139,6 @@ begin end; end; -function InitRichEditLibrary: Integer; -const - RICHED20_DLL = 'RICHED20.DLL'; - {$IFDEF AllowMSFTEDIT} - MSFTEDIT_DLL = 'MSFTEDIT.DLL'; - {$ENDIF} -var - {$IFDEF AllowMSFTEDIT} - hModule : THandle; - hVersion: Integer; - {$ENDIF} - emError : DWord; -begin - if FRichEditModule = 0 then - begin - FRichEditVersion := -1; - emError := SetErrorMode(SEM_NOOPENFILEERRORBOX); - try - FRichEditModule := LoadLibrary(RICHED20_DLL); - if FRichEditModule <= HINSTANCE_ERROR then - FRichEditModule := 0; - if FRichEditModule <> 0 then - FRichEditVersion := GetModuleVersionFile(FRichEditModule); -{$IFDEF AllowMSFTEDIT} - repeat - if FRichEditVersion > 40 then - break; - hModule := LoadLibrary(MSFTEDIT_DLL); - if hModule <= HINSTANCE_ERROR then - hModule := 0; - if hModule <> 0 then - begin - hVersion := GetModuleVersionFile(hModule); - if hVersion > FRichEditVersion then - begin - if FRichEditModule <> 0 then - FreeLibrary(FRichEditModule); - FRichEditModule := hModule; - FRichEditVersion := hVersion; - break; - end; - FreeLibrary(hModule); - end; - until True; -{$ENDIF} - if (FRichEditModule <> 0) and (FRichEditVersion = 0) then - FRichEditVersion := 20; - finally - SetErrorMode(emError); - end; - end; - Result := FRichEditVersion; -end; - function RichEditStreamLoad(dwCookie: Longint; pbBuff: PByte; cb: Longint; var pcb: Longint): Longint; stdcall; var pBuff: PAnsiChar; @@ -1547,7 +1486,7 @@ type TAccessCustomMemo = class(TCustomMemo); InheritedCreateParams = procedure(var Params: TCreateParams) of object; - procedure THppRichedit.CreateParams(var Params: TCreateParams); +procedure THppRichedit.CreateParams(var Params: TCreateParams); const aHideScrollBars: array[Boolean] of DWORD = (ES_DISABLENOSCROLL, 0); aHideSelections: array[Boolean] of DWORD = (ES_NOHIDESEL, 0); @@ -1555,19 +1494,10 @@ const var Method: TMethod; begin - FVersion := InitRichEditLibrary; Method.Code := @TAccessCustomMemo.CreateParams; Method.Data := Self; InheritedCreateParams(Method)(Params); - if FVersion >= 20 then - begin -{$IFDEF AllowMSFTEDIT} - if FVersion = 41 then - CreateSubClass(Params, MSFTEDIT_CLASS) - else -{$ENDIF} - CreateSubClass(Params, RICHEDIT_CLASS20W); - end; + CreateSubClass(Params, MSFTEDIT_CLASS); with Params do begin Style := Style or aHideScrollBars[HideScrollBars] or aHideSelections[HideSelection] and @@ -1578,18 +1508,6 @@ begin end; end; -procedure THppRichedit.CreateWindowHandle(const Params: TCreateParams); -begin -(* - {$IFDEF AllowMSFTEDIT} - if FVersion = 41 then - CreateUnicodeHandle(Self, Params, MSFTEDIT_CLASS) else - {$ENDIF} - CreateUnicodeHandle(Self, Params, RICHEDIT_CLASS20W); -*) -inherited; -end; - procedure THppRichedit.CreateWnd; const EM_SETEDITSTYLE = WM_USER + 204; @@ -2052,6 +1970,14 @@ begin end; initialization + emError := SetErrorMode(SEM_NOOPENFILEERRORBOX); + try + FRichEditModule := LoadLibrary(MSFTEDIT_DLL); + if FRichEditModule <= HINSTANCE_ERROR then + FRichEditModule := 0; + finally + SetErrorMode(emError); + end; finalization if FRichEditModule <> 0 then FreeLibrary(FRichEditModule); -- cgit v1.2.3