richmemo: added hittest (CharAtPos) example

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4087 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2015-04-19 03:30:11 +00:00
parent 8d29dccb15
commit a32406dc1d
4 changed files with 184 additions and 0 deletions

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="hittest"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="richmemopackage"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="hittest.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="hittest"/>
</Unit0>
<Unit1>
<Filename Value="mainform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="mainform"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="hittest"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program hittest;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, mainform
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,32 @@
object Form1: TForm1
Left = 457
Height = 240
Top = 261
Width = 320
Caption = 'Form1'
ClientHeight = 240
ClientWidth = 320
LCLVersion = '1.2.4.0'
object RichMemo1: TRichMemo
Left = 8
Height = 208
Top = 16
Width = 304
Anchors = [akTop, akLeft, akRight, akBottom]
HideSelection = False
Lines.Strings = (
'Move mouse cursor over this Rich Memo. '
'Form caption should change to the result of '
'CharAtPos'
'123457890 123457890 123457890'
''
''
'123457890 123457890 123457890'
)
OnMouseMove = RichMemo1MouseMove
Rtf = '{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Segoe UI;}{\f1\fnil Segoe UI;}}'#13#10'{\*\generator Riched20 6.3.9600}\viewkind4\uc1 '#13#10'\pard\f0\fs18 Move mouse cursor over this Rich Memo. Form caption should change to the result of CharAtPos\par'#13#10'123457890 123457890 123457890\par'#13#10'\par'#13#10'\par'#13#10'123457890 123457890 123457890\f1\par'#13#10'\par'#13#10'}'#13#10#0
ScrollBars = ssVertical
TabOrder = 0
ZoomFactor = 1
end
end

View File

@ -0,0 +1,40 @@
unit mainform;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, RichMemo;
type
{ TForm1 }
TForm1 = class(TForm)
RichMemo1: TRichMemo;
procedure RichMemo1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.RichMemo1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Caption:=IntToStr(RichMemo1.CharAtPos(x,y));
end;
end.