Can anyone tell me HOW TO make Super and/or Subscript

Please discuss general Delphi programming topics here.

Can anyone tell me HOW TO make Super and/or Subscript

Postby Nyux » April 12th, 2006, 3:58 am

Can anyone tell me how to make Super and/or Subscript report in Quickreport Delphi 7, something like "CaCo3"


Please Help Me,
Email at :
mansyur_03@yahoo.co.id
Nyux
Member
Member
 
Posts: 1
Joined: April 12th, 2006, 3:52 am

Postby martincg » April 24th, 2006, 11:56 pm

Is this any use- something I copied from somewhere with apologies to whoever I copied it from.

Code: Select all
// yOffset values
type
  TCharacterFormat = (CFM_Superscript, CFM_Subscript, CFM_Normal);

procedure RE_SetCharFormat(RichEdit: TRichEdit; CharacterFormat: TCharacterFormat);
var
  // The CHARFORMAT structure contains information about
  // character formatting in a rich edit control.
  Format: TCharFormat;
begin
  FillChar(Format, SizeOf(Format), 0);
  with Format do
  begin
    cbSize := SizeOf(Format);
    dwMask := CFM_OFFSET;
    // Character offset, in twips, from the baseline.
    // If the value of this member is positive,
    // the character is a superscript;
    // if it is negative, the character is a subscript.
    case CharacterFormat of
      CFM_Superscript: yOffset := 60;
      CFM_Subscript: yOffset := -60;
      CFM_Normal: yOffset := 0;
    end;
  end;
  // The EM_SETCHARFORMAT message sets character formatting in a rich edit control.
  // SCF_SELECTION: Applies the formatting to the current selection
  Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));
end;

// Examples:
// Beispiele:

// Apply Superscript to the current selection
// Markierte Zeichen hoch stellen
procedure TForm1.Button1Click(Sender: TObject);
begin
  RE_SetCharFormat(RichEdit1, CFM_Superscript);
end;

// Apply Subscript to the current selection
// Markierte Zeichen tief stellen
procedure TForm1.Button2Click(Sender: TObject);
begin
  RE_SetCharFormat(RichEdit1, CFM_Subscript);
end;
martincg
Active Member
Active Member
 
Posts: 10
Joined: April 22nd, 2006, 11:13 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 11 guests

cron