Board index » delphi » TRichEdit freezes program

TRichEdit freezes program

I have a form with a TRichEdit. I do not want the user to copy the text,
so I have not implemented anything for CopyToClipboard and the control
is ReadOnly. But when I press Control-C the program freezes with no
apparent reason. None of the procedures is called, nor KeyDown for the
control or the form. Any way to solve this?

Thanks a lot, Pablo.

Controls in the form:

object fmShowBiograpy: TfmShowBiograpy
  Left = 192
  Top = 116
  Width = 461
  Height = 286
  ActiveControl = reBiographies
  BorderIcons = [biSystemMenu, biMinimize]
  Caption = 'fmShowBiograpy'
  Color = clBtnFace
  Constraints.MaxHeight = 600
  Constraints.MaxWidth = 800
  Constraints.MinHeight = 20
  Constraints.MinWidth = 20
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  KeyPreview = True
  OldCreateOrder = False
  OnClose = FormClose
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object pnChapter: TPanel
    Left = 0
    Top = 0
    Width = 453
    Height = 38
    Align = alTop
    Alignment = taLeftJustify
    Caption = 'pnChapter'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -19
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
    TabOrder = 0
    object cbChapters: TComboBox
      Left = 150
      Top = 7
      Width = 70
      Height = 24
      Style = csDropDownList
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -13
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ItemHeight = 16
      ParentFont = False
      TabOrder = 0
      OnClick = cbChaptersClick
    end
  end
  object reBiographies: TRichEdit
    Left = 0
    Top = 38
    Width = 453
    Height = 221
    Align = alClient
    Lines.Strings = (
      'reBiographies')
    ReadOnly = True
    ScrollBars = ssVertical
    TabOrder = 1
    WantReturns = False
    OnKeyDown = reBiographiesKeyDown
  end
end

 

Re:TRichEdit freezes program


Quote
In article <37D0EAA6.8F7F3...@argen.net>, P. F. Due?as wrote:
> I have a form with a TRichEdit. I do not want the user to copy the text,
> so I have not implemented anything for CopyToClipboard and the control
> is ReadOnly. But when I press Control-C the program freezes with no
> apparent reason.

I cannot reproduce the hang (D4.03, Win95B).
Try a different approach: simply prevent the user from selecting any text.
For that you add a handler to the OnSelectionChange event and in it do a

  (sender As Trichedit).SelLength := 0;

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:TRichEdit freezes program


Thanks a lot for your answer. I couldn't reproduce the hang on a fresh
program, so I thought the problem was in some part of the code. This
form is modeless and is showed from the main form. This main form has
another rich edit control, and a menu with a Ctrl-C shortcut to copy
only one paragraph. So, the problem was that entering Ctrl-C in the
child form fired the event in the main form for this menu shortcut and
that entered in an endless loop. That was the problem. Now the form is
modal and there is no problem. ?Is there any way for a Modeless form not
to call the parent form shortcuts?

By the way, thanks for your tip, I have forgotten to add it.

Thanks a lot, Pablo.

Quote
"Peter Below (TeamB)" wrote:

> I cannot reproduce the hang (D4.03, Win95B).

> Try a different approach: simply prevent the user from selecting any text.
> For that you add a handler to the OnSelectionChange event and in it do a

>   (sender As Trichedit).SelLength := 0;

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!

Re:TRichEdit freezes program


Quote
In article <37D24E43.C167A...@argen.net>, P. F. Due?as wrote:
> ?Is there any way for a Modeless form not
> to call the parent form shortcuts?

The active form will take precedence in handling shortcuts (unless you
are using D2, i think i remember a bug in the logic in that version).
But it all depends on where the shortcut is defined. If you depend on
the standard handling of it in the richedit it would only be honored
while that control has focus, for instance.

If push comes to shove you always have the option of handling the forms
OnShortcut event (if D4 or above).

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads