Private Sub ctlRichText1_KeyDown(KeyCode As Integer, _
ByVal Shift As Integer)
Dim rtf As RichTextBox
Set rtf = Me!ctlRichText1.Object
If KeyCode = 9 Then ' TAB key was pressed.
' Ignore the TAB key, so focus doesn't
' leave the control
KeyCode = 0
' Replace selected text with the tab character
rtf.SelText = vbTab
End If
End Sub
//richEdit1 of type TRichEdit
with richEdit1 do
begin
//move caret to end
SelStart := GetTextLen;
//add one unformatted line
SelText := 'This is the first line' + #13#10;
//add some normal font text
SelText := 'Formatted lines in RichEdit' + #13#10;
//bigger text
SelAttributes.Size := 13;
//add bold + red
SelAttributes.Style := [fsBold];
SelAttributes.Color := clRed;
SelText := 'About';
//only bold
SelAttributes.Color := clWindowText;
SelText := ' Delphi ';
//add italic + blue
SelAttributes.Style := [fsItalic];
SelAttributes.Color := clBlue;
SelText := 'Programming';
//new line
SelText := #13#10;
//add normal again
SelAttributes.Size := 8;
SelAttributes.Color := clGreen;
SelText := 'think of AddFormattedLine custom procedure...';
end;
...
RELoadRTF( ortf:hWnd, chr( 9 ) + Chr( 0 ), SF_TEXT )
FwKeyboard( ortf, VK_RIGHT ) //otherwise all text is highlighted. don't know why
*-------------------------------------------------------------------------------------------------------------------------------
METHOD KeyDown( nKey, nFlags ) CLASS RchEdt
logfile( "trace.log", { "Keydown", nKey } )
::PostMsg( FM_CHANGE ) //FM_HIGHLIGHT )
Return Nil //Super:KeyDown( nKey, nFlags )
METHOD KeyChar( nKey, nFlags ) CLASS TRichEdit
if ::lReadOnly .and. ! GetKeyState( VK_ESCAPE )
return 0
endif
if nKey == VK_TAB // added by mmercado
Return 0
endif
Super:KeyChar( nKey, nFlags )
::PostMsg( FM_CHANGE )
if ::lHighlight
::PostMsg( FM_HIGHLIGHT )
endif
return nil
METHOD KeyDown( nKey, nFlags ) CLASS TRichEdit
if ( nKey == VK_INSERT .and. GetKeyState( VK_SHIFT ) .or. ;
nKey == Asc( "V" ) .and. GetKeyState( VK_CONTROL ) )
if ! ::lReadOnly
::Paste()
::PostMsg( FM_CHANGE )
endif
return 0
endif
if ::lReadOnly
if nKey == VK_BACK .or. nKey == VK_DELETE .or. nKey == VK_RETURN
return 0
endif
endif
if nKey == VK_TAB // added by mmercado
::insertRtf( Chr( 9 ) )
::PostMsg( FM_CHANGE )
Return 0
endif
Super:KeyDown( nKey, nFlags )
::PostMsg( FM_CHANGE )
if ::lHighlight
if nKey == VK_DELETE .or. nKey == VK_BACK
::PostMsg( FM_HIGHLIGHT )
endif
endif
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 114 guests