whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

45 Visitors Online


 
...format text in a TRichEdit by means of Shortcuts?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (3):  
     


// Shortcuts to format the selected Text:
// Tastaturkürzel, um den markierten Text zu formatieren:

Ctrl + B: Bold         Fett
Ctrl + I: Italic       Kursiv
Ctrl + S: Strikeout    Durchgestrichen
Ctrl + U: fsUnderline  Unterstrichen

// Put this Code into your Richedit's OnKeyPress handler:
// Diesen Code ins OnKeyPress Ereignis Prozedur hinzufügen:

procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
const
  
KEY_CTRL_B = 02;
  KEY_CTRL_I = 9;
  KEY_CTRL_S = 19;
  KEY_CTRL_U = 21;
begin
  with 
(Sender as TRichEdit).SelAttributes do
    case 
Ord(Key) of
      
KEY_CTRL_B: 
        begin
          
Key := #0;
          if fsBold in Style then
            
Style := Style - [fsBold]
          else
            
Style := Style + [fsBold];
        end;
      KEY_CTRL_I: 
        begin
          
Key := #0;
          if fsItalic in Style then
            
Style := Style - [fsItalic]
          else
            
Style := Style + [fsItalic];
        end;
      KEY_CTRL_S: 
        begin
          
Key := #0;
          if fsStrikeout in Style then
            
Style := Style - [fsStrikeout]
          else
            
Style := Style + [fsStrikeout];
        end;
      KEY_CTRL_U: 
        begin
          
Key := #0;
          if fsUnderline in Style then
            
Style := Style - [fsUnderline]
          else
            
Style := Style + [fsUnderline];
        end;
    end;
end;


 

Rate this tip:

poor
very good


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