Actionlist-question

Peter Kiers
Peter Kiers used Ask the Experts™
on
Dear experts,

I use a actionlist in my application, the use these items:
->Undo
->Cut
->Copy
->Paste
->SelectAll
->Delete
->Bullets
They are all hooked up to my menu-items.

But I want also a menu-item for numbering text.
Like the bullets, but then numbers. Only the actionlist
contains no such item. What do I have to do to make one?

Peter
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ferruccio AccalaiSenior developer, analyst and customer assistance

Commented:
There is no Standard action for the Richedit numbering.
You have to create a new Action and add the following code

procedure TMainForm.Action1Execute(Sender: TObject);
var
  fmt: TParaformat2;
begin
  FillChar(fmt, SizeOf(fmt), 0);
  fmt.cbSize := SizeOf(fmt);

  // The PARAFORMAT2 structure is used to set the numbering style.

  // This is done through the following structure members:
  fmt.dwMask := PFM_NUMBERING or PFM_NUMBERINGSTART or PFM_NUMBERINGSTYLE or PFM_NUMBERINGTAB;

  // Set the following values (bitwise-or them together) to identify

  // which of the remaining structure members are valid:

  // PFM_NUMBERING, PFM_NUMBERINGSTART, PFM_NUMBERINGSTYLE, and PFM_NUMBERINGTAB
  fmt.wNumbering := 2;

  // 0 no numbering or bullets

  // 1 (PFN_BULLET) uses bullet character

  // 2 Uses Arabic numbers (1, 2, 3, ...).

  // 3 Uses lowercase letters (a, b, c, ...).

  // 4 Uses uppercase letters (A, B, C, ...).

  // 5 Uses lowercase Roman numerals (i, ii, iii, ...).

  // 6 Uses uppercase Roman numerals (I, II, III, ...).

  // 7 Uses a sequence of characters beginning with the Unicode

  // character specified by the wNumberingStart member.
  fmt.wNumberingStart := 1;

  // Starting value for numbering.
  fmt.wNumberingStyle := $200;

  // Styles for numbering:

  // 0 : Follows the number with a right parenthesis.  1)

  // $100 : Encloses the number in parentheses.       (1)

  // $200 : Follows the number with a period.          1.

  // $300 : Displays only the number.                  1

  // $400 : Continues a numbered list without applying the next number or bullet.

  // $8000 : Starts a new number with wNumberingStart.
  fmt.wNumberingTab := 1440 div 4;

  // Minimum space between a paragraph number and the paragraph text, in twips
  RichEdit1.Perform(EM_SETPARAFORMAT, 0, lParam(@fmt));
end;
Senior developer, analyst and customer assistance
Commented:
I don't know how is coded your project, btw to test if you're in Numbering mode or note you could create a global boolean variable like Numbers: Boolean;
And then test if it's already numbered or not

So your Action1Execute code will be as follow:

var
Numbers: Boolean

procedure TMainForm.Action1Execute(Sender: TObject);
var
  fmt: TParaformat2;
begin
  FillChar(fmt, SizeOf(fmt), 0);
  fmt.cbSize := SizeOf(fmt);
  fmt.dwMask := PFM_NUMBERING or PFM_NUMBERINGSTART or PFM_NUMBERINGSTYLE or PFM_NUMBERINGTAB;
  if not Numbers then
  begin
    Numbers := True;
    fmt.wNumbering := 2;
  end
  else
  begin
    Numbers := False;
    fmt.wNumbering := 0;
  end;
  fmt.wNumberingStart := 1;
  fmt.wNumberingStyle := $200;
  fmt.wNumberingTab := 1440 div 4;
  Editor.Perform(EM_SETPARAFORMAT, 0, lParam(@fmt));
end;
Peter KiersOperator

Author

Commented:
Do I have to declare something because I get alot of undeclared identifier;
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Peter KiersOperator

Author

Commented:
uses Richedit
Ferruccio AccalaiSenior developer, analyst and customer assistance

Commented:
Are you using TRichEdit?
Is Richedit in the uses clause?
If not add it.
Peter KiersOperator

Author

Commented:
500 points are comming to you.

Grtz, Peter Kiers

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial