was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

49 Visitors Online


 
...im RichEdit Zeichen hoch/tief stellen?
Autor: Thomas Stutz
[ Tip ausdrucken ]  

Tip Bewertung (58):  
     




// 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;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners