diff --git a/components/richmemo/samples/testsimple/project1.lpi b/components/richmemo/samples/testsimple/project1.lpi index ef08f6139..f43b24e80 100644 --- a/components/richmemo/samples/testsimple/project1.lpi +++ b/components/richmemo/samples/testsimple/project1.lpi @@ -6,7 +6,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -47,10 +47,10 @@ - - + + - + @@ -135,7 +135,7 @@ - + @@ -190,7 +190,7 @@ - + @@ -236,19 +236,19 @@ - - + + - + - - + + - + @@ -292,7 +292,7 @@ - + @@ -317,10 +317,10 @@ - - + + - + @@ -329,70 +329,73 @@ - + + + + - + - - + + - - + + - + - + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - + @@ -400,60 +403,56 @@ - + - + - + - + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - - - diff --git a/components/richmemo/samples/testsimple/unit1.lfm b/components/richmemo/samples/testsimple/unit1.lfm index 7c48c9e5a..b2b78a40a 100644 --- a/components/richmemo/samples/testsimple/unit1.lfm +++ b/components/richmemo/samples/testsimple/unit1.lfm @@ -1,228 +1,108 @@ object Form1: TForm1 - Left = 344 - Height = 596 - Top = 51 - Width = 751 - Align = alNone - AllowDropFiles = False - AutoScroll = True - AutoSize = False - BorderIcons = [biSystemMenu, biMinimize, biMaximize] - BorderStyle = bsSizeable - BorderWidth = 0 + Left = 196 + Height = 457 + Top = 181 + Width = 634 + ActiveControl = RichMemo1 Caption = 'Form1' - ClientHeight = 596 - ClientWidth = 751 - DefaultMonitor = dmActiveForm - DockSite = False - DragKind = dkDrag - DragMode = dmManual - Enabled = True - FormStyle = fsNormal + ClientHeight = 457 + ClientWidth = 634 OnCreate = FormCreate - ParentBiDiMode = True - ParentFont = False - Position = poDesigned - ShowInTaskBar = stDefault - UseDockManager = False LCLVersion = '0.9.27' - WindowState = wsNormal object RichMemo1: TRichMemo - Left = 24 - Height = 432 - Top = 24 - Width = 704 - Align = alNone - Alignment = taLeftJustify + Left = 8 + Height = 366 + Top = 8 + Width = 619 Anchors = [akTop, akLeft, akRight, akBottom] - BorderStyle = bsSingle - Color = clWindow - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True + Font.Height = -13 + Font.Name = 'Tahoma' HideSelection = False Lines.Strings = ( 'RichMemo1' ) - MaxLength = 0 - ParentBidiMode = True - ParentColor = False - ParentFont = True - ParentShowHint = True - ReadOnly = False + ParentFont = False ScrollBars = ssBoth TabOrder = 0 - TabStop = True - Visible = True - WantReturns = True - WantTabs = False WordWrap = False end object Button1: TButton Left = 24 Height = 25 - Top = 472 + Top = 382 Width = 160 - Align = alNone Anchors = [akLeft, akBottom] - AutoSize = False - Cancel = False Caption = 'Make Bold and Red' - Color = clBtnFace - Default = False - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True - ParentBidiMode = True - ModalResult = 0 OnClick = Button1Click - ParentFont = True - ParentShowHint = True TabOrder = 1 - TabStop = True - Visible = True end object Button2: TButton Left = 192 Height = 25 - Top = 472 + Top = 382 Width = 97 - Align = alNone Anchors = [akLeft, akBottom] - AutoSize = False - Cancel = False Caption = 'Get Attribs' - Color = clBtnFace - Default = False - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True - ParentBidiMode = True - ModalResult = 0 OnClick = Button2Click - ParentFont = True - ParentShowHint = True TabOrder = 2 - TabStop = True - Visible = True end object Button3: TButton Left = 304 Height = 25 - Top = 472 + Top = 382 Width = 96 - Align = alNone Anchors = [akLeft, akBottom] - AutoSize = False - Cancel = False Caption = 'Select Font' - Color = clBtnFace - Default = False - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True - ParentBidiMode = True - ModalResult = 0 OnClick = Button3Click - ParentFont = True - ParentShowHint = True TabOrder = 3 - TabStop = True - Visible = True end object Button4: TButton - Left = 112 + Left = 528 Height = 25 - Top = 552 + Top = 382 Width = 75 - Align = alNone - AutoSize = False - Cancel = False + Anchors = [akLeft, akBottom] Caption = 'Export' - Color = clBtnFace - Default = False - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True - ParentBidiMode = True - ModalResult = 0 OnClick = Button4Click - ParentFont = True - ParentShowHint = True TabOrder = 4 - TabStop = True - Visible = True end object Button5: TButton - Left = 24 + Left = 440 Height = 25 - Top = 552 + Top = 382 Width = 75 - Align = alNone - AutoSize = False - Cancel = False + Anchors = [akLeft, akBottom] Caption = 'Import' - Color = clBtnFace - Default = False - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True - ParentBidiMode = True - ModalResult = 0 OnClick = Button5Click - ParentFont = True - ParentShowHint = True TabOrder = 5 - TabStop = True - Visible = True end object Button6: TButton Left = 24 Height = 25 - Top = 504 + Top = 415 Width = 160 - Align = alNone - AutoSize = False - Cancel = False + Anchors = [akLeft, akBottom] Caption = 'Next Style Range' - Color = clBtnFace - Default = False - DragCursor = crDrag - DragKind = dkDrag - DragMode = dmManual - Enabled = True - ParentBidiMode = True - ModalResult = 0 OnClick = Button6Click - ParentFont = True - ParentShowHint = True TabOrder = 6 - TabStop = True - Visible = True end object FontDialog1: TFontDialog MinFontSize = 0 MaxFontSize = 0 - left = 696 - top = 472 + left = 352 + top = 552 end object SaveDialog1: TSaveDialog DefaultExt = '.rtf' Filter = 'RichText file (*.rtf)|*.rtf' Options = [ofOverwritePrompt, ofEnableSizing, ofViewDetail] - left = 616 - top = 472 + left = 280 + top = 552 end object OpenDialog1: TOpenDialog DefaultExt = '.rtf' Filter = 'RichText file (*.rtf)|*.rtf' - left = 536 - top = 472 + left = 208 + top = 552 end end diff --git a/components/richmemo/samples/testsimple/unit1.lrs b/components/richmemo/samples/testsimple/unit1.lrs index e048cac2d..77916e5a7 100644 --- a/components/richmemo/samples/testsimple/unit1.lrs +++ b/components/richmemo/samples/testsimple/unit1.lrs @@ -1,64 +1,34 @@ { This is an automatically generated lazarus resource file } LazarusResources.Add('TForm1','FORMDATA',[ - 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'X'#1#6'Height'#3'T'#2#3'Top'#2'3'#5'Width' - +#3#239#2#5'Align'#7#6'alNone'#14'AllowDropFiles'#8#10'AutoScroll'#9#8'AutoSi' - +'ze'#8#11'BorderIcons'#11#12'biSystemMenu'#10'biMinimize'#10'biMaximize'#0#11 - +'BorderStyle'#7#10'bsSizeable'#11'BorderWidth'#2#0#7'Caption'#6#5'Form1'#12 - +'ClientHeight'#3'T'#2#11'ClientWidth'#3#239#2#14'DefaultMonitor'#7#12'dmActi' - +'veForm'#8'DockSite'#8#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'E' - +'nabled'#9#9'FormStyle'#7#8'fsNormal'#8'OnCreate'#7#10'FormCreate'#14'Parent' - +'BiDiMode'#9#10'ParentFont'#8#8'Position'#7#10'poDesigned'#13'ShowInTaskBar' - +#7#9'stDefault'#14'UseDockManager'#8#10'LCLVersion'#6#6'0.9.27'#11'WindowSta' - +'te'#7#8'wsNormal'#0#9'TRichMemo'#9'RichMemo1'#4'Left'#2#24#6'Height'#3#176#1 - +#3'Top'#2#24#5'Width'#3#192#2#5'Align'#7#6'alNone'#9'Alignment'#7#13'taLeftJ' - +'ustify'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#11'Border' - +'Style'#7#8'bsSingle'#5'Color'#7#8'clWindow'#10'DragCursor'#7#6'crDrag'#8'Dr' - +'agKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'#9#13'HideSelection' - +#8#13'Lines.Strings'#1#6#9'RichMemo1'#0#9'MaxLength'#2#0#14'ParentBidiMode'#9 - +#11'ParentColor'#8#10'ParentFont'#9#14'ParentShowHint'#9#8'ReadOnly'#8#10'Sc' - +'rollBars'#7#6'ssBoth'#8'TabOrder'#2#0#7'TabStop'#9#7'Visible'#9#11'WantRetu' - +'rns'#9#8'WantTabs'#8#8'WordWrap'#8#0#0#7'TButton'#7'Button1'#4'Left'#2#24#6 - +'Height'#2#25#3'Top'#3#216#1#5'Width'#3#160#0#5'Align'#7#6'alNone'#7'Anchors' - +#11#6'akLeft'#8'akBottom'#0#8'AutoSize'#8#6'Cancel'#8#7'Caption'#6#17'Make B' - +'old and Red'#5'Color'#7#9'clBtnFace'#7'Default'#8#10'DragCursor'#7#6'crDrag' - +#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'#9#14'ParentBid' - +'iMode'#9#11'ModalResult'#2#0#7'OnClick'#7#12'Button1Click'#10'ParentFont'#9 - +#14'ParentShowHint'#9#8'TabOrder'#2#1#7'TabStop'#9#7'Visible'#9#0#0#7'TButto' - +'n'#7'Button2'#4'Left'#3#192#0#6'Height'#2#25#3'Top'#3#216#1#5'Width'#2'a'#5 - +'Align'#7#6'alNone'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#8'AutoSize'#8#6'Ca' - +'ncel'#8#7'Caption'#6#11'Get Attribs'#5'Color'#7#9'clBtnFace'#7'Default'#8#10 - +'DragCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7 - +'Enabled'#9#14'ParentBidiMode'#9#11'ModalResult'#2#0#7'OnClick'#7#12'Button2' - +'Click'#10'ParentFont'#9#14'ParentShowHint'#9#8'TabOrder'#2#2#7'TabStop'#9#7 - +'Visible'#9#0#0#7'TButton'#7'Button3'#4'Left'#3'0'#1#6'Height'#2#25#3'Top'#3 - +#216#1#5'Width'#2'`'#5'Align'#7#6'alNone'#7'Anchors'#11#6'akLeft'#8'akBottom' - +#0#8'AutoSize'#8#6'Cancel'#8#7'Caption'#6#11'Select Font'#5'Color'#7#9'clBtn' - +'Face'#7'Default'#8#10'DragCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'Dra' - +'gMode'#7#8'dmManual'#7'Enabled'#9#14'ParentBidiMode'#9#11'ModalResult'#2#0#7 - +'OnClick'#7#12'Button3Click'#10'ParentFont'#9#14'ParentShowHint'#9#8'TabOrde' - +'r'#2#3#7'TabStop'#9#7'Visible'#9#0#0#7'TButton'#7'Button4'#4'Left'#2'p'#6'H' - +'eight'#2#25#3'Top'#3'('#2#5'Width'#2'K'#5'Align'#7#6'alNone'#8'AutoSize'#8#6 - +'Cancel'#8#7'Caption'#6#6'Export'#5'Color'#7#9'clBtnFace'#7'Default'#8#10'Dr' - +'agCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'E' - +'nabled'#9#14'ParentBidiMode'#9#11'ModalResult'#2#0#7'OnClick'#7#12'Button4C' - +'lick'#10'ParentFont'#9#14'ParentShowHint'#9#8'TabOrder'#2#4#7'TabStop'#9#7 - +'Visible'#9#0#0#7'TButton'#7'Button5'#4'Left'#2#24#6'Height'#2#25#3'Top'#3'(' - +#2#5'Width'#2'K'#5'Align'#7#6'alNone'#8'AutoSize'#8#6'Cancel'#8#7'Caption'#6 - +#6'Import'#5'Color'#7#9'clBtnFace'#7'Default'#8#10'DragCursor'#7#6'crDrag'#8 - +'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'#9#14'ParentBidiM' - +'ode'#9#11'ModalResult'#2#0#7'OnClick'#7#12'Button5Click'#10'ParentFont'#9#14 - +'ParentShowHint'#9#8'TabOrder'#2#5#7'TabStop'#9#7'Visible'#9#0#0#7'TButton'#7 - +'Button6'#4'Left'#2#24#6'Height'#2#25#3'Top'#3#248#1#5'Width'#3#160#0#5'Alig' - +'n'#7#6'alNone'#8'AutoSize'#8#6'Cancel'#8#7'Caption'#6#16'Next Style Range'#5 - +'Color'#7#9'clBtnFace'#7'Default'#8#10'DragCursor'#7#6'crDrag'#8'DragKind'#7 - +#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'#9#14'ParentBidiMode'#9#11'Mo' - +'dalResult'#2#0#7'OnClick'#7#12'Button6Click'#10'ParentFont'#9#14'ParentShow' - +'Hint'#9#8'TabOrder'#2#6#7'TabStop'#9#7'Visible'#9#0#0#11'TFontDialog'#11'Fo' - +'ntDialog1'#11'MinFontSize'#2#0#11'MaxFontSize'#2#0#4'left'#3#184#2#3'top'#3 - +#216#1#0#0#11'TSaveDialog'#11'SaveDialog1'#10'DefaultExt'#6#4'.rtf'#6'Filter' - +#6#27'RichText file (*.rtf)|*.rtf'#7'Options'#11#17'ofOverwritePrompt'#14'of' - +'EnableSizing'#12'ofViewDetail'#0#4'left'#3'h'#2#3'top'#3#216#1#0#0#11'TOpen' - +'Dialog'#11'OpenDialog1'#10'DefaultExt'#6#4'.rtf'#6'Filter'#6#27'RichText fi' - +'le (*.rtf)|*.rtf'#4'left'#3#24#2#3'top'#3#216#1#0#0#0 + 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#196#0#6'Height'#3#201#1#3'Top'#3#181#0#5 + +'Width'#3'z'#2#13'ActiveControl'#7#9'RichMemo1'#7'Caption'#6#5'Form1'#12'Cli' + +'entHeight'#3#201#1#11'ClientWidth'#3'z'#2#8'OnCreate'#7#10'FormCreate'#10'L' + +'CLVersion'#6#6'0.9.27'#0#9'TRichMemo'#9'RichMemo1'#4'Left'#2#8#6'Height'#3 + +'n'#1#3'Top'#2#8#5'Width'#3'k'#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight' + +#8'akBottom'#0#11'Font.Height'#2#243#9'Font.Name'#6#6'Tahoma'#13'HideSelecti' + +'on'#8#13'Lines.Strings'#1#6#9'RichMemo1'#0#10'ParentFont'#8#10'ScrollBars'#7 + +#6'ssBoth'#8'TabOrder'#2#0#8'WordWrap'#8#0#0#7'TButton'#7'Button1'#4'Left'#2 + +#24#6'Height'#2#25#3'Top'#3'~'#1#5'Width'#3#160#0#7'Anchors'#11#6'akLeft'#8 + +'akBottom'#0#7'Caption'#6#17'Make Bold and Red'#7'OnClick'#7#12'Button1Click' + +#8'TabOrder'#2#1#0#0#7'TButton'#7'Button2'#4'Left'#3#192#0#6'Height'#2#25#3 + +'Top'#3'~'#1#5'Width'#2'a'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6 + +#11'Get Attribs'#7'OnClick'#7#12'Button2Click'#8'TabOrder'#2#2#0#0#7'TButton' + +#7'Button3'#4'Left'#3'0'#1#6'Height'#2#25#3'Top'#3'~'#1#5'Width'#2'`'#7'Anch' + +'ors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#11'Select Font'#7'OnClick'#7#12 + +'Button3Click'#8'TabOrder'#2#3#0#0#7'TButton'#7'Button4'#4'Left'#3#16#2#6'He' + +'ight'#2#25#3'Top'#3'~'#1#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0 + +#7'Caption'#6#6'Export'#7'OnClick'#7#12'Button4Click'#8'TabOrder'#2#4#0#0#7 + +'TButton'#7'Button5'#4'Left'#3#184#1#6'Height'#2#25#3'Top'#3'~'#1#5'Width'#2 + +'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#6'Import'#7'OnClick'#7 + +#12'Button5Click'#8'TabOrder'#2#5#0#0#7'TButton'#7'Button6'#4'Left'#2#24#6'H' + +'eight'#2#25#3'Top'#3#159#1#5'Width'#3#160#0#7'Anchors'#11#6'akLeft'#8'akBot' + +'tom'#0#7'Caption'#6#16'Next Style Range'#7'OnClick'#7#12'Button6Click'#8'Ta' + +'bOrder'#2#6#0#0#11'TFontDialog'#11'FontDialog1'#11'MinFontSize'#2#0#11'MaxF' + +'ontSize'#2#0#4'left'#3'`'#1#3'top'#3'('#2#0#0#11'TSaveDialog'#11'SaveDialog' + +'1'#10'DefaultExt'#6#4'.rtf'#6'Filter'#6#27'RichText file (*.rtf)|*.rtf'#7'O' + +'ptions'#11#17'ofOverwritePrompt'#14'ofEnableSizing'#12'ofViewDetail'#0#4'le' + +'ft'#3#24#1#3'top'#3'('#2#0#0#11'TOpenDialog'#11'OpenDialog1'#10'DefaultExt' + +#6#4'.rtf'#6'Filter'#6#27'RichText file (*.rtf)|*.rtf'#4'left'#3#208#0#3'top' + +#3'('#2#0#0#0 ]); diff --git a/components/richmemo/samples/testsimple/unit1.pas b/components/richmemo/samples/testsimple/unit1.pas index 820ccb3a1..1fb8513b9 100644 --- a/components/richmemo/samples/testsimple/unit1.pas +++ b/components/richmemo/samples/testsimple/unit1.pas @@ -45,10 +45,14 @@ implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); +var + fp : TFontParams; begin Caption := Format('sel start %d, sel length %d', [RichMemo1.SelStart, RichMemo1.SelLength]); - RichMemo1.SetTextAttributes( - RichMemo1.SelStart, RichMemo1.SelLength, GetFontParams(clRed, [fsBold]) ); + RichMemo1.GetTextAttributes(RichMemo1.SelStart, fp); + fp.Color := clRed; + fp.Style := [fsBold]; + RichMemo1.SetTextAttributes(RichMemo1.SelStart, RichMemo1.SelLength, fp); end; procedure TForm1.Button2Click(Sender: TObject); diff --git a/components/richmemo/win32/win32richmemo.pas b/components/richmemo/win32/win32richmemo.pas index bdeba7266..e2c6394a6 100644 --- a/components/richmemo/win32/win32richmemo.pas +++ b/components/richmemo/win32/win32richmemo.pas @@ -25,7 +25,7 @@ type published class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override; class function GetTextAttributes(const AWinControl: TWinControl; TextStart: Integer; - var Params: TIntFontParams): Boolean; virtual; + var Params: TIntFontParams): Boolean; override; class procedure SetTextAttributes(const AWinControl: TWinControl; TextStart, TextLen: Integer; const Params: TIntFontParams); override; class procedure SetHideSelection(const AWinControl: TWinControl; AHideSelection: Boolean); override; @@ -147,7 +147,10 @@ var OrigLen : Integer; NeedLock : Boolean; begin - if not Assigned(RichEditManager) or not Assigned(AWinControl) then Exit; + if not Assigned(RichEditManager) or not Assigned(AWinControl) then begin + Result := false; + Exit; + end; RichEditManager.GetSelection(AWinControl.Handle, OrigStart, OrigLen); diff --git a/components/richmemo/win32/win32richmemoproc.pas b/components/richmemo/win32/win32richmemoproc.pas index 2dea80586..1fd73ce82 100644 --- a/components/richmemo/win32/win32richmemoproc.pas +++ b/components/richmemo/win32/win32richmemoproc.pas @@ -96,7 +96,7 @@ end; procedure CharFormatToFontParams(const fmt: TCHARFORMAT; var Params: TIntFontParams); begin Params.Name := fmt.szFaceName; - Params.Size := fmt.cbSize; + Params.Size := Round(fmt.yHeight/TwipsInFontSize); Params.Color := fmt.crTextColor; Params.Style := EffectsToFontStyles(fmt.dwEffects); end; @@ -154,8 +154,7 @@ begin fmt.cbSize := sizeof(fmt); fmt.dwMask := CFM_COLOR or CFM_FACE or CFM_SIZE or CFM_EFFECTS; - mask := SendMessage(RichEditWnd, EM_GETCHARFORMAT, w, PtrInt(@fmt)); - if mask = 0 then Exit; + SendMessage(RichEditWnd, EM_GETCHARFORMAT, w, PtrInt(@fmt)); CharFormatToFontParams(fmt, Params); Result := true;