[Ocs-comps-commits] OCS2/Samples/VCL/AddinManager/complex/RichEdit Client1.cfg,NONE,1.1 Client1.dof,
Brought to you by:
tectsoft
Update of /cvsroot/ocs-comps/OCS2/Samples/VCL/AddinManager/complex/RichEdit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10593/Samples/VCL/AddinManager/complex/RichEdit Added Files: Client1.cfg Client1.dof Client1.dpr Client1.res Client2.cfg Client2.dof Client2.dpr Client2.res OrckaRichEditServer.pas OrckaRichEditShared.pas overview.rtf RichEdit.cfg RichEdit.dof RichEdit.dpr RichEdit.res RichEditPluginDemo.bpg Unit1.dfm Unit1.pas Log Message: Initially added to source control --- NEW FILE: OrckaRichEditServer.pas --- unit OrckaRichEditServer; interface uses ShareMem, Classes, ComCtrls, OrckaRichEditShared, Windows; type TRichEditServerMain = class(TRichEditServerTwo) private FClientList: TList; procedure CheckFileSave; function GetClientTwo(Index: Integer): TRichEditClientTwo; protected function GetClientCount: Longint; function GetClient(Index: Longint): TRichEditClient; public constructor Create; destructor Destroy; override; (* These are the methods that the Clients can call *) function InsertClient(AClient: TRichEditClient): Boolean; override; function RemoveClient(AClient: TRichEditClient): Boolean; override; procedure Print(PrintCaption: TString); override; (* This method was introduced in version 2 *) procedure OpenTemplate(TemplateName: TString); override; (* These Methods are used by the exe to control the Addins *) function CanClose: Boolean; function New: Boolean; procedure AfterNew; function BeforePrint: Boolean; procedure AfterPrint; function OpenDocument: Boolean; function SaveDocument(FileName: string): Boolean; function SaveDocumentAs: Boolean; (* MessageBox wrapper *) function MsgBox(Msg: string; Caption: string = 'RichEdit Demo'; uType: Longint = MB_OK): Longint; (* Properties to get Client information *) property Count: Longint read GetClientCount; property Client[Index: Longint]: TRichEditClient read GetClient; property ClientTwo[Index: Longint]: TRichEditClientTwo read GetClientTwo; end; implementation uses SysUtils, Unit1; const CurrentVersion = 2; { TRichEditServerMain } function TRichEditServerMain.GetClient(Index: Longint): TRichEditClient; begin Result := TRichEditClient(FClientList.Items[Index]); end; function TRichEditServerMain.GetClientCount: Longint; begin Result := FClientList.Count; end; constructor TRichEditServerMain.Create; begin FClientList := TList.Create; end; destructor TRichEditServerMain.Destroy; begin FClientList.Free; inherited Destroy; end; function TRichEditServerMain.InsertClient( AClient: TRichEditClient): Boolean; var cName, aName: string; I: Longint; begin Result := False; cName := AClient.GetName; for i := 0 to Count -1 do begin aName := Client[I].GetName; if CompareText(aName, cName) = 0 then Exit; end; (* if we get here then the client hasn't been added before check the clients version we are currently supporting version 2 *) if AClient.GetVersion > CurrentVersion then Exit; FClientList.Add(AClient); Result := True; end; function TRichEditServerMain.RemoveClient( AClient: TRichEditClient): Boolean; var I: Longint; begin Result := False; for I := Count -1 downto 0 do begin if AClient = Client[I] then begin FClientList[I] := nil; Result := True; Break; end; end; end; procedure TRichEditServerMain.Print(PrintCaption: TString); begin Form1.RichEdit1.Print(PrintCaption); end; procedure TRichEditServerMain.OpenTemplate(TemplateName: TString); begin end; function TRichEditServerMain.CanClose: Boolean; var I: Longint; Cancel: Boolean; begin (* This method was introduced in Version 2 of RichEdit EXE *) Cancel := False; for I := Count -1 downto 0 do begin if Client[I].GetVersion > 1 then ClientTwo[I].Closing(Cancel); if Cancel then Break; end; Result := not Cancel; end; function TRichEditServerMain.New: Boolean; var I: Longint; begin CheckFileSave; Result := False; for I := 0 to Count -1 do begin if Client[I].GetVersion > 1 then ClientTwo[I].BeforeNew(Result); if Result then Exit; end; Form1.SetFileName(sNewDocument); Form1.RichEdit1.Lines.Clear; Form1.HasChanged := False; AfterNew; end; procedure TRichEditServerMain.AfterNew; var I: Longint; begin for I := 0 to Count -1 do begin if Client[I].GetVersion > 1 then ClientTwo[I].AfterNew; end; end; function TRichEditServerMain.BeforePrint: Boolean; var I: Longint; begin Result := False; (* Ask each client if they will allow printing *) for I := 0 to Count -1 do begin Client[I].BeforePrint(Result); (* if They won't allow printing then don't ask further clients *) if Result then Break; end; (* Negate Result *) Result := not Result; (* if we can still print then print the document *) if Result then Print('Orcka Addin Manager Demo'#0); end; procedure TRichEditServerMain.AfterPrint; var I: Longint; begin for I := 0 to Count -1 do Client[I].AfterPrint; end; function TRichEditServerMain.OpenDocument: Boolean; var I: Longint; FName: TString; begin Result := False; FillChar(FName, SizeOf(TString), 0); CheckFileSave; for I := 0 to Count -1 do begin Client[I].DoOpenDocument(FName, Result); if Result then Break; end; Result := not Result; if Result then begin if Form1.OpenDialog1.Execute then Form1.OpenDocument(Form1.OpenDialog1.FileName); end else begin Form1.OpenDocument(FNAme); end; end; function TRichEditServerMain.SaveDocument(FileName: string): Boolean; begin CheckFileSave; if Form1.OpenDialog1.Execute then begin Form1.OpenDocument(Form1.OpenDialog1.FileName); //Form1.RichEdit1.ReadOnly := ofReadOnly in Form1.OpenDialog1.Options; end; end; procedure TRichEditServerMain.CheckFileSave; begin if not Form1.HasChanged then Exit; case MsgBox(Format(sSave, [Form1.FileName]), sCaption, MB_YESNOCANCEL or MB_ICONQUESTION) of IDYes: if Form1.FileName = sNewDocument then begin if Form1.SaveDialog1.Execute then Form1.SaveDocument(Form1.SaveDialog1.FileName); end else Form1.SaveDocument(Form1.FileName); IDCancel: Abort; end; end; function TRichEditServerMain.MsgBox(Msg: string; Caption: string = 'RichEdit Demo'; uType: Longint = MB_OK): Longint; begin Result := MessageBox(Form1.Handle, PChar(Msg), PChar(Caption), uType); end; function TRichEditServerMain.SaveDocumentAs: Boolean; begin with Form1 do begin if SaveDialog1.Execute then begin if FileExists(SaveDialog1.FileName) then if MSgBox(Format(sOverWrite, [SaveDialog1.FileName]), sCaption, MB_YESNOCANCEL or MB_ICONEXCLAMATION) <> idYes then Exit; RichEdit1.Lines.SaveToFile(SaveDialog1.FileName); SetFileName(SaveDialog1.FileName); HasChanged := False; end; end; end; function TRichEditServerMain.GetClientTwo( Index: Integer): TRichEditClientTwo; begin Result := TRichEditClientTwo(FClientList.Items[Index]); end; end. --- NEW FILE: Client1.dpr --- library Client1; uses OrckaRichEditShared, Graphics, Windows,OrckaAddinManagerShared; {$R *.RES} type TClientOne = class(TRichEditClient) private FRichEditServer: TRichEditServer; FService: TOToolServices; public constructor Create(AService: TOToolServices; ARichEditServer: TRichEditServer); destructor Destroy; override; function GetVersion: Longint; override; function GetName: TString; override; procedure DoOpenDocument(var FileName: TString; var Handled: Boolean); override; procedure DoSaveDocument(var FileName: TString; var Handled: Boolean); override; procedure BeforePrint(var Cancel: Boolean); override; procedure AfterPrint; override; end; { TClientOne } const ClientName = 'Client One'; Version = 1; var ClientTwo: TClientOne; procedure PluginExit; stdcall; begin ClientTwo.Free; end; function Plugin (InParams: TOrckaAddinManagerParams; var ExitProc: Pointer): Boolean; stdcall; begin ClientTwo := TClientOne.Create(InParams.Service, InParams.User); ExitProc := @PluginExit; Result := True; end; exports Plugin name OrckaAddinManagerExportProc; constructor TClientOne.Create(AService: TOToolServices; ARichEditServer: TRichEditServer); begin FService := AService; FRichEditServer := ARichEditServer; FRichEditServer.InsertClient(Self); end; destructor TClientOne.Destroy; begin FRichEditServer.RemoveClient(Self); inherited Destroy; end; procedure TClientOne.AfterPrint; begin MessageBox(FService.GetHandle, Pchar(ClientName + ' After Print'), PChar(ClientName), MB_OK); end; procedure TClientOne.BeforePrint(var Cancel: Boolean); begin if MessageBox(FService.GetHandle, Pchar(ClientName + ' Before Print'#13#13 + 'Do you want to cancel printing'), PChar(ClientName), MB_YESNO) = IDYes then Cancel := True else Cancel := False; end; procedure TClientOne.DoOpenDocument(var FileName: TString; var Handled: Boolean); begin Handled := True; FileName := 'c:\Boot.Ini'; end; procedure TClientOne.DoSaveDocument(var FileName: TString; var Handled: Boolean); begin MessageBox(FService.GetHandle, PChar(ClientName + 'Save Document'), PChar(ClientName), MB_OK); end; function TClientOne.GetName: TString; begin Result := ClientName; end; function TClientOne.GetVersion: Longint; begin Result := Version; end; begin end. --- NEW FILE: RichEdit.res --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Client2.dof --- [FileVersion] Version=6.0 [Compiler] A=0 B=0 C=1 D=1 E=0 F=0 G=1 H=1 I=0 J=1 K=0 L=1 M=0 N=1 O=0 P=1 Q=0 R=0 S=0 T=1 U=0 V=1 W=0 X=1 Y=1 Z=1 ShowHints=1 ShowWarnings=1 UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [Linker] MapFile=0 OutputObjs=0 ConsoleApp=1 DebugInfo=0 RemoteSymbols=0 MinStackSize=16384 MaxStackSize=1048576 ImageBase=4194304 ExeDescription= [Directories] OutputDir= UnitOutputDir= PackageDLLOutputDir= PackageDCPOutputDir= SearchPath=D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source Packages=Vcl50;Vclx50;VclSmp50;Qrpt50;Vcldb50;Vclbde50;ibevnt50;vcldbx50;TeeUI50;TeeDB50;Tee50;TeeQR50;VCLIB50;vclie50;Inetdb50;Inet50;NMFast50;dclocx50;dclaxserver50 Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] RunParams= HostApplication= Launcher= UseLauncher=0 DebugCWD= [Language] ActiveLang= ProjectLang=$00000409 RootDir= [Version Info] IncludeVerInfo=1 AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=0 Build=8 Debug=0 PreRelease=0 Special=0 Private=0 DLL=0 Locale=1033 CodePage=1252 [Version Info Keys] CompanyName=Orcka FileDescription= FileVersion=1.0.0.8 InternalName= LegalCopyright=Copyright © 2000. Orcka Development. LegalTrademarks= OriginalFilename= ProductName= ProductVersion=1.0.0.0 Comments= [HistoryLists\hlUnitAliases] Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlSearchPath] Count=1 Item0=D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source --- NEW FILE: Client2.cfg --- -$A0 -$B- -$C+ -$D+ -$E- -$F- -$G+ -$H+ -$I- -$J+ -$K- -$L+ -$M- -$N+ -$O- -$P+ -$Q- -$R- -$S- -$T+ -$U- -$V+ -$W- -$X+ -$YD -$Z1 -cg -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -H+ -W+ -M -$M16384,1048576 -K$00400000 -LE"d:\program files\borland\delphi6\Projects\Bpl" -LN"d:\program files\borland\delphi6\Projects\Bpl" -U"D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source" -O"D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source" -I"D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source" -R"D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source" --- NEW FILE: RichEdit.dpr --- program RichEdit; uses ShareMem, Forms, Unit1 in 'Unit1.pas' {Form1}, OrckaRichEditShared in 'OrckaRichEditShared.pas', OrckaRichEditServer in 'OrckaRichEditServer.pas'; {$R *.RES} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. --- NEW FILE: Client1.dof --- [FileVersion] Version=6.0 [Compiler] A=0 B=0 C=1 D=1 E=0 F=0 G=1 H=1 I=0 J=1 K=0 L=1 M=0 N=1 O=0 P=1 Q=0 R=0 S=0 T=1 U=0 V=1 W=0 X=1 Y=1 Z=1 ShowHints=1 ShowWarnings=1 UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [Linker] MapFile=0 OutputObjs=0 ConsoleApp=1 DebugInfo=0 RemoteSymbols=0 MinStackSize=16384 MaxStackSize=1048576 ImageBase=4194304 ExeDescription= [Directories] OutputDir= UnitOutputDir= PackageDLLOutputDir= PackageDCPOutputDir= SearchPath=D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source Packages=Vcl50;Vclx50;VclSmp50;Qrpt50;Vcldb50;Vclbde50;ibevnt50;vcldbx50;TeeUI50;TeeDB50;Tee50;TeeQR50;VCLIB50;vclie50;Inetdb50;Inet50;NMFast50;dclocx50;dclaxserver50 Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] RunParams= HostApplication= Launcher= UseLauncher=0 DebugCWD= [Language] ActiveLang= ProjectLang=$00000409 RootDir= [Version Info] IncludeVerInfo=1 AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=0 Build=3 Debug=0 PreRelease=0 Special=0 Private=0 DLL=0 Locale=1033 CodePage=1252 [Version Info Keys] CompanyName=Orcka FileDescription= FileVersion=1.0.0.3 InternalName= LegalCopyright=Copyright © 2000. Orcka Development. LegalTrademarks= OriginalFilename= ProductName= ProductVersion=1.0.0.0 Comments= [HistoryLists\hlUnitAliases] Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlSearchPath] Count=1 Item0=D:\packages\CDGen\Source;D:\packages\CDMail\Source;D:\packages\CDSubCls\Source --- NEW FILE: RichEdit.cfg --- -$A1 -$B- -$C+ -$D+ -$E- -$F- -$G+ -$H+ -$I- -$J+ -$K- -$L+ -$M- -$N+ -$O- -$P+ -$Q- -$R- -$S- -$T+ -$U- -$V+ -$W- -$X+ -$YD -$Z1 -cg -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -H+ -W+ -M -$M16384,1048576 -K$00400000 -LE"d:\program files\borland\delphi6\Projects\Bpl" -LN"d:\program files\borland\delphi6\Projects\Bpl" --- NEW FILE: overview.rtf --- {\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fcharset1 MS Sans Serif;}{\f3\fswiss Arial;}{\f4\fscript Mistral;}} {\colortbl\red0\green0\blue0;\red255\green0\blue255;\red255\green0\blue0;\red0\green0\blue255;} \deflang1033\pard\qc\plain\f3\fs32\cf1\b Rich Edit Control Overview\plain\f3\fs32\cf2\b \par \plain\f3\fs16\cf0\b (from Win32SDK Help) \par \pard\plain\f3\fs20\cf0 \par \pard\li500\ri840\fi-20\plain\f4\fs30\cf0 A rich edit control is a window in which the user can enter and edit text. The text can be assigned character and paragraph formatting, and can include embedded OLE objects. Rich edit controls provide a programming interface for formatting text. However, an application must implement any user interface components necessary to make formatting operations available to the user\plain\f3\fs20\cf0 . \par \pard\li480\ri840\plain\f3\fs20\cf0 \par Rich edit controls support almost all of the messages and notification messages used with multiline edit controls. Thus, applications that already use edit controls can be easily changed to use rich edit controls. Additional messages and notifications enable applications to access the functionality unique to rich edit controls. For information about edit controls, see \plain\f3\fs20\cf0\i Edit Controls\plain\f3\fs20\cf0 . \par \par An application can send messages to a rich edit control to perform such operations as formatting text, printing, and saving. An application can process notification messages to monitor events in a rich edit control. For example, an application can process notifications to filter keyboard and mouse input, to permit or deny changes to protected text, or to resize the control as needed to fit its content. \par \par You create a rich edi\plain\f3\fs20\cf0\i t co\plain\f3\fs20\cf0 ntrol by using the \plain\f3\fs20\cf3\b\ul CreateWindowEx\plain\f3\fs20\cf0 function, specifying the "RichEdit" window class. Because the common control library registers this window class, you must call the \plain\f3\fs20\cf0\b\ul InitCommonControls\plain\f3\fs20\cf0 function to ensure that the library is loaded before the rich edit control is created. \par \par Rich edit controls support most of the window styles used with edit controls as well as additional styles. You should specify the \plain\f3\fs20\cf0\b ES_MULTILINE\plain\f3\fs20\cf0 window style if you want to allow more than one line of text in the control. \par } |